diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index 3cf9c87..62fcc0f 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -80,7 +80,14 @@ is divided into following sections: - + + + + + + + + @@ -95,8 +102,14 @@ is divided into following sections: + + + + + + @@ -109,40 +122,41 @@ is divided into following sections: - - - - - - - - - - - + + + + + + + + + + + + - - - - - + + + + + - - - - - + + + + + @@ -196,8 +210,17 @@ is divided into following sections: - + + + + + + + + + + @@ -324,7 +347,9 @@ is divided into following sections: - + + + @@ -334,7 +359,8 @@ is divided into following sections: - + + @@ -346,11 +372,56 @@ is divided into following sections: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + @@ -445,6 +516,7 @@ is divided into following sections: + @@ -460,7 +532,7 @@ is divided into following sections: - + @@ -589,10 +661,10 @@ is divided into following sections: - + - + @@ -601,44 +673,53 @@ is divided into following sections: - To run this application from the command line without Ant, try: + To run this application from the command line without Ant, try: - java -cp "${run.classpath.with.dist.jar}" ${main.class} + java -cp "${run.classpath.with.dist.jar}" ${main.class} - + + + + + + + + + + + + + + - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" + + + - - - - - - - To run this application from the command line without Ant, try: + + + To run this application from the command line without Ant, try: - java -jar "${dist.jar.resolved}" + java -jar "${dist.jar.resolved}" + + + + + + - + + + + + + + + + + + Must select one file in the IDE or set profile.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + Must select some files in the IDE or set javac.includes diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index 5f2664b..b9b022f 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.38.3.45 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=7ce24f55 -nbproject/build-impl.xml.script.CRC32=cf0abb2c -nbproject/build-impl.xml.stylesheet.CRC32=229523de@1.38.3.45 +nbproject/build-impl.xml.script.CRC32=83187d5f +nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45 diff --git a/src/com/wimbli/WorldBorder/BorderCheckTask.java b/src/com/wimbli/WorldBorder/BorderCheckTask.java index 7f96226..34cd5df 100644 --- a/src/com/wimbli/WorldBorder/BorderCheckTask.java +++ b/src/com/wimbli/WorldBorder/BorderCheckTask.java @@ -1,10 +1,8 @@ package com.wimbli.WorldBorder; -import java.util.ConcurrentModificationException; -import java.util.Iterator; - import org.bukkit.ChatColor; import org.bukkit.entity.Player; +import org.bukkit.entity.Vehicle; import org.bukkit.Location; import org.bukkit.Server; import org.bukkit.util.Vector; @@ -21,28 +19,21 @@ public class BorderCheckTask implements Runnable public void run() { - if (Config.movedPlayers.isEmpty() || server == null) - return; +// long startTime = Config.Now(); // for monitoring plugin efficiency + Player[] players = server.getOnlinePlayers(); - for (Iterator p = Config.movedPlayers.iterator(); p.hasNext();) + if (server == null) { - Player player = null; - try - { - String playerName = p.next(); - player = server.getPlayer(playerName); - p.remove(); - } - catch (ConcurrentModificationException ex) - { - // trying to 'continue' here instead can lead to server crash, so... - return; - } +// Config.timeUsed += Config.Now() - startTime; // for monitoring plugin efficiency + return; + } - if (player == null || !player.isOnline()) continue; + for (int i = 0; i < players.length; i++){ + if (players[i] == null || !players[i].isOnline()) continue; - Location loc = player.getLocation(); + Location loc = players[i].getLocation(); if (loc == null) continue; + World world = loc.getWorld(); if (world == null) continue; BorderData border = Config.Border(world.getName()); @@ -51,18 +42,28 @@ public class BorderCheckTask implements Runnable if (border.insideBorder(loc.getX(), loc.getZ(), Config.ShapeRound())) continue; - Location newLoc = newLocation(player, loc, border); + Location newLoc = newLocation(players[i], loc, border); - if (!player.isInsideVehicle()) - player.teleport(newLoc); + if (!players[i].isInsideVehicle()) + players[i].teleport(newLoc); else - { // vehicles need to be offset vertically and have velocity stopped - double vertOffset = player.getVehicle().getLocation().getY() - loc.getY(); - newLoc.setY(newLoc.getY() + vertOffset); - player.getVehicle().setVelocity(new Vector(0, 0, 0)); - player.getVehicle().teleport(newLoc); + { + Vehicle ride = players[i].getVehicle(); + if (ride != null) + { // vehicles need to be offset vertically and have velocity stopped + double vertOffset = ride.getLocation().getY() - loc.getY(); + newLoc.setY(newLoc.getY() + vertOffset); + ride.setVelocity(new Vector(0, 0, 0)); + ride.teleport(newLoc); + } + else + { // when riding a pig, player.getVehicle() returns null; so, we unfortunately need to eject player in this rare case + players[i].leaveVehicle(); + players[i].teleport(newLoc); + } } } +// Config.timeUsed += Config.Now() - startTime; // for monitoring plugin efficiency } private static Location newLocation(Player player, Location loc, BorderData border) diff --git a/src/com/wimbli/WorldBorder/Config.java b/src/com/wimbli/WorldBorder/Config.java index 14f7870..3dd9cb4 100644 --- a/src/com/wimbli/WorldBorder/Config.java +++ b/src/com/wimbli/WorldBorder/Config.java @@ -1,6 +1,7 @@ package com.wimbli.WorldBorder; import java.text.DecimalFormat; +import java.util.Calendar; import java.util.Collections; import java.util.LinkedHashMap; import java.util.HashSet; @@ -41,6 +42,14 @@ public class Config private static double knockBack = 3.0; private static int timerTicks = 4; +/* // for monitoring plugin efficiency + public static long timeUsed = 0; + public static long Now() + { + return Calendar.getInstance().getTimeInMillis(); + } +*/ + public static void setBorder(String world, BorderData border) { borders.put(world, border); @@ -144,7 +153,7 @@ public class Config public static void setTimerTicks(int ticks) { timerTicks = ticks; - Log("Timer delay set to " + timerTicks + " tick(s). That is roughly " + (timerTicks * 50) + "ms."); + Log("Timer delay set to " + timerTicks + " tick(s). That is roughly " + (timerTicks * 50) + "ms / " + (((double)timerTicks * 50.0) / 1000.0) + " seconds."); StartBorderTimer(); save(true); } diff --git a/src/com/wimbli/WorldBorder/WBPlayerListener.java b/src/com/wimbli/WorldBorder/WBPlayerListener.java deleted file mode 100644 index d78b77c..0000000 --- a/src/com/wimbli/WorldBorder/WBPlayerListener.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.wimbli.WorldBorder; - -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerListener; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerTeleportEvent; - - -public class WBPlayerListener extends PlayerListener -{ - @Override - public void onPlayerJoin(PlayerJoinEvent event) - { - Config.movedPlayers.add(event.getPlayer().getName()); - } - - @Override - public void onPlayerMove(PlayerMoveEvent event) - { - if (event.isCancelled()) return; - - Config.movedPlayers.add(event.getPlayer().getName()); - } - - @Override - public void onPlayerTeleport(PlayerTeleportEvent event) - { - if (event.isCancelled()) return; - - Config.movedPlayers.add(event.getPlayer().getName()); - } -} diff --git a/src/com/wimbli/WorldBorder/WorldBorder.java b/src/com/wimbli/WorldBorder/WorldBorder.java index e4865cd..e4ce9e6 100644 --- a/src/com/wimbli/WorldBorder/WorldBorder.java +++ b/src/com/wimbli/WorldBorder/WorldBorder.java @@ -1,16 +1,12 @@ package com.wimbli.WorldBorder; -import org.bukkit.event.Event; import org.bukkit.Location; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.PluginDescriptionFile; -import org.bukkit.plugin.PluginManager; public class WorldBorder extends JavaPlugin { - WBPlayerListener playerListener = new WBPlayerListener(); - public void onEnable() { PluginDescriptionFile desc = this.getDescription(); @@ -22,15 +18,21 @@ public class WorldBorder extends JavaPlugin // Well I for one find this info useful, so... Location spawn = getServer().getWorlds().get(0).getSpawnLocation(); - System.out.println("For reference, the main world's spawn location is at X: " + Config.coord.format(spawn.getX()) + " Y: " + Config.coord.format(spawn.getY()) + " Z: " + Config.coord.format(spawn.getZ())); - - PluginManager pm = this.getServer().getPluginManager(); - pm.registerEvent(Event.Type.PLAYER_MOVE, this.playerListener, Event.Priority.High, this); - pm.registerEvent(Event.Type.PLAYER_TELEPORT, this.playerListener, Event.Priority.High, this); - pm.registerEvent(Event.Type.PLAYER_JOIN, this.playerListener, Event.Priority.High, this); + System.out.println("For reference, the main world's spawn location is at X: " + (int)spawn.getX() + " Y: " + (int)spawn.getY() + " Z: " + (int)spawn.getZ()); // our one real command, though it does also have aliases "wb" and "worldborder" getCommand("wborder").setExecutor(new WBCommand(this)); + +/* // for monitoring plugin efficiency + getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() + { + public long startTime = Config.Now(); + public void run() + { + Config.Log("Running for " + (int)((Config.Now() - startTime) / (60000)) + " minutes, has used total border checking time of " + Config.timeUsed + "ms."); + } + }, 1200, 1200); +*/ } public void onDisable()