Fix NoClipCommand
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
c6b6ce3abd
Commit
868de95898
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.other;
|
package de.steamwar.bausystem.features.other;
|
||||||
|
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
import net.minecraft.server.v1_15_R1.EnumGamemode;
|
import net.minecraft.server.v1_15_R1.EnumGamemode;
|
||||||
import net.minecraft.server.v1_15_R1.PlayerInteractManager;
|
import net.minecraft.server.v1_15_R1.PlayerInteractManager;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -27,11 +28,12 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
@UtilityClass
|
||||||
public class NoClipCommand_15 {
|
public class NoClipCommand_15 {
|
||||||
|
|
||||||
private static Field gameModeField;
|
private Field gameModeField;
|
||||||
|
|
||||||
public static void setGameModeInternal(Player player, GameMode gameMode) {
|
public void setGameModeInternal(Player player, GameMode gameMode) {
|
||||||
CraftPlayer craftPlayer = (CraftPlayer) player;
|
CraftPlayer craftPlayer = (CraftPlayer) player;
|
||||||
EnumGamemode enumGamemode = EnumGamemode.getById(gameMode.getValue());
|
EnumGamemode enumGamemode = EnumGamemode.getById(gameMode.getValue());
|
||||||
try {
|
try {
|
||||||
@ -42,7 +44,7 @@ public class NoClipCommand_15 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkCache() throws NoSuchFieldException {
|
private void checkCache() throws NoSuchFieldException {
|
||||||
if (gameModeField == null) {
|
if (gameModeField == null) {
|
||||||
gameModeField = PlayerInteractManager.class.getDeclaredField("gamemode");
|
gameModeField = PlayerInteractManager.class.getDeclaredField("gamemode");
|
||||||
gameModeField.setAccessible(true);
|
gameModeField.setAccessible(true);
|
||||||
|
@ -30,10 +30,8 @@ import de.steamwar.bausystem.region.utils.RegionType;
|
|||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
@Linked(LinkageType.COMMAND)
|
@Linked(LinkageType.COMMAND)
|
||||||
|
@ -42,6 +42,7 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockCanBuildEvent;
|
import org.bukkit.event.block.BlockCanBuildEvent;
|
||||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
@ -79,14 +80,6 @@ public class NoClipCommand extends SWCommand implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(BauSystem.getInstance(), PacketType.Play.Client.SPECTATE) {
|
|
||||||
@Override
|
|
||||||
public void onPacketReceiving(PacketEvent event) {
|
|
||||||
if (NOCLIPS.contains(event.getPlayer())) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(help = true)
|
@Register(help = true)
|
||||||
@ -138,4 +131,15 @@ public class NoClipCommand extends SWCommand implements Listener {
|
|||||||
event.getPlayer().setFlying(true);
|
event.getPlayer().setFlying(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true)
|
||||||
|
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||||
|
if (event.getCause() != PlayerTeleportEvent.TeleportCause.SPECTATE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (NOCLIPS.contains(event.getPlayer())) {
|
||||||
|
event.getPlayer().setSpectatorTarget(null);
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren