Update more messages
This commit is contained in:
parent
ae60e6e642
commit
cae9cb1e26
4 changed files with 59 additions and 21 deletions
|
@ -1,6 +1,8 @@
|
||||||
package dev.zontreck.essentials;
|
package dev.zontreck.essentials;
|
||||||
|
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
|
import net.minecraft.sounds.SoundEvent;
|
||||||
|
import net.minecraft.sounds.SoundEvents;
|
||||||
|
|
||||||
public class Messages {
|
public class Messages {
|
||||||
public static final String ESSENTIALS_PREFIX;
|
public static final String ESSENTIALS_PREFIX;
|
||||||
|
@ -35,6 +37,18 @@ public class Messages {
|
||||||
public static final String TELEPORT_REQUEST_DENIED;
|
public static final String TELEPORT_REQUEST_DENIED;
|
||||||
public static final String TELEPORT_REQUEST_CANCELLED;
|
public static final String TELEPORT_REQUEST_CANCELLED;
|
||||||
|
|
||||||
|
public static final String TELEPORT_ACCEPT;
|
||||||
|
public static final String TELEPORT_DENY;
|
||||||
|
public static final SoundEvent TPA_SOUND;
|
||||||
|
public static final String TPA_HERE;
|
||||||
|
|
||||||
|
public static final String PLAYER_NOT_FOUND;
|
||||||
|
public static final String NO_TP_TO_SELF;
|
||||||
|
public static final String NO_MORE_THAN_ONE_TPA;
|
||||||
|
public static final String TPA;
|
||||||
|
|
||||||
|
public static final String TELEPORT_REQUEST_ACCEPTED;
|
||||||
|
|
||||||
static{
|
static{
|
||||||
ESSENTIALS_PREFIX = "!Gray![!Dark_Green!AE!Gray!] ";
|
ESSENTIALS_PREFIX = "!Gray![!Dark_Green!AE!Gray!] ";
|
||||||
|
|
||||||
|
@ -74,5 +88,18 @@ public class Messages {
|
||||||
TELEPORT_REQUEST_NOT_FOUND = ESSENTIALS_PREFIX + "!Dark_Red!The teleport request could not be found. Perhaps it already expired or was cancelled/denied already.";
|
TELEPORT_REQUEST_NOT_FOUND = ESSENTIALS_PREFIX + "!Dark_Red!The teleport request could not be found. Perhaps it already expired or was cancelled/denied already.";
|
||||||
TELEPORT_REQUEST_DENIED = ESSENTIALS_PREFIX + "!Dark_Red!Teleport request was denied";
|
TELEPORT_REQUEST_DENIED = ESSENTIALS_PREFIX + "!Dark_Red!Teleport request was denied";
|
||||||
TELEPORT_REQUEST_CANCELLED = ESSENTIALS_PREFIX + "!Dark_Red!Teleport request was cancelled";
|
TELEPORT_REQUEST_CANCELLED = ESSENTIALS_PREFIX + "!Dark_Red!Teleport request was cancelled";
|
||||||
|
TELEPORT_REQUEST_ACCEPTED = ESSENTIALS_PREFIX + "!Dark_Green!Teleport request was accepted";
|
||||||
|
|
||||||
|
TPA_SOUND = SoundEvents.ANVIL_FALL;
|
||||||
|
TELEPORT_ACCEPT = "!Dark_Gray![!Dark_Green!Accept!Dark_Gray!]";
|
||||||
|
TELEPORT_DENY = "!Dark_Gray![!Dark_Red!Deny!Dark_Gray!]";
|
||||||
|
|
||||||
|
TPA_HERE = "[0] !Bold!!Dark_Purple!is requesting you to teleport to them!\n\n";
|
||||||
|
|
||||||
|
PLAYER_NOT_FOUND = ESSENTIALS_PREFIX + "!Dark_Red!Error: Player not found";
|
||||||
|
NO_TP_TO_SELF = ESSENTIALS_PREFIX + "!Dark_Red!You cannot teleport to yourself!";
|
||||||
|
NO_MORE_THAN_ONE_TPA = ESSENTIALS_PREFIX + "!Dark_Red!You already have a TPA Request active, wait for it to expire, or use the cancel button/command";
|
||||||
|
|
||||||
|
TPA = "[0] !Bold!!Dark_Purple! is requesting to teleport to you!\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package dev.zontreck.essentials.commands.teleport;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
|
|
||||||
|
import dev.zontreck.essentials.Messages;
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
import dev.zontreck.libzontreck.chat.Clickable;
|
import dev.zontreck.libzontreck.chat.Clickable;
|
||||||
import dev.zontreck.libzontreck.chat.HoverTip;
|
import dev.zontreck.libzontreck.chat.HoverTip;
|
||||||
|
@ -17,6 +18,7 @@ import net.minecraft.network.chat.HoverEvent;
|
||||||
import net.minecraft.network.chat.Style;
|
import net.minecraft.network.chat.Style;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.network.chat.TextComponent;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraftforge.network.NetworkHooks;
|
||||||
|
|
||||||
public class TPACommand {
|
public class TPACommand {
|
||||||
|
|
||||||
|
@ -33,7 +35,7 @@ public class TPACommand {
|
||||||
private static int tpa(CommandSourceStack source, ServerPlayer serverPlayer) {
|
private static int tpa(CommandSourceStack source, ServerPlayer serverPlayer) {
|
||||||
// Send the request to player
|
// Send the request to player
|
||||||
if(serverPlayer == null){
|
if(serverPlayer == null){
|
||||||
source.sendFailure(new TextComponent(ChatColor.DARK_RED+"Error: Player not found"));
|
source.sendFailure(ChatHelpers.macro(Messages.PLAYER_NOT_FOUND));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +43,7 @@ public class TPACommand {
|
||||||
|
|
||||||
|
|
||||||
if(play.getUUID() == serverPlayer.getUUID()){
|
if(play.getUUID() == serverPlayer.getUUID()){
|
||||||
source.sendFailure(new TextComponent(ChatColor.DARK_RED+"You cannot teleport to yourself!"));
|
source.sendFailure(ChatHelpers.macro(Messages.NO_TP_TO_SELF));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,11 +51,11 @@ public class TPACommand {
|
||||||
|
|
||||||
for(TeleportContainer cont2 : TeleportRegistry.get()){
|
for(TeleportContainer cont2 : TeleportRegistry.get()){
|
||||||
if(cont2.compareTo(cont)==0){
|
if(cont2.compareTo(cont)==0){
|
||||||
ChatHelpers.broadcastTo(cont.FromPlayer, new TextComponent(ChatColor.DARK_RED+ "You already have a TPA Request active, wait for it to expire, or use the cancel button/command"), source.getServer());
|
ChatHelpers.broadcastTo(cont.FromPlayer, ChatHelpers.macro(Messages.NO_MORE_THAN_ONE_TPA), source.getServer());
|
||||||
return 0;
|
return 0;
|
||||||
}else {
|
}else {
|
||||||
if(cont2.FromPlayer == cont.FromPlayer){
|
if(cont2.FromPlayer == cont.FromPlayer){
|
||||||
ChatHelpers.broadcastTo(cont.FromPlayer, new TextComponent(ChatColor.DARK_RED+ "You already have a TPA Request active, wait for it to expire, or use the cancel button/command"), source.getServer());
|
ChatHelpers.broadcastTo(cont.FromPlayer, ChatHelpers.macro(Messages.NO_MORE_THAN_ONE_TPA), source.getServer());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +63,7 @@ public class TPACommand {
|
||||||
|
|
||||||
|
|
||||||
ClickEvent ce = Clickable.command("/tpcancel "+cont.TeleportID.toString());
|
ClickEvent ce = Clickable.command("/tpcancel "+cont.TeleportID.toString());
|
||||||
HoverEvent he = HoverTip.get(ChatColor.DARK_GREEN+"Cancel this teleport request (Not yet implemented)");
|
HoverEvent he = HoverTip.get(ChatColor.DARK_GREEN+"Cancel this teleport request");
|
||||||
|
|
||||||
Style s = Style.EMPTY.withFont(Style.DEFAULT_FONT).withHoverEvent(he).withClickEvent(ce);
|
Style s = Style.EMPTY.withFont(Style.DEFAULT_FONT).withHoverEvent(he).withClickEvent(ce);
|
||||||
|
|
||||||
|
@ -77,15 +79,18 @@ public class TPACommand {
|
||||||
|
|
||||||
Style s2 = Style.EMPTY.withFont(Style.DEFAULT_FONT).withClickEvent(ce2).withHoverEvent(he2);
|
Style s2 = Style.EMPTY.withFont(Style.DEFAULT_FONT).withClickEvent(ce2).withHoverEvent(he2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Profile p;
|
Profile p;
|
||||||
try {
|
try {
|
||||||
p = Profile.get_profile_of(cont.FromPlayer.toString());
|
p = Profile.get_profile_of(cont.FromPlayer.toString());
|
||||||
} catch (UserProfileNotYetExistsException e) {
|
} catch (UserProfileNotYetExistsException e) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
ChatHelpers.broadcastTo(cont.ToPlayer, new TextComponent(p.name_color+p.nickname + ChatColor.BOLD + ChatColor.DARK_PURPLE+" is requesting to teleport to you\n \n").
|
serverPlayer.playSound(Messages.TPA_SOUND, 1, serverPlayer.getRandom().nextFloat());
|
||||||
append(new TextComponent(ChatColor.DARK_GRAY+"["+ChatColor.DARK_GREEN+"ACCEPT" + ChatColor.DARK_GRAY+"] ").setStyle(s)).
|
ChatHelpers.broadcastTo(cont.ToPlayer, ChatHelpers.macro(Messages.TPA, p.name_color+p.nickname).
|
||||||
append(new TextComponent(ChatColor.DARK_GRAY + "["+ChatColor.DARK_RED+"DENY"+ChatColor.DARK_GRAY+"]").setStyle(s2)), serverPlayer.server);
|
append(ChatHelpers.macro(Messages.TELEPORT_ACCEPT+" ").setStyle(s)).
|
||||||
|
append(ChatHelpers.macro(Messages.TELEPORT_DENY).setStyle(s2)), serverPlayer.server);
|
||||||
|
|
||||||
TeleportRegistry.get().add(cont);
|
TeleportRegistry.get().add(cont);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -2,6 +2,7 @@ package dev.zontreck.essentials.commands.teleport;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
|
|
||||||
|
import dev.zontreck.essentials.Messages;
|
||||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||||
import dev.zontreck.libzontreck.chat.Clickable;
|
import dev.zontreck.libzontreck.chat.Clickable;
|
||||||
import dev.zontreck.libzontreck.chat.HoverTip;
|
import dev.zontreck.libzontreck.chat.HoverTip;
|
||||||
|
@ -35,11 +36,11 @@ public class TPAHereCommand {
|
||||||
|
|
||||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||||
if(serverPlayer == null){
|
if(serverPlayer == null){
|
||||||
source.sendFailure(new TextComponent(ChatColor.DARK_RED+"Error: Player not found"));
|
source.sendFailure(ChatHelpers.macro(Messages.PLAYER_NOT_FOUND));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(play.getUUID() == serverPlayer.getUUID()){
|
if(play.getUUID() == serverPlayer.getUUID()){
|
||||||
source.sendFailure(new TextComponent(ChatColor.DARK_RED+"You cannot teleport to yourself!"));
|
source.sendFailure(ChatHelpers.macro(Messages.NO_TP_TO_SELF));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,11 +48,11 @@ public class TPAHereCommand {
|
||||||
|
|
||||||
for(TeleportContainer cont2 : TeleportRegistry.get()){
|
for(TeleportContainer cont2 : TeleportRegistry.get()){
|
||||||
if(cont2.compareTo(cont)==0){
|
if(cont2.compareTo(cont)==0){
|
||||||
ChatHelpers.broadcastTo(cont.ToPlayer, new TextComponent(ChatColor.DARK_RED+ "You already have a TPA Request active, wait for it to expire, or use the cancel button/command"), source.getServer());
|
ChatHelpers.broadcastTo(cont.ToPlayer, ChatHelpers.macro(Messages.NO_MORE_THAN_ONE_TPA), source.getServer());
|
||||||
return 0;
|
return 0;
|
||||||
}else {
|
}else {
|
||||||
if(cont2.ToPlayer.equals(cont.ToPlayer)){
|
if(cont2.ToPlayer.equals(cont.ToPlayer)){
|
||||||
ChatHelpers.broadcastTo(cont.FromPlayer, new TextComponent(ChatColor.DARK_RED+ "You already have a TPA Request active, wait for it to expire, or use the cancel button/command"), source.getServer());
|
ChatHelpers.broadcastTo(cont.ToPlayer, ChatHelpers.macro(Messages.NO_MORE_THAN_ONE_TPA), source.getServer());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +60,7 @@ public class TPAHereCommand {
|
||||||
|
|
||||||
|
|
||||||
ClickEvent ce = Clickable.command("/tpcancel "+cont.TeleportID.toString());
|
ClickEvent ce = Clickable.command("/tpcancel "+cont.TeleportID.toString());
|
||||||
HoverEvent he = HoverTip.get(ChatColor.DARK_GREEN+"Cancel this teleport request (Not yet implemented)");
|
HoverEvent he = HoverTip.get(ChatColor.DARK_GREEN+"Cancel this teleport request");
|
||||||
|
|
||||||
Style s = Style.EMPTY.withFont(Style.DEFAULT_FONT).withHoverEvent(he).withClickEvent(ce);
|
Style s = Style.EMPTY.withFont(Style.DEFAULT_FONT).withHoverEvent(he).withClickEvent(ce);
|
||||||
|
|
||||||
|
@ -81,16 +82,17 @@ public class TPAHereCommand {
|
||||||
} catch (UserProfileNotYetExistsException e) {
|
} catch (UserProfileNotYetExistsException e) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
ChatHelpers.broadcastTo(cont.FromPlayer, new TextComponent(p.name_color+p.nickname + ChatColor.BOLD + ChatColor.DARK_PURPLE+" is requesting you to teleport to them\n \n").
|
serverPlayer.playSound(Messages.TPA_SOUND, 1, serverPlayer.getRandom().nextFloat());
|
||||||
append(new TextComponent(ChatColor.DARK_GRAY+"["+ChatColor.DARK_GREEN+"ACCEPT" + ChatColor.DARK_GRAY+"] ").setStyle(s)).
|
ChatHelpers.broadcastTo(cont.FromPlayer, ChatHelpers.macro(Messages.TPA_HERE, p.name_color+p.nickname).
|
||||||
append(new TextComponent(ChatColor.DARK_GRAY + "["+ChatColor.DARK_RED+"DENY"+ChatColor.DARK_GRAY+"]").setStyle(s2)), serverPlayer.server);
|
append(ChatHelpers.macro(Messages.TELEPORT_ACCEPT+" ").setStyle(s)).
|
||||||
|
append(ChatHelpers.macro(Messages.TELEPORT_DENY).setStyle(s2)), serverPlayer.server);
|
||||||
|
|
||||||
TeleportRegistry.get().add(cont);
|
TeleportRegistry.get().add(cont);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int usage(CommandSourceStack source) {
|
private static int usage(CommandSourceStack source) {
|
||||||
source.sendSuccess(new TextComponent("/tpa USAGE\n\n "+ChatColor.BOLD + ChatColor.DARK_GRAY+"/tpa "+ChatColor.DARK_RED+"target_player\n"), false);
|
source.sendSuccess(new TextComponent("/tpahere USAGE\n\n "+ChatColor.BOLD + ChatColor.DARK_GRAY+"/tpahere "+ChatColor.DARK_RED+"target_player\n"), false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package dev.zontreck.essentials.commands.teleport;
|
package dev.zontreck.essentials.commands.teleport;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
|
@ -32,19 +33,22 @@ public class TPAcceptCommand {
|
||||||
UUID teleporter = UUID.fromString(TPID);
|
UUID teleporter = UUID.fromString(TPID);
|
||||||
|
|
||||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||||
for(TeleportContainer cont : TeleportRegistry.get()){
|
Iterator<TeleportContainer> it = TeleportRegistry.get().iterator();
|
||||||
|
while(it.hasNext())
|
||||||
|
{
|
||||||
|
TeleportContainer cont = it.next();
|
||||||
if(cont.TeleportID.equals(teleporter)){
|
if(cont.TeleportID.equals(teleporter)){
|
||||||
// Accepting!
|
// Accepting!
|
||||||
|
|
||||||
ServerPlayer from = source.getServer().getPlayerList().getPlayer(cont.FromPlayer);
|
ServerPlayer from = source.getServer().getPlayerList().getPlayer(cont.FromPlayer);
|
||||||
ServerPlayer to = source.getServer().getPlayerList().getPlayer(cont.ToPlayer);
|
ServerPlayer to = source.getServer().getPlayerList().getPlayer(cont.ToPlayer);
|
||||||
|
|
||||||
Component comp = new TextComponent(Messages.ESSENTIALS_PREFIX + ChatColor.DARK_PURPLE+"Teleport request was accepted. Opening wormhole!");
|
Component comp = ChatHelpers.macro(Messages.TELEPORT_REQUEST_ACCEPTED);
|
||||||
|
|
||||||
ChatHelpers.broadcastTo(cont.FromPlayer, comp, source.getServer());
|
ChatHelpers.broadcastTo(cont.FromPlayer, comp, source.getServer());
|
||||||
ChatHelpers.broadcastTo(cont.ToPlayer, comp, source.getServer());
|
ChatHelpers.broadcastTo(cont.ToPlayer, comp, source.getServer());
|
||||||
|
|
||||||
TeleportRegistry.get().remove(cont);
|
it.remove();
|
||||||
|
|
||||||
|
|
||||||
cont.PlayerInst = from;
|
cont.PlayerInst = from;
|
||||||
|
@ -58,7 +62,7 @@ public class TPAcceptCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component comp = new TextComponent(ChatColor.DARK_RED+"The teleport was not found, perhaps the request expired or was already cancelled/denied");
|
Component comp = ChatHelpers.macro(Messages.TELEPORT_REQUEST_NOT_FOUND);
|
||||||
|
|
||||||
ChatHelpers.broadcastTo(play.getUUID(), comp, source.getServer());
|
ChatHelpers.broadcastTo(play.getUUID(), comp, source.getServer());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue