diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/re/jag/parquet/commands/CameraMode.java | 58 | ||||
-rw-r--r-- | src/main/java/re/jag/parquet/commands/ListAllPlayerSaves.java | 31 | ||||
-rw-r--r-- | src/main/java/re/jag/parquet/interfaces/CameraModeData.java (renamed from src/main/java/re/jag/parquet/commands/CameraModeData.java) | 2 | ||||
-rw-r--r-- | src/main/java/re/jag/parquet/mixin/ServerPlayerEntityMixin.java | 6 |
4 files changed, 74 insertions, 23 deletions
diff --git a/src/main/java/re/jag/parquet/commands/CameraMode.java b/src/main/java/re/jag/parquet/commands/CameraMode.java index f65e1e7..0b74f1e 100644 --- a/src/main/java/re/jag/parquet/commands/CameraMode.java +++ b/src/main/java/re/jag/parquet/commands/CameraMode.java @@ -15,47 +15,77 @@ import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.LiteralText; import net.minecraft.world.GameMode; +import re.jag.parquet.interfaces.CameraModeData; public class CameraMode { public static void register(CommandDispatcher<ServerCommandSource> dispatcher) { - LiteralArgumentBuilder<ServerCommandSource> camermode = literal("c"). + LiteralArgumentBuilder<ServerCommandSource> camermode = literal("c"). executes((c) -> camera( c.getSource(), c.getSource().getPlayer())). then(argument("player", EntityArgumentType.player()). executes( (c) -> camera(c.getSource(), EntityArgumentType.getPlayer(c, "player")))); - LiteralArgumentBuilder<ServerCommandSource> survivalmode = literal("s"). + LiteralArgumentBuilder<ServerCommandSource> survivalmode = literal("s"). executes((c) -> survival( c.getSource(), c.getSource().getPlayer())). then(argument("player", EntityArgumentType.player()). executes( (c) -> survival(c.getSource(), EntityArgumentType.getPlayer(c, "player")))); + LiteralArgumentBuilder<ServerCommandSource> defaultmode = literal("d"). + executes((c) -> defmode( c.getSource(), c.getSource().getPlayer())). + then(argument("player", EntityArgumentType.player()). + executes( (c) -> defmode(c.getSource(), EntityArgumentType.getPlayer(c, "player")))); - dispatcher.register(camermode); - dispatcher.register(survivalmode); + dispatcher.register(camermode); + dispatcher.register(survivalmode); + dispatcher.register(defaultmode); + } + + private static void add_status_effects(ServerPlayerEntity player) { + + player.addStatusEffect(new StatusEffectInstance(StatusEffects.NIGHT_VISION, 999999, 0, false, false)); + player.addStatusEffect(new StatusEffectInstance(StatusEffects.CONDUIT_POWER, 999999, 0, false, false)); + } + + private static void remove_status_effects(ServerPlayerEntity player) { + player.networkHandler.sendPacket(new RemoveEntityStatusEffectS2CPacket(player.getEntityId(), StatusEffects.NIGHT_VISION)); + player.removeStatusEffect(StatusEffects.NIGHT_VISION); + player.networkHandler.sendPacket(new RemoveEntityStatusEffectS2CPacket(player.getEntityId(), StatusEffects.CONDUIT_POWER)); + player.removeStatusEffect(StatusEffects.CONDUIT_POWER); } private static int camera(ServerCommandSource source, ServerPlayerEntity player) { if (! ((CameraModeData)player).saveCameraPosition() ) { - source.sendFeedback(new LiteralText("Gamemode is already camera"), false); - return 0; + source.sendFeedback(new LiteralText("Reset location already exists"), false); + } else { + add_status_effects(player); } player.setGameMode(GameMode.SPECTATOR); player.addVelocity(0,0.1,0); player.networkHandler.sendPacket(new EntityVelocityUpdateS2CPacket(player)); - player.addStatusEffect(new StatusEffectInstance(StatusEffects.NIGHT_VISION, 999999, 0, false, false)); - player.addStatusEffect(new StatusEffectInstance(StatusEffects.CONDUIT_POWER, 999999, 0, false, false)); + return 1; } private static int survival(ServerCommandSource source, ServerPlayerEntity player) { if (! ((CameraModeData)player).restoreCameraPosition() ) { - source.sendFeedback(new LiteralText("Gamemode is already survival"), false); - return 0; + source.sendFeedback(new LiteralText("No reset location stored"), false); + } else { + remove_status_effects(player); } player.setGameMode(GameMode.SURVIVAL); - player.networkHandler.sendPacket(new RemoveEntityStatusEffectS2CPacket(player.getEntityId(), StatusEffects.NIGHT_VISION)); - player.removeStatusEffect(StatusEffects.NIGHT_VISION); - player.networkHandler.sendPacket(new RemoveEntityStatusEffectS2CPacket(player.getEntityId(), StatusEffects.CONDUIT_POWER)); - player.removeStatusEffect(StatusEffects.CONDUIT_POWER); + + return 1; + } + + //Reset to server default gamemode + private static int defmode(ServerCommandSource source, ServerPlayerEntity player) { + if (! ((CameraModeData)player).restoreCameraPosition() ) { + source.sendFeedback(new LiteralText("No reset location stored"), false); + } else { + remove_status_effects(player); + } + + player.setGameMode( player.getServer().getDefaultGameMode() ); + return 1; } } diff --git a/src/main/java/re/jag/parquet/commands/ListAllPlayerSaves.java b/src/main/java/re/jag/parquet/commands/ListAllPlayerSaves.java index 53e8a7e..5b5668f 100644 --- a/src/main/java/re/jag/parquet/commands/ListAllPlayerSaves.java +++ b/src/main/java/re/jag/parquet/commands/ListAllPlayerSaves.java @@ -1,25 +1,42 @@ package re.jag.parquet.commands; +import java.util.UUID; + import static net.minecraft.server.command.CommandManager.literal; +import static net.minecraft.server.command.CommandManager.argument; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import java.util.UUID; +import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.authlib.GameProfile; + import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.LiteralText; import net.minecraft.world.dimension.DimensionType; public class ListAllPlayerSaves { public static void register(CommandDispatcher<ServerCommandSource> dispatcher) { - LiteralArgumentBuilder<ServerCommandSource> listplayersaves = literal("listplayersaves"). + LiteralArgumentBuilder<ServerCommandSource> savedata = literal("savedata"). requires(source -> source.hasPermissionLevel(4)). - executes((c) -> execute(c.getSource())); + executes((c) -> help(c.getSource())). + then( literal("playersave"). + then(literal("list"). + executes((c) -> list_local_saves(c.getSource())) + ). + then(argument("UUID", StringArgumentType.word()). + executes((c) -> get_player_save_uuid(c.getSource(), StringArgumentType.getString(c, "UUID"))) + ) + ); - dispatcher.register(listplayersaves); + dispatcher.register(savedata); + } + + private static int help(ServerCommandSource source) { + source.sendFeedback(new LiteralText("Test"), false); + return 1; } - private static int execute(ServerCommandSource source) { + private static int list_local_saves(ServerCommandSource source) { String uuid_list[] = source.getMinecraftServer().getWorld(DimensionType.OVERWORLD).getSaveHandler().getSavedPlayerIds(); for (int i = 0; i < uuid_list.length; i++) { @@ -34,5 +51,9 @@ public class ListAllPlayerSaves { return 1; } + + private static int get_player_save_uuid(ServerCommandSource source, String uuid) { + return 1; + } } diff --git a/src/main/java/re/jag/parquet/commands/CameraModeData.java b/src/main/java/re/jag/parquet/interfaces/CameraModeData.java index c1319f9..78830db 100644 --- a/src/main/java/re/jag/parquet/commands/CameraModeData.java +++ b/src/main/java/re/jag/parquet/interfaces/CameraModeData.java @@ -1,4 +1,4 @@ -package re.jag.parquet.commands; +package re.jag.parquet.interfaces; public interface CameraModeData { boolean saveCameraPosition(); diff --git a/src/main/java/re/jag/parquet/mixin/ServerPlayerEntityMixin.java b/src/main/java/re/jag/parquet/mixin/ServerPlayerEntityMixin.java index 259d65a..0cb1827 100644 --- a/src/main/java/re/jag/parquet/mixin/ServerPlayerEntityMixin.java +++ b/src/main/java/re/jag/parquet/mixin/ServerPlayerEntityMixin.java @@ -1,7 +1,5 @@ package re.jag.parquet.mixin; -import re.jag.parquet.commands.CameraModeData; - import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -15,6 +13,7 @@ import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.world.World; import net.minecraft.world.dimension.DimensionType; +import re.jag.parquet.interfaces.CameraModeData; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; @@ -60,7 +59,8 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntity implements Ca this.saved_dimension = DimensionType.byRawId(dim_raw_id); } - + + //INTERFACE CameraModeData public boolean saveCameraPosition() { if (!this.save_active) { this.saved_x = getX(); |