Downgrade to 1.18.2

This commit is contained in:
Aria 2023-02-22 13:05:45 -07:00
parent c7040f83ae
commit 19573bbd56
63 changed files with 424 additions and 311 deletions

View file

@ -9,6 +9,7 @@ import dev.zontreck.otemod.commands.homes.DelHomeCommand;
import dev.zontreck.otemod.commands.homes.HomeCommand;
import dev.zontreck.otemod.commands.homes.HomesCommand;
import dev.zontreck.otemod.commands.homes.SetHomeCommand;
import dev.zontreck.otemod.commands.items.ShareItemInChatCommand;
import dev.zontreck.otemod.commands.profilecmds.ChatColorCommand;
import dev.zontreck.otemod.commands.profilecmds.NameColorCommand;
import dev.zontreck.otemod.commands.profilecmds.NickCommand;
@ -135,5 +136,7 @@ public class CommandRegistry {
LoadSchem.register(ev.getDispatcher());
Place.register(ev.getDispatcher());
PlaceAsAir.register(ev.getDispatcher());
ShareItemInChatCommand.register(ev.getDispatcher());
}
}

View file

@ -9,6 +9,7 @@ import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
public class FlyCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
@ -29,12 +30,8 @@ public class FlyCommand {
// homeName = StringArgumentType.getString(ctx2, "nickname");
// if(homeName==null)return 0;
CommandSourceStack ctx = ctx2.getSource();
if(! ctx.isPlayer())
{
return 1;
}
ServerPlayer p = ctx.getPlayer();
ServerPlayer p = (ServerPlayer)ctx.getEntity();
if(p==null)return 1;
if(p.getAbilities().mayfly){
@ -42,12 +39,12 @@ public class FlyCommand {
p.getAbilities().flying=false;
p.onUpdateAbilities();
ctx.sendSuccess(Component.literal(OTEMod.OTEPrefix + ChatColor.DARK_PURPLE + " Your ability to fly has been disabled"), false);
ctx.sendSuccess(new TextComponent(OTEMod.OTEPrefix + ChatColor.DARK_PURPLE + " Your ability to fly has been disabled"), false);
}else {
p.getAbilities().mayfly=true;
p.onUpdateAbilities();
ctx.sendSuccess(Component.literal(OTEMod.OTEPrefix + ChatColor.DARK_PURPLE + " You can now fly"), false);
ctx.sendSuccess(new TextComponent(OTEMod.OTEPrefix + ChatColor.DARK_PURPLE + " You can now fly"), false);
}
return 0;

View file

@ -13,7 +13,8 @@ import dev.zontreck.otemod.chat.ChatServerOverride;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Player;
import net.minecraft.network.chat.TextComponent;
public class DelHomeCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
@ -34,11 +35,11 @@ public class DelHomeCommand {
// homeName = StringArgumentType.getString(ctx2, "nickname");
// if(homeName==null)return 0;
if(! ctx.isPlayer())
if(!(ctx.getEntity() instanceof Player))
{
return 1;
}
ServerPlayer p = ctx.getPlayer();
ServerPlayer p = (ServerPlayer) ctx.getEntity();
Connection con = OTEMod.DB.getConnection();
try {
con.beginRequest();
@ -54,13 +55,13 @@ public class DelHomeCommand {
pstat.execute();
ChatServerOverride.broadcastTo(ctx.getPlayer().getUUID(), Component.literal(OTEMod.OTEPrefix + ChatColor.doColors("!dark_green! Home was deleted successfully")), ctx.getServer());
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors("!dark_green! Home was deleted successfully")), ctx.getServer());
con.endRequest();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
ChatServerOverride.broadcastTo(ctx.getPlayer().getUUID(), Component.literal(OTEMod.OTEPrefix + ChatColor.doColors("!dark_red! Home was unable to be deleted")), ctx.getServer());
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors("!dark_red! Home was unable to be deleted")), ctx.getServer());
return 1;
}

View file

@ -12,6 +12,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.libzontreck.exceptions.InvalidDeserialization;
import dev.zontreck.libzontreck.exceptions.InvalidSideException;
import dev.zontreck.otemod.OTEMod;
import dev.zontreck.otemod.chat.ChatServerOverride;
import dev.zontreck.otemod.commands.teleport.TeleportActioner;
@ -22,11 +23,12 @@ import net.minecraft.commands.Commands;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TextColor;
import net.minecraft.network.chat.TextComponent;
public class HomeCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
@ -47,11 +49,11 @@ public class HomeCommand {
// homeName = StringArgumentType.getString(ctx2, "nickname");
// if(homeName==null)return 0;
if(! ctx.isPlayer())
if(!(ctx.getEntity() instanceof Player))
{
return 1;
}
ServerPlayer p = ctx.getPlayer();
ServerPlayer p = (ServerPlayer)ctx.getEntity();
Connection con = OTEMod.DB.getConnection();
String SQL="";
try {
@ -83,7 +85,13 @@ public class HomeCommand {
position = dest.Position.asMinecraftVector();
rot = dest.Rotation.asMinecraftVector();
ServerLevel dimL = dest.getActualDimension();
ServerLevel dimL=null;
try {
dimL = (ServerLevel)dest.getActualDimension();
} catch (InvalidSideException e) {
e.printStackTrace();
return 1;
}
TeleportActioner.ApplyTeleportEffect(p);
// Instantiate a Teleport Runner
@ -101,15 +109,15 @@ public class HomeCommand {
Style sxx = Style.EMPTY.withColor(TextColor.parseColor(ChatColor.DARK_GREEN)).withFont(Style.DEFAULT_FONT);
ChatServerOverride.broadcastTo(ctx.getPlayer().getUUID(), Component.literal(OTEMod.OTEPrefix + ChatColor.doColors("!dark_green!Home found! Wormhole opening now...")), ctx.getServer());
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !dark_green!Home found! Wormhole opening now...")), ctx.getServer());
con.endRequest();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
if(!e.getMessage().equals("%%"))
ChatServerOverride.broadcastTo(ctx.getPlayer().getUUID(), Component.literal(OTEMod.OTEPrefix + ChatColor.doColors("!Dark_Red! Could not go to the home")), ctx.getServer());
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !Dark_Red! Could not go to the home")), ctx.getServer());
else
ctx.sendFailure(Component.literal("FAILED SQL: "+ ChatColor.GOLD+ SQL));
ctx.sendFailure(new TextComponent("FAILED SQL: "+ ChatColor.GOLD+ SQL));
} catch (InvalidDeserialization e) {
// TODO Auto-generated catch block
e.printStackTrace();

View file

@ -18,8 +18,9 @@ import dev.zontreck.otemod.chat.ChatServerOverride;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Player;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TextComponent;
public class HomesCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
@ -30,12 +31,12 @@ public class HomesCommand {
private static int getHomes(CommandContext<CommandSourceStack> ctx)
{
// Request homes
if(! ctx.getSource().isPlayer())
if(!(ctx.getSource().getEntity() instanceof Player))
{
return 1;
}
ServerPlayer p = ctx.getSource().getPlayer();
ServerPlayer p = (ServerPlayer)ctx.getSource().getEntity();
Connection con = OTEMod.DB.getConnection();
try {
con.beginRequest();
@ -46,13 +47,13 @@ public class HomesCommand {
homes.add(rs.getString("home_name"));
}
ChatServerOverride.broadcastTo(p.getUUID(), Component.literal(OTEMod.OTEPrefix + ChatColor.doColors(" !Dark_Purple!There are !gold!"+String.valueOf(homes.size())+" !dark_purple!total homes.")), p.server);
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !Dark_Purple!There are !gold!"+String.valueOf(homes.size())+" !dark_purple!total homes.")), p.server);
con.endRequest();
for (String string : homes) {
Style st = Style.EMPTY.withFont(Style.DEFAULT_FONT).withHoverEvent(HoverTip.get(ChatColor.BOLD+ChatColor.DARK_GREEN+"Click here to go to this home")).withClickEvent(Clickable.command("/home "+string));
ChatServerOverride.broadcastTo(ctx.getSource().getPlayer().getUUID(), Component.literal(ChatColor.BOLD + ChatColor.MINECOIN_GOLD+"["+ChatColor.resetChat()+ChatColor.UNDERLINE+ChatColor.BOLD+ChatColor.DARK_GREEN+"HOME"+ChatColor.resetChat()+ChatColor.BOLD+ChatColor.MINECOIN_GOLD+"] "+ChatColor.resetChat()+ChatColor.YELLOW+string).setStyle(st), ctx.getSource().getServer());
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(ChatColor.BOLD + ChatColor.MINECOIN_GOLD+"["+ChatColor.resetChat()+ChatColor.UNDERLINE+ChatColor.BOLD+ChatColor.DARK_GREEN+"HOME"+ChatColor.resetChat()+ChatColor.BOLD+ChatColor.MINECOIN_GOLD+"] "+ChatColor.resetChat()+ChatColor.YELLOW+string).setStyle(st), ctx.getSource().getServer());
}
} catch (SQLException e) {

View file

@ -16,9 +16,10 @@ import dev.zontreck.otemod.database.TeleportDestination;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
public class SetHomeCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
@ -39,12 +40,12 @@ public class SetHomeCommand {
// homeName = StringArgumentType.getString(ctx2, "nickname");
// if(homeName==null)return 0;
if(! ctx.isPlayer())
if(!(ctx.getEntity() instanceof Player))
{
return 1;
}
ServerPlayer p = ctx.getPlayer();
ServerPlayer p = (ServerPlayer)ctx.getEntity();
Connection con = OTEMod.DB.getConnection();
try {
con.beginRequest();
@ -63,13 +64,13 @@ public class SetHomeCommand {
pstat.execute();
ChatServerOverride.broadcastTo(p.getUUID(), Component.literal(OTEMod.OTEPrefix + ChatColor.doColors(" !dark_green!Home was created or updated successfully!")), ctx.getServer());
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !dark_green!Home was created or updated successfully!")), ctx.getServer());
con.endRequest();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
ChatServerOverride.broadcastTo(p.getUUID(), Component.literal(OTEMod.OTEPrefix + ChatColor.doColors(" !dark_red!Home could not be updated or created for a unknown reason!")), ctx.getServer());
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !dark_red!Home could not be updated or created for a unknown reason!")), ctx.getServer());
return 1;
}

View file

@ -0,0 +1,58 @@
package dev.zontreck.otemod.commands.items;
import com.mojang.brigadier.CommandDispatcher;
import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.libzontreck.chat.HoverTip;
import dev.zontreck.otemod.OTEMod;
import dev.zontreck.otemod.configs.Profile;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.AirItem;
import net.minecraft.world.item.ItemStack;
public class ShareItemInChatCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
{
dispatcher.register(Commands.literal("shareitem").executes(c->share_item(c.getSource())));
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
//String arg = StringArgumentType.getString(command, "nickname");
//return setHome(command.getSource(), arg);
//}));
}
private static int share_item(CommandSourceStack source) {
if(source.getEntity() instanceof Player)
{
ServerPlayer play = (ServerPlayer)source.getEntity();
ItemStack is = play.getItemInHand(InteractionHand.MAIN_HAND);
if(is.getItem() instanceof AirItem)
{
play.displayClientMessage(new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!You cannot share air in the chat.")), false);
return 0;
}
Profile prof = Profile.get_profile_of(play.getUUID().toString());
MutableComponent component = new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !Dark_Green!" + is.getDisplayName()+" !White!-!Dark_Purple! Hover here to see the item that "+prof.name_color+prof.nickname+"!Dark_Purple! shared"));
Style style = Style.EMPTY.withFont(Style.DEFAULT_FONT);
component = component.withStyle(style.withHoverEvent(HoverTip.getItem(is)));
play.server.sendMessage(component, play.getUUID());
}else {
return 1;
}
return 0;
}
}

View file

@ -9,6 +9,9 @@ import dev.zontreck.otemod.configs.Profile;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.server.command.EnumArgument;
public class ChatColorCommand {
@ -35,15 +38,16 @@ public class ChatColorCommand {
String colorcoded = ChatColor.from(string);
// Get profile
if(source.getPlayer()==null){
if(!(source.getEntity() instanceof Player)){
return 1;
}
Profile p = Profile.get_profile_of(source.getPlayer().getStringUUID());
ServerPlayer play = (ServerPlayer)source.getEntity();
Profile p = Profile.get_profile_of(play.getStringUUID());
p.chat_color = colorcoded;
p.commit();
OTEMod.PROFILES.put(source.getPlayer().getStringUUID(), p);
OTEMod.PROFILES.put(play.getStringUUID(), p);
source.sendSuccess(Component.literal(OTEMod.OTEPrefix + " "+ChatColor.DARK_PURPLE + "Your chat color has been updated"), false);
source.sendSuccess(new TextComponent(OTEMod.OTEPrefix + " "+ChatColor.DARK_PURPLE + "Your chat color has been updated"), false);
return 0;
}

View file

@ -9,6 +9,9 @@ import dev.zontreck.otemod.configs.Profile;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.server.command.EnumArgument;
public class NameColorCommand {
@ -35,16 +38,16 @@ public class NameColorCommand {
String colorcoded = ChatColor.from(string);
// Get profile
if(source.getPlayer()==null){
source.sendFailure(Component.literal(ChatColor.DARK_RED+"Only a player can use this command"));
if(!(source.getEntity() instanceof Player)){
return 1;
}
Profile p = Profile.get_profile_of(source.getPlayer().getStringUUID());
ServerPlayer play = (ServerPlayer)source.getEntity();
Profile p = Profile.get_profile_of(play.getStringUUID());
p.name_color = colorcoded;
p.commit();
OTEMod.PROFILES.put(source.getPlayer().getStringUUID(), p);
OTEMod.PROFILES.put(play.getStringUUID(), p);
source.sendSuccess(Component.literal(OTEMod.OTEPrefix+ " "+ChatColor.DARK_PURPLE + "Your name color has been updated"), false);
source.sendSuccess(new TextComponent(OTEMod.OTEPrefix+ " "+ChatColor.DARK_PURPLE + "Your name color has been updated"), false);
return 0;
}

View file

@ -9,13 +9,16 @@ import dev.zontreck.otemod.configs.Profile;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
public class NickCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
{
dispatcher.register(Commands.literal("nick")
.executes(c->setchatcolor(c.getSource(), c.getSource().getPlayer().getName().getString()))
.executes(c->setchatcolor(c.getSource(), c.getSource().getPlayerOrException().getName().getString()))
.then(Commands.argument("new_name", StringArgumentType.string())//StringArgumentType.string())
.executes(c -> setchatcolor(c.getSource(), StringArgumentType.getString(c, "new_name")))// EnumArgument.getS(c, "color")))
)
@ -30,16 +33,17 @@ public class NickCommand {
public static int setchatcolor(CommandSourceStack source, String string) {
// Get profile
if(source.getPlayer()==null){
source.sendFailure(Component.literal(ChatColor.DARK_RED+"Only a player can use this command"));
if(!(source.getEntity() instanceof Player)){
return 1;
}
Profile p = Profile.get_profile_of(source.getPlayer().getStringUUID());
ServerPlayer play = (ServerPlayer)source.getEntity();
Profile p = Profile.get_profile_of(play.getStringUUID());
p.nickname = string;
p.commit();
OTEMod.PROFILES.put(source.getPlayer().getStringUUID(), p);
OTEMod.PROFILES.put(play.getStringUUID(), p);
source.sendSuccess(Component.literal(OTEMod.OTEPrefix+ " "+ChatColor.DARK_PURPLE + "Your nickname has been updated"), false);
source.sendSuccess(new TextComponent(OTEMod.OTEPrefix+ " "+ChatColor.DARK_PURPLE + "Your nickname has been updated"), false);
return 0;
}

View file

@ -9,6 +9,9 @@ import dev.zontreck.otemod.configs.Profile;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.server.command.EnumArgument;
public class PrefixColorCommand {
@ -35,16 +38,17 @@ public class PrefixColorCommand {
String colorcoded = ChatColor.from(string);
// Get profile
if(source.getPlayer()==null){
source.sendFailure(Component.literal(ChatColor.DARK_RED+"Only a player can use this command"));
if(!(source.getEntity() instanceof Player)){
return 1;
}
Profile p = Profile.get_profile_of(source.getPlayer().getStringUUID());
ServerPlayer play = (ServerPlayer)source.getEntity();
Profile p = Profile.get_profile_of(play.getStringUUID());
p.prefix_color = colorcoded;
p.commit();
OTEMod.PROFILES.put(source.getPlayer().getStringUUID(), p);
OTEMod.PROFILES.put(play.getStringUUID(), p);
source.sendSuccess(Component.literal(OTEMod.OTEPrefix+ " "+ChatColor.DARK_PURPLE + "Your prefix color has been updated"), false);
source.sendSuccess(new TextComponent(OTEMod.OTEPrefix+ " "+ChatColor.DARK_PURPLE + "Your prefix color has been updated"), false);
return 0;
}

View file

@ -9,6 +9,9 @@ import dev.zontreck.otemod.configs.Profile;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
public class PrefixCommand {
@ -30,16 +33,17 @@ public class PrefixCommand {
public static int setchatcolor(CommandSourceStack source, String string) {
// Get profile
if(source.getPlayer()==null){
source.sendFailure(Component.literal(ChatColor.DARK_RED+"Only a player can use this command"));
if(!(source.getEntity() instanceof Player)){
return 1;
}
Profile p = Profile.get_profile_of(source.getPlayer().getStringUUID());
ServerPlayer play = (ServerPlayer)source.getEntity();
Profile p = Profile.get_profile_of(play.getStringUUID());
p.prefix = string;
p.commit();
OTEMod.PROFILES.put(source.getPlayer().getStringUUID(), p);
OTEMod.PROFILES.put(play.getStringUUID(), p);
source.sendSuccess(Component.literal(OTEMod.OTEPrefix+ " "+ChatColor.DARK_PURPLE + "Your prefix has been updated"), false);
source.sendSuccess(new TextComponent(OTEMod.OTEPrefix+ " "+ChatColor.DARK_PURPLE + "Your prefix has been updated"), false);
return 0;
}

View file

@ -17,8 +17,10 @@ import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
@ -109,8 +111,12 @@ public class RTPCommand {
//return 0; // Removed until the player data registry is implemented
}
CommandRegistry.markUsed("rtp");*/
ServerPlayer pla = source.getPlayer();
TeleportContainer cont = new TeleportContainer(pla, null, source.getPlayer().getRotationVector(), source.getLevel());
if(!(source.getEntity() instanceof Player)){
return 1;
}
ServerPlayer pla = (ServerPlayer)source.getEntity();
TeleportContainer cont = new TeleportContainer(pla, null, pla.getRotationVector(), source.getLevel());
@ -125,7 +131,7 @@ public class RTPCommand {
boolean found_place= false;
int tries=0;
ChatServerOverride.broadcastTo(pla.getUUID(), Component.literal(ChatColor.DARK_GRAY + "["+ChatColor.DARK_GREEN+"OTEMOD"+ChatColor.DARK_GRAY+"] "+ChatColor.GREEN+"Searching for a suitable landing location..."), source.getServer());
ChatServerOverride.broadcastTo(pla.getUUID(), new TextComponent(ChatColor.DARK_GRAY + "["+ChatColor.DARK_GREEN+"OTEMOD"+ChatColor.DARK_GRAY+"] "+ChatColor.GREEN+"Searching for a suitable landing location..."), source.getServer());
/*
*
*
@ -212,7 +218,7 @@ public class RTPCommand {
}*/
v=findPosition(source.getLevel(), allowWater);
ChatServerOverride.broadcastTo(pla.getUUID(), Component.literal(ChatColor.DARK_GRAY + "["+ChatColor.DARK_GREEN + "OTEMOD" + ChatColor.DARK_GRAY + "] "+ChatColor.DARK_PURPLE+" A suitable location has been found. Wormhole opening now!"), source.getServer());
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!"), source.getServer());
// Apply the effect
TeleportActioner.ApplyTeleportEffect(pla);
@ -230,6 +236,8 @@ public class RTPCommand {
}
private static int doCancel(CommandSourceStack source, String TPID) {
ServerPlayer play = (ServerPlayer)source.getEntity();
UUID teleporter = UUID.fromString(TPID);
for(TeleportContainer cont : OTEMod.TeleportRegistry){
if(cont.TeleportID.equals(teleporter)){
@ -238,7 +246,7 @@ public class RTPCommand {
ServerPlayer from = source.getServer().getPlayerList().getPlayer(cont.FromPlayer);
ServerPlayer to = source.getServer().getPlayerList().getPlayer(cont.ToPlayer);
Component comp = Component.literal(ChatColor.DARK_GRAY + "["+ ChatColor.DARK_GREEN+ "OTEMOD" + ChatColor.DARK_GRAY+"] " + ChatColor.DARK_PURPLE+"Teleport request was accepted. Opening wormhole!");
Component comp = new TextComponent(ChatColor.DARK_GRAY + "["+ ChatColor.DARK_GREEN+ "OTEMOD" + ChatColor.DARK_GRAY+"] " + ChatColor.DARK_PURPLE+"Teleport request was accepted. Opening wormhole!");
ChatServerOverride.broadcastTo(cont.FromPlayer, comp, source.getServer());
ChatServerOverride.broadcastTo(cont.ToPlayer, comp, source.getServer());
@ -257,9 +265,9 @@ public class RTPCommand {
}
}
Component comp = Component.literal(ChatColor.DARK_RED+"The teleport was not found, perhaps the request expired or was already cancelled/denied");
Component comp = new TextComponent(ChatColor.DARK_RED+"The teleport was not found, perhaps the request expired or was already cancelled/denied");
ChatServerOverride.broadcastTo(source.getPlayer().getUUID(), comp, source.getServer());
ChatServerOverride.broadcastTo(play.getUUID(), comp, source.getServer());
return 0;
}

View file

@ -15,6 +15,7 @@ import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
public class TPACommand {
@ -32,24 +33,26 @@ public class TPACommand {
private static int tpa(CommandSourceStack source, ServerPlayer serverPlayer) {
// Send the request to player
if(serverPlayer == null){
source.sendFailure(Component.literal(ChatColor.DARK_RED+"Error: Player not found"));
source.sendFailure(new TextComponent(ChatColor.DARK_RED+"Error: Player not found"));
return 1;
}
ServerPlayer play = (ServerPlayer)source.getEntity();
if(!OTEMod.DEVELOPER){
if(source.getPlayer().getUUID() == serverPlayer.getUUID()){
source.sendFailure(Component.literal(ChatColor.DARK_RED+"You cannot teleport to yourself!"));
if(play.getUUID() == serverPlayer.getUUID()){
source.sendFailure(new TextComponent(ChatColor.DARK_RED+"You cannot teleport to yourself!"));
return 1;
}
}
TeleportContainer cont = new TeleportContainer(source.getPlayer().getUUID(), serverPlayer.getUUID());
TeleportContainer cont = new TeleportContainer(play.getUUID(), serverPlayer.getUUID());
for(TeleportContainer cont2 : OTEMod.TeleportRegistry){
if(cont2.compareTo(cont)==0){
ChatServerOverride.broadcastTo(cont.FromPlayer, Component.literal(ChatColor.DARK_RED+ "You already have a TPA Request active, wait for it to expire, or use the cancel button/command"), source.getServer());
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());
return 0;
}else {
if(cont2.FromPlayer == cont.FromPlayer){
ChatServerOverride.broadcastTo(cont.FromPlayer, Component.literal(ChatColor.DARK_RED+ "You already have a TPA Request active, wait for it to expire, or use the cancel button/command"), source.getServer());
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());
return 0;
}
}
@ -62,7 +65,7 @@ public class TPACommand {
Style s = Style.EMPTY.withFont(Style.DEFAULT_FONT).withHoverEvent(he).withClickEvent(ce);
// Send the alerts
ChatServerOverride.broadcastTo(cont.FromPlayer, Component.literal(ChatColor.BOLD + ChatColor.DARK_GREEN +"TPA Request Sent! ").append(Component.literal(ChatColor.BOLD+ChatColor.DARK_GRAY+"["+ChatColor.DARK_RED+"X"+ChatColor.DARK_GRAY+"]").setStyle(s)), serverPlayer.server);
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);
ce = Clickable.command("/tpaccept "+cont.TeleportID.toString());
@ -74,16 +77,16 @@ public class TPACommand {
Style s2 = Style.EMPTY.withFont(Style.DEFAULT_FONT).withClickEvent(ce2).withHoverEvent(he2);
Profile p = Profile.get_profile_of(cont.FromPlayer.toString());
ChatServerOverride.broadcastTo(cont.ToPlayer, Component.literal(p.name_color+p.nickname + ChatColor.BOLD + ChatColor.DARK_PURPLE+" is requesting to teleport to you\n \n").
append(Component.literal(ChatColor.DARK_GRAY+"["+ChatColor.DARK_GREEN+"ACCEPT" + ChatColor.DARK_GRAY+"] ").setStyle(s)).
append(Component.literal(ChatColor.DARK_GRAY + "["+ChatColor.DARK_RED+"DENY"+ChatColor.DARK_GRAY+"]").setStyle(s2)), serverPlayer.server);
ChatServerOverride.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);
return 0;
}
private static int usage(CommandSourceStack source) {
source.sendSuccess(Component.literal("/tpa USAGE\n\n "+ChatColor.BOLD + ChatColor.DARK_GRAY+"/tpa "+ChatColor.DARK_RED+"target_player\n"), false);
source.sendSuccess(new TextComponent("/tpa USAGE\n\n "+ChatColor.BOLD + ChatColor.DARK_GRAY+"/tpa "+ChatColor.DARK_RED+"target_player\n"), false);
return 0;
}
}

View file

@ -15,6 +15,7 @@ import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
public class TPAHereCommand {
@ -31,25 +32,27 @@ public class TPAHereCommand {
private static int tpa(CommandSourceStack source, ServerPlayer serverPlayer) {
// Send the request to player
ServerPlayer play = (ServerPlayer)source.getEntity();
if(serverPlayer == null){
source.sendFailure(Component.literal(ChatColor.DARK_RED+"Error: Player not found"));
source.sendFailure(new TextComponent(ChatColor.DARK_RED+"Error: Player not found"));
return 1;
}
if(!OTEMod.DEVELOPER){
if(source.getPlayer().getUUID() == serverPlayer.getUUID()){
source.sendFailure(Component.literal(ChatColor.DARK_RED+"You cannot teleport to yourself!"));
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(), source.getPlayer().getUUID());
TeleportContainer cont = new TeleportContainer(serverPlayer.getUUID(), play.getUUID());
for(TeleportContainer cont2 : OTEMod.TeleportRegistry){
if(cont2.compareTo(cont)==0){
ChatServerOverride.broadcastTo(cont.ToPlayer, Component.literal(ChatColor.DARK_RED+ "You already have a TPA Request active, wait for it to expire, or use the cancel button/command"), source.getServer());
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());
return 0;
}else {
if(cont2.ToPlayer.equals(cont.ToPlayer)){
ChatServerOverride.broadcastTo(cont.FromPlayer, Component.literal(ChatColor.DARK_RED+ "You already have a TPA Request active, wait for it to expire, or use the cancel button/command"), source.getServer());
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());
return 0;
}
}
@ -62,7 +65,7 @@ public class TPAHereCommand {
Style s = Style.EMPTY.withFont(Style.DEFAULT_FONT).withHoverEvent(he).withClickEvent(ce);
// Send the alerts
ChatServerOverride.broadcastTo(cont.ToPlayer, Component.literal(ChatColor.BOLD + ChatColor.DARK_GREEN +"TPA Request Sent! ").append(Component.literal(ChatColor.BOLD+ChatColor.DARK_GRAY+"["+ChatColor.DARK_RED+"X"+ChatColor.DARK_GRAY+"]").setStyle(s)), serverPlayer.server);
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);
ce = Clickable.command("/tpaccept "+cont.TeleportID.toString());
@ -74,16 +77,16 @@ public class TPAHereCommand {
Style s2 = Style.EMPTY.withFont(Style.DEFAULT_FONT).withClickEvent(ce2).withHoverEvent(he2);
Profile p = Profile.get_profile_of(cont.ToPlayer.toString());
ChatServerOverride.broadcastTo(cont.FromPlayer, Component.literal(p.name_color+p.nickname + ChatColor.BOLD + ChatColor.DARK_PURPLE+" is requesting you to teleport to them\n \n").
append(Component.literal(ChatColor.DARK_GRAY+"["+ChatColor.DARK_GREEN+"ACCEPT" + ChatColor.DARK_GRAY+"] ").setStyle(s)).
append(Component.literal(ChatColor.DARK_GRAY + "["+ChatColor.DARK_RED+"DENY"+ChatColor.DARK_GRAY+"]").setStyle(s2)), serverPlayer.server);
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").
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);
return 0;
}
private static int usage(CommandSourceStack source) {
source.sendSuccess(Component.literal("/tpa USAGE\n\n "+ChatColor.BOLD + ChatColor.DARK_GRAY+"/tpa "+ChatColor.DARK_RED+"target_player\n"), false);
source.sendSuccess(new TextComponent("/tpa USAGE\n\n "+ChatColor.BOLD + ChatColor.DARK_GRAY+"/tpa "+ChatColor.DARK_RED+"target_player\n"), false);
return 0;
}
}

View file

@ -11,6 +11,7 @@ import dev.zontreck.otemod.chat.ChatServerOverride;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
public class TPAcceptCommand {
@ -29,6 +30,8 @@ public class TPAcceptCommand {
private static int doCancel(CommandSourceStack source, String TPID) {
UUID teleporter = UUID.fromString(TPID);
ServerPlayer play = (ServerPlayer)source.getEntity();
for(TeleportContainer cont : OTEMod.TeleportRegistry){
if(cont.TeleportID.equals(teleporter)){
// Accepting!
@ -36,7 +39,7 @@ public class TPAcceptCommand {
ServerPlayer from = source.getServer().getPlayerList().getPlayer(cont.FromPlayer);
ServerPlayer to = source.getServer().getPlayerList().getPlayer(cont.ToPlayer);
Component comp = Component.literal(OTEMod.OTEPrefix + " " + ChatColor.DARK_PURPLE+"Teleport request was accepted. Opening wormhole!");
Component comp = new TextComponent(OTEMod.OTEPrefix + " " + ChatColor.DARK_PURPLE+"Teleport request was accepted. Opening wormhole!");
ChatServerOverride.broadcastTo(cont.FromPlayer, comp, source.getServer());
ChatServerOverride.broadcastTo(cont.ToPlayer, comp, source.getServer());
@ -55,9 +58,9 @@ public class TPAcceptCommand {
}
}
Component comp = Component.literal(ChatColor.DARK_RED+"The teleport was not found, perhaps the request expired or was already cancelled/denied");
Component comp = new TextComponent(ChatColor.DARK_RED+"The teleport was not found, perhaps the request expired or was already cancelled/denied");
ChatServerOverride.broadcastTo(source.getPlayer().getUUID(), comp, source.getServer());
ChatServerOverride.broadcastTo(play.getUUID(), comp, source.getServer());
return 0;
}

View file

@ -11,6 +11,8 @@ import dev.zontreck.otemod.chat.ChatServerOverride;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
public class TPCancelCommand {
@ -28,10 +30,12 @@ public class TPCancelCommand {
private static int doCancel(CommandSourceStack source, String TPID) {
UUID teleporter = UUID.fromString(TPID);
ServerPlayer play = (ServerPlayer)source.getEntity();
for(TeleportContainer cont : OTEMod.TeleportRegistry){
if(cont.TeleportID.equals(teleporter)){
// Canceling!
Component comp = Component.literal(OTEMod.OTEPrefix + " " + ChatColor.DARK_PURPLE+"Teleport request was cancelled");
Component comp = new TextComponent(OTEMod.OTEPrefix + " " + ChatColor.DARK_PURPLE+"Teleport request was cancelled");
ChatServerOverride.broadcastTo(cont.FromPlayer, comp, source.getServer());
ChatServerOverride.broadcastTo(cont.ToPlayer, comp, source.getServer());
@ -41,9 +45,9 @@ public class TPCancelCommand {
}
}
Component comp = Component.literal(ChatColor.DARK_RED+"The teleport was not found, perhaps the request expired or was already cancelled");
Component comp = new TextComponent(ChatColor.DARK_RED+"The teleport was not found, perhaps the request expired or was already cancelled");
ChatServerOverride.broadcastTo(source.getPlayer().getUUID(), comp, source.getServer());
ChatServerOverride.broadcastTo(play.getUUID(), comp, source.getServer());
return 0;
}

View file

@ -11,6 +11,8 @@ import dev.zontreck.otemod.chat.ChatServerOverride;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
public class TPDenyCommand {
@ -28,10 +30,12 @@ public class TPDenyCommand {
private static int doCancel(CommandSourceStack source, String TPID) {
UUID teleporter = UUID.fromString(TPID);
ServerPlayer play = (ServerPlayer)source.getEntity();
for(TeleportContainer cont : OTEMod.TeleportRegistry){
if(cont.TeleportID.equals(teleporter)){
// Canceling!
Component comp = Component.literal(OTEMod.OTEPrefix + " " + ChatColor.DARK_PURPLE+"Teleport request was denied");
Component comp = new TextComponent(OTEMod.OTEPrefix + " " + ChatColor.DARK_PURPLE+"Teleport request was denied");
ChatServerOverride.broadcastTo(cont.FromPlayer, comp, source.getServer());
ChatServerOverride.broadcastTo(cont.ToPlayer, comp, source.getServer());
@ -41,9 +45,9 @@ public class TPDenyCommand {
}
}
Component comp = Component.literal(ChatColor.DARK_RED+"The teleport was not found, perhaps the request expired or was already cancelled/denied");
Component comp = new TextComponent(ChatColor.DARK_RED+"The teleport was not found, perhaps the request expired or was already cancelled/denied");
ChatServerOverride.broadcastTo(source.getPlayer().getUUID(), comp, source.getServer());
ChatServerOverride.broadcastTo(play.getUUID(), comp, source.getServer());
return 0;
}

View file

@ -19,7 +19,7 @@ public class TeleportActioner
player.server.execute(new Runnable(){
public void run(){
MobEffectInstance inst = new MobEffectInstance(MobEffects.DARKNESS, 200, 1, true, true);
MobEffectInstance inst = new MobEffectInstance(MobEffects.BLINDNESS, 200, 1, true, true);
MobEffectInstance regen = new MobEffectInstance(MobEffects.REGENERATION, 200, 2, true, true);
// 10-05-2022 - Adjusted to 100 on duration due to a small issue where it would sometimes stop levitation prior to the teleport taking effect.

View file

@ -6,6 +6,8 @@ import dev.zontreck.otemod.implementation.vault.VaultContainer;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.SimpleMenuProvider;
import net.minecraftforge.network.NetworkHooks;
@ -24,14 +26,15 @@ public class TrashCommand {
private static int vault(CommandSourceStack source) {
//VaultContainer cont = new VaultContainer(i, source.getPlayer().getUUID());
//cont.startOpen(source.getPlayer());
ServerPlayer play = (ServerPlayer)source.getEntity();
VaultContainer container = new VaultContainer(play, -1);
VaultContainer container = new VaultContainer(source.getPlayer(), -1);
NetworkHooks.openScreen(source.getPlayer(), new SimpleMenuProvider(container.serverMenu, Component.literal("Trash")));
NetworkHooks.openGui(play, new SimpleMenuProvider(container.serverMenu, new TextComponent("Trash")));
// Add to the master vault registry
if(VaultContainer.VAULT_REGISTRY.containsKey(source.getPlayer().getUUID()))VaultContainer.VAULT_REGISTRY.remove(source.getPlayer().getUUID());
VaultContainer.VAULT_REGISTRY.put(source.getPlayer().getUUID(), container);
if(VaultContainer.VAULT_REGISTRY.containsKey(play.getUUID()))VaultContainer.VAULT_REGISTRY.remove(play.getUUID());
VaultContainer.VAULT_REGISTRY.put(play.getUUID(), container);
return 0;
}

View file

@ -10,6 +10,7 @@ import dev.zontreck.otemod.implementation.vault.VaultContainer;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.SimpleMenuProvider;
import net.minecraft.world.entity.player.Player;
@ -31,12 +32,13 @@ public class VaultCommand {
private static int vault(CommandSourceStack source, int i) {
//VaultContainer cont = new VaultContainer(i, source.getPlayer().getUUID());
//cont.startOpen(source.getPlayer());
ServerPlayer play = (ServerPlayer)source.getEntity();
if(i <0)
{
ChatServerOverride.broadcastTo(source.getPlayer().getUUID(), Component.literal(ChatColor.doColors(OTEMod.OTEPrefix+" !Dark_Red!You can only specify a vault number in the positive range")), source.getServer());
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(ChatColor.doColors(OTEMod.OTEPrefix+" !Dark_Red!You can only specify a vault number in the positive range")), source.getServer());
return 0;
}
doOpen(source.getPlayer(), i);
doOpen(play, i);
return 0;
@ -46,7 +48,7 @@ public class VaultCommand {
VaultContainer container = new VaultContainer(p, i);
NetworkHooks.openScreen(p, new SimpleMenuProvider(container.serverMenu, Component.literal("Vault "+i)));
NetworkHooks.openGui(p, new SimpleMenuProvider(container.serverMenu, new TextComponent("Vault "+i)));
// Add to the master vault registry
if(VaultContainer.VAULT_REGISTRY.containsKey(p.getUUID()))VaultContainer.VAULT_REGISTRY.remove(p.getUUID());

View file

@ -16,6 +16,8 @@ import dev.zontreck.otemod.database.TeleportDestination;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
@ -34,12 +36,7 @@ public class DelWarpCommand {
private static int setWarp(CommandSourceStack source, String string) {
if(! source.isPlayer())
{
ChatServerOverride.broadcastTo(source.getPlayer().getUUID(), Component.literal(OTEMod.OTEPrefix + OTEMod.ONLY_PLAYER), source.getServer());
return 1;
}
ServerPlayer p = source.getPlayer();
ServerPlayer p = (ServerPlayer)source.getEntity();
Connection con = OTEMod.DB.getConnection();
try {
con.beginRequest();
@ -56,13 +53,13 @@ public class DelWarpCommand {
pstat.execute();
ChatServerOverride.broadcastTo(source.getPlayer().getUUID(), Component.literal(ChatColor.GREEN).append(Component.translatable("dev.zontreck.otemod.msgs.warps.del.success")), source.getServer());
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(ChatColor.GREEN).append(new TranslatableComponent("dev.zontreck.otemod.msgs.warps.del.success")), source.getServer());
con.endRequest();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
ChatServerOverride.broadcastTo(source.getPlayer().getUUID(), Component.literal(ChatColor.DARK_RED).append(Component.translatable("dev.zontreck.otemod.msgs.warps.del.fail")), source.getServer());
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(ChatColor.DARK_RED).append(new TranslatableComponent("dev.zontreck.otemod.msgs.warps.del.fail")), source.getServer());
}
return 0;

View file

@ -16,6 +16,8 @@ import dev.zontreck.otemod.database.TeleportDestination;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
@ -34,14 +36,7 @@ public class RTPWarpCommand {
private static int setWarp(CommandSourceStack source, String string) {
if(! source.isPlayer())
{
ChatServerOverride.broadcastTo(source.getPlayer().getUUID(), Component.literal(OTEMod.OTEPrefix + OTEMod.ONLY_PLAYER), source.getServer());
return 1;
}
ServerPlayer p = source.getPlayer();
ServerPlayer p = (ServerPlayer)source.getEntity();
Connection con = OTEMod.DB.getConnection();
try {
con.beginRequest();
@ -60,13 +55,13 @@ public class RTPWarpCommand {
pstat.execute();
ChatServerOverride.broadcastTo(source.getPlayer().getUUID(), Component.literal(ChatColor.GREEN).append(Component.translatable("dev.zontreck.otemod.msgs.warps.set.success")), source.getServer());
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(ChatColor.GREEN).append(new TranslatableComponent("dev.zontreck.otemod.msgs.warps.set.success")), source.getServer());
con.endRequest();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
ChatServerOverride.broadcastTo(source.getPlayer().getUUID(), Component.literal(ChatColor.DARK_RED).append(Component.translatable("dev.zontreck.otemod.msgs.warps.set.fail")), source.getServer());
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(ChatColor.DARK_RED).append(new TranslatableComponent("dev.zontreck.otemod.msgs.warps.set.fail")), source.getServer());
}
return 0;

View file

@ -16,6 +16,8 @@ import dev.zontreck.otemod.database.TeleportDestination;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
@ -34,13 +36,7 @@ public class SetWarpCommand {
private static int setWarp(CommandSourceStack source, String string) {
if(! source.isPlayer())
{
ChatServerOverride.broadcastTo(source.getPlayer().getUUID(), Component.literal(OTEMod.OTEPrefix + OTEMod.ONLY_PLAYER), source.getServer());
return 1;
}
ServerPlayer p = source.getPlayer();
ServerPlayer p = (ServerPlayer)source.getEntity();
Connection con = OTEMod.DB.getConnection();
try {
con.beginRequest();
@ -59,13 +55,13 @@ public class SetWarpCommand {
pstat.execute();
ChatServerOverride.broadcastTo(source.getPlayer().getUUID(), Component.literal(ChatColor.GREEN).append(Component.translatable("dev.zontreck.otemod.msgs.warps.set.success")), source.getServer());
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(ChatColor.GREEN).append(new TranslatableComponent("dev.zontreck.otemod.msgs.warps.set.success")), source.getServer());
con.endRequest();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
ChatServerOverride.broadcastTo(source.getPlayer().getUUID(), Component.literal(ChatColor.DARK_RED).append(Component.translatable("dev.zontreck.otemod.msgs.warps.set.fail")), source.getServer());
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(ChatColor.DARK_RED).append(new TranslatableComponent("dev.zontreck.otemod.msgs.warps.set.fail")), source.getServer());
}
return 0;

View file

@ -9,6 +9,7 @@ import com.mojang.brigadier.arguments.StringArgumentType;
import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.libzontreck.chat.Clickable;
import dev.zontreck.libzontreck.exceptions.InvalidSideException;
import dev.zontreck.otemod.OTEMod;
import dev.zontreck.otemod.chat.ChatServerOverride;
import dev.zontreck.otemod.commands.teleport.RTPCommand;
@ -18,8 +19,8 @@ import dev.zontreck.otemod.database.TeleportDestination;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
@ -36,13 +37,8 @@ public class WarpCommand {
}
private static int warp(CommandSourceStack source, String string) {
if(!source.isPlayer()){
ChatServerOverride.broadcastTo(source.getPlayer().getUUID(), Component.literal(OTEMod.OTEPrefix + OTEMod.ONLY_PLAYER), source.getServer());
return 1;
}
ServerPlayer p = source.getPlayer();
ServerPlayer p = (ServerPlayer)source.getEntity();
Connection con = OTEMod.DB.getConnection();
String SQL = "";
try{
@ -59,8 +55,13 @@ public class WarpCommand {
TeleportDestination dest = new TeleportDestination(NbtUtils.snbtToStructure(rs.getString("teleporter")));
ServerLevel dimL = dest.getActualDimension();
ServerLevel dimL = null;
try{
dimL=(ServerLevel) dest.getActualDimension();
}catch(InvalidSideException e)
{
return 1;
}
final int type = rs.getInt("warptype");
final ServerLevel f_dim = dimL;
@ -79,7 +80,7 @@ public class WarpCommand {
});
tx.start();
}else {
ChatServerOverride.broadcastTo(source.getPlayer().getUUID(), Component.literal(ChatColor.DARK_RED+"No such warp"), source.getServer());
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(ChatColor.DARK_RED+"No such warp"), source.getServer());
}
@ -91,7 +92,8 @@ public class WarpCommand {
}
private static int nowarp(CommandSourceStack source) {
ChatServerOverride.broadcastTo(source.getPlayer().getUUID(), Component.literal(ChatColor.DARK_RED + "You must supply the warp name. If you need to know what warps are available, please use the warps command, or click this message.").withStyle(Style.EMPTY.withFont(Style.DEFAULT_FONT).withClickEvent(Clickable.command("/warps"))), source.getServer());
ServerPlayer p = (ServerPlayer)source.getEntity();
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(ChatColor.DARK_RED + "You must supply the warp name. If you need to know what warps are available, please use the warps command, or click this message.").withStyle(Style.EMPTY.withFont(Style.DEFAULT_FONT).withClickEvent(Clickable.command("/warps"))), source.getServer());
return 0;
}

View file

@ -18,6 +18,7 @@ import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
public class WarpsCommand {
@ -33,13 +34,9 @@ public class WarpsCommand {
}
private static int warps(CommandSourceStack source) {
if(!source.isPlayer())
{
ChatServerOverride.broadcastTo(source.getPlayer().getUUID(), Component.literal(OTEMod.OTEPrefix + OTEMod.ONLY_PLAYER), source.getServer());
return 1;
}
ServerPlayer p = source.getPlayer();
ServerPlayer p = (ServerPlayer)source.getEntity();
Connection con = OTEMod.DB.getConnection();
try{
// Begin
@ -54,7 +51,7 @@ public class WarpsCommand {
count++;
}
rs=pstat.executeQuery();// Reset the query
ChatServerOverride.broadcastTo(p.getUUID(), Component.literal(OTEMod.OTEPrefix + " "+ChatColor.resetChat() + "There are "+count+" warps available"), source.getServer());
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix + " "+ChatColor.resetChat() + "There are "+count+" warps available"), source.getServer());
while(rs.next())
{
@ -69,16 +66,16 @@ public class WarpsCommand {
ClickEvent click = Clickable.command("/warp "+warpName);
Style S = Style.EMPTY.withFont(Style.DEFAULT_FONT).withHoverEvent(hover).withClickEvent(click);
Component warpMsg = Component.literal(ChatColor.GREEN + warpName + ChatColor.resetChat()).withStyle(S);
Component warpMsg = new TextComponent(ChatColor.GREEN + warpName + ChatColor.resetChat()).withStyle(S);
// Now, display the warp name, along with the warp's owner information
HoverEvent h2 = HoverTip.get(prof.name_color+prof.nickname+ChatColor.resetChat()+ChatColor.AQUA+" is the owner of this warp");
S = Style.EMPTY.withFont(Style.DEFAULT_FONT).withHoverEvent(h2);
Component ownerInfo = Component.literal(ChatColor.GOLD+ " [Hover to see the warp's info]").withStyle(S);
Component ownerInfo = new TextComponent(ChatColor.GOLD+ " [Hover to see the warp's info]").withStyle(S);
// Combine the two
warpMsg = Component.literal("").append(warpMsg).append(ownerInfo);
ChatServerOverride.broadcastTo(source.getPlayer().getUUID(), warpMsg, source.getServer());
warpMsg = new TextComponent("").append(warpMsg).append(ownerInfo);
ChatServerOverride.broadcastTo(p.getUUID(), warpMsg, source.getServer());
}
}catch (Exception E)
{

View file

@ -26,7 +26,7 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.NbtIo;
import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.fml.loading.FMLConfig;
@ -46,9 +46,9 @@ public class LoadSchem {
private static int loadSchematic(CommandSourceStack source, String name) {
// Perform sanity checks
if(!source.isPlayer())return 1;
ServerPlayer play = source.getPlayer();
ServerPlayer play = (ServerPlayer)source.getEntity();
if(play==null)return 1;
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_load)){
@ -115,17 +115,17 @@ public class LoadSchem {
MemoryHolder.setBlocks(play, blocks);
}else {
ChatServerOverride.broadcastTo(play.getUUID(), Component.literal(OTEMod.OTEPrefix + ChatColor.doColors(" !Dark_Red!No such ZSchem exists!")), source.getServer());
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !Dark_Red!No such ZSchem exists!")), source.getServer());
return 0;
}
ChatServerOverride.broadcastTo(play.getUUID(), Component.literal(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!ZSchem loaded from disk!")), OTEMod.THE_SERVER);
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!ZSchem loaded from disk!")), OTEMod.THE_SERVER);
return 0;
}
}
}
ChatServerOverride.broadcastTo(play.getUUID(), Component.literal(ChatColor.doColors("!Dark_Red! You must set the first position")), OTEMod.THE_SERVER);
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(ChatColor.doColors("!Dark_Red! You must set the first position")), OTEMod.THE_SERVER);
return 0;
}
@ -134,9 +134,9 @@ public class LoadSchem {
{
String usage = OTEMod.OTEPrefix;
usage += ChatColor.doColors("!gold! /loadzschem [string:name]");
ServerPlayer play=source.getPlayer();
ServerPlayer play=(ServerPlayer)source.getEntity();
if(play==null)return 1;
ChatServerOverride.broadcastTo(play.getUUID(), Component.literal(usage), OTEMod.THE_SERVER);
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(usage), OTEMod.THE_SERVER);
return 0;
}
}

View file

@ -17,6 +17,7 @@ import dev.zontreck.otemod.zschem.MemoryHolder.Container;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
// This command will place the loaded schematic in world. The schematic will originate from position 1. The positions are relative and are added onto position 1.
@ -34,7 +35,7 @@ public class Place {
private static int place(CommandSourceStack source) {
ServerPlayer play = source.getPlayer();
ServerPlayer play = (ServerPlayer)source.getEntity();
if(play==null)return 1;
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_place)){
@ -44,7 +45,7 @@ public class Place {
if(!MemoryHolder.hasPlayerCached(play)){
ChatServerOverride.broadcastTo(play.getUUID(), Component.literal(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!You must first load the zschem!")), OTEMod.THE_SERVER);
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!You must first load the zschem!")), OTEMod.THE_SERVER);
return 1;
}
@ -65,13 +66,13 @@ public class Place {
}else {
ChatServerOverride.broadcastTo(play.getUUID(), Component.literal(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!You must first load the zschem!")), OTEMod.THE_SERVER);
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!You must first load the zschem!")), OTEMod.THE_SERVER);
return 1;
}
ChatServerOverride.broadcastTo(play.getUUID(), Component.literal(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Enqueued!")), OTEMod.THE_SERVER);
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Enqueued!")), OTEMod.THE_SERVER);
return 0;
}

View file

@ -19,6 +19,7 @@ import dev.zontreck.otemod.zschem.MemoryHolder.Container;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.block.Blocks;
@ -37,7 +38,7 @@ public class PlaceAsAir {
private static int place(CommandSourceStack source) {
ServerPlayer play = source.getPlayer();
ServerPlayer play = (ServerPlayer)source.getEntity();
if(play==null)return 1;
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_air)){
@ -47,7 +48,7 @@ public class PlaceAsAir {
if(!MemoryHolder.hasPlayerCached(play)){
ChatServerOverride.broadcastTo(play.getUUID(), Component.literal(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!You must first set the positions!")), OTEMod.THE_SERVER);
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!You must first set the positions!")), OTEMod.THE_SERVER);
return 1;
}
@ -72,13 +73,13 @@ public class PlaceAsAir {
}else {
ChatServerOverride.broadcastTo(play.getUUID(), Component.literal(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!You must first set the positions!")), OTEMod.THE_SERVER);
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!You must first set the positions!")), OTEMod.THE_SERVER);
return 1;
}
ChatServerOverride.broadcastTo(play.getUUID(), Component.literal(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Enqueued!")), OTEMod.THE_SERVER);
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Enqueued!")), OTEMod.THE_SERVER);
return 0;
}

View file

@ -25,6 +25,7 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.NbtIo;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.fml.loading.FMLConfig;
import net.minecraftforge.fml.loading.FMLPaths;
@ -43,9 +44,8 @@ public class SaveSchem {
private static int saveSchematic(CommandSourceStack source, String name) {
// Perform sanity checks
if(!source.isPlayer())return 1;
ServerPlayer play = source.getPlayer();
ServerPlayer play = (ServerPlayer)source.getEntity();
if(play==null)return 1;
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_save)){
@ -107,12 +107,12 @@ public class SaveSchem {
} catch (IOException e) {
e.printStackTrace();
}
ChatServerOverride.broadcastTo(play.getUUID(), Component.literal(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!ZSchem saved to disk!")), OTEMod.THE_SERVER);
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!ZSchem saved to disk!")), OTEMod.THE_SERVER);
return 0;
}
}
}
ChatServerOverride.broadcastTo(play.getUUID(), Component.literal(ChatColor.doColors("!Dark_Red! You must first set the positions")), OTEMod.THE_SERVER);
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(ChatColor.doColors("!Dark_Red! You must first set the positions")), OTEMod.THE_SERVER);
return 0;
}
@ -121,9 +121,9 @@ public class SaveSchem {
{
String usage = OTEMod.OTEPrefix;
usage += ChatColor.doColors("!gold! /savezschem [string:name]");
ServerPlayer play=source.getPlayer();
ServerPlayer play=(ServerPlayer)source.getEntity();
if(play==null)return 1;
ChatServerOverride.broadcastTo(play.getUUID(), Component.literal(usage), OTEMod.THE_SERVER);
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(usage), OTEMod.THE_SERVER);
return 0;
}
}

View file

@ -12,6 +12,7 @@ import dev.zontreck.otemod.zschem.MemoryHolder;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
public class SetPos1 {
@ -28,7 +29,7 @@ public class SetPos1 {
private static int setzPos1(CommandSourceStack source) {
ServerPlayer play = source.getPlayer();
ServerPlayer play = (ServerPlayer)source.getEntity();
if(play==null)return 1;
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_pos1)){
@ -38,7 +39,7 @@ public class SetPos1 {
MemoryHolder.setPos1(play, new Vector3(source.getPosition()));
MemoryHolder.setLevel(play, source.getLevel());
ChatServerOverride.broadcastTo(play.getUUID(), Component.literal(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Position 1 set!")), OTEMod.THE_SERVER);
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Position 1 set!")), OTEMod.THE_SERVER);
return 0;
}

View file

@ -12,6 +12,7 @@ import dev.zontreck.otemod.zschem.MemoryHolder;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
public class SetPos2 {
@ -27,7 +28,7 @@ public class SetPos2 {
}
private static int setzPos2(CommandSourceStack source) {
ServerPlayer play = source.getPlayer();
ServerPlayer play = (ServerPlayer)source.getEntity();
if(play==null)return 1;
if(!LuckPermsHelper.hasGroupOrPerm(play, Permissions.zschem, Permissions.zschem_pos2)){
@ -38,7 +39,7 @@ public class SetPos2 {
MemoryHolder.setPos2(play, new Vector3(source.getPosition()));
MemoryHolder.setLevel(play, source.getLevel());
ChatServerOverride.broadcastTo(play.getUUID(), Component.literal(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Position 2 set!")), OTEMod.THE_SERVER);
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Position 2 set!")), OTEMod.THE_SERVER);
return 0;
}