From f1d623df607a3e707e451f32c3b49df0a269abf0 Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Sat, 18 May 2013 19:54:17 +0200 Subject: [PATCH] Fixed a typo. --- .../craftinc/gates/commands/CommandInfo.java | 2 +- .../gates/listeners/PluginPlayerListener.java | 111 ------------------ 2 files changed, 1 insertion(+), 112 deletions(-) delete mode 100644 src/de/craftinc/gates/listeners/PluginPlayerListener.java diff --git a/src/de/craftinc/gates/commands/CommandInfo.java b/src/de/craftinc/gates/commands/CommandInfo.java index 22bb6a5..fc8a16d 100644 --- a/src/de/craftinc/gates/commands/CommandInfo.java +++ b/src/de/craftinc/gates/commands/CommandInfo.java @@ -18,7 +18,7 @@ public class CommandInfo extends BaseCommand requiredParameters.add("id"); - helpDescription = "Print detailed informations about a certain gate."; + helpDescription = "Print detailed information about a certain gate."; requiredPermission = Plugin.permissionInfo; diff --git a/src/de/craftinc/gates/listeners/PluginPlayerListener.java b/src/de/craftinc/gates/listeners/PluginPlayerListener.java deleted file mode 100644 index 416dffc..0000000 --- a/src/de/craftinc/gates/listeners/PluginPlayerListener.java +++ /dev/null @@ -1,111 +0,0 @@ -package de.craftinc.gates.listeners; - -import java.util.Calendar; -import java.util.HashMap; -import java.util.logging.Level; - -import org.bukkit.ChatColor; -import org.bukkit.Chunk; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerMoveEvent; - -import de.craftinc.gates.Gate; -import de.craftinc.gates.GatesManager; -import de.craftinc.gates.Plugin; - - -public class PluginPlayerListener implements Listener -{ - protected HashMap lastBorderMessage = new HashMap(); - - @EventHandler(priority = EventPriority.NORMAL) - public void onPlayerMove(PlayerMoveEvent event) - { - if (event.isCancelled()) { - return; - } - - GatesManager gateManager = Plugin.getPlugin().getGatesManager(); - Gate gateAtLocation = gateManager.getGateAtLocation(event.getTo()); - - if (gateAtLocation == null) { - return; - } - - // Check for permission - if (!hasPermission(event.getPlayer(), gateAtLocation)) { - - String playerName = event.getPlayer().getName(); - - if (playerName == null) { - return; - } - - // get the current time - Long now = Calendar.getInstance().getTimeInMillis(); - - // do not display messages more often than once per second - if (!this.lastBorderMessage.containsKey(playerName) || this.lastBorderMessage.get(playerName) < now - 10000L) { - event.getPlayer().sendMessage(ChatColor.RED + "You are not allowed to use this gate!"); - this.lastBorderMessage.put(playerName, now); - } - - return; - } - - // Teleport the player - checkChunkLoad(gateAtLocation.getLocation().getBlock()); - - Location gateExit = gateAtLocation.getExit(); - Location gateLocation = gateAtLocation.getLocation(); - Location playerLocation = event.getPlayer().getLocation(); - - Float newYaw = gateExit.getYaw() - gateLocation.getYaw() + playerLocation.getYaw(); - - Location teleportToLocation = new Location( gateExit.getWorld(), - gateExit.getX(), - gateExit.getY(), - gateExit.getZ(), - newYaw, - playerLocation.getPitch() ); - - event.getPlayer().teleport(teleportToLocation); - event.setTo(teleportToLocation); - - event.getPlayer().sendMessage(ChatColor.DARK_AQUA + "Thank you for traveling with Craft Inc. Gates."); - } - - - private void checkChunkLoad(Block b) - { - World w = b.getWorld(); - Chunk c = b.getChunk(); - - if (!w.isChunkLoaded(c)) - { - Plugin.log(Level.FINE, "Loading chunk: " + c.toString() + " on: " + w.toString()); - w.loadChunk(c); - } - } - - - protected boolean hasPermission(Player player, Gate gate) - { - if (Plugin.getPermission() == null) // fallback: use the standard bukkit permission system - { - return player.hasPermission(Plugin.permissionUse); - } - else { - boolean permAtLocation = Plugin.getPermission().has(gate.getLocation().getWorld(), player.getName(), Plugin.permissionUse); - boolean permAtExit = Plugin.getPermission().has(gate.getExit().getWorld(), player.getName(), Plugin.permissionUse); - - return permAtLocation && permAtExit; - } - } -}