Changed groupId from com.micle to dev.micle. Updated code to match newest MCP mappings.
This commit is contained in:
@ -1,89 +0,0 @@
|
|||||||
package com.micle.loginprotection.events;
|
|
||||||
|
|
||||||
import com.micle.loginprotection.LoginProtection;
|
|
||||||
import com.micle.loginprotection.network.C2SKeyPress;
|
|
||||||
import com.micle.loginprotection.setup.Config;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.multiplayer.ServerData;
|
|
||||||
import net.minecraft.server.integrated.IntegratedServer;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
||||||
import net.minecraftforge.client.event.InputEvent;
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
||||||
import org.lwjgl.glfw.GLFW;
|
|
||||||
|
|
||||||
public class OnKeyPressEventHandler {
|
|
||||||
@SubscribeEvent
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
public void KeyPressEvent(InputEvent.KeyInputEvent event) {
|
|
||||||
Minecraft instance = Minecraft.getInstance();
|
|
||||||
ServerData server_online = instance.getCurrentServer();
|
|
||||||
IntegratedServer server_local = instance.getSingleplayerServer();
|
|
||||||
if (server_online == null && server_local == null) { return; }
|
|
||||||
if (Minecraft.getInstance().screen != null) { return; }
|
|
||||||
if (checkKeyAllowed(instance, event.getKey())) { return; }
|
|
||||||
|
|
||||||
try {
|
|
||||||
LoginProtection.INSTANCE.sendToServer(new C2SKeyPress());
|
|
||||||
} catch (NullPointerException ignored) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
public void MouseClickEvent(InputEvent.ClickInputEvent event) {
|
|
||||||
Minecraft instance = Minecraft.getInstance();
|
|
||||||
ServerData server_online = instance.getCurrentServer();
|
|
||||||
IntegratedServer server_local = instance.getSingleplayerServer();
|
|
||||||
if (server_online == null && server_local == null) { return; }
|
|
||||||
if (Minecraft.getInstance().screen != null) { return; }
|
|
||||||
if (checkKeyAllowed(instance, event.getKeyBinding().getKey().getValue())) { return; }
|
|
||||||
|
|
||||||
try {
|
|
||||||
LoginProtection.INSTANCE.sendToServer(new C2SKeyPress());
|
|
||||||
} catch (NullPointerException ignored) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
private static boolean checkKeyAllowed(Minecraft instance, int key) {
|
|
||||||
boolean isAllowed = false;
|
|
||||||
|
|
||||||
if (key == GLFW.GLFW_KEY_ESCAPE) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.PAUSE.toString()); }
|
|
||||||
if (key == GLFW.GLFW_KEY_F3) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.DEBUG.toString()); }
|
|
||||||
if (key == instance.options.keyFullscreen.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.FULLSCREEN.toString()); }
|
|
||||||
if (key == instance.options.keyTogglePerspective.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.PERSPECTIVE.toString()); }
|
|
||||||
if (key == instance.options.keySmoothCamera.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SMOOTH_CAMERA.toString()); }
|
|
||||||
if (key == instance.options.keyScreenshot.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SCREENSHOT.toString()); }
|
|
||||||
if (key == instance.options.keySpectatorOutlines.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SPECTATOR_OUTLINES.toString()); }
|
|
||||||
if (key == instance.options.keyAdvancements.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.ADVANCEMENTS.toString()); }
|
|
||||||
if (key == instance.options.keyPlayerList.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.PLAYER_LIST.toString()); }
|
|
||||||
if (key == instance.options.keyChat.getKey().getValue() ||
|
|
||||||
key == instance.options.keyCommand.getKey().getValue() ||
|
|
||||||
key == GLFW.GLFW_KEY_ENTER) {
|
|
||||||
isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.CHAT.toString());
|
|
||||||
}
|
|
||||||
if (key == instance.options.keySocialInteractions.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SOCIAL_INTERACTIONS.toString()); }
|
|
||||||
if (key == instance.options.keyLoadHotbarActivator.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.LOAD_HOTBAR_ACTIVATOR.toString()); }
|
|
||||||
if (key == instance.options.keySaveHotbarActivator.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SAVE_HOTBAR_ACTIVATOR.toString()); }
|
|
||||||
if (key == instance.options.keySwapOffhand.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SWAP_ITEM.toString()); }
|
|
||||||
if (key == instance.options.keyInventory.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.INVENTORY.toString()); }
|
|
||||||
for (int i = 0; i < instance.options.keyHotbarSlots.length; i++) {
|
|
||||||
if (key == instance.options.keyHotbarSlots[i].getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.HOTBAR.toString()); }
|
|
||||||
}
|
|
||||||
if (key == instance.options.keyDrop.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.DROP_ITEM.toString()); }
|
|
||||||
if (key == instance.options.keyUse.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.USE_ITEM.toString()); }
|
|
||||||
if (key == instance.options.keyPickItem.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.PICK_BLOCK.toString()); }
|
|
||||||
if (key == instance.options.keyAttack.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.ATTACK.toString()); }
|
|
||||||
if (key == instance.options.keyUp.getKey().getValue() ||
|
|
||||||
key == instance.options.keyRight.getKey().getValue() ||
|
|
||||||
key == instance.options.keyDown.getKey().getValue() ||
|
|
||||||
key == instance.options.keyLeft.getKey().getValue() ||
|
|
||||||
key == instance.options.keySprint.getKey().getValue()) {
|
|
||||||
isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.MOVE.toString());
|
|
||||||
}
|
|
||||||
if (key == instance.options.keyShift.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SNEAK.toString()); }
|
|
||||||
if (key == instance.options.keyJump.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.JUMP.toString()); }
|
|
||||||
|
|
||||||
return isAllowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +1,8 @@
|
|||||||
package com.micle.loginprotection;
|
package dev.micle.loginprotection;
|
||||||
|
|
||||||
import com.micle.loginprotection.data.ProtectedPlayers;
|
import dev.micle.loginprotection.data.ProtectedPlayers;
|
||||||
import com.micle.loginprotection.setup.Config;
|
import dev.micle.loginprotection.setup.Config;
|
||||||
import com.micle.loginprotection.setup.Registration;
|
import dev.micle.loginprotection.setup.Registration;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
@ -1,6 +1,6 @@
|
|||||||
package com.micle.loginprotection.data;
|
package dev.micle.loginprotection.data;
|
||||||
|
|
||||||
import com.micle.loginprotection.setup.Config;
|
import dev.micle.loginprotection.setup.Config;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
package com.micle.loginprotection.data;
|
package dev.micle.loginprotection.data;
|
||||||
|
|
||||||
import com.micle.loginprotection.setup.Config;
|
import dev.micle.loginprotection.setup.Config;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||||
@ -38,7 +38,7 @@ public class ProtectedPlayers {
|
|||||||
if (protected_player == null) { return; }
|
if (protected_player == null) { return; }
|
||||||
protected_players.remove(protected_player);
|
protected_players.remove(protected_player);
|
||||||
|
|
||||||
ServerPlayerEntity player = ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayer(player_uuid);
|
ServerPlayerEntity player = ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayerByUUID(player_uuid);
|
||||||
if (player == null) { return; }
|
if (player == null) { return; }
|
||||||
|
|
||||||
if (!Config.Server.POST_GRACE_ENABLED.get()) { return; }
|
if (!Config.Server.POST_GRACE_ENABLED.get()) { return; }
|
||||||
89
src/main/java/dev/micle/loginprotection/events/OnKeyPressEventHandler.java
Executable file
89
src/main/java/dev/micle/loginprotection/events/OnKeyPressEventHandler.java
Executable file
@ -0,0 +1,89 @@
|
|||||||
|
package dev.micle.loginprotection.events;
|
||||||
|
|
||||||
|
import dev.micle.loginprotection.LoginProtection;
|
||||||
|
import dev.micle.loginprotection.network.C2SKeyPress;
|
||||||
|
import dev.micle.loginprotection.setup.Config;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.multiplayer.ServerData;
|
||||||
|
import net.minecraft.server.integrated.IntegratedServer;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import net.minecraftforge.client.event.InputEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
|
public class OnKeyPressEventHandler {
|
||||||
|
@SubscribeEvent
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public void KeyPressEvent(InputEvent.KeyInputEvent event) {
|
||||||
|
Minecraft instance = Minecraft.getInstance();
|
||||||
|
ServerData server_online = instance.getCurrentServerData();
|
||||||
|
IntegratedServer server_local = instance.getIntegratedServer();
|
||||||
|
if (server_online == null && server_local == null) { return; }
|
||||||
|
if (Minecraft.getInstance().currentScreen != null) { return; }
|
||||||
|
if (checkKeyAllowed(instance, event.getKey())) { return; }
|
||||||
|
|
||||||
|
try {
|
||||||
|
LoginProtection.INSTANCE.sendToServer(new C2SKeyPress());
|
||||||
|
} catch (NullPointerException ignored) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public void MouseClickEvent(InputEvent.ClickInputEvent event) {
|
||||||
|
Minecraft instance = Minecraft.getInstance();
|
||||||
|
ServerData server_online = instance.getCurrentServerData();
|
||||||
|
IntegratedServer server_local = instance.getIntegratedServer();
|
||||||
|
if (server_online == null && server_local == null) { return; }
|
||||||
|
if (Minecraft.getInstance().currentScreen != null) { return; }
|
||||||
|
if (checkKeyAllowed(instance, event.getKeyBinding().getKey().getKeyCode())) { return; }
|
||||||
|
|
||||||
|
try {
|
||||||
|
LoginProtection.INSTANCE.sendToServer(new C2SKeyPress());
|
||||||
|
} catch (NullPointerException ignored) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
private static boolean checkKeyAllowed(Minecraft instance, int key) {
|
||||||
|
boolean isAllowed = false;
|
||||||
|
|
||||||
|
if (key == GLFW.GLFW_KEY_ESCAPE) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.PAUSE.toString()); }
|
||||||
|
if (key == GLFW.GLFW_KEY_F3) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.DEBUG.toString()); }
|
||||||
|
if (key == instance.gameSettings.keyBindFullscreen.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.FULLSCREEN.toString()); }
|
||||||
|
if (key == instance.gameSettings.keyBindTogglePerspective.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.PERSPECTIVE.toString()); }
|
||||||
|
if (key == instance.gameSettings.keyBindSmoothCamera.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SMOOTH_CAMERA.toString()); }
|
||||||
|
if (key == instance.gameSettings.keyBindScreenshot.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SCREENSHOT.toString()); }
|
||||||
|
if (key == instance.gameSettings.keyBindSpectatorOutlines.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SPECTATOR_OUTLINES.toString()); }
|
||||||
|
if (key == instance.gameSettings.keyBindAdvancements.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.ADVANCEMENTS.toString()); }
|
||||||
|
if (key == instance.gameSettings.keyBindPlayerList.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.PLAYER_LIST.toString()); }
|
||||||
|
if (key == instance.gameSettings.keyBindChat.getKey().getKeyCode() ||
|
||||||
|
key == instance.gameSettings.keyBindCommand.getKey().getKeyCode() ||
|
||||||
|
key == GLFW.GLFW_KEY_ENTER) {
|
||||||
|
isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.CHAT.toString());
|
||||||
|
}
|
||||||
|
if (key == instance.gameSettings.field_244602_au.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SOCIAL_INTERACTIONS.toString()); }
|
||||||
|
if (key == instance.gameSettings.keyBindLoadToolbar.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.LOAD_HOTBAR_ACTIVATOR.toString()); }
|
||||||
|
if (key == instance.gameSettings.keyBindSaveToolbar.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SAVE_HOTBAR_ACTIVATOR.toString()); }
|
||||||
|
if (key == instance.gameSettings.keyBindSwapHands.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SWAP_ITEM.toString()); }
|
||||||
|
if (key == instance.gameSettings.keyBindInventory.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.INVENTORY.toString()); }
|
||||||
|
for (int i = 0; i < instance.gameSettings.keyBindsHotbar.length; i++) {
|
||||||
|
if (key == instance.gameSettings.keyBindsHotbar[i].getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.HOTBAR.toString()); }
|
||||||
|
}
|
||||||
|
if (key == instance.gameSettings.keyBindDrop.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.DROP_ITEM.toString()); }
|
||||||
|
if (key == instance.gameSettings.keyBindUseItem.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.USE_ITEM.toString()); }
|
||||||
|
if (key == instance.gameSettings.keyBindPickBlock.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.PICK_BLOCK.toString()); }
|
||||||
|
if (key == instance.gameSettings.keyBindAttack.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.ATTACK.toString()); }
|
||||||
|
if (key == instance.gameSettings.keyBindForward.getKey().getKeyCode() ||
|
||||||
|
key == instance.gameSettings.keyBindRight.getKey().getKeyCode() ||
|
||||||
|
key == instance.gameSettings.keyBindBack.getKey().getKeyCode() ||
|
||||||
|
key == instance.gameSettings.keyBindLeft.getKey().getKeyCode() ||
|
||||||
|
key == instance.gameSettings.keyBindSprint.getKey().getKeyCode()) {
|
||||||
|
isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.MOVE.toString());
|
||||||
|
}
|
||||||
|
if (key == instance.gameSettings.keyBindSneak.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SNEAK.toString()); }
|
||||||
|
if (key == instance.gameSettings.keyBindJump.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.JUMP.toString()); }
|
||||||
|
|
||||||
|
return isAllowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,8 +1,8 @@
|
|||||||
package com.micle.loginprotection.events;
|
package dev.micle.loginprotection.events;
|
||||||
|
|
||||||
import com.micle.loginprotection.LoginProtection;
|
import dev.micle.loginprotection.LoginProtection;
|
||||||
import com.micle.loginprotection.data.ProtectedPlayer;
|
import dev.micle.loginprotection.data.ProtectedPlayer;
|
||||||
import com.micle.loginprotection.setup.Config;
|
import dev.micle.loginprotection.setup.Config;
|
||||||
import net.minecraft.entity.MobEntity;
|
import net.minecraft.entity.MobEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
|
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
|
||||||
@ -14,10 +14,10 @@ public class OnLivingSetAttackTargetEventHandler {
|
|||||||
if (!(event.getTarget() instanceof PlayerEntity)) { return; }
|
if (!(event.getTarget() instanceof PlayerEntity)) { return; }
|
||||||
PlayerEntity target = (PlayerEntity) event.getTarget();
|
PlayerEntity target = (PlayerEntity) event.getTarget();
|
||||||
|
|
||||||
ProtectedPlayer player = LoginProtection.protected_players.getPlayer(target.getUUID());
|
ProtectedPlayer player = LoginProtection.protected_players.getPlayer(target.getUniqueID());
|
||||||
if (player == null) { return; }
|
if (player == null) { return; }
|
||||||
if (player.isLoading() && !Config.Server.MAIN_IGNORE_PLAYER_ENABLED.get()) { return; }
|
if (player.isLoading() && !Config.Server.MAIN_IGNORE_PLAYER_ENABLED.get()) { return; }
|
||||||
if (!player.isLoading() && !Config.Server.POST_GRACE_IGNORE_PLAYER_ENABLED.get()) { return; }
|
if (!player.isLoading() && !Config.Server.POST_GRACE_IGNORE_PLAYER_ENABLED.get()) { return; }
|
||||||
((MobEntity) event.getEntityLiving()).setTarget(null);
|
((MobEntity) event.getEntityLiving()).setAttackTarget(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
package com.micle.loginprotection.events;
|
package dev.micle.loginprotection.events;
|
||||||
|
|
||||||
import com.micle.loginprotection.LoginProtection;
|
import dev.micle.loginprotection.LoginProtection;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraftforge.event.entity.living.LivingDamageEvent;
|
import net.minecraftforge.event.entity.living.LivingDamageEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
@ -11,7 +11,7 @@ public class OnPlayerDamageEventHandler {
|
|||||||
if (!(event.getEntity() instanceof PlayerEntity)) { return; }
|
if (!(event.getEntity() instanceof PlayerEntity)) { return; }
|
||||||
PlayerEntity player = (PlayerEntity) event.getEntity();
|
PlayerEntity player = (PlayerEntity) event.getEntity();
|
||||||
|
|
||||||
if (LoginProtection.protected_players.getPlayer(player.getUUID()) != null) {
|
if (LoginProtection.protected_players.getPlayer(player.getUniqueID()) != null) {
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
package com.micle.loginprotection.events;
|
package dev.micle.loginprotection.events;
|
||||||
|
|
||||||
import com.micle.loginprotection.LoginProtection;
|
import dev.micle.loginprotection.LoginProtection;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
@ -11,7 +11,7 @@ public class OnPlayerJoinEventHandler {
|
|||||||
if (!(event.getEntity() instanceof PlayerEntity)) { return; }
|
if (!(event.getEntity() instanceof PlayerEntity)) { return; }
|
||||||
PlayerEntity player = (PlayerEntity) event.getEntity();
|
PlayerEntity player = (PlayerEntity) event.getEntity();
|
||||||
|
|
||||||
LoginProtection.protected_players.addPlayer(player.getUUID());
|
LoginProtection.protected_players.addPlayer(player.getUniqueID());
|
||||||
System.out.println(player.getUUID() + " (" + player.getDisplayName().getString() + ") is being protected!");
|
System.out.println(player.getUniqueID() + " (" + player.getDisplayName().getString() + ") is being protected!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
package com.micle.loginprotection.events;
|
package dev.micle.loginprotection.events;
|
||||||
|
|
||||||
import com.micle.loginprotection.LoginProtection;
|
import dev.micle.loginprotection.LoginProtection;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
@ -11,6 +11,6 @@ public class OnPlayerLeaveEventHandler {
|
|||||||
if (!(event.getEntity() instanceof PlayerEntity)) { return; }
|
if (!(event.getEntity() instanceof PlayerEntity)) { return; }
|
||||||
PlayerEntity player = event.getPlayer();
|
PlayerEntity player = event.getPlayer();
|
||||||
|
|
||||||
LoginProtection.protected_players.removePlayer(player.getUUID());
|
LoginProtection.protected_players.removePlayer(player.getUniqueID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,14 +1,14 @@
|
|||||||
package com.micle.loginprotection.events;
|
package dev.micle.loginprotection.events;
|
||||||
|
|
||||||
import com.micle.loginprotection.LoginProtection;
|
import dev.micle.loginprotection.LoginProtection;
|
||||||
import net.minecraftforge.event.TickEvent;
|
import net.minecraftforge.event.TickEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
|
||||||
public class OnPlayerTickEventHandler {
|
public class OnPlayerTickEventHandler {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void PlayerTickEvent(TickEvent.PlayerTickEvent event) {
|
public void PlayerTickEvent(TickEvent.PlayerTickEvent event) {
|
||||||
if (LoginProtection.protected_players.getPlayer(event.player.getUUID()) == null) { return; }
|
if (LoginProtection.protected_players.getPlayer(event.player.getUniqueID()) == null) { return; }
|
||||||
|
|
||||||
LoginProtection.protected_players.updateGracePeriod(event.player.getUUID());
|
LoginProtection.protected_players.updateGracePeriod(event.player.getUniqueID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
package com.micle.loginprotection.network;
|
package dev.micle.loginprotection.network;
|
||||||
|
|
||||||
import com.micle.loginprotection.LoginProtection;
|
import dev.micle.loginprotection.LoginProtection;
|
||||||
import com.micle.loginprotection.setup.Config;
|
import dev.micle.loginprotection.setup.Config;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraft.potion.EffectInstance;
|
import net.minecraft.potion.EffectInstance;
|
||||||
@ -25,29 +25,29 @@ public class C2SKeyPress {
|
|||||||
context.enqueueWork(() -> {
|
context.enqueueWork(() -> {
|
||||||
final ServerPlayerEntity sender = context.getSender();
|
final ServerPlayerEntity sender = context.getSender();
|
||||||
if (sender == null) { return; }
|
if (sender == null) { return; }
|
||||||
if (LoginProtection.protected_players.getPlayer(sender.getUUID()) == null) { return; }
|
if (LoginProtection.protected_players.getPlayer(sender.getUniqueID()) == null) { return; }
|
||||||
if (!LoginProtection.protected_players.getPlayer(sender.getUUID()).isLoading()) { return; }
|
if (!LoginProtection.protected_players.getPlayer(sender.getUniqueID()).isLoading()) { return; }
|
||||||
|
|
||||||
if (!Config.Server.POST_GRACE_ENABLED.get()) {
|
if (!Config.Server.POST_GRACE_ENABLED.get()) {
|
||||||
LoginProtection.protected_players.removePlayer(sender.getUUID());
|
LoginProtection.protected_players.removePlayer(sender.getUniqueID());
|
||||||
sender.sendMessage(new StringTextComponent("[LoginProtection] You are now seen as active."), sender.getUUID());
|
sender.sendMessage(new StringTextComponent("[LoginProtection] You are now seen as active."), sender.getUniqueID());
|
||||||
} else {
|
} else {
|
||||||
LoginProtection.protected_players.getPlayer(sender.getUUID()).setLoading(false);
|
LoginProtection.protected_players.getPlayer(sender.getUniqueID()).setLoading(false);
|
||||||
sender.sendMessage(new StringTextComponent("[LoginProtection] Grace period started!"), sender.getUUID());
|
sender.sendMessage(new StringTextComponent("[LoginProtection] Grace period started!"), sender.getUniqueID());
|
||||||
}
|
}
|
||||||
if (sender.isInWater()) {
|
if (sender.isInWater()) {
|
||||||
if (Config.Server.POST_DROWN_ENABLED.get()) {
|
if (Config.Server.POST_DROWN_ENABLED.get()) {
|
||||||
sender.setAirSupply(sender.getMaxAirSupply());
|
sender.setAir(sender.getMaxAir());
|
||||||
}
|
}
|
||||||
if (Config.Server.POST_WATER_ENABLED.get()) {
|
if (Config.Server.POST_WATER_ENABLED.get()) {
|
||||||
sender.addEffect(new EffectInstance(Effects.WATER_BREATHING, Config.Server.POST_WATER_DURATION.get()*20, 0));
|
sender.addPotionEffect(new EffectInstance(Effects.WATER_BREATHING, Config.Server.POST_WATER_DURATION.get()*20, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sender.isInLava() && Config.Server.POST_LAVA_ENABLED.get()) {
|
if (sender.isInLava() && Config.Server.POST_LAVA_ENABLED.get()) {
|
||||||
sender.addEffect(new EffectInstance(Effects.FIRE_RESISTANCE, Config.Server.POST_LAVA_DURATION.get()*20, 0));
|
sender.addPotionEffect(new EffectInstance(Effects.FIRE_RESISTANCE, Config.Server.POST_LAVA_DURATION.get()*20, 0));
|
||||||
}
|
}
|
||||||
if (sender.isOnFire() && Config.Server.POST_FIRE_ENABLED.get()) {
|
if (sender.isBurning() && Config.Server.POST_FIRE_ENABLED.get()) {
|
||||||
sender.addEffect(new EffectInstance(Effects.FIRE_RESISTANCE, Config.Server.POST_FIRE_DURATION.get()*20, 0));
|
sender.addPotionEffect(new EffectInstance(Effects.FIRE_RESISTANCE, Config.Server.POST_FIRE_DURATION.get()*20, 0));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
context.setPacketHandled(true);
|
context.setPacketHandled(true);
|
||||||
@ -1,7 +1,7 @@
|
|||||||
package com.micle.loginprotection.setup;
|
package dev.micle.loginprotection.setup;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.micle.loginprotection.LoginProtection;
|
import dev.micle.loginprotection.LoginProtection;
|
||||||
import net.minecraftforge.common.ForgeConfigSpec;
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
import net.minecraftforge.fml.ModLoadingContext;
|
import net.minecraftforge.fml.ModLoadingContext;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
@ -1,8 +1,8 @@
|
|||||||
package com.micle.loginprotection.setup;
|
package dev.micle.loginprotection.setup;
|
||||||
|
|
||||||
import com.micle.loginprotection.LoginProtection;
|
import dev.micle.loginprotection.LoginProtection;
|
||||||
import com.micle.loginprotection.events.*;
|
import dev.micle.loginprotection.events.*;
|
||||||
import com.micle.loginprotection.network.C2SKeyPress;
|
import dev.micle.loginprotection.network.C2SKeyPress;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
Reference in New Issue
Block a user