Fix tp commands
This commit is contained in:
parent
603952e185
commit
8b013b7baa
9 changed files with 76 additions and 70 deletions
|
@ -1,7 +1,13 @@
|
|||
package dev.zontreck.essentials.commands.teleport;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
|
||||
import dev.zontreck.essentials.AriasEssentials;
|
||||
import dev.zontreck.essentials.Messages;
|
||||
import dev.zontreck.essentials.util.RTPContainer;
|
||||
import dev.zontreck.essentials.util.RandomPositionFactory;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
|
@ -55,7 +61,7 @@ public class RTPCommand {
|
|||
RTPContainer container = RandomPositionFactory.beginRTPSearch(pla, pos, pla.getRotationVector(), pla.getLevel());
|
||||
while(!container.complete)
|
||||
{
|
||||
if(!OTEMod.ALIVE)
|
||||
if(!AriasEssentials.ALIVE)
|
||||
{
|
||||
container.aborted=true;
|
||||
container.containingThread.interrupt();
|
||||
|
@ -70,7 +76,7 @@ public class RTPCommand {
|
|||
}
|
||||
v = container.container.world_pos.Position;
|
||||
|
||||
ChatServerOverride.broadcastTo(pla.getUUID(), new TextComponent(ChatColor.DARK_GRAY + "["+ChatColor.DARK_GREEN + "OTEMOD" + ChatColor.DARK_GRAY + "] "+ChatColor.DARK_PURPLE+" A suitable location has been found. Wormhole opening now!"), OTEMod.THE_SERVER);
|
||||
ChatHelpers.broadcastTo(pla.getUUID(), new TextComponent(Messages.ESSENTIALS_PREFIX + ChatColor.DARK_PURPLE+" A suitable location has been found. Wormhole opening now!"), pla.server);
|
||||
|
||||
// Apply the effect
|
||||
TeleportActioner.ApplyTeleportEffect(pla);
|
||||
|
|
|
@ -5,6 +5,9 @@ import com.mojang.brigadier.CommandDispatcher;
|
|||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.chat.Clickable;
|
||||
import dev.zontreck.libzontreck.chat.HoverTip;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
|
@ -35,21 +38,22 @@ public class TPACommand {
|
|||
}
|
||||
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
if(!OTEMod.DEVELOPER){
|
||||
if(play.getUUID() == serverPlayer.getUUID()){
|
||||
source.sendFailure(new TextComponent(ChatColor.DARK_RED+"You cannot teleport to yourself!"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if(play.getUUID() == serverPlayer.getUUID()){
|
||||
source.sendFailure(new TextComponent(ChatColor.DARK_RED+"You cannot teleport to yourself!"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
TeleportContainer cont = new TeleportContainer(play.getUUID(), serverPlayer.getUUID());
|
||||
|
||||
for(TeleportContainer cont2 : OTEMod.TeleportRegistry){
|
||||
for(TeleportContainer cont2 : TeleportRegistry.get()){
|
||||
if(cont2.compareTo(cont)==0){
|
||||
ChatServerOverride.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, 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());
|
||||
return 0;
|
||||
}else {
|
||||
if(cont2.FromPlayer == cont.FromPlayer){
|
||||
ChatServerOverride.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, 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());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +66,7 @@ public class TPACommand {
|
|||
Style s = Style.EMPTY.withFont(Style.DEFAULT_FONT).withHoverEvent(he).withClickEvent(ce);
|
||||
|
||||
// Send the alerts
|
||||
ChatServerOverride.broadcastTo(cont.FromPlayer, new TextComponent(ChatColor.BOLD + ChatColor.DARK_GREEN +"TPA Request Sent! ").append(new TextComponent(ChatColor.BOLD+ChatColor.DARK_GRAY+"["+ChatColor.DARK_RED+"X"+ChatColor.DARK_GRAY+"]").setStyle(s)), serverPlayer.server);
|
||||
ChatHelpers.broadcastTo(cont.FromPlayer, new TextComponent(ChatColor.BOLD + ChatColor.DARK_GREEN +"TPA Request Sent! ").append(new TextComponent(ChatColor.BOLD+ChatColor.DARK_GRAY+"["+ChatColor.DARK_RED+"X"+ChatColor.DARK_GRAY+"]").setStyle(s)), serverPlayer.server);
|
||||
|
||||
|
||||
ce = Clickable.command("/tpaccept "+cont.TeleportID.toString());
|
||||
|
@ -79,11 +83,11 @@ public class TPACommand {
|
|||
} catch (UserProfileNotYetExistsException e) {
|
||||
return 1;
|
||||
}
|
||||
ChatServerOverride.broadcastTo(cont.ToPlayer, new TextComponent(p.name_color+p.nickname + ChatColor.BOLD + ChatColor.DARK_PURPLE+" is requesting to teleport to you\n \n").
|
||||
ChatHelpers.broadcastTo(cont.ToPlayer, new TextComponent(p.name_color+p.nickname + ChatColor.BOLD + ChatColor.DARK_PURPLE+" is requesting to teleport to you\n \n").
|
||||
append(new TextComponent(ChatColor.DARK_GRAY+"["+ChatColor.DARK_GREEN+"ACCEPT" + ChatColor.DARK_GRAY+"] ").setStyle(s)).
|
||||
append(new TextComponent(ChatColor.DARK_GRAY + "["+ChatColor.DARK_RED+"DENY"+ChatColor.DARK_GRAY+"]").setStyle(s2)), serverPlayer.server);
|
||||
|
||||
OTEMod.TeleportRegistry.add(cont);
|
||||
TeleportRegistry.get().add(cont);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,10 +5,9 @@ import com.mojang.brigadier.CommandDispatcher;
|
|||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.chat.Clickable;
|
||||
import dev.zontreck.libzontreck.chat.HoverTip;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import dev.zontreck.otemod.implementation.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
|
@ -39,21 +38,20 @@ public class TPAHereCommand {
|
|||
source.sendFailure(new TextComponent(ChatColor.DARK_RED+"Error: Player not found"));
|
||||
return 1;
|
||||
}
|
||||
if(!OTEMod.DEVELOPER){
|
||||
if(play.getUUID() == serverPlayer.getUUID()){
|
||||
source.sendFailure(new TextComponent(ChatColor.DARK_RED+"You cannot teleport to yourself!"));
|
||||
return 1;
|
||||
}
|
||||
if(play.getUUID() == serverPlayer.getUUID()){
|
||||
source.sendFailure(new TextComponent(ChatColor.DARK_RED+"You cannot teleport to yourself!"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
TeleportContainer cont = new TeleportContainer(serverPlayer.getUUID(), play.getUUID());
|
||||
|
||||
for(TeleportContainer cont2 : OTEMod.TeleportRegistry){
|
||||
for(TeleportContainer cont2 : TeleportRegistry.get()){
|
||||
if(cont2.compareTo(cont)==0){
|
||||
ChatServerOverride.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, 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());
|
||||
return 0;
|
||||
}else {
|
||||
if(cont2.ToPlayer.equals(cont.ToPlayer)){
|
||||
ChatServerOverride.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, 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());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +64,7 @@ public class TPAHereCommand {
|
|||
Style s = Style.EMPTY.withFont(Style.DEFAULT_FONT).withHoverEvent(he).withClickEvent(ce);
|
||||
|
||||
// Send the alerts
|
||||
ChatServerOverride.broadcastTo(cont.ToPlayer, new TextComponent(ChatColor.BOLD + ChatColor.DARK_GREEN +"TPA Request Sent! ").append(new TextComponent(ChatColor.BOLD+ChatColor.DARK_GRAY+"["+ChatColor.DARK_RED+"X"+ChatColor.DARK_GRAY+"]").setStyle(s)), serverPlayer.server);
|
||||
ChatHelpers.broadcastTo(cont.ToPlayer, new TextComponent(ChatColor.BOLD + ChatColor.DARK_GREEN +"TPA Request Sent! ").append(new TextComponent(ChatColor.BOLD+ChatColor.DARK_GRAY+"["+ChatColor.DARK_RED+"X"+ChatColor.DARK_GRAY+"]").setStyle(s)), serverPlayer.server);
|
||||
|
||||
|
||||
ce = Clickable.command("/tpaccept "+cont.TeleportID.toString());
|
||||
|
@ -83,11 +81,11 @@ public class TPAHereCommand {
|
|||
} catch (UserProfileNotYetExistsException e) {
|
||||
return 1;
|
||||
}
|
||||
ChatServerOverride.broadcastTo(cont.FromPlayer, new TextComponent(p.name_color+p.nickname + ChatColor.BOLD + ChatColor.DARK_PURPLE+" is requesting you to teleport to them\n \n").
|
||||
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").
|
||||
append(new TextComponent(ChatColor.DARK_GRAY+"["+ChatColor.DARK_GREEN+"ACCEPT" + ChatColor.DARK_GRAY+"] ").setStyle(s)).
|
||||
append(new TextComponent(ChatColor.DARK_GRAY + "["+ChatColor.DARK_RED+"DENY"+ChatColor.DARK_GRAY+"]").setStyle(s2)), serverPlayer.server);
|
||||
|
||||
OTEMod.TeleportRegistry.add(cont);
|
||||
TeleportRegistry.get().add(cont);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,9 @@ import java.util.UUID;
|
|||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import dev.zontreck.essentials.Messages;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -37,12 +39,12 @@ public class TPAcceptCommand {
|
|||
ServerPlayer from = source.getServer().getPlayerList().getPlayer(cont.FromPlayer);
|
||||
ServerPlayer to = source.getServer().getPlayerList().getPlayer(cont.ToPlayer);
|
||||
|
||||
Component comp = new TextComponent(OTEMod.OTEPrefix + " " + ChatColor.DARK_PURPLE+"Teleport request was accepted. Opening wormhole!");
|
||||
Component comp = new TextComponent(Messages.ESSENTIALS_PREFIX + ChatColor.DARK_PURPLE+"Teleport request was accepted. Opening wormhole!");
|
||||
|
||||
ChatServerOverride.broadcastTo(cont.FromPlayer, comp, source.getServer());
|
||||
ChatServerOverride.broadcastTo(cont.ToPlayer, comp, source.getServer());
|
||||
ChatHelpers.broadcastTo(cont.FromPlayer, comp, source.getServer());
|
||||
ChatHelpers.broadcastTo(cont.ToPlayer, comp, source.getServer());
|
||||
|
||||
OTEMod.TeleportRegistry.remove(cont);
|
||||
TeleportRegistry.get().remove(cont);
|
||||
|
||||
|
||||
cont.PlayerInst = from;
|
||||
|
@ -58,7 +60,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");
|
||||
|
||||
ChatServerOverride.broadcastTo(play.getUUID(), comp, source.getServer());
|
||||
ChatHelpers.broadcastTo(play.getUUID(), comp, source.getServer());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package dev.zontreck.otemod.commands.teleport;
|
||||
package dev.zontreck.essentials.commands.teleport;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import dev.zontreck.essentials.Messages;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -32,22 +32,22 @@ public class TPCancelCommand {
|
|||
UUID teleporter = UUID.fromString(TPID);
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
|
||||
for(TeleportContainer cont : OTEMod.TeleportRegistry){
|
||||
for(TeleportContainer cont : TeleportRegistry.get()){
|
||||
if(cont.TeleportID.equals(teleporter)){
|
||||
// Canceling!
|
||||
Component comp = new TextComponent(OTEMod.OTEPrefix + " " + ChatColor.DARK_PURPLE+"Teleport request was cancelled");
|
||||
Component comp = new TextComponent(Messages.ESSENTIALS_PREFIX + ChatColor.DARK_PURPLE+"Teleport request was cancelled");
|
||||
|
||||
ChatServerOverride.broadcastTo(cont.FromPlayer, comp, source.getServer());
|
||||
ChatServerOverride.broadcastTo(cont.ToPlayer, comp, source.getServer());
|
||||
ChatHelpers.broadcastTo(cont.FromPlayer, comp, source.getServer());
|
||||
ChatHelpers.broadcastTo(cont.ToPlayer, comp, source.getServer());
|
||||
|
||||
OTEMod.TeleportRegistry.remove(cont);
|
||||
TeleportRegistry.get().remove(cont);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Component comp = new TextComponent(ChatColor.DARK_RED+"The teleport was not found, perhaps the request expired or was already cancelled");
|
||||
|
||||
ChatServerOverride.broadcastTo(play.getUUID(), comp, source.getServer());
|
||||
ChatHelpers.broadcastTo(play.getUUID(), comp, source.getServer());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package dev.zontreck.otemod.commands.teleport;
|
||||
package dev.zontreck.essentials.commands.teleport;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import dev.zontreck.essentials.Messages;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -32,22 +32,22 @@ public class TPDenyCommand {
|
|||
UUID teleporter = UUID.fromString(TPID);
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
|
||||
for(TeleportContainer cont : OTEMod.TeleportRegistry){
|
||||
for(TeleportContainer cont : TeleportRegistry.get()){
|
||||
if(cont.TeleportID.equals(teleporter)){
|
||||
// Canceling!
|
||||
Component comp = new TextComponent(OTEMod.OTEPrefix + " " + ChatColor.DARK_PURPLE+"Teleport request was denied");
|
||||
Component comp = new TextComponent(Messages.ESSENTIALS_PREFIX + ChatColor.DARK_PURPLE+"Teleport request was denied");
|
||||
|
||||
ChatServerOverride.broadcastTo(cont.FromPlayer, comp, source.getServer());
|
||||
ChatServerOverride.broadcastTo(cont.ToPlayer, comp, source.getServer());
|
||||
ChatHelpers.broadcastTo(cont.FromPlayer, comp, source.getServer());
|
||||
ChatHelpers.broadcastTo(cont.ToPlayer, comp, source.getServer());
|
||||
|
||||
OTEMod.TeleportRegistry.remove(cont);
|
||||
TeleportRegistry.get().remove(cont);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Component comp = new TextComponent(ChatColor.DARK_RED+"The teleport was not found, perhaps the request expired or was already cancelled/denied");
|
||||
|
||||
ChatServerOverride.broadcastTo(play.getUUID(), comp, source.getServer());
|
||||
ChatHelpers.broadcastTo(play.getUUID(), comp, source.getServer());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue