Dieser Commit ist enthalten in:
Ursprung
04a2d60fae
Commit
74e57fa3a1
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.lobby;
|
package de.steamwar.lobby;
|
||||||
|
|
||||||
import de.steamwar.lobby.command.DebugCommand;
|
import de.steamwar.lobby.command.ModifyCommand;
|
||||||
import de.steamwar.lobby.command.FlyCommand;
|
import de.steamwar.lobby.command.FlyCommand;
|
||||||
import de.steamwar.lobby.command.HologramCommand;
|
import de.steamwar.lobby.command.HologramCommand;
|
||||||
import de.steamwar.lobby.command.PortalCommand;
|
import de.steamwar.lobby.command.PortalCommand;
|
||||||
@ -47,7 +47,7 @@ public class LobbySystem extends JavaPlugin {
|
|||||||
new PortalCommand();
|
new PortalCommand();
|
||||||
new HologramCommand();
|
new HologramCommand();
|
||||||
new FlyCommand();
|
new FlyCommand();
|
||||||
new DebugCommand();
|
new ModifyCommand();
|
||||||
|
|
||||||
config = new Config(getConfig());
|
config = new Config(getConfig());
|
||||||
new PlayerSpawn();
|
new PlayerSpawn();
|
||||||
|
@ -43,7 +43,7 @@ public class HologramCommand extends SWCommand {
|
|||||||
public void portalCreate(Player player, String id, String... text) {
|
public void portalCreate(Player player, String id, String... text) {
|
||||||
if (PortalCommand.noPermissions(player)) return;
|
if (PortalCommand.noPermissions(player)) return;
|
||||||
|
|
||||||
new Hologram(id, player.getLocation(), String.join(" ", text));
|
new Hologram(id, player.getLocation(), String.join(" ", text), false);
|
||||||
LobbySystem.config().save();
|
LobbySystem.config().save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,32 +33,32 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class DebugCommand extends SWCommand implements Listener {
|
public class ModifyCommand extends SWCommand implements Listener {
|
||||||
|
|
||||||
private static final Set<HumanEntity> debugMode = new HashSet<>();
|
private static final Set<HumanEntity> modifying = new HashSet<>();
|
||||||
|
|
||||||
public static boolean debugging(HumanEntity player) {
|
public static boolean modifying(HumanEntity player) {
|
||||||
return debugMode.contains(player);
|
return modifying.contains(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DebugCommand() {
|
public ModifyCommand() {
|
||||||
super("debug");
|
super("modify");
|
||||||
Bukkit.getPluginManager().registerEvents(this, LobbySystem.getPlugin());
|
Bukkit.getPluginManager().registerEvents(this, LobbySystem.getPlugin());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void debug(Player player) {
|
public void modify(Player player) {
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
if(!user.getUserGroup().isTeamGroup())
|
if(!user.getUserGroup().isTeamGroup())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
debugMode.add(player);
|
modifying.add(player);
|
||||||
player.setGameMode(GameMode.CREATIVE);
|
player.setGameMode(GameMode.CREATIVE);
|
||||||
player.setOp(true);
|
player.setOp(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onLeave(PlayerQuitEvent event) {
|
public void onLeave(PlayerQuitEvent event) {
|
||||||
debugMode.remove(event.getPlayer());
|
modifying.remove(event.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -32,6 +32,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class Displayable extends BasicListener {
|
public class Displayable extends BasicListener {
|
||||||
|
|
||||||
@ -41,14 +42,20 @@ public class Displayable extends BasicListener {
|
|||||||
private final int chunkZ;
|
private final int chunkZ;
|
||||||
private final Consumer<Player> show;
|
private final Consumer<Player> show;
|
||||||
private final Consumer<Player> hide;
|
private final Consumer<Player> hide;
|
||||||
|
private final Function<Player, Boolean> playerFilter;
|
||||||
|
|
||||||
public Displayable(Location location, Consumer<Player> show, Consumer<Player> hide) {
|
public Displayable(Location location, Consumer<Player> show, Consumer<Player> hide) {
|
||||||
|
this(location, show, hide, player -> true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Displayable(Location location, Consumer<Player> show, Consumer<Player> hide, Function<Player, Boolean> playerFilter) {
|
||||||
this.chunkX = posToChunk(location.getX());
|
this.chunkX = posToChunk(location.getX());
|
||||||
this.chunkZ = posToChunk(location.getZ());
|
this.chunkZ = posToChunk(location.getZ());
|
||||||
this.show = show;
|
this.show = show;
|
||||||
this.hide = hide;
|
this.hide = hide;
|
||||||
|
this.playerFilter = playerFilter;
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> checkLocation(player, player.getLocation()));
|
Bukkit.getOnlinePlayers().forEach(this::checkLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Player> getVisitors() {
|
public Set<Player> getVisitors() {
|
||||||
@ -57,15 +64,19 @@ public class Displayable extends BasicListener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onJoin(PlayerJoinEvent e) {
|
public void onJoin(PlayerJoinEvent e) {
|
||||||
checkLocation(e.getPlayer(), e.getPlayer().getLocation());
|
checkLocation(e.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onMove(PlayerMoveEvent e) {
|
public void onMove(PlayerMoveEvent e) {
|
||||||
checkLocation(e.getPlayer(), e.getTo());
|
checkLocation(e.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkLocation(Player player, Location at) {
|
public void checkLocation(Player player) {
|
||||||
|
if(!playerFilter.apply(player))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Location at = player.getLocation();
|
||||||
boolean shown = visible.contains(player);
|
boolean shown = visible.contains(player);
|
||||||
int viewDistance = player.getClientViewDistance() / 2;
|
int viewDistance = player.getClientViewDistance() / 2;
|
||||||
boolean see = Math.abs(chunkX - posToChunk(at.getX())) < viewDistance && Math.abs(chunkZ - posToChunk(at.getZ())) < viewDistance;
|
boolean see = Math.abs(chunkX - posToChunk(at.getX())) < viewDistance && Math.abs(chunkZ - posToChunk(at.getZ())) < viewDistance;
|
||||||
|
@ -21,6 +21,7 @@ package de.steamwar.lobby.display;
|
|||||||
|
|
||||||
import com.comphenix.tinyprotocol.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
|
import de.steamwar.lobby.command.ModifyCommand;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -101,7 +102,6 @@ public class Hologram implements ConfigurationSerializable {
|
|||||||
public static Hologram getHologram(String id) {
|
public static Hologram getHologram(String id) {
|
||||||
return holograms.get(id);
|
return holograms.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Displayable display;
|
private final Displayable display;
|
||||||
private final int entityId;
|
private final int entityId;
|
||||||
|
|
||||||
@ -115,10 +115,10 @@ public class Hologram implements ConfigurationSerializable {
|
|||||||
private String text;
|
private String text;
|
||||||
|
|
||||||
public Hologram(Map<String, Object> map) {
|
public Hologram(Map<String, Object> map) {
|
||||||
this((String) map.get("id"), (Location) map.get("location"), (String) map.get("text"));
|
this((String) map.get("id"), (Location) map.get("location"), (String) map.get("text"), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Hologram(String id, Location location, String text) {
|
public Hologram(String id, Location location, String text, boolean debugHologram) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
@ -136,7 +136,7 @@ public class Hologram implements ConfigurationSerializable {
|
|||||||
|
|
||||||
destroy = destroyPacket(entityId);
|
destroy = destroyPacket(entityId);
|
||||||
|
|
||||||
display = new Displayable(location, this::show, this::hide);
|
display = new Displayable(location, this::show, this::hide, debugHologram ? ModifyCommand::modifying : player -> true);
|
||||||
|
|
||||||
if(id != null)
|
if(id != null)
|
||||||
holograms.put(id, this);
|
holograms.put(id, this);
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.lobby.listener;
|
package de.steamwar.lobby.listener;
|
||||||
|
|
||||||
import de.steamwar.lobby.command.DebugCommand;
|
import de.steamwar.lobby.command.ModifyCommand;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -38,7 +38,7 @@ public class InventoryInteraction extends BasicListener {
|
|||||||
event.getItem().setAmount(2);
|
event.getItem().setAmount(2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!DebugCommand.debugging(event.getPlayer()))
|
if(!ModifyCommand.modifying(event.getPlayer()))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,13 +54,13 @@ public class InventoryInteraction extends BasicListener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void handleInventoryClick(InventoryClickEvent event) {
|
public void handleInventoryClick(InventoryClickEvent event) {
|
||||||
if(!DebugCommand.debugging(event.getWhoClicked()))
|
if(!ModifyCommand.modifying(event.getWhoClicked()))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerSwapHandItemsEvent(PlayerSwapHandItemsEvent event) {
|
public void handlePlayerSwapHandItemsEvent(PlayerSwapHandItemsEvent event) {
|
||||||
if(!DebugCommand.debugging(event.getPlayer()))
|
if(!ModifyCommand.modifying(event.getPlayer()))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.lobby.listener;
|
package de.steamwar.lobby.listener;
|
||||||
|
|
||||||
import de.steamwar.lobby.command.DebugCommand;
|
import de.steamwar.lobby.command.ModifyCommand;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
@ -42,19 +42,19 @@ public class WorldInteraction extends BasicListener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handleBlockBreak(BlockBreakEvent event) {
|
public void handleBlockBreak(BlockBreakEvent event) {
|
||||||
if(!DebugCommand.debugging(event.getPlayer()))
|
if(!ModifyCommand.modifying(event.getPlayer()))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handleBlockPlace(BlockPlaceEvent event) {
|
public void handleBlockPlace(BlockPlaceEvent event) {
|
||||||
if(!DebugCommand.debugging(event.getPlayer()))
|
if(!ModifyCommand.modifying(event.getPlayer()))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handleHangingBreak(HangingBreakByEntityEvent event) {
|
public void handleHangingBreak(HangingBreakByEntityEvent event) {
|
||||||
if(!DebugCommand.debugging((HumanEntity) event.getRemover()))
|
if(!ModifyCommand.modifying((HumanEntity) event.getRemover()))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ public class FightserverPortal implements PortalHandler, Comparable<FightserverP
|
|||||||
this.target = target;
|
this.target = target;
|
||||||
this.bluePlayers = bluePlayers;
|
this.bluePlayers = bluePlayers;
|
||||||
this.redPlayers = redPlayers;
|
this.redPlayers = redPlayers;
|
||||||
hologram = new Hologram(null, portal.getPos1().clone().add(portal.denormalize(new Vector(0.5, 0.5, 0.5))), "");
|
hologram = new Hologram(null, portal.getPos1().clone().add(portal.denormalize(new Vector(0.5, 0.5, 0.5))), "a", false);
|
||||||
|
|
||||||
setServer(null);
|
setServer(null);
|
||||||
|
|
||||||
|
@ -126,8 +126,8 @@ public class Portal implements PortalHandler, ConfigurationSerializable {
|
|||||||
this.handler = handlerConstructor.apply(this);
|
this.handler = handlerConstructor.apply(this);
|
||||||
this.type = handler.type();
|
this.type = handler.type();
|
||||||
|
|
||||||
this.debugPos1 = new Hologram(null, pos1, id + " POS1");
|
this.debugPos1 = new Hologram(null, pos1, id + " POS1", true);
|
||||||
this.debugPos2 = new Hologram(null, pos2, id + " POS2");
|
this.debugPos2 = new Hologram(null, pos2, id + " POS2", true);
|
||||||
|
|
||||||
portals.put(id, this);
|
portals.put(id, this);
|
||||||
perChunk(minChunkX, maxChunkX, minChunkZ, maxChunkZ).forEach(coords -> chunkPortals.computeIfAbsent(coords, coords1 -> new ArrayList<>()).add(this));
|
perChunk(minChunkX, maxChunkX, minChunkZ, maxChunkZ).forEach(coords -> chunkPortals.computeIfAbsent(coords, coords1 -> new ArrayList<>()).add(this));
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
package de.steamwar.lobby.portal;
|
package de.steamwar.lobby.portal;
|
||||||
|
|
||||||
import de.steamwar.lobby.LobbySystem;
|
import de.steamwar.lobby.LobbySystem;
|
||||||
import de.steamwar.lobby.command.DebugCommand;
|
import de.steamwar.lobby.command.ModifyCommand;
|
||||||
import de.steamwar.lobby.listener.Portals;
|
import de.steamwar.lobby.listener.Portals;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -72,7 +72,7 @@ public class TeleportPortal implements PortalHandler {
|
|||||||
player.sendMessage("§cAus unbekannten Gründen führt dieses Portal zurzeit in den Limbus");
|
player.sendMessage("§cAus unbekannten Gründen führt dieses Portal zurzeit in den Limbus");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(DebugCommand.debugging(player))
|
if(ModifyCommand.modifying(player))
|
||||||
player.sendMessage("teleport " + portal.getId() + " -> " + target.getId());
|
player.sendMessage("teleport " + portal.getId() + " -> " + target.getId());
|
||||||
|
|
||||||
player.teleport(target.denormalize(portal.normalize(to)).toLocation(to.getWorld(), (float) (to.getYaw() - Math.toDegrees(target.getYrotation() - portal.getYrotation())), to.getPitch()), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
player.teleport(target.denormalize(portal.normalize(to)).toLocation(to.getWorld(), (float) (to.getYaw() - Math.toDegrees(target.getYrotation() - portal.getYrotation())), to.getPitch()), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren