Dieser Commit ist enthalten in:
Ursprung
04a2d60fae
Commit
74e57fa3a1
@ -19,7 +19,7 @@
|
||||
|
||||
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.HologramCommand;
|
||||
import de.steamwar.lobby.command.PortalCommand;
|
||||
@ -47,7 +47,7 @@ public class LobbySystem extends JavaPlugin {
|
||||
new PortalCommand();
|
||||
new HologramCommand();
|
||||
new FlyCommand();
|
||||
new DebugCommand();
|
||||
new ModifyCommand();
|
||||
|
||||
config = new Config(getConfig());
|
||||
new PlayerSpawn();
|
||||
|
@ -43,7 +43,7 @@ public class HologramCommand extends SWCommand {
|
||||
public void portalCreate(Player player, String id, String... text) {
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -33,32 +33,32 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import java.util.HashSet;
|
||||
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) {
|
||||
return debugMode.contains(player);
|
||||
public static boolean modifying(HumanEntity player) {
|
||||
return modifying.contains(player);
|
||||
}
|
||||
|
||||
public DebugCommand() {
|
||||
super("debug");
|
||||
public ModifyCommand() {
|
||||
super("modify");
|
||||
Bukkit.getPluginManager().registerEvents(this, LobbySystem.getPlugin());
|
||||
}
|
||||
|
||||
@Register
|
||||
public void debug(Player player) {
|
||||
public void modify(Player player) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
if(!user.getUserGroup().isTeamGroup())
|
||||
return;
|
||||
|
||||
debugMode.add(player);
|
||||
modifying.add(player);
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
player.setOp(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
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.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Displayable extends BasicListener {
|
||||
|
||||
@ -41,14 +42,20 @@ public class Displayable extends BasicListener {
|
||||
private final int chunkZ;
|
||||
private final Consumer<Player> show;
|
||||
private final Consumer<Player> hide;
|
||||
private final Function<Player, Boolean> playerFilter;
|
||||
|
||||
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.chunkZ = posToChunk(location.getZ());
|
||||
this.show = show;
|
||||
this.hide = hide;
|
||||
this.playerFilter = playerFilter;
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach(player -> checkLocation(player, player.getLocation()));
|
||||
Bukkit.getOnlinePlayers().forEach(this::checkLocation);
|
||||
}
|
||||
|
||||
public Set<Player> getVisitors() {
|
||||
@ -57,15 +64,19 @@ public class Displayable extends BasicListener {
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
checkLocation(e.getPlayer(), e.getPlayer().getLocation());
|
||||
checkLocation(e.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
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);
|
||||
int viewDistance = player.getClientViewDistance() / 2;
|
||||
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.TinyProtocol;
|
||||
import de.steamwar.lobby.command.ModifyCommand;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -101,7 +102,6 @@ public class Hologram implements ConfigurationSerializable {
|
||||
public static Hologram getHologram(String id) {
|
||||
return holograms.get(id);
|
||||
}
|
||||
|
||||
private final Displayable display;
|
||||
private final int entityId;
|
||||
|
||||
@ -115,10 +115,10 @@ public class Hologram implements ConfigurationSerializable {
|
||||
private String text;
|
||||
|
||||
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.location = location;
|
||||
this.text = text;
|
||||
@ -136,7 +136,7 @@ public class Hologram implements ConfigurationSerializable {
|
||||
|
||||
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)
|
||||
holograms.put(id, this);
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.lobby.listener;
|
||||
|
||||
import de.steamwar.lobby.command.DebugCommand;
|
||||
import de.steamwar.lobby.command.ModifyCommand;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -38,7 +38,7 @@ public class InventoryInteraction extends BasicListener {
|
||||
event.getItem().setAmount(2);
|
||||
return;
|
||||
}
|
||||
if(!DebugCommand.debugging(event.getPlayer()))
|
||||
if(!ModifyCommand.modifying(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@ -54,13 +54,13 @@ public class InventoryInteraction extends BasicListener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void handleInventoryClick(InventoryClickEvent event) {
|
||||
if(!DebugCommand.debugging(event.getWhoClicked()))
|
||||
if(!ModifyCommand.modifying(event.getWhoClicked()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerSwapHandItemsEvent(PlayerSwapHandItemsEvent event) {
|
||||
if(!DebugCommand.debugging(event.getPlayer()))
|
||||
if(!ModifyCommand.modifying(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
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.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
@ -42,19 +42,19 @@ public class WorldInteraction extends BasicListener {
|
||||
|
||||
@EventHandler
|
||||
public void handleBlockBreak(BlockBreakEvent event) {
|
||||
if(!DebugCommand.debugging(event.getPlayer()))
|
||||
if(!ModifyCommand.modifying(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleBlockPlace(BlockPlaceEvent event) {
|
||||
if(!DebugCommand.debugging(event.getPlayer()))
|
||||
if(!ModifyCommand.modifying(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleHangingBreak(HangingBreakByEntityEvent event) {
|
||||
if(!DebugCommand.debugging((HumanEntity) event.getRemover()))
|
||||
if(!ModifyCommand.modifying((HumanEntity) event.getRemover()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public class FightserverPortal implements PortalHandler, Comparable<FightserverP
|
||||
this.target = target;
|
||||
this.bluePlayers = bluePlayers;
|
||||
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);
|
||||
|
||||
|
@ -126,8 +126,8 @@ public class Portal implements PortalHandler, ConfigurationSerializable {
|
||||
this.handler = handlerConstructor.apply(this);
|
||||
this.type = handler.type();
|
||||
|
||||
this.debugPos1 = new Hologram(null, pos1, id + " POS1");
|
||||
this.debugPos2 = new Hologram(null, pos2, id + " POS2");
|
||||
this.debugPos1 = new Hologram(null, pos1, id + " POS1", true);
|
||||
this.debugPos2 = new Hologram(null, pos2, id + " POS2", true);
|
||||
|
||||
portals.put(id, 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;
|
||||
|
||||
import de.steamwar.lobby.LobbySystem;
|
||||
import de.steamwar.lobby.command.DebugCommand;
|
||||
import de.steamwar.lobby.command.ModifyCommand;
|
||||
import de.steamwar.lobby.listener.Portals;
|
||||
import org.bukkit.Location;
|
||||
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");
|
||||
return;
|
||||
}
|
||||
if(DebugCommand.debugging(player))
|
||||
if(ModifyCommand.modifying(player))
|
||||
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);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren