Switch over various components
This commit is contained in:
parent
45796de812
commit
4437104c19
73 changed files with 202 additions and 2516 deletions
|
@ -9,8 +9,10 @@ plugins {
|
|||
|
||||
|
||||
version = "${mc_version}-${my_version}"
|
||||
group = 'dev.zontreck.otemod' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'otemod'
|
||||
|
||||
group = "${my_modgroup}"
|
||||
archivesBaseName = "${my_modid}"
|
||||
|
||||
|
||||
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||
|
|
|
@ -4,10 +4,13 @@ org.gradle.jvmargs=-Xmx8G
|
|||
org.gradle.daemon=false
|
||||
|
||||
my_version=1.3.7.0226231329
|
||||
my_modgroup=dev.zontreck.otemod
|
||||
my_modid=otemod
|
||||
|
||||
mc_version=1.18.2
|
||||
forge_version=40.2.1
|
||||
libz_version=1.0.4.13
|
||||
libz_version=1.0.5.0302231758
|
||||
|
||||
parchment_version=2022.11.06
|
||||
jei_version=10.2.1.283
|
||||
# luckperms_version=5.4
|
||||
# luckperms_version=5.4
|
||||
|
|
|
@ -41,15 +41,12 @@ import dev.zontreck.otemod.blocks.ModBlocks;
|
|||
import dev.zontreck.otemod.blocks.entity.ModEntities;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import dev.zontreck.otemod.commands.CommandRegistry;
|
||||
import dev.zontreck.otemod.commands.teleport.TeleportContainer;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import dev.zontreck.otemod.enchantments.ModEnchantments;
|
||||
import dev.zontreck.otemod.entities.ModEntityTypes;
|
||||
import dev.zontreck.otemod.entities.monsters.client.PossumRenderer;
|
||||
import dev.zontreck.otemod.events.LoreHandlers;
|
||||
import dev.zontreck.otemod.implementation.DelayedExecutorService;
|
||||
import dev.zontreck.otemod.implementation.inits.ModMenuTypes;
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import dev.zontreck.otemod.implementation.scrubber.ItemScrubberScreen;
|
||||
import dev.zontreck.otemod.implementation.scrubber.MagicalScrubberScreen;
|
||||
import dev.zontreck.otemod.implementation.vault.VaultScreen;
|
||||
|
@ -69,8 +66,8 @@ public class OTEMod
|
|||
public static final String MOD_ID = "otemod";
|
||||
public static final String MODIFY_BIOMES = "modify_biomes";
|
||||
public static final ResourceLocation MODIFY_BIOMES_RL = new ResourceLocation(OTEMod.MOD_ID, MODIFY_BIOMES);
|
||||
public static Map<String,Profile> PROFILES = new HashMap<String,Profile>();
|
||||
public static List<TeleportContainer> TeleportRegistry = new ArrayList<>();
|
||||
|
||||
//public static List<TeleportContainer> TeleportRegistry = new ArrayList<>();
|
||||
public static MinecraftServer THE_SERVER;
|
||||
public static boolean ALIVE=false;
|
||||
public static boolean HEALER_WAIT=true; // Only on loading finish should this unlock
|
||||
|
@ -82,11 +79,7 @@ public class OTEMod
|
|||
public static String OTEPrefix = "";
|
||||
public static String ONLY_PLAYER = "";
|
||||
public static IEventBus bus;
|
||||
public static final DelayedExecutorService delayedExecutor;
|
||||
|
||||
static{
|
||||
delayedExecutor = new DelayedExecutorService();
|
||||
}
|
||||
|
||||
|
||||
public OTEMod()
|
||||
{
|
||||
|
@ -114,7 +107,6 @@ public class OTEMod
|
|||
MinecraftForge.EVENT_BUS.register(new ChatServerOverride());
|
||||
MinecraftForge.EVENT_BUS.register(new CommandRegistry());
|
||||
MinecraftForge.EVENT_BUS.register(new VaultWatcher());
|
||||
MinecraftForge.EVENT_BUS.register(delayedExecutor);
|
||||
MinecraftForge.EVENT_BUS.register(new dev.zontreck.otemod.zschem.EventHandler());
|
||||
ModMenuTypes.CONTAINERS.register(bus);
|
||||
|
||||
|
@ -178,7 +170,7 @@ public class OTEMod
|
|||
//e.printStackTrace();
|
||||
}
|
||||
|
||||
Iterator<TeleportContainer> containers = OTEMod.TeleportRegistry.iterator();
|
||||
/*Iterator<TeleportContainer> containers = OTEMod.TeleportRegistry.iterator();
|
||||
while(containers.hasNext())
|
||||
{
|
||||
TeleportContainer cont = containers.next();
|
||||
|
@ -187,7 +179,7 @@ public class OTEMod
|
|||
ChatServerOverride.broadcastTo(cont.ToPlayer, expire, OTEMod.THE_SERVER);
|
||||
|
||||
containers.remove();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
OTEMod.LOGGER.info("Tearing down OTEMod teleport queue - The server is going down");
|
||||
|
|
|
@ -8,13 +8,16 @@ import java.util.UUID;
|
|||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.chat.HoverTip;
|
||||
import dev.zontreck.libzontreck.events.ProfileLoadedEvent;
|
||||
import dev.zontreck.libzontreck.events.ProfileUnloadedEvent;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.util.ItemUtils;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import dev.zontreck.otemod.configs.PlayerFlyCache;
|
||||
import dev.zontreck.otemod.enchantments.ModEnchantments;
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import dev.zontreck.otemod.implementation.profiles.UserProfileNotYetExistsException;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
|
@ -34,12 +37,11 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
|||
public class ChatServerOverride {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onJoin(final PlayerEvent.PlayerLoggedInEvent ev)
|
||||
public void onJoin(final ProfileLoadedEvent ev)
|
||||
{
|
||||
//Player joined, send custom alert
|
||||
if(ev.getEntity().level.isClientSide)return;
|
||||
ServerPlayer play = (ServerPlayer)ev.getEntity();
|
||||
Profile prof = Profile.factory(play);
|
||||
ServerPlayer play = ev.player;
|
||||
Profile prof = ev.profile;
|
||||
|
||||
|
||||
if(prof.flying)
|
||||
|
@ -61,23 +63,16 @@ public class ChatServerOverride {
|
|||
|
||||
if(!OTEServerConfig.USE_CUSTOM_JOINLEAVE.get()) return;
|
||||
|
||||
ChatServerOverride.broadcast(new TextComponent(ChatColor.doColors("!Dark_Gray![!Dark_Green!+!Dark_Gray!] !Bold!!Dark_Aqua!"+prof.nickname)), ev.getEntity().getServer());
|
||||
ChatHelpers.broadcast(new TextComponent(ChatColor.doColors("!Dark_Gray![!Dark_Green!+!Dark_Gray!] !Bold!!Dark_Aqua!"+prof.nickname)), ev.server);
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLeave(final PlayerEvent.PlayerLoggedOutEvent ev)
|
||||
public void onLeave(final ProfileUnloadedEvent ev)
|
||||
{
|
||||
if(ev.getEntity().level.isClientSide)return;
|
||||
// Get player profile, send disconnect alert, then commit profile and remove it from memory
|
||||
Profile px=null;
|
||||
try {
|
||||
px = Profile.get_profile_of(ev.getEntity().getStringUUID());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Profile.unload(px);
|
||||
ServerPlayer sp = (ServerPlayer)ev.getEntity();
|
||||
Profile px=ev.oldProfile;
|
||||
// TODO: Create a some extra entries in ProfileUnloadedEvent
|
||||
|
||||
|
||||
if(px==null)return;
|
||||
|
@ -135,64 +130,8 @@ public class ChatServerOverride {
|
|||
hover=hover.withFont(Style.DEFAULT_FONT).withHoverEvent(HoverTip.get(ChatColor.MINECOIN_GOLD+"User Name: "+XD.username));
|
||||
ev.setCanceled(true);
|
||||
|
||||
ChatServerOverride.broadcast(new TextComponent(prefixStr+nameStr+message).setStyle(hover), ev.getPlayer().server);
|
||||
ChatHelpers.broadcast(new TextComponent(prefixStr+nameStr+message).setStyle(hover), ev.getPlayer().server);
|
||||
}
|
||||
|
||||
|
||||
public static void broadcastAbove(Component message, MinecraftServer s)
|
||||
{
|
||||
s.execute(new Runnable() {
|
||||
public void run(){
|
||||
|
||||
// This will broadcast to all players
|
||||
for(ServerPlayer play : s.getPlayerList().getPlayers())
|
||||
{
|
||||
play.displayClientMessage(message, true); // Send the message!
|
||||
}
|
||||
LogToConsole(new TextComponent("[all] ").append(message));
|
||||
}
|
||||
});
|
||||
}
|
||||
public static void LogToConsole(Component Message)
|
||||
{
|
||||
OTEMod.LOGGER.info(Message.getString());
|
||||
}
|
||||
public static void broadcast(Component message, MinecraftServer s)
|
||||
{
|
||||
s.execute(new Runnable() {
|
||||
public void run(){
|
||||
|
||||
// This will broadcast to all players
|
||||
for(ServerPlayer play : s.getPlayerList().getPlayers())
|
||||
{
|
||||
play.displayClientMessage(message, false); // Send the message!
|
||||
}
|
||||
LogToConsole(new TextComponent("[all] ").append(message));
|
||||
}
|
||||
});
|
||||
}
|
||||
public static void broadcastTo(UUID ID, Component message, MinecraftServer s)
|
||||
{
|
||||
s.execute(new Runnable() {
|
||||
public void run(){
|
||||
|
||||
ServerPlayer play = s.getPlayerList().getPlayer(ID);
|
||||
play.displayClientMessage(message, false); // Send the message!
|
||||
|
||||
LogToConsole(new TextComponent("[server] -> ["+play.getName().toString()+"] ").append(message));
|
||||
}
|
||||
});
|
||||
}
|
||||
public static void broadcastToAbove(UUID ID, Component message, MinecraftServer s)
|
||||
{
|
||||
s.execute(new Runnable() {
|
||||
public void run(){
|
||||
|
||||
ServerPlayer play = s.getPlayerList().getPlayer(ID);
|
||||
play.displayClientMessage(message, true); // Send the message!
|
||||
|
||||
LogToConsole(new TextComponent("[server] -> ["+play.getName().toString()+"] ").append(message));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,29 +5,14 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
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;
|
||||
import dev.zontreck.otemod.commands.profilecmds.PrefixColorCommand;
|
||||
import dev.zontreck.otemod.commands.profilecmds.PrefixCommand;
|
||||
import dev.zontreck.otemod.commands.teleport.RTPCommand;
|
||||
import dev.zontreck.otemod.commands.teleport.TPACommand;
|
||||
import dev.zontreck.otemod.commands.teleport.TPAHereCommand;
|
||||
import dev.zontreck.otemod.commands.teleport.TPAcceptCommand;
|
||||
import dev.zontreck.otemod.commands.teleport.TPCancelCommand;
|
||||
import dev.zontreck.otemod.commands.teleport.TPDenyCommand;
|
||||
import dev.zontreck.otemod.commands.vaults.TrashCommand;
|
||||
import dev.zontreck.otemod.commands.vaults.VaultCommand;
|
||||
import dev.zontreck.otemod.commands.warps.DelWarpCommand;
|
||||
import dev.zontreck.otemod.commands.warps.RTPWarpCommand;
|
||||
import dev.zontreck.otemod.commands.warps.SetWarpCommand;
|
||||
import dev.zontreck.otemod.commands.warps.WarpCommand;
|
||||
import dev.zontreck.otemod.commands.warps.WarpsCommand;
|
||||
import dev.zontreck.otemod.commands.zschem.LoadSchem;
|
||||
import dev.zontreck.otemod.commands.zschem.Place;
|
||||
import dev.zontreck.otemod.commands.zschem.PlaceAsAir;
|
||||
|
@ -99,12 +84,6 @@ public class CommandRegistry {
|
|||
@SubscribeEvent
|
||||
public void onRegisterCommands(final RegisterCommandsEvent ev)
|
||||
{
|
||||
HomesCommand.register(ev.getDispatcher());
|
||||
SetHomeCommand.register(ev.getDispatcher());
|
||||
HomeCommand.register(ev.getDispatcher());
|
||||
DelHomeCommand.register(ev.getDispatcher());
|
||||
|
||||
//FlyCommand.register(ev.getDispatcher());
|
||||
|
||||
ChatColorCommand.register(ev.getDispatcher());
|
||||
NameColorCommand.register(ev.getDispatcher());
|
||||
|
@ -113,23 +92,10 @@ public class CommandRegistry {
|
|||
NickCommand.register(ev.getDispatcher());
|
||||
|
||||
|
||||
TPACommand.register(ev.getDispatcher());
|
||||
TPCancelCommand.register(ev.getDispatcher());
|
||||
TPDenyCommand.register(ev.getDispatcher());
|
||||
TPAcceptCommand.register(ev.getDispatcher());
|
||||
TPAHereCommand.register(ev.getDispatcher());
|
||||
RTPCommand.register(ev.getDispatcher());
|
||||
|
||||
|
||||
VaultCommand.register(ev.getDispatcher());
|
||||
TrashCommand.register(ev.getDispatcher());
|
||||
|
||||
SetWarpCommand.register(ev.getDispatcher());
|
||||
DelWarpCommand.register(ev.getDispatcher());
|
||||
RTPWarpCommand.register(ev.getDispatcher());
|
||||
WarpsCommand.register(ev.getDispatcher());
|
||||
WarpCommand.register(ev.getDispatcher());
|
||||
|
||||
SetPos1.register(ev.getDispatcher());
|
||||
SetPos2.register(ev.getDispatcher());
|
||||
SaveSchem.register(ev.getDispatcher());
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
package dev.zontreck.otemod.commands.homes;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
|
||||
public class DelHomeCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("rmhome").executes(c->rmHome(c.getSource(), "default")).then(Commands.argument("nickname", StringArgumentType.string()).executes(c -> rmHome(c.getSource(), StringArgumentType.getString(c, "nickname")))));
|
||||
|
||||
//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 rmHome(CommandSourceStack ctx, String homeName)
|
||||
{
|
||||
// Request homes
|
||||
// String homeName = "";
|
||||
// CommandSourceStack ctx = ctx2.getSource();
|
||||
// homeName = StringArgumentType.getString(ctx2, "nickname");
|
||||
// if(homeName==null)return 0;
|
||||
try{
|
||||
ServerPlayer p = ctx.getPlayerOrException();
|
||||
Profile prof = Profile.get_profile_of(p.getStringUUID());
|
||||
prof.player_homes.delete(homeName);
|
||||
|
||||
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors("!dark_green! Home was deleted successfully")), ctx.getServer());
|
||||
}catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
|
||||
ChatServerOverride.broadcastTo(ctx.getEntity().getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors("!dark_red! Home could not be deleted due to an unknown error")), ctx.getServer());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
package dev.zontreck.otemod.commands.homes;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import dev.zontreck.otemod.commands.teleport.TeleportActioner;
|
||||
import dev.zontreck.otemod.commands.teleport.TeleportContainer;
|
||||
import dev.zontreck.otemod.database.TeleportDestination;
|
||||
import dev.zontreck.otemod.implementation.homes.Home;
|
||||
import dev.zontreck.otemod.implementation.homes.NoSuchHomeException;
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import dev.zontreck.otemod.implementation.profiles.UserProfileNotYetExistsException;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
|
||||
public class HomeCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("home").executes(c-> home(c.getSource(), "default")).then(Commands.argument("nickname", StringArgumentType.string()).executes(c -> home(c.getSource(), StringArgumentType.getString(c, "nickname")))));
|
||||
|
||||
//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 home(CommandSourceStack ctx, String homeName)
|
||||
{
|
||||
// Request homes
|
||||
// String homeName = "";
|
||||
// CommandSourceStack ctx = ctx2.getSource();
|
||||
// homeName = StringArgumentType.getString(ctx2, "nickname");
|
||||
// if(homeName==null)return 0;
|
||||
try{
|
||||
ServerPlayer p = ctx.getPlayerOrException();
|
||||
Profile prof = Profile.get_profile_of(p.getStringUUID());
|
||||
Home home = prof.player_homes.get(homeName);
|
||||
|
||||
TeleportDestination dest = home.destination;
|
||||
TeleportActioner.ApplyTeleportEffect(p);
|
||||
TeleportContainer cont = new TeleportContainer(p, dest.Position.asMinecraftVector(), dest.Rotation.asMinecraftVector(), dest.getActualDimension());
|
||||
TeleportActioner.PerformTeleport(cont);
|
||||
|
||||
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !dark_green!Home found! Wormhole opening now...")), ctx.getServer());
|
||||
}catch(CommandSyntaxException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return 1;
|
||||
}catch(NoSuchHomeException e)
|
||||
{
|
||||
|
||||
ChatServerOverride.broadcastTo(ctx.getEntity().getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !dark_red!Home not found. Maybe it does not exist?")), ctx.getServer());
|
||||
return 0;
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package dev.zontreck.otemod.commands.homes;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
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.homes.Home;
|
||||
import dev.zontreck.otemod.implementation.homes.Homes;
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import dev.zontreck.otemod.implementation.profiles.UserProfileNotYetExistsException;
|
||||
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.network.chat.Style;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
|
||||
public class HomesCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("homes").executes(HomesCommand::getHomes));
|
||||
}
|
||||
|
||||
private static int getHomes(CommandContext<CommandSourceStack> ctx)
|
||||
{
|
||||
// Request homes
|
||||
try{
|
||||
ServerPlayer player = ctx.getSource().getPlayerOrException();
|
||||
|
||||
Profile p = Profile.get_profile_of(player.getStringUUID());
|
||||
Homes homes = p.player_homes;
|
||||
|
||||
ChatServerOverride.broadcastTo(player.getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !Dark_Purple!There are !gold!"+String.valueOf(homes.count())+" !dark_purple!total homes.")), player.server);
|
||||
|
||||
|
||||
for (Home string : homes.getList()) {
|
||||
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.homeName));
|
||||
|
||||
ChatServerOverride.broadcastTo(player.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(CommandSyntaxException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
package dev.zontreck.otemod.commands.homes;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.vectors.Vector2;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import dev.zontreck.otemod.database.TeleportDestination;
|
||||
import dev.zontreck.otemod.implementation.homes.Home;
|
||||
import dev.zontreck.otemod.implementation.homes.Homes;
|
||||
import dev.zontreck.otemod.implementation.homes.HomesProvider;
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import dev.zontreck.otemod.implementation.profiles.UserProfileNotYetExistsException;
|
||||
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.TextComponent;
|
||||
|
||||
public class SetHomeCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("sethome").executes(c->setHome(c.getSource(), "default")).then(Commands.argument("nickname", StringArgumentType.string()).executes(c -> setHome(c.getSource(), StringArgumentType.getString(c, "nickname")))));
|
||||
|
||||
//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 setHome(CommandSourceStack ctx, String homeName)
|
||||
{
|
||||
// Request homes
|
||||
// String homeName = "";
|
||||
// CommandSourceStack ctx = ctx2.getSource();
|
||||
// homeName = StringArgumentType.getString(ctx2, "nickname");
|
||||
// if(homeName==null)return 0;
|
||||
|
||||
ServerPlayer p;
|
||||
try {
|
||||
p = ctx.getPlayerOrException();
|
||||
Vec3 position = p.position();
|
||||
Vec2 rot = p.getRotationVector();
|
||||
|
||||
TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.getLevel());
|
||||
|
||||
Home newhome = new Home(p, homeName, dest);
|
||||
Profile profile = Profile.get_profile_of(p.getStringUUID());
|
||||
Homes homes = profile.player_homes;
|
||||
homes.add(newhome);
|
||||
|
||||
|
||||
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !dark_green!Home was created or updated successfully!")), ctx.getServer());
|
||||
} catch (CommandSyntaxException e) {
|
||||
|
||||
ChatServerOverride.broadcastTo(ctx.getEntity().getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !dark_red!Home could not be created or updated!")), ctx.getServer());
|
||||
e.printStackTrace();
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
ChatServerOverride.broadcastTo(ctx.getEntity().getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !dark_red!Home could not be created or updated!")), ctx.getServer());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -4,10 +4,10 @@ import com.mojang.brigadier.CommandDispatcher;
|
|||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
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 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 net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
@ -54,7 +54,7 @@ public class ShareItemInChatCommand {
|
|||
Style style = Style.EMPTY.withFont(Style.DEFAULT_FONT);
|
||||
component = component.withStyle(style.withHoverEvent(HoverTip.getItem(is)));
|
||||
|
||||
ChatServerOverride.broadcast(component, OTEMod.THE_SERVER);
|
||||
ChatHelpers.broadcast(component, OTEMod.THE_SERVER);
|
||||
|
||||
}else {
|
||||
return 1;
|
||||
|
|
|
@ -2,11 +2,12 @@ package dev.zontreck.otemod.commands.profilecmds;
|
|||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor.ColorOptions;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import dev.zontreck.otemod.implementation.profiles.UserProfileNotYetExistsException;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -51,7 +52,7 @@ public class ChatColorCommand {
|
|||
}
|
||||
p.chat_color = colorcoded;
|
||||
p.commit();
|
||||
OTEMod.PROFILES.put(play.getStringUUID(), p);
|
||||
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
||||
|
||||
source.sendSuccess(new TextComponent(OTEMod.OTEPrefix + " "+ChatColor.DARK_PURPLE + "Your chat color has been updated"), false);
|
||||
|
||||
|
|
|
@ -2,11 +2,12 @@ package dev.zontreck.otemod.commands.profilecmds;
|
|||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor.ColorOptions;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import dev.zontreck.otemod.implementation.profiles.UserProfileNotYetExistsException;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -51,7 +52,7 @@ public class NameColorCommand {
|
|||
}
|
||||
p.name_color = colorcoded;
|
||||
p.commit();
|
||||
OTEMod.PROFILES.put(play.getStringUUID(), p);
|
||||
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
||||
|
||||
source.sendSuccess(new TextComponent(OTEMod.OTEPrefix+ " "+ChatColor.DARK_PURPLE + "Your name color has been updated"), false);
|
||||
|
||||
|
|
|
@ -3,10 +3,11 @@ package dev.zontreck.otemod.commands.profilecmds;
|
|||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import dev.zontreck.otemod.implementation.profiles.UserProfileNotYetExistsException;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -47,7 +48,7 @@ public class NickCommand {
|
|||
}
|
||||
p.nickname = string;
|
||||
p.commit();
|
||||
OTEMod.PROFILES.put(play.getStringUUID(), p);
|
||||
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
||||
|
||||
source.sendSuccess(new TextComponent(OTEMod.OTEPrefix+ " "+ChatColor.DARK_PURPLE + "Your nickname has been updated"), false);
|
||||
|
||||
|
|
|
@ -2,14 +2,14 @@ package dev.zontreck.otemod.commands.profilecmds;
|
|||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor.ColorOptions;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import dev.zontreck.otemod.implementation.profiles.UserProfileNotYetExistsException;
|
||||
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;
|
||||
|
@ -52,7 +52,7 @@ public class PrefixColorCommand {
|
|||
}
|
||||
p.prefix_color = colorcoded;
|
||||
p.commit();
|
||||
OTEMod.PROFILES.put(play.getStringUUID(), p);
|
||||
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
||||
|
||||
source.sendSuccess(new TextComponent(OTEMod.OTEPrefix+ " "+ChatColor.DARK_PURPLE + "Your prefix color has been updated"), false);
|
||||
|
||||
|
|
|
@ -3,10 +3,11 @@ package dev.zontreck.otemod.commands.profilecmds;
|
|||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import dev.zontreck.otemod.implementation.profiles.UserProfileNotYetExistsException;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -47,7 +48,7 @@ public class PrefixCommand {
|
|||
}
|
||||
p.prefix = string;
|
||||
p.commit();
|
||||
OTEMod.PROFILES.put(play.getStringUUID(), p);
|
||||
LibZontreck.PROFILES.put(play.getStringUUID(), p);
|
||||
|
||||
source.sendSuccess(new TextComponent(OTEMod.OTEPrefix+ " "+ChatColor.DARK_PURPLE + "Your prefix has been updated"), false);
|
||||
|
||||
|
|
|
@ -1,92 +0,0 @@
|
|||
package dev.zontreck.otemod.commands.teleport;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class RTPCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("rtp").executes(c->rtp(c.getSource())));
|
||||
|
||||
//executes(c -> doCancel(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 rtp(CommandSourceStack source) {
|
||||
|
||||
/*if(!CommandRegistry.canUse("rtp")) {
|
||||
ChatServerOverride.broadcastTo(source.getPlayer().getUUID(), Component.translatable("dev.zontreck.otemod.msgs.command_cooling_down").append(Component.literal(""+CommandRegistry.getRemaining("rtp"))).append(Component.translatable("dev.zontreck.otemod.msgs.command_cooling_down_seconds")), source.getServer());
|
||||
|
||||
// exit
|
||||
//return 0; // Removed until the player data registry is implemented
|
||||
}
|
||||
CommandRegistry.markUsed("rtp");*/
|
||||
if(!(source.getEntity() instanceof Player)){
|
||||
return 1;
|
||||
}
|
||||
final ServerPlayer pla = (ServerPlayer)source.getEntity();
|
||||
|
||||
final TeleportContainer cont = new TeleportContainer(pla, Vec3.ZERO, pla.getRotationVector(), source.getLevel());
|
||||
|
||||
|
||||
|
||||
Thread tx = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run(){
|
||||
// We can now execute the loop to search for a safe spot!
|
||||
Vector3 v = new Vector3();
|
||||
// RTP is not designed to be safe really, but we at least want to check if where we are putting the player is air
|
||||
|
||||
Vec3 pos = pla.position();
|
||||
|
||||
boolean found_place= false;
|
||||
RTPContainer container = RandomPositionFactory.beginRTPSearch(pla, pos, pla.getRotationVector(), pla.getLevel());
|
||||
while(!container.complete)
|
||||
{
|
||||
if(!OTEMod.ALIVE)
|
||||
{
|
||||
container.aborted=true;
|
||||
container.containingThread.interrupt();
|
||||
return;
|
||||
}
|
||||
if(container.tries>30)
|
||||
{
|
||||
// abort!
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
||||
// Apply the effect
|
||||
TeleportActioner.ApplyTeleportEffect(pla);
|
||||
cont.Position=v.asMinecraftVector();
|
||||
|
||||
TeleportActioner.PerformTeleport(cont);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
tx.start();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,154 +0,0 @@
|
|||
package dev.zontreck.otemod.commands.teleport;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
import net.minecraft.world.level.levelgen.Heightmap.Types;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class RTPContainer {
|
||||
public TeleportContainer container;
|
||||
public int tries = -1;
|
||||
public boolean complete = false;
|
||||
public boolean aborted=false;
|
||||
public Thread containingThread;
|
||||
private Types heightMapType;
|
||||
private int SearchDirection;
|
||||
|
||||
public static final List<Block> BLACKLIST;
|
||||
|
||||
static {
|
||||
List<Block> tmp = new ArrayList<>();
|
||||
tmp.add(Blocks.LAVA);
|
||||
tmp.add(Blocks.BEDROCK);
|
||||
tmp.add(Blocks.WATER);
|
||||
|
||||
BLACKLIST = tmp;
|
||||
}
|
||||
|
||||
public void moveDown() {
|
||||
container.world_pos.Position = container.world_pos.Position.moveDown();
|
||||
container.Position = container.world_pos.Position.asMinecraftVector();
|
||||
}
|
||||
|
||||
public void moveUp() {
|
||||
container.world_pos.Position = container.world_pos.Position.moveUp();
|
||||
container.Position = container.world_pos.Position.asMinecraftVector();
|
||||
}
|
||||
|
||||
public void move()
|
||||
{
|
||||
if(SearchDirection==1){
|
||||
moveUp();
|
||||
}else if(SearchDirection==0)
|
||||
{
|
||||
moveDown();
|
||||
}
|
||||
}
|
||||
public void moveOpposite()
|
||||
{
|
||||
if(SearchDirection==1){
|
||||
moveDown();
|
||||
}else if(SearchDirection==0)
|
||||
{
|
||||
moveUp();
|
||||
}
|
||||
}
|
||||
|
||||
public void newPosition() {
|
||||
if(!OTEMod.ALIVE)return;
|
||||
containingThread=Thread.currentThread();
|
||||
Random rng = new Random(Instant.now().getEpochSecond());
|
||||
Vector3 pos = new Vector3(rng.nextDouble(0xFFFF), 0, rng.nextDouble(0xFFFF));
|
||||
BlockPos bpos = pos.asBlockPos();
|
||||
container.Dimension.getChunk(bpos.getX() >> 4, bpos.getZ() >> 4, ChunkStatus.HEIGHTMAPS);
|
||||
pos = new Vector3(
|
||||
container.Dimension.getHeightmapPos(heightMapType, pos.asBlockPos()));
|
||||
while (!container.Dimension.getWorldBorder().isWithinBounds(pos.asBlockPos())) {
|
||||
pos = new Vector3(rng.nextDouble(0xffff), 0, rng.nextDouble(0xffff));
|
||||
bpos = pos.asBlockPos();
|
||||
container.Dimension.getChunk(bpos.getX() >> 4, bpos.getZ() >> 4, ChunkStatus.HEIGHTMAPS);
|
||||
pos = new Vector3(
|
||||
container.Dimension.getHeightmapPos(heightMapType, pos.asBlockPos()));
|
||||
}
|
||||
|
||||
container.world_pos.Position = pos;
|
||||
container.Position = container.world_pos.Position.asMinecraftVector();
|
||||
|
||||
if (pos.y < -60) {
|
||||
newPosition();
|
||||
return;
|
||||
}
|
||||
|
||||
if (pos.y >= container.Dimension.getLogicalHeight()) {
|
||||
spiralPositions(pos);
|
||||
}
|
||||
|
||||
tries++;
|
||||
}
|
||||
|
||||
private void spiralPositions(Vector3 position)
|
||||
{
|
||||
for(BlockPos pos : BlockPos.spiralAround(new BlockPos(position.x, container.Dimension.getSeaLevel(), position.z), 16, Direction.WEST, Direction.NORTH)){
|
||||
if(isSafe(pos)){
|
||||
// Set the new position
|
||||
container.world_pos.Position = new Vector3(pos);
|
||||
container.Position = container.world_pos.Position.asMinecraftVector();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected RTPContainer(ServerPlayer player, Vec3 pos, Vec2 rot, ServerLevel level) {
|
||||
container = new TeleportContainer(player, pos, rot, level);
|
||||
if(container.Dimension.dimensionType().hasCeiling())
|
||||
{
|
||||
heightMapType = Heightmap.Types.MOTION_BLOCKING_NO_LEAVES;
|
||||
SearchDirection=-1;
|
||||
}else {
|
||||
heightMapType = Types.MOTION_BLOCKING_NO_LEAVES;
|
||||
SearchDirection=1;
|
||||
}
|
||||
newPosition();
|
||||
}
|
||||
|
||||
public boolean isSafe(BlockPos blockPos) {
|
||||
containingThread=Thread.currentThread();
|
||||
BlockState b = container.Dimension.getBlockState(blockPos);
|
||||
BlockState b2 = container.Dimension.getBlockState(blockPos.above());
|
||||
BlockState b3 = container.Dimension.getBlockState(blockPos.below());
|
||||
|
||||
if (b.isAir() && b2.isAir()) {
|
||||
if (!b3.isAir()) {
|
||||
if (BLACKLIST.contains(b3.getBlock())) {
|
||||
return false;
|
||||
} else
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
} else
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package dev.zontreck.otemod.commands.teleport;
|
||||
|
||||
import dev.zontreck.otemod.implementation.DelayedExecutorService;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
/**
|
||||
* The factory system used to start searching for a random teleport position
|
||||
*/
|
||||
public class RandomPositionFactory {
|
||||
|
||||
public static RTPContainer beginRTPSearch(ServerPlayer player, Vec3 pos, Vec2 rot, ServerLevel level)
|
||||
{
|
||||
RTPContainer contain= new RTPContainer(player, pos, rot, level);
|
||||
Thread tx = new Thread(new RandomPositionLocator(contain));
|
||||
tx.setName("RTPTask-"+String.valueOf(DelayedExecutorService.getNext()));
|
||||
tx.start();
|
||||
|
||||
return contain;
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
package dev.zontreck.otemod.commands.teleport;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import dev.zontreck.otemod.events.RTPEvent;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
/**
|
||||
* This class aims to serve as the Random Position Locate system
|
||||
* It aims to be as non-thread blocking as possible to avoid server lag
|
||||
*
|
||||
* To utilize, initialize a RTPContainer from the RandomPositionFactory and execute from there.
|
||||
*/
|
||||
public class RandomPositionLocator implements Runnable
|
||||
{
|
||||
private final RTPContainer contain;
|
||||
|
||||
public RandomPositionLocator(RTPContainer rtp)
|
||||
{
|
||||
contain=rtp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if(!OTEMod.ALIVE)return;
|
||||
ChatServerOverride.broadcastTo(contain.container.PlayerInst.getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !Dark_Purple!Searching... Attempt "+String.valueOf(contain.tries)+"/30")), OTEMod.THE_SERVER);
|
||||
|
||||
ServerLevel levl = contain.container.Dimension;
|
||||
ChunkAccess chunk = levl.getChunk(contain.container.world_pos.Position.asBlockPos());
|
||||
ChunkPos cpos = chunk.getPos();
|
||||
boolean needsLoading = false;
|
||||
needsLoading = !(levl.getForcedChunks().contains(cpos.toLong()));
|
||||
|
||||
|
||||
if(needsLoading)
|
||||
levl.setChunkForced(cpos.x, cpos.z, true);
|
||||
|
||||
int curChecks=0;
|
||||
while(curChecks<30)
|
||||
{
|
||||
if(contain.isSafe(contain.container.world_pos.Position.asBlockPos()))
|
||||
{
|
||||
contain.complete=true;
|
||||
if(needsLoading)
|
||||
levl.setChunkForced(cpos.x, cpos.z, false);
|
||||
|
||||
if(MinecraftForge.EVENT_BUS.post(new RTPEvent(contain.container.PlayerInst, contain.container.world_pos)))
|
||||
{
|
||||
contain.complete=false;
|
||||
ChatServerOverride.broadcastTo(contain.container.PlayerInst.getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !Dark_Red!Last position checked was probably claimed. Another mod has asked us not to send you to that location, continuing the search")), OTEMod.THE_SERVER);
|
||||
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}else {
|
||||
curChecks++;
|
||||
contain.move();
|
||||
OTEMod.LOGGER.info("[DEBUG] "+ChatColor.doColors("!Dark_Red!Checking position: "+contain.container.world_pos.Position.toString()+"; "+contain.container.Dimension.getBlockState(contain.container.world_pos.Position.asBlockPos()).getBlock().toString()+"; "+contain.container.Dimension.getBlockState(contain.container.world_pos.Position.asBlockPos().below()).getBlock().toString()));
|
||||
}
|
||||
}
|
||||
if(needsLoading)
|
||||
levl.setChunkForced(cpos.x, cpos.z, false);
|
||||
|
||||
contain.newPosition();
|
||||
|
||||
if(contain.tries > 30)
|
||||
{
|
||||
// Abort
|
||||
ChatServerOverride.broadcastTo(contain.container.PlayerInst.getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !Dark_Red!Could not find a suitable location in 30 attempts")), OTEMod.THE_SERVER);
|
||||
contain.aborted=true;
|
||||
return;
|
||||
}else {
|
||||
// Schedule the task to execute
|
||||
//run();
|
||||
RandomPositionLocator next = new RandomPositionLocator(contain);
|
||||
OTEMod.delayedExecutor.schedule(next, 2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
package dev.zontreck.otemod.commands.teleport;
|
||||
|
||||
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 net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
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 {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("tpa").executes(c->usage(c.getSource())).then(Commands.argument("player", EntityArgument.player()).executes(c -> tpa(c.getSource(), EntityArgument.getPlayer(c, "player")))));
|
||||
|
||||
//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 tpa(CommandSourceStack source, ServerPlayer serverPlayer) {
|
||||
// Send the request to player
|
||||
if(serverPlayer == null){
|
||||
source.sendFailure(new TextComponent(ChatColor.DARK_RED+"Error: Player not found"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
TeleportContainer cont = new TeleportContainer(play.getUUID(), serverPlayer.getUUID());
|
||||
|
||||
for(TeleportContainer cont2 : OTEMod.TeleportRegistry){
|
||||
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());
|
||||
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());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ClickEvent ce = Clickable.command("/tpcancel "+cont.TeleportID.toString());
|
||||
HoverEvent he = HoverTip.get(ChatColor.DARK_GREEN+"Cancel this teleport request (Not yet implemented)");
|
||||
|
||||
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);
|
||||
|
||||
|
||||
ce = Clickable.command("/tpaccept "+cont.TeleportID.toString());
|
||||
he = HoverTip.get(ChatColor.DARK_GREEN + "Accept tp request");
|
||||
ClickEvent ce2 = Clickable.command("/tpdeny "+cont.TeleportID.toString());
|
||||
HoverEvent he2 = HoverTip.get(ChatColor.DARK_RED+"Deny this request");
|
||||
s = Style.EMPTY.withFont(Style.DEFAULT_FONT).withClickEvent(ce).withHoverEvent(he);
|
||||
|
||||
Style s2 = Style.EMPTY.withFont(Style.DEFAULT_FONT).withClickEvent(ce2).withHoverEvent(he2);
|
||||
|
||||
Profile p;
|
||||
try {
|
||||
p = Profile.get_profile_of(cont.FromPlayer.toString());
|
||||
} 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").
|
||||
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(new TextComponent("/tpa USAGE\n\n "+ChatColor.BOLD + ChatColor.DARK_GRAY+"/tpa "+ChatColor.DARK_RED+"target_player\n"), false);
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
package dev.zontreck.otemod.commands.teleport;
|
||||
|
||||
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 net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
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 {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("tpahere").executes(c->usage(c.getSource())).then(Commands.argument("player", EntityArgument.player()).executes(c -> tpa(c.getSource(), EntityArgument.getPlayer(c, "player")))));
|
||||
|
||||
//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 tpa(CommandSourceStack source, ServerPlayer serverPlayer) {
|
||||
// Send the request to player
|
||||
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
if(serverPlayer == null){
|
||||
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;
|
||||
}
|
||||
}
|
||||
TeleportContainer cont = new TeleportContainer(serverPlayer.getUUID(), play.getUUID());
|
||||
|
||||
for(TeleportContainer cont2 : OTEMod.TeleportRegistry){
|
||||
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());
|
||||
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());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ClickEvent ce = Clickable.command("/tpcancel "+cont.TeleportID.toString());
|
||||
HoverEvent he = HoverTip.get(ChatColor.DARK_GREEN+"Cancel this teleport request (Not yet implemented)");
|
||||
|
||||
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);
|
||||
|
||||
|
||||
ce = Clickable.command("/tpaccept "+cont.TeleportID.toString());
|
||||
he = HoverTip.get(ChatColor.DARK_GREEN + "Accept tp request");
|
||||
ClickEvent ce2 = Clickable.command("/tpdeny "+cont.TeleportID.toString());
|
||||
HoverEvent he2 = HoverTip.get(ChatColor.DARK_RED+"Deny this request");
|
||||
s = Style.EMPTY.withFont(Style.DEFAULT_FONT).withClickEvent(ce).withHoverEvent(he);
|
||||
|
||||
Style s2 = Style.EMPTY.withFont(Style.DEFAULT_FONT).withClickEvent(ce2).withHoverEvent(he2);
|
||||
|
||||
Profile p;
|
||||
try {
|
||||
p = Profile.get_profile_of(cont.ToPlayer.toString());
|
||||
} 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").
|
||||
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(new TextComponent("/tpa USAGE\n\n "+ChatColor.BOLD + ChatColor.DARK_GRAY+"/tpa "+ChatColor.DARK_RED+"target_player\n"), false);
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
package dev.zontreck.otemod.commands.teleport;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
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 {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("tpaccept").then(Commands.argument("TeleportUUID", StringArgumentType.string()).executes(c->doCancel(c.getSource(), StringArgumentType.getString(c, "TeleportUUID")))));
|
||||
|
||||
//executes(c -> doCancel(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 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!
|
||||
|
||||
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!");
|
||||
|
||||
ChatServerOverride.broadcastTo(cont.FromPlayer, comp, source.getServer());
|
||||
ChatServerOverride.broadcastTo(cont.ToPlayer, comp, source.getServer());
|
||||
|
||||
OTEMod.TeleportRegistry.remove(cont);
|
||||
|
||||
|
||||
cont.PlayerInst = from;
|
||||
cont.Position = to.position();
|
||||
cont.Rotation = to.getRotationVector();
|
||||
cont.Dimension = to.getLevel();
|
||||
|
||||
TeleportActioner.ApplyTeleportEffect(from);
|
||||
TeleportActioner.PerformTeleport(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());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
package dev.zontreck.otemod.commands.teleport;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
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 {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("tpcancel").then(Commands.argument("TeleportUUID", StringArgumentType.string()).executes(c->doCancel(c.getSource(), StringArgumentType.getString(c, "TeleportUUID")))));
|
||||
|
||||
//executes(c -> doCancel(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 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 = 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());
|
||||
|
||||
OTEMod.TeleportRegistry.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());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
package dev.zontreck.otemod.commands.teleport;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
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 {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("tpdeny").then(Commands.argument("TeleportUUID", StringArgumentType.string()).executes(c->doCancel(c.getSource(), StringArgumentType.getString(c, "TeleportUUID")))));
|
||||
|
||||
//executes(c -> doCancel(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 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 = 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());
|
||||
|
||||
OTEMod.TeleportRegistry.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());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package dev.zontreck.otemod.commands.teleport;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
|
||||
public class TeleportActioner
|
||||
{
|
||||
public static void PerformTeleport(TeleportContainer contain){
|
||||
//sub_runnable run = new sub_runnable(contain);
|
||||
OTEMod.delayedExecutor.schedule(new TeleportRunnable(contain), 2);
|
||||
}
|
||||
|
||||
public static void ApplyTeleportEffect(ServerPlayer player){
|
||||
|
||||
// 10/05/2022 - Thinking ahead here to future proof it so i can do things in threads safely
|
||||
// By adding this task onto the main server thread, any thread can call the TeleportActioner and it will be actioned on the main thread without needing to repeat the process of sending this to the server thread.
|
||||
player.server.execute(new Runnable(){
|
||||
public void run(){
|
||||
|
||||
MobEffectInstance inst = new MobEffectInstance(MobEffects.BLINDNESS, 250, 1, true, true);
|
||||
// 02/26/2023 - Adjusted to 400 due to 1.18.2, the teleport is slightly more delayed, and thus a regen is needed incase levitation runs out too soon
|
||||
MobEffectInstance regen = new MobEffectInstance(MobEffects.REGENERATION, 400, 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.
|
||||
// 02/26/2023 - Adjusted to 200 on duration due to 1.18.2 causing levitation to run out too quickly before teleport
|
||||
// Small tradeoff is the player now levitates slightly longer at the destination. This is acceptable. Compensated by increasing regen strength by 1
|
||||
MobEffectInstance levitate = new MobEffectInstance(MobEffects.LEVITATION, 200, 1, true, true);
|
||||
|
||||
|
||||
player.addEffect(inst);
|
||||
player.addEffect(regen);
|
||||
player.addEffect(levitate); // ensure the player can't fall into lava in the short time we are not in control (if the player was silly enough to make a home above lava!!!)
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
package dev.zontreck.otemod.commands.teleport;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.libzontreck.vectors.WorldPosition;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class TeleportContainer implements Comparable{
|
||||
public UUID FromPlayer;
|
||||
public UUID ToPlayer;
|
||||
public long StartedAt;
|
||||
public UUID TeleportID;
|
||||
public WorldPosition world_pos;
|
||||
|
||||
/*
|
||||
* The following variables are only used when actioning the teleport itself, and should only be initialized once the teleport is about to engage
|
||||
*/
|
||||
public ServerPlayer PlayerInst;
|
||||
public Vec3 Position;
|
||||
public Vec2 Rotation;
|
||||
public ServerLevel Dimension;
|
||||
|
||||
|
||||
public boolean has_expired(){
|
||||
if(Instant.now().getEpochSecond() > (StartedAt + (60)))
|
||||
{
|
||||
return true;
|
||||
}else return false;
|
||||
}
|
||||
|
||||
public TeleportContainer (UUID From, UUID To)
|
||||
{
|
||||
FromPlayer = From;
|
||||
ToPlayer=To;
|
||||
TeleportID = UUID.randomUUID();
|
||||
|
||||
StartedAt = Instant.now().getEpochSecond();
|
||||
}
|
||||
|
||||
public TeleportContainer(ServerPlayer f_p, Vec3 f_pos, Vec2 f_rot, ServerLevel f_dim) {
|
||||
SetTeleportDestination(f_p, f_pos, f_rot, f_dim);
|
||||
world_pos = new WorldPosition(new Vector3(f_pos), f_dim);
|
||||
}
|
||||
|
||||
private void SetTeleportDestination(ServerPlayer f_p, Vec3 f_pos, Vec2 f_rot, ServerLevel f_dim) {
|
||||
PlayerInst = f_p;
|
||||
Position = f_pos;
|
||||
Rotation = f_rot;
|
||||
Dimension = f_dim;
|
||||
world_pos = new WorldPosition(new Vector3(f_pos), f_dim);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
if(o instanceof TeleportContainer){
|
||||
TeleportContainer cont = (TeleportContainer)o;
|
||||
if(cont.FromPlayer != FromPlayer){
|
||||
return -1;
|
||||
}else {
|
||||
if(cont.ToPlayer != ToPlayer)return 1;
|
||||
else return 0;
|
||||
}
|
||||
}else return -1;
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package dev.zontreck.otemod.commands.teleport;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.configs.PlayerFlyCache;
|
||||
import dev.zontreck.otemod.implementation.DelayedExecutorService;
|
||||
|
||||
public class TeleportRunnable implements Runnable
|
||||
{
|
||||
|
||||
public final TeleportContainer Action;
|
||||
public TeleportRunnable(TeleportContainer cont){
|
||||
Action = cont;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final PlayerFlyCache c = PlayerFlyCache.cachePlayer(Action.PlayerInst);
|
||||
Action.PlayerInst.teleportTo(Action.Dimension, Action.Position.x, Action.Position.y, Action.Position.z, Action.Rotation.y, Action.Rotation.x);
|
||||
|
||||
OTEMod.delayedExecutor.schedule(new Runnable(){
|
||||
public PlayerFlyCache cached = c;
|
||||
public TeleportContainer container=Action;
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
c.Assert(container.PlayerInst);
|
||||
container.PlayerInst.setPos(container.Position);
|
||||
container.PlayerInst.giveExperiencePoints(1);
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
}
|
|
@ -3,13 +3,12 @@ package dev.zontreck.otemod.commands.vaults;
|
|||
import com.mojang.brigadier.CommandDispatcher;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import dev.zontreck.otemod.implementation.vault.NoMoreVaultException;
|
||||
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;
|
||||
|
@ -36,7 +35,7 @@ public class TrashCommand {
|
|||
try {
|
||||
container = new VaultContainer(play, -1);
|
||||
} catch (NoMoreVaultException e) {
|
||||
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!You cannot open anymore vaults. Craft a new vault!")), play.server);
|
||||
ChatHelpers.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!You cannot open anymore vaults. Craft a new vault!")), play.server);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,20 +4,15 @@ import com.mojang.brigadier.CommandDispatcher;
|
|||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import dev.zontreck.otemod.implementation.vault.NoMoreVaultException;
|
||||
import dev.zontreck.otemod.implementation.vault.Vault;
|
||||
import dev.zontreck.otemod.implementation.vault.VaultContainer;
|
||||
import dev.zontreck.otemod.implementation.vault.VaultProvider;
|
||||
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;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
public class VaultCommand {
|
||||
|
@ -39,7 +34,7 @@ public class VaultCommand {
|
|||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
if(i <0)
|
||||
{
|
||||
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());
|
||||
ChatHelpers.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(play, i);
|
||||
|
@ -54,7 +49,7 @@ public class VaultCommand {
|
|||
try {
|
||||
container = new VaultContainer(p, i);
|
||||
} catch (NoMoreVaultException e) {
|
||||
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!You cannot open anymore vaults. Craft a new vault!")), p.server);
|
||||
ChatHelpers.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!You cannot open anymore vaults. Craft a new vault!")), p.server);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
package dev.zontreck.otemod.commands.warps;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.vectors.Vector2;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import dev.zontreck.otemod.database.TeleportDestination;
|
||||
import dev.zontreck.otemod.implementation.warps.NoSuchWarpException;
|
||||
import dev.zontreck.otemod.implementation.warps.Warp;
|
||||
import dev.zontreck.otemod.implementation.warps.WarpsProvider;
|
||||
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;
|
||||
|
||||
public class DelWarpCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("delwarp").then(Commands.argument("nickname", StringArgumentType.string()).executes(c -> setWarp(c.getSource(), StringArgumentType.getString(c, "nickname")))));
|
||||
|
||||
//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 setWarp(CommandSourceStack source, String string) {
|
||||
|
||||
ServerPlayer p = (ServerPlayer)source.getEntity();
|
||||
|
||||
Warp warp;
|
||||
try {
|
||||
warp = WarpsProvider.WARPS_INSTANCE.getNamedWarp(string);
|
||||
} catch (NoSuchWarpException e) {
|
||||
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!That warp does not exist")), p.server);
|
||||
return 0;
|
||||
}
|
||||
if(p.getUUID().equals(warp.owner) || p.hasPermissions(5))
|
||||
{
|
||||
try {
|
||||
WarpsProvider.WARPS_INSTANCE.delete(WarpsProvider.WARPS_INSTANCE.getNamedWarp(string));
|
||||
} catch (NoSuchWarpException e) {
|
||||
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!That warp does not exist")), p.server);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Warp deleted successfully")), p.server);
|
||||
|
||||
}else {
|
||||
|
||||
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!Warp could not be deleted, because you do not own the warp.")), p.server);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
package dev.zontreck.otemod.commands.warps;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.vectors.Vector2;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import dev.zontreck.otemod.database.TeleportDestination;
|
||||
import dev.zontreck.otemod.implementation.warps.Warp;
|
||||
import dev.zontreck.otemod.implementation.warps.WarpsProvider;
|
||||
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;
|
||||
|
||||
public class RTPWarpCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("rtpwarp").then(Commands.argument("nickname", StringArgumentType.string()).executes(c -> setWarp(c.getSource(), StringArgumentType.getString(c, "nickname")))));
|
||||
|
||||
//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 setWarp(CommandSourceStack source, String string) {
|
||||
|
||||
ServerPlayer p = (ServerPlayer)source.getEntity();
|
||||
|
||||
Vec3 position = p.position();
|
||||
Vec2 rot = p.getRotationVector();
|
||||
|
||||
TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.getLevel());
|
||||
Warp warp = new Warp(p.getUUID(), string, true, true, dest);
|
||||
WarpsProvider.WARPS_INSTANCE.add(warp);
|
||||
|
||||
|
||||
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Random Position Teleport (RTP) Warp created successfully")), p.server);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
package dev.zontreck.otemod.commands.warps;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.vectors.Vector2;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import dev.zontreck.otemod.database.TeleportDestination;
|
||||
import dev.zontreck.otemod.implementation.warps.Warp;
|
||||
import dev.zontreck.otemod.implementation.warps.WarpsProvider;
|
||||
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;
|
||||
|
||||
public class SetWarpCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("setwarp").then(Commands.argument("nickname", StringArgumentType.string()).executes(c -> setWarp(c.getSource(), StringArgumentType.getString(c, "nickname")))));
|
||||
|
||||
//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 setWarp(CommandSourceStack source, String string) {
|
||||
|
||||
ServerPlayer p = (ServerPlayer)source.getEntity();
|
||||
|
||||
|
||||
Vec3 position = p.position();
|
||||
Vec2 rot = p.getRotationVector();
|
||||
|
||||
TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.getLevel());
|
||||
Warp w = new Warp(p.getUUID(), string, false, true, dest);
|
||||
WarpsProvider.WARPS_INSTANCE.add(w);
|
||||
|
||||
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Warp created successfully")), p.server);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
package dev.zontreck.otemod.commands.warps;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.chat.Clickable;
|
||||
import dev.zontreck.libzontreck.exceptions.InvalidSideException;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import dev.zontreck.otemod.commands.teleport.RTPCommand;
|
||||
import dev.zontreck.otemod.commands.teleport.RTPContainer;
|
||||
import dev.zontreck.otemod.commands.teleport.RandomPositionFactory;
|
||||
import dev.zontreck.otemod.commands.teleport.TeleportActioner;
|
||||
import dev.zontreck.otemod.commands.teleport.TeleportContainer;
|
||||
import dev.zontreck.otemod.database.TeleportDestination;
|
||||
import dev.zontreck.otemod.implementation.warps.NoSuchWarpException;
|
||||
import dev.zontreck.otemod.implementation.warps.Warp;
|
||||
import dev.zontreck.otemod.implementation.warps.WarpsProvider;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class WarpCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("warp").executes(c-> nowarp(c.getSource())).then(Commands.argument("name", StringArgumentType.string()).executes(c->warp(c.getSource(), StringArgumentType.getString(c, "name")))));
|
||||
|
||||
//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 warp(CommandSourceStack source, String string) {
|
||||
|
||||
final ServerPlayer p;
|
||||
try{
|
||||
p=source.getPlayerOrException();
|
||||
Warp warp = WarpsProvider.WARPS_INSTANCE.getNamedWarp(string);
|
||||
|
||||
TeleportDestination dest = warp.destination;
|
||||
|
||||
ServerLevel dimL=(ServerLevel) dest.getActualDimension();
|
||||
|
||||
|
||||
final int type = warp.RTP ? 1 : 0;
|
||||
final ServerLevel f_dim = dimL;
|
||||
|
||||
if(type == 1)
|
||||
{
|
||||
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix+ ChatColor.doColors(" !Dark_Green!Attempting to locate a safe location. This may take a minute or two")), p.server);
|
||||
}else{
|
||||
|
||||
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix+ ChatColor.doColors(" !Dark_Purple!Warping!")), p.server);
|
||||
}
|
||||
|
||||
Thread tx = new Thread(new Runnable(){
|
||||
public void run(){
|
||||
|
||||
if(type==1){
|
||||
try {
|
||||
dest.Position = Vector3.ZERO;
|
||||
RTPContainer cont = RandomPositionFactory.beginRTPSearch(p, Vec3.ZERO, Vec2.ZERO, f_dim);
|
||||
while(!cont.complete)
|
||||
{
|
||||
if(!OTEMod.ALIVE)
|
||||
{
|
||||
cont.aborted=true;
|
||||
cont.containingThread.interrupt();
|
||||
return;
|
||||
}
|
||||
if(cont.tries>30)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
dest.Position = cont.container.world_pos.Position;
|
||||
|
||||
//RTPCommand.findPosition(source.getLevel(), false, p.getUUID());
|
||||
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Location found, warping!")), p.server);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
TeleportActioner.ApplyTeleportEffect(p);
|
||||
TeleportContainer tc = new TeleportContainer(p, dest.Position.asMinecraftVector(), dest.Rotation.asMinecraftVector(), f_dim);
|
||||
TeleportActioner.PerformTeleport(tc);
|
||||
}
|
||||
});
|
||||
tx.start();
|
||||
}catch(NoSuchWarpException e)
|
||||
{
|
||||
ChatServerOverride.broadcastTo(source.getEntity().getUUID(), new TextComponent(ChatColor.DARK_RED+"No such warp"), source.getServer());
|
||||
} catch (CommandSyntaxException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int nowarp(CommandSourceStack source) {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
package dev.zontreck.otemod.commands.warps;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
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.otemod.implementation.warps.Warp;
|
||||
import dev.zontreck.otemod.implementation.warps.WarpsProvider;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
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 {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("warps").executes(c-> warps(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 warps(CommandSourceStack source) {
|
||||
|
||||
|
||||
ServerPlayer p = (ServerPlayer)source.getEntity();
|
||||
|
||||
Map<String, Warp> warps = WarpsProvider.WARPS_INSTANCE.get();
|
||||
|
||||
ChatServerOverride.broadcastTo(p.getUUID(), new TextComponent(OTEMod.OTEPrefix + " "+ChatColor.resetChat() + "There are "+warps.size()+" warps available"), source.getServer());
|
||||
|
||||
Iterator<Entry<String, Warp>> it = warps.entrySet().iterator();
|
||||
while(it.hasNext())
|
||||
{
|
||||
// TODO: Implement public and private. Private requires an ACL be implemented. New GUI
|
||||
Warp warp = it.next().getValue();
|
||||
// Pull the owner profile
|
||||
Profile prof=null;
|
||||
try {
|
||||
prof = Profile.get_profile_of(warp.owner.toString());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
e.printStackTrace();
|
||||
return 1;
|
||||
}
|
||||
String warpName = warp.WarpName;
|
||||
int warpType = 0;
|
||||
if(warp.RTP) warpType=1;
|
||||
|
||||
String appendType = (warpType == 0) ? "standard warp." : "RTP Warp. This has a position randomizer.";
|
||||
|
||||
HoverEvent hover = HoverTip.get(ChatColor.BOLD + ChatColor.DARK_PURPLE + "This warp is a "+appendType);
|
||||
ClickEvent click = Clickable.command("/warp "+warpName);
|
||||
Style S = Style.EMPTY.withFont(Style.DEFAULT_FONT).withHoverEvent(hover).withClickEvent(click);
|
||||
|
||||
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 = new TextComponent(ChatColor.GOLD+ " [Hover to see the warp's info]").withStyle(S);
|
||||
|
||||
// Combine the two
|
||||
warpMsg = new TextComponent("").append(warpMsg).append(ownerInfo);
|
||||
ChatServerOverride.broadcastTo(p.getUUID(), warpMsg, source.getServer());
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -11,10 +11,10 @@ import com.mojang.brigadier.CommandDispatcher;
|
|||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.libzontreck.vectors.WorldPosition;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import dev.zontreck.otemod.integrations.LuckPermsHelper;
|
||||
import dev.zontreck.otemod.permissions.Permissions;
|
||||
import dev.zontreck.otemod.zschem.MemoryHolder;
|
||||
|
@ -115,17 +115,17 @@ public class LoadSchem {
|
|||
MemoryHolder.setBlocks(play, blocks);
|
||||
|
||||
}else {
|
||||
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !Dark_Red!No such ZSchem exists!")), source.getServer());
|
||||
ChatHelpers.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !Dark_Red!No such ZSchem exists!")), source.getServer());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!ZSchem loaded from disk!")), OTEMod.THE_SERVER);
|
||||
ChatHelpers.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!ZSchem loaded from disk!")), OTEMod.THE_SERVER);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(ChatColor.doColors("!Dark_Red! You must set the first position")), OTEMod.THE_SERVER);
|
||||
ChatHelpers.broadcastTo(play.getUUID(), new TextComponent(ChatColor.doColors("!Dark_Red! You must set the first position")), OTEMod.THE_SERVER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ public class LoadSchem {
|
|||
usage += ChatColor.doColors("!gold! /loadzschem [string:name]");
|
||||
ServerPlayer play=(ServerPlayer)source.getEntity();
|
||||
if(play==null)return 1;
|
||||
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(usage), OTEMod.THE_SERVER);
|
||||
ChatHelpers.broadcastTo(play.getUUID(), new TextComponent(usage), OTEMod.THE_SERVER);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||
import com.mojang.brigadier.CommandDispatcher;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import dev.zontreck.otemod.integrations.LuckPermsHelper;
|
||||
|
@ -45,7 +46,7 @@ public class Place {
|
|||
|
||||
if(!MemoryHolder.hasPlayerCached(play)){
|
||||
|
||||
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!You must first load the zschem!")), OTEMod.THE_SERVER);
|
||||
ChatHelpers.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!You must first load the zschem!")), OTEMod.THE_SERVER);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -66,13 +67,13 @@ public class Place {
|
|||
|
||||
}else {
|
||||
|
||||
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!You must first load the zschem!")), OTEMod.THE_SERVER);
|
||||
ChatHelpers.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(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Enqueued!")), OTEMod.THE_SERVER);
|
||||
ChatHelpers.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Enqueued!")), OTEMod.THE_SERVER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.List;
|
|||
import com.mojang.brigadier.CommandDispatcher;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
|
@ -48,7 +49,7 @@ public class PlaceAsAir {
|
|||
|
||||
if(!MemoryHolder.hasPlayerCached(play)){
|
||||
|
||||
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!You must first set the positions!")), OTEMod.THE_SERVER);
|
||||
ChatHelpers.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!You must first set the positions!")), OTEMod.THE_SERVER);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -73,13 +74,13 @@ public class PlaceAsAir {
|
|||
|
||||
}else {
|
||||
|
||||
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!You must first set the positions!")), OTEMod.THE_SERVER);
|
||||
ChatHelpers.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(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Enqueued!")), OTEMod.THE_SERVER);
|
||||
ChatHelpers.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Enqueued!")), OTEMod.THE_SERVER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.mojang.brigadier.CommandDispatcher;
|
|||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
|
@ -107,12 +108,12 @@ public class SaveSchem {
|
|||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!ZSchem saved to disk!")), OTEMod.THE_SERVER);
|
||||
ChatHelpers.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!ZSchem saved to disk!")), OTEMod.THE_SERVER);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(ChatColor.doColors("!Dark_Red! You must first set the positions")), OTEMod.THE_SERVER);
|
||||
ChatHelpers.broadcastTo(play.getUUID(), new TextComponent(ChatColor.doColors("!Dark_Red! You must first set the positions")), OTEMod.THE_SERVER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -123,7 +124,7 @@ public class SaveSchem {
|
|||
usage += ChatColor.doColors("!gold! /savezschem [string:name]");
|
||||
ServerPlayer play=(ServerPlayer)source.getEntity();
|
||||
if(play==null)return 1;
|
||||
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(usage), OTEMod.THE_SERVER);
|
||||
ChatHelpers.broadcastTo(play.getUUID(), new TextComponent(usage), OTEMod.THE_SERVER);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package dev.zontreck.otemod.commands.zschem;
|
|||
import com.mojang.brigadier.CommandDispatcher;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
|
@ -39,7 +40,7 @@ public class SetPos1 {
|
|||
MemoryHolder.setPos1(play, new Vector3(source.getPosition()));
|
||||
MemoryHolder.setLevel(play, source.getLevel());
|
||||
|
||||
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Position 1 set!")), OTEMod.THE_SERVER);
|
||||
ChatHelpers.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Position 1 set!")), OTEMod.THE_SERVER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package dev.zontreck.otemod.commands.zschem;
|
|||
import com.mojang.brigadier.CommandDispatcher;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
|
@ -39,7 +40,7 @@ public class SetPos2 {
|
|||
MemoryHolder.setPos2(play, new Vector3(source.getPosition()));
|
||||
MemoryHolder.setLevel(play, source.getLevel());
|
||||
|
||||
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Position 2 set!")), OTEMod.THE_SERVER);
|
||||
ChatHelpers.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Green!Position 2 set!")), OTEMod.THE_SERVER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -2,9 +2,7 @@ package dev.zontreck.otemod.configs;
|
|||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
|
@ -29,6 +27,9 @@ public class OTEServerConfig {
|
|||
public static final ForgeConfigSpec.ConfigValue<Integer> MAX_VAULTS;
|
||||
public static final ForgeConfigSpec.ConfigValue<List<String>> EXCLUDE_DIMS;
|
||||
|
||||
public static final ForgeConfigSpec.ConfigValue<Double> CHANCE_OF_PLAYER_HEAD;
|
||||
public static final ForgeConfigSpec.ConfigValue<Boolean> ENABLE_PLAYER_HEAD_DROPS;
|
||||
|
||||
|
||||
public static final ForgeConfigSpec.BooleanValue USE_CUSTOM_JOINLEAVE;
|
||||
public static final ForgeConfigSpec.BooleanValue USE_CUSTOM_CHATREPLACER;
|
||||
|
@ -42,12 +43,19 @@ public class OTEServerConfig {
|
|||
|
||||
BUILDER.push("OTE");
|
||||
INITIAL_ITEMS_TO_GIVE_ON_FIRST_JOIN = BUILDER.comment("What items, identified by modid:item, to give to a brand new user on the server").define("New Player Gear", defaults);
|
||||
SPAWN_EGG_CHANCE = BUILDER.comment("What is the chance for a spawn egg to drop from a mob when looting 3 is used? Default: 0.25").define("spawn_egg_chance", 0.25);
|
||||
MAX_VAULTS = BUILDER.comment("What is the maximum number of vaults a player may have available? (0 is unlimited)").define("max_vaults", 0);
|
||||
ITEM_DESPAWN_TIMER = BUILDER.comment("How many times should the item's expire be cancelled. The vanilla expire time is 5 minutes, so this would be ticked down once every 5 minutes.").define("item_extra_lives", 2);
|
||||
|
||||
BUILDER.push("drops");
|
||||
ENABLE_PLAYER_HEAD_DROPS = BUILDER.comment("Whether to enable dropping of player Heads").define("enable_player_head_drops", true);
|
||||
SPAWN_EGG_CHANCE = BUILDER.comment("What is the chance for a spawn egg to drop from a mob when looting 3 is used? Default: 0.25").define("spawn_egg_chance", 0.25);
|
||||
CHANCE_OF_PLAYER_HEAD = BUILDER.comment("Chance of a player head dropping on death").define("player_death_drops_head", 0.5);
|
||||
|
||||
BUILDER.pop();
|
||||
BUILDER.pop();
|
||||
BUILDER.push("COMMANDS");
|
||||
|
||||
|
||||
RTP_COOLDOWN = BUILDER.comment("How many seconds between RTP uses? This can be quite laggy on the server due to the potential that new chunks are getting generated").define("rtp.cooldown", 30); // Default of 30 should be enough
|
||||
|
||||
BUILDER.pop();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package dev.zontreck.otemod.configs;
|
||||
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Abilities;
|
||||
|
||||
public class PlayerFlyCache
|
||||
{
|
||||
|
@ -17,6 +18,10 @@ public class PlayerFlyCache
|
|||
}
|
||||
|
||||
public void Assert(ServerPlayer play){
|
||||
Abilities playerAbilities = play.getAbilities();
|
||||
playerAbilities.flying=Flying;
|
||||
playerAbilities.mayfly=FlyEnabled;
|
||||
|
||||
play.onUpdateAbilities();
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package dev.zontreck.otemod.database;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.attribute.FileAttribute;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraftforge.fml.loading.FMLPaths;
|
||||
|
||||
public class FileTreeDatastore {
|
||||
private static final Path BASE;
|
||||
|
||||
static{
|
||||
Path X = FMLPaths.CONFIGDIR.get().resolve("otemod");
|
||||
BASE=X;
|
||||
if(!BASE.toFile().exists())
|
||||
{
|
||||
try {
|
||||
Files.createDirectory(BASE);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Path of(String nick)
|
||||
{
|
||||
return BASE.resolve(nick);
|
||||
}
|
||||
|
||||
public static List<File> getListOfFiles(Path files)
|
||||
{
|
||||
List<File> fileList = new ArrayList<>();
|
||||
|
||||
File[] entries = files.toFile().listFiles();
|
||||
for (File file : entries) {
|
||||
fileList.add(file);
|
||||
}
|
||||
return fileList;
|
||||
}
|
||||
}
|
29
src/main/java/dev/zontreck/otemod/database/OTEDatastore.java
Normal file
29
src/main/java/dev/zontreck/otemod/database/OTEDatastore.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
package dev.zontreck.otemod.database;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import dev.zontreck.libzontreck.util.FileTreeDatastore;
|
||||
|
||||
public class OTEDatastore extends FileTreeDatastore
|
||||
{
|
||||
private static final Path OTEBASE;
|
||||
|
||||
static{
|
||||
Path X = FileTreeDatastore.of("otemod");
|
||||
OTEBASE=X;
|
||||
if(!OTEBASE.toFile().exists())
|
||||
{
|
||||
try {
|
||||
Files.createDirectory(OTEBASE);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Path of(String nick)
|
||||
{
|
||||
return OTEBASE.resolve(nick);
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package dev.zontreck.otemod.database;
|
||||
|
||||
import dev.zontreck.libzontreck.vectors.Vector2;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.libzontreck.vectors.WorldPosition;
|
||||
import dev.zontreck.libzontreck.exceptions.InvalidDeserialization;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
||||
/**
|
||||
* This defines the data structure, and methods for deserializing and serializing teleport destinations, for easier storage in the database
|
||||
**/
|
||||
public class TeleportDestination extends WorldPosition
|
||||
{
|
||||
public Vector2 Rotation;
|
||||
|
||||
public TeleportDestination(CompoundTag tag) throws InvalidDeserialization
|
||||
{
|
||||
super(tag, true);
|
||||
Rotation = new Vector2(tag.getString("Rotation"));
|
||||
}
|
||||
public TeleportDestination(Vector3 pos, Vector2 rot, String dim)
|
||||
{
|
||||
super(pos, dim);
|
||||
Rotation = rot;
|
||||
}
|
||||
|
||||
public TeleportDestination(Vector3 pos, Vector2 rot, ServerLevel dim)
|
||||
{
|
||||
super(pos,dim);
|
||||
Rotation=rot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
||||
return NbtUtils.structureToSnbt(serialize());
|
||||
|
||||
}
|
||||
|
||||
public CompoundTag serialize(){
|
||||
|
||||
CompoundTag tag = super.serializePretty();
|
||||
tag.putString("Rotation", Rotation.toString());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,18 @@
|
|||
package dev.zontreck.otemod.events;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
|
||||
import dev.zontreck.libzontreck.items.lore.LoreContainer;
|
||||
import dev.zontreck.libzontreck.items.lore.LoreEntry;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.util.ItemUtils;
|
||||
import dev.zontreck.libzontreck.util.heads.HeadUtilities;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import dev.zontreck.otemod.enchantments.MobEggEnchantment;
|
||||
import dev.zontreck.otemod.enchantments.ModEnchantments;
|
||||
import dev.zontreck.otemod.items.tags.ItemStatType;
|
||||
|
@ -16,6 +27,7 @@ import net.minecraft.world.entity.LivingEntity;
|
|||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.storage.loot.LootTable;
|
||||
import net.minecraftforge.common.ForgeSpawnEggItem;
|
||||
|
@ -37,6 +49,7 @@ public class EventHandler {
|
|||
public void onEntityKilled(LivingDropsEvent ev){
|
||||
if(ev.getEntity().level.isClientSide)return;
|
||||
|
||||
Entity killedentity = ev.getEntityLiving();
|
||||
Entity ent = ev.getSource().getEntity();
|
||||
if(ent instanceof Player)
|
||||
{
|
||||
|
@ -68,6 +81,51 @@ public class EventHandler {
|
|||
tag.putInt(MobEggEnchantment.TAG_BIAS, bias);
|
||||
}
|
||||
}
|
||||
|
||||
if(killedentity instanceof Player)
|
||||
{
|
||||
if(!OTEServerConfig.ENABLE_PLAYER_HEAD_DROPS.get())
|
||||
{
|
||||
return;
|
||||
}
|
||||
int looting=0;
|
||||
ServerPlayer killedPlayer = (ServerPlayer)ent;
|
||||
if(ent instanceof Player){
|
||||
ServerPlayer pla = (ServerPlayer)ent;
|
||||
looting = ItemUtils.getEnchantmentLevel(Enchantments.MOB_LOOTING, pla.getMainHandItem());
|
||||
|
||||
}
|
||||
|
||||
// Calculate chance
|
||||
double base_chance = OTEServerConfig.CHANCE_OF_PLAYER_HEAD.get();
|
||||
base_chance += looting;
|
||||
base_chance *= 100;
|
||||
|
||||
Random rng = new Random();
|
||||
double num = rng.nextDouble(0,100000);
|
||||
if(num <= base_chance)
|
||||
{
|
||||
Profile profile=null;
|
||||
try {
|
||||
profile = Profile.get_profile_of(killedPlayer.getStringUUID());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ItemStack head = HeadUtilities.get(killedentity.getName().getContents()).setHoverName(ChatHelpers.macro(profile.nickname+"'s Head"));
|
||||
LoreContainer lore = new LoreContainer(head);
|
||||
LoreEntry entry = new LoreEntry();
|
||||
entry.text = ChatHelpers.macroize("!dark_green!Player: " + profile.name_color+profile.username);
|
||||
entry.bold=true;
|
||||
lore.miscData.LoreData.add(entry);
|
||||
entry = new LoreEntry();
|
||||
entry.text = "!Dark_Purple!Date: !Dark_Red!" + Date.from(Instant.now()).toString();
|
||||
lore.miscData.LoreData.add(entry);
|
||||
|
||||
|
||||
ev.getDrops().add(new ItemEntity(killedentity.level, killedentity.getX(), killedentity.getY(), killedentity.getZ(), head));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
package dev.zontreck.otemod.events;
|
||||
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.libzontreck.vectors.WorldPosition;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
@Cancelable
|
||||
public class RTPEvent extends Event
|
||||
{
|
||||
public ServerPlayer player;
|
||||
public WorldPosition position;
|
||||
|
||||
public RTPEvent(ServerPlayer player, WorldPosition position)
|
||||
{
|
||||
this.player=player;
|
||||
this.position=position;
|
||||
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package dev.zontreck.otemod.implementation;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import net.minecraftforge.event.TickEvent.ServerTickEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
|
||||
|
||||
@EventBusSubscriber(modid=OTEMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE)
|
||||
public class DelayedExecutorService {
|
||||
private static int COUNT = 0;
|
||||
public class DelayedExecution
|
||||
{
|
||||
public DelayedExecution(Runnable run, long unix) {
|
||||
scheduled=run;
|
||||
unix_time=unix;
|
||||
}
|
||||
public Runnable scheduled;
|
||||
public long unix_time;
|
||||
}
|
||||
|
||||
public List<DelayedExecution> EXECUTORS = new ArrayList<>();
|
||||
|
||||
public void schedule(Runnable run, int seconds)
|
||||
{
|
||||
long unix = Instant.now().getEpochSecond()+ (seconds);
|
||||
DelayedExecution exe = new DelayedExecution(run,unix);
|
||||
EXECUTORS.add(exe);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTick(ServerTickEvent ev)
|
||||
{
|
||||
if(!OTEMod.ALIVE)
|
||||
{
|
||||
OTEMod.LOGGER.info("Tearing down delayed executor service");
|
||||
|
||||
return;
|
||||
}
|
||||
Iterator<DelayedExecution> it = EXECUTORS.iterator();
|
||||
while(it.hasNext())
|
||||
{
|
||||
DelayedExecution e = it.next();
|
||||
if(e.unix_time < Instant.now().getEpochSecond())
|
||||
{
|
||||
it.remove();
|
||||
Thread tx = new Thread(e.scheduled);
|
||||
tx.setName("DelayedExecutorTask-"+String.valueOf(DelayedExecutorService.getNext()));
|
||||
tx.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int getNext()
|
||||
{
|
||||
COUNT++;
|
||||
return COUNT;
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package dev.zontreck.otemod.implementation.events;
|
||||
|
||||
import dev.zontreck.otemod.implementation.homes.Home;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public class HomeCreatedEvent extends Event
|
||||
{
|
||||
public Home home;
|
||||
public HomeCreatedEvent(Home home)
|
||||
{
|
||||
this.home=home;
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
package dev.zontreck.otemod.implementation.events;
|
||||
|
||||
import dev.zontreck.otemod.implementation.homes.Home;
|
||||
|
||||
public class HomeDeletedEvent extends HomeCreatedEvent
|
||||
{
|
||||
|
||||
public HomeDeletedEvent(Home home) {
|
||||
super(home);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package dev.zontreck.otemod.implementation.events;
|
||||
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public class ProfileCreatedEvent extends Event
|
||||
{
|
||||
public String playerID;
|
||||
public ProfileCreatedEvent(Profile newProfile)
|
||||
{
|
||||
playerID = newProfile.user_id;
|
||||
}
|
||||
}
|
|
@ -1,9 +1,7 @@
|
|||
package dev.zontreck.otemod.implementation.events;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import dev.zontreck.otemod.implementation.vault.Vault;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public class VaultCreatedEvent extends Event
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package dev.zontreck.otemod.implementation.events;
|
||||
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
|
||||
public class VaultDeletedEvent extends VaultCreatedEvent{
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package dev.zontreck.otemod.implementation.events;
|
||||
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
package dev.zontreck.otemod.implementation.events;
|
||||
|
||||
import dev.zontreck.otemod.implementation.warps.Warp;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public class WarpCreatedEvent extends Event
|
||||
{
|
||||
public Warp warp;
|
||||
public WarpCreatedEvent(Warp w)
|
||||
{
|
||||
warp=w;
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
package dev.zontreck.otemod.implementation.events;
|
||||
|
||||
import dev.zontreck.otemod.implementation.warps.Warp;
|
||||
|
||||
public class WarpDeletedEvent extends WarpCreatedEvent
|
||||
{
|
||||
|
||||
public WarpDeletedEvent(Warp w) {
|
||||
super(w);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package dev.zontreck.otemod.implementation.homes;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import dev.zontreck.libzontreck.exceptions.InvalidDeserialization;
|
||||
import dev.zontreck.otemod.database.TeleportDestination;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class Home {
|
||||
public UUID owner;
|
||||
public String homeName;
|
||||
public TeleportDestination destination;
|
||||
|
||||
|
||||
public Home(ServerPlayer player, String name, TeleportDestination dest)
|
||||
{
|
||||
owner=player.getUUID();
|
||||
homeName=name;
|
||||
destination=dest;
|
||||
}
|
||||
|
||||
public Home(CompoundTag tag)
|
||||
{
|
||||
owner = tag.getUUID("owner");
|
||||
homeName = tag.getString("name");
|
||||
try {
|
||||
destination = new TeleportDestination(tag.getCompound("dest"));
|
||||
} catch (InvalidDeserialization e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public CompoundTag serialize()
|
||||
{
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.putUUID("owner", owner);
|
||||
tag.putString("name", homeName);
|
||||
tag.put("dest", destination.serialize());
|
||||
|
||||
return tag;
|
||||
}
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
package dev.zontreck.otemod.implementation.homes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.events.HomeCreatedEvent;
|
||||
import dev.zontreck.otemod.implementation.events.HomeDeletedEvent;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
|
||||
public class Homes {
|
||||
private Map<String, Home> homes = new HashMap<>();
|
||||
|
||||
public String playerID;
|
||||
public Homes(String playerID)
|
||||
{
|
||||
this.playerID=playerID;
|
||||
}
|
||||
|
||||
public int count()
|
||||
{
|
||||
return homes.size();
|
||||
}
|
||||
|
||||
public List<Home> getList()
|
||||
{
|
||||
return new ArrayList<>(homes.values());
|
||||
}
|
||||
|
||||
public Home get(String name) throws NoSuchHomeException
|
||||
{
|
||||
if(homes.containsKey(name))
|
||||
return homes.get(name);
|
||||
else throw new NoSuchHomeException();
|
||||
}
|
||||
|
||||
public void delete(String name) throws NoSuchHomeException
|
||||
{
|
||||
Home home = homes.get(name);
|
||||
HomeDeletedEvent e = new HomeDeletedEvent(home);
|
||||
homes.remove(name);
|
||||
|
||||
OTEMod.bus.post(e);
|
||||
HomesProvider.commitHomes(this);
|
||||
}
|
||||
|
||||
public void add(Home toAdd)
|
||||
{
|
||||
HomeCreatedEvent hce = new HomeCreatedEvent(toAdd);
|
||||
OTEMod.bus.post(hce);
|
||||
|
||||
homes.put(toAdd.homeName, toAdd);
|
||||
|
||||
HomesProvider.commitHomes(this);
|
||||
}
|
||||
|
||||
public static Homes deserialize(CompoundTag tag)
|
||||
{
|
||||
Homes ret = new Homes(null);
|
||||
ListTag theHomes = tag.getList("homes", Tag.TAG_COMPOUND);
|
||||
for (Tag tag2 : theHomes) {
|
||||
Home h = new Home((CompoundTag)tag2);
|
||||
ret.homes.put(h.homeName, h);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public CompoundTag serialize()
|
||||
{
|
||||
CompoundTag tag = new CompoundTag();
|
||||
ListTag lst = new ListTag();
|
||||
for (Map.Entry<String,Home> entry : homes.entrySet()) {
|
||||
lst.add(entry.getValue().serialize());
|
||||
}
|
||||
tag.put("homes", lst);
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package dev.zontreck.otemod.implementation.homes;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.UUID;
|
||||
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
|
||||
public class HomesProvider {
|
||||
/**
|
||||
* DO NOT USE. Internal use only.
|
||||
* @see Profile#player_homes
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public static Homes getHomesForPlayer(String player)
|
||||
{
|
||||
Path homesFile = Profile.BASE.resolve(player).resolve("homes.nbt");
|
||||
|
||||
Homes homes = new Homes(player);
|
||||
if(homesFile.toFile().exists())
|
||||
{
|
||||
try {
|
||||
homes=Homes.deserialize(NbtIo.read(homesFile.toFile()));
|
||||
homes.playerID=player;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return homes;
|
||||
}
|
||||
|
||||
public static void commitHomes(Homes playerHomes)
|
||||
{
|
||||
|
||||
Path homesFile = Profile.BASE.resolve(playerHomes.playerID).resolve("homes.nbt");
|
||||
|
||||
try {
|
||||
NbtIo.write(playerHomes.serialize(), homesFile.toFile());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
package dev.zontreck.otemod.implementation.homes;
|
||||
|
||||
public class NoSuchHomeException extends Exception{
|
||||
|
||||
}
|
|
@ -1,162 +0,0 @@
|
|||
package dev.zontreck.otemod.implementation.profiles;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import dev.zontreck.libzontreck.LibZontreck.ForgeEventBus;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.database.FileTreeDatastore;
|
||||
import dev.zontreck.otemod.implementation.events.ProfileCreatedEvent;
|
||||
import dev.zontreck.otemod.implementation.homes.Homes;
|
||||
import dev.zontreck.otemod.implementation.homes.HomesProvider;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.eventbus.EventBus;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
public class Profile {
|
||||
public String username;
|
||||
public String user_id;
|
||||
public String prefix;
|
||||
public String nickname;
|
||||
public String name_color; // ChatColor.X
|
||||
public String prefix_color;
|
||||
public String chat_color;
|
||||
public Boolean flying;
|
||||
public int available_vaults;
|
||||
public Homes player_homes;
|
||||
|
||||
private File accessor;
|
||||
|
||||
public static final Path BASE = FileTreeDatastore.of("profiles");
|
||||
|
||||
public Profile(String username, String prefix, String nickname, String name_color, String ID, String prefix_color, String chat_color, Boolean isFlying, int vaults, File vaultFile) {
|
||||
this.username = username;
|
||||
this.prefix = prefix;
|
||||
this.nickname = nickname;
|
||||
this.name_color = name_color;
|
||||
this.user_id = ID;
|
||||
this.prefix_color = prefix_color;
|
||||
this.chat_color = chat_color;
|
||||
this.flying=isFlying;
|
||||
this.available_vaults=vaults;
|
||||
player_homes = HomesProvider.getHomesForPlayer(ID);
|
||||
|
||||
|
||||
this.accessor = vaultFile;
|
||||
}
|
||||
|
||||
|
||||
public static Profile get_profile_of(String UUID) throws UserProfileNotYetExistsException
|
||||
{
|
||||
if(OTEMod.PROFILES.containsKey(UUID)){
|
||||
return OTEMod.PROFILES.get(UUID);
|
||||
}else {
|
||||
// Create or load profile
|
||||
Path userProfile = BASE.resolve(UUID);
|
||||
if(userProfile.toFile().exists())
|
||||
{
|
||||
// Load profile data
|
||||
File ace = userProfile.resolve("profile.dat").toFile();
|
||||
try {
|
||||
Profile actual = load(NbtIo.read(ace), ace);
|
||||
OTEMod.PROFILES.put(UUID, actual);
|
||||
return actual;
|
||||
} catch (IOException e) {
|
||||
throw new UserProfileNotYetExistsException(UUID);
|
||||
}
|
||||
|
||||
}else {
|
||||
// Create directory, then throw a exception so a new profile gets created
|
||||
try {
|
||||
Files.createDirectories(userProfile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
throw new UserProfileNotYetExistsException(UUID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Profile load(CompoundTag tag, File accessor)
|
||||
{
|
||||
return new Profile(tag.getString("user"), tag.getString("prefix"), tag.getString("nick"), tag.getString("nickc"), tag.getString("id"), tag.getString("prefixc"), tag.getString("chatc"), tag.getBoolean("flying"), tag.getInt("vaults"), accessor);
|
||||
}
|
||||
|
||||
private static void generateNewProfile(ServerPlayer player)
|
||||
{
|
||||
|
||||
Path userProfile = BASE.resolve(player.getStringUUID());
|
||||
if(userProfile.toFile().exists())
|
||||
{
|
||||
// Load profile data
|
||||
File ace = userProfile.resolve("profile.dat").toFile();
|
||||
Profile template = new Profile(player.getName().getString(), "Member", player.getDisplayName().getString(), ChatColor.GREEN, player.getStringUUID(), ChatColor.AQUA, ChatColor.WHITE, false, 0, ace);
|
||||
template.commit();
|
||||
|
||||
|
||||
OTEMod.bus.post(new ProfileCreatedEvent(template));
|
||||
|
||||
template=null;
|
||||
return;
|
||||
}else {
|
||||
try {
|
||||
Files.createDirectories(userProfile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
generateNewProfile(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finalize()
|
||||
{
|
||||
OTEMod.LOGGER.info("Profile is unloaded for "+username);
|
||||
}
|
||||
|
||||
public static void unload(Profile prof)
|
||||
{
|
||||
OTEMod.PROFILES.remove(prof.user_id);
|
||||
prof=null;
|
||||
}
|
||||
|
||||
public static Profile factory(ServerPlayer play)
|
||||
{
|
||||
try {
|
||||
return get_profile_of(play.getStringUUID());
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
generateNewProfile(play);
|
||||
return factory(play);
|
||||
}
|
||||
}
|
||||
|
||||
public void commit()
|
||||
{
|
||||
// Save data to FileTree
|
||||
CompoundTag serial = new CompoundTag();
|
||||
serial.putString("user", username);
|
||||
serial.putString("prefix", prefix);
|
||||
serial.putString("nick", nickname);
|
||||
serial.putString("id", user_id);
|
||||
serial.putString("nickc", name_color);
|
||||
serial.putString("prefixc", prefix_color);
|
||||
serial.putString("chatc", chat_color);
|
||||
serial.putBoolean("flying", flying);
|
||||
serial.putInt("vaults", available_vaults);
|
||||
|
||||
|
||||
|
||||
try {
|
||||
NbtIo.write(serial, accessor);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package dev.zontreck.otemod.implementation.profiles;
|
||||
|
||||
public class UserProfileNotYetExistsException extends Exception{
|
||||
String playerID;
|
||||
public UserProfileNotYetExistsException(String id){
|
||||
super("A user profile does not yet exist");
|
||||
playerID=id;
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ package dev.zontreck.otemod.implementation.vault;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
|
||||
|
|
|
@ -11,11 +11,12 @@ import java.util.UUID;
|
|||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import dev.zontreck.otemod.implementation.events.VaultModifiedEvent;
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import dev.zontreck.otemod.implementation.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.otemod.implementation.vault.VaultProvider.VaultAccessStrategy;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
@ -87,7 +88,7 @@ public class VaultContainer
|
|||
if(VAULT_NUMBER == -1)return; // We have no need to save the trash
|
||||
boolean isEmpty=true;
|
||||
CompoundTag saved = myInventory.serializeNBT();
|
||||
ChatServerOverride.broadcastToAbove(owner, new TextComponent(ChatColor.BOLD+ChatColor.DARK_GREEN+"Saving the vault's contents..."), server);
|
||||
ChatHelpers.broadcastToAbove(owner, new TextComponent(ChatColor.BOLD+ChatColor.DARK_GREEN+"Saving the vault's contents..."), server);
|
||||
|
||||
Profile profile=null;
|
||||
try {
|
||||
|
|
|
@ -6,11 +6,11 @@ import java.nio.file.Files;
|
|||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import dev.zontreck.otemod.database.FileTreeDatastore;
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import dev.zontreck.otemod.database.OTEDatastore;
|
||||
|
||||
public class VaultProvider extends FileTreeDatastore
|
||||
public class VaultProvider extends OTEDatastore
|
||||
{
|
||||
public enum VaultAccessStrategy
|
||||
{
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
package dev.zontreck.otemod.implementation.warps;
|
||||
|
||||
public class NoSuchWarpException extends Exception
|
||||
{
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package dev.zontreck.otemod.implementation.warps;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import dev.zontreck.libzontreck.exceptions.InvalidDeserialization;
|
||||
import dev.zontreck.otemod.database.TeleportDestination;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
public class Warp {
|
||||
public UUID owner;
|
||||
public String WarpName;
|
||||
public boolean RTP;
|
||||
public boolean isPublic;
|
||||
public TeleportDestination destination;
|
||||
|
||||
public Warp(UUID owner, String name, boolean rtp, boolean publicWarp, TeleportDestination destination)
|
||||
{
|
||||
this.owner=owner;
|
||||
WarpName=name;
|
||||
RTP=rtp;
|
||||
isPublic=publicWarp;
|
||||
this.destination=destination;
|
||||
}
|
||||
|
||||
public static Warp deserialize(CompoundTag tag) throws InvalidDeserialization
|
||||
{
|
||||
return new Warp(tag.getUUID("owner"), tag.getString("name"), tag.getBoolean("rtp"), tag.getBoolean("public"), new TeleportDestination(tag.getCompound("destination")));
|
||||
}
|
||||
|
||||
public CompoundTag serialize()
|
||||
{
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.putUUID("owner", owner);
|
||||
tag.putString("name", WarpName);
|
||||
tag.putBoolean("rtp", RTP);
|
||||
tag.putBoolean("public", isPublic);
|
||||
tag.put("destination", destination.serialize());
|
||||
|
||||
return tag;
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
package dev.zontreck.otemod.implementation.warps;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import dev.zontreck.libzontreck.exceptions.InvalidDeserialization;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.events.WarpCreatedEvent;
|
||||
import dev.zontreck.otemod.implementation.events.WarpDeletedEvent;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
public class Warps
|
||||
{
|
||||
private Map<String,Warp> warps = new HashMap<>();
|
||||
|
||||
private Warps(){
|
||||
|
||||
}
|
||||
|
||||
public Warp getNamedWarp(String name) throws NoSuchWarpException
|
||||
{
|
||||
if(warps.containsKey(name))
|
||||
return warps.get(name);
|
||||
else throw new NoSuchWarpException();
|
||||
}
|
||||
|
||||
public void add(Warp w)
|
||||
{
|
||||
warps.put(w.WarpName,w);
|
||||
WarpsProvider.updateFile();
|
||||
|
||||
WarpCreatedEvent e = new WarpCreatedEvent(w);
|
||||
OTEMod.bus.post(e);
|
||||
}
|
||||
|
||||
public Map<String, Warp> get()
|
||||
{
|
||||
return new HashMap<String, Warp>(warps);
|
||||
}
|
||||
|
||||
public void delete(Warp w)
|
||||
{
|
||||
warps.remove(w.WarpName);
|
||||
WarpsProvider.updateFile();
|
||||
|
||||
WarpDeletedEvent e = new WarpDeletedEvent(w);
|
||||
OTEMod.bus.post(e);
|
||||
}
|
||||
|
||||
public static Warps getNew()
|
||||
{
|
||||
return new Warps();
|
||||
}
|
||||
|
||||
public CompoundTag serialize()
|
||||
{
|
||||
CompoundTag tag = new CompoundTag();
|
||||
ListTag lst = new ListTag();
|
||||
for(Map.Entry<String, Warp> entry : warps.entrySet())
|
||||
{
|
||||
lst.add(entry.getValue().serialize());
|
||||
}
|
||||
|
||||
tag.put("warps", lst);
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static Warps deserialize(CompoundTag tag)
|
||||
{
|
||||
Warps w = new Warps();
|
||||
ListTag lst = tag.getList("warps", Tag.TAG_COMPOUND);
|
||||
for (Tag tag2 : lst) {
|
||||
Warp warp;
|
||||
try {
|
||||
warp = Warp.deserialize((CompoundTag)tag2);
|
||||
w.warps.put(warp.WarpName, warp);
|
||||
} catch (InvalidDeserialization e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package dev.zontreck.otemod.implementation.warps;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import dev.zontreck.otemod.database.FileTreeDatastore;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
|
||||
public class WarpsProvider extends FileTreeDatastore
|
||||
{
|
||||
public static final Path BASE = of("warps");
|
||||
public static final Path WARPS_DATA = BASE.resolve("warps.nbt");
|
||||
|
||||
public static final Warps WARPS_INSTANCE;
|
||||
static{
|
||||
if(!BASE.toFile().exists()){
|
||||
try {
|
||||
Files.createDirectory(BASE);
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
WARPS_INSTANCE = getOrCreate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new warps instance, or returns a fully deserialized instance
|
||||
* @return
|
||||
*/
|
||||
private static Warps getOrCreate()
|
||||
{
|
||||
Warps instance = null;
|
||||
if(WARPS_DATA.toFile().exists())
|
||||
{
|
||||
try{
|
||||
instance= Warps.deserialize(NbtIo.read(WARPS_DATA.toFile()));
|
||||
|
||||
}catch(Exception e){
|
||||
instance=Warps.getNew();
|
||||
}
|
||||
}else {
|
||||
instance=Warps.getNew();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static void updateFile()
|
||||
{
|
||||
try {
|
||||
NbtIo.write(WARPS_INSTANCE.serialize(), WARPS_DATA.toFile());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package dev.zontreck.otemod.integrations;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -35,6 +36,6 @@ public class LuckPermsHelper {
|
|||
}
|
||||
|
||||
public static void sendNoPermissionsMessage(ServerPlayer play, String perm, String group) {
|
||||
ChatServerOverride.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !Dark_Red!You do not have permission to use that command. You need permission !Gold!"+perm+" !White! or !Gold!"+group)), play.server);
|
||||
ChatHelpers.broadcastTo(play.getUUID(), new TextComponent(OTEMod.OTEPrefix + ChatColor.doColors(" !Dark_Red!You do not have permission to use that command. You need permission !Gold!"+perm+" !White! or !Gold!"+group)), play.server);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,13 @@ package dev.zontreck.otemod.items;
|
|||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.items.lore.LoreContainer;
|
||||
import dev.zontreck.libzontreck.items.lore.LoreEntry;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import dev.zontreck.otemod.events.LoreHandlers;
|
||||
import dev.zontreck.otemod.implementation.profiles.Profile;
|
||||
import dev.zontreck.otemod.implementation.profiles.UserProfileNotYetExistsException;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
|
@ -56,12 +57,12 @@ public class VaultItem extends Item
|
|||
{
|
||||
if(p.available_vaults >= OTEServerConfig.MAX_VAULTS.get())
|
||||
{
|
||||
ChatServerOverride.broadcastTo(pPlayer.getUUID(), new TextComponent(ChatColor.doColors(OTEMod.OTEPrefix+" !Dark_Red!You cannot activate anymore vaults due to the maximum set by the server admin")), OTEMod.THE_SERVER);
|
||||
ChatHelpers.broadcastTo(pPlayer.getUUID(), new TextComponent(ChatColor.doColors(OTEMod.OTEPrefix+" !Dark_Red!You cannot activate anymore vaults due to the maximum set by the server admin")), OTEMod.THE_SERVER);
|
||||
return InteractionResultHolder.pass(is);
|
||||
} else {
|
||||
p.available_vaults++;
|
||||
p.commit();
|
||||
ChatServerOverride.broadcastTo(pPlayer.getUUID(), new TextComponent(ChatColor.doColors(OTEMod.OTEPrefix+" !Dark_Green!You now have "+String.valueOf(p.available_vaults)+" available vaults")), OTEMod.THE_SERVER);
|
||||
ChatHelpers.broadcastTo(pPlayer.getUUID(), new TextComponent(ChatColor.doColors(OTEMod.OTEPrefix+" !Dark_Green!You now have "+String.valueOf(p.available_vaults)+" available vaults")), OTEMod.THE_SERVER);
|
||||
pPlayer.setItemInHand(pUsedHand, new ItemStack(Items.AIR));
|
||||
|
||||
return InteractionResultHolder.consume(is);
|
||||
|
@ -69,7 +70,7 @@ public class VaultItem extends Item
|
|||
}else {
|
||||
p.available_vaults++;
|
||||
p.commit();
|
||||
ChatServerOverride.broadcastTo(pPlayer.getUUID(), new TextComponent(ChatColor.doColors(OTEMod.OTEPrefix+" !Dark_Green!You now have "+String.valueOf(p.available_vaults)+" available vaults")), OTEMod.THE_SERVER);
|
||||
ChatHelpers.broadcastTo(pPlayer.getUUID(), new TextComponent(ChatColor.doColors(OTEMod.OTEPrefix+" !Dark_Green!You now have "+String.valueOf(p.available_vaults)+" available vaults")), OTEMod.THE_SERVER);
|
||||
pPlayer.setItemInHand(pUsedHand, new ItemStack(Items.AIR));
|
||||
|
||||
return InteractionResultHolder.consume(is);
|
||||
|
|
|
@ -10,10 +10,9 @@ import java.util.concurrent.locks.Lock;
|
|||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatServerOverride;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@ -86,7 +85,7 @@ public class MemoryHolder {
|
|||
if(c.isExpired()){
|
||||
imeuc.remove();
|
||||
|
||||
ChatServerOverride.broadcastTo(entry.getKey(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!ZSchem Session expired")), c.lvl.getServer());
|
||||
ChatHelpers.broadcastTo(entry.getKey(), new TextComponent(OTEMod.OTEPrefix+ChatColor.doColors(" !Dark_Red!ZSchem Session expired")), c.lvl.getServer());
|
||||
}
|
||||
}
|
||||
}finally{
|
||||
|
|
|
@ -56,6 +56,6 @@ This mod is a work in progress and is planned to add a procedural adventure syst
|
|||
[[dependencies.otemod]]
|
||||
modId="libzontreck"
|
||||
mandatory=true
|
||||
versionRange="[1.0.4.13,1.0.5.0]"
|
||||
versionRange="[1.0.5,1.0.6.0]"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
Reference in a new issue