From dad4547c21a2510bc93ac0156200a887db820f0a Mon Sep 17 00:00:00 2001 From: Eric Stokes Date: Thu, 30 Jun 2011 07:30:55 -0600 Subject: [PATCH] More code cleanup, remove bogus method in MVPlayerListener --- .../MultiverseCore/MVPlayerListener.java | 4 +++- .../MultiverseCore/MVPlayerSession.java | 4 ++-- .../MultiverseCore/MultiverseCore.java | 21 ------------------ .../command/CommandManager.java | 1 - .../MultiverseCore/command/QueuedCommand.java | 16 +++++++------- src/com/onarandombox/utils/DebugLog.java | 22 +++++++++---------- src/com/onarandombox/utils/Destination.java | 4 ++-- src/com/onarandombox/utils/UpdateChecker.java | 8 +++---- 8 files changed, 30 insertions(+), 50 deletions(-) diff --git a/src/com/onarandombox/MultiverseCore/MVPlayerListener.java b/src/com/onarandombox/MultiverseCore/MVPlayerListener.java index fb44fda3..4dbdf956 100644 --- a/src/com/onarandombox/MultiverseCore/MVPlayerListener.java +++ b/src/com/onarandombox/MultiverseCore/MVPlayerListener.java @@ -24,8 +24,10 @@ public class MVPlayerListener extends PlayerListener { ps.setRespawnWorld(event.getTo().getWorld()); } + @Override public void onPlayerKick(PlayerKickEvent event) { - event.setCancelled(true); + // TODO Auto-generated method stub + super.onPlayerKick(event); } @Override diff --git a/src/com/onarandombox/MultiverseCore/MVPlayerSession.java b/src/com/onarandombox/MultiverseCore/MVPlayerSession.java index c5054534..e33e7ec5 100644 --- a/src/com/onarandombox/MultiverseCore/MVPlayerSession.java +++ b/src/com/onarandombox/MultiverseCore/MVPlayerSession.java @@ -44,7 +44,7 @@ public class MVPlayerSession { */ public boolean getTeleportable() { Long time = (new Date()).getTime(); - if ((time - this.teleportLast) > config.getInt("portalcooldown", 5000)) { + if ((time - this.teleportLast) > this.config.getInt("portalcooldown", 5000)) { return true; } else { return false; @@ -57,7 +57,7 @@ public class MVPlayerSession { */ public void message(String msg) { Long time = (new Date()).getTime(); - if ((time - this.messageLast) > config.getInt("messagecooldown", 2000)) { + if ((time - this.messageLast) > this.config.getInt("messagecooldown", 2000)) { this.player.sendMessage(msg); this.messageLast = time; } diff --git a/src/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/com/onarandombox/MultiverseCore/MultiverseCore.java index 47a09b43..12ff12f9 100644 --- a/src/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -2,37 +2,17 @@ package com.onarandombox.MultiverseCore; import java.io.File; import java.util.ArrayList; -import java.util.Calendar; import java.util.Collection; import java.util.HashMap; import java.util.List; -import java.util.Map; -import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; -import org.bukkit.ChatColor; import org.bukkit.World; import org.bukkit.World.Environment; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; -import org.bukkit.entity.Animals; -import org.bukkit.entity.Chicken; -import org.bukkit.entity.Cow; -import org.bukkit.entity.Creeper; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Ghast; -import org.bukkit.entity.Giant; -import org.bukkit.entity.Monster; -import org.bukkit.entity.Pig; -import org.bukkit.entity.PigZombie; import org.bukkit.entity.Player; -import org.bukkit.entity.Sheep; -import org.bukkit.entity.Skeleton; -import org.bukkit.entity.Slime; -import org.bukkit.entity.Spider; -import org.bukkit.entity.Squid; -import org.bukkit.entity.Zombie; import org.bukkit.event.Event; import org.bukkit.event.Event.Priority; import org.bukkit.generator.ChunkGenerator; @@ -45,7 +25,6 @@ import com.iConomy.iConomy; import com.nijiko.permissions.PermissionHandler; import com.nijikokun.bukkit.Permissions.Permissions; import com.onarandombox.MultiverseCore.command.CommandManager; -import com.onarandombox.MultiverseCore.command.QueuedCommand; import com.onarandombox.MultiverseCore.command.commands.*; import com.onarandombox.MultiverseCore.configuration.DefaultConfiguration; import com.onarandombox.utils.DebugLog; diff --git a/src/com/onarandombox/MultiverseCore/command/CommandManager.java b/src/com/onarandombox/MultiverseCore/command/CommandManager.java index 88d188a2..8f13a864 100644 --- a/src/com/onarandombox/MultiverseCore/command/CommandManager.java +++ b/src/com/onarandombox/MultiverseCore/command/CommandManager.java @@ -15,7 +15,6 @@ import java.util.List; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; import com.onarandombox.MultiverseCore.MultiverseCore; diff --git a/src/com/onarandombox/MultiverseCore/command/QueuedCommand.java b/src/com/onarandombox/MultiverseCore/command/QueuedCommand.java index 330ce522..66e114e0 100644 --- a/src/com/onarandombox/MultiverseCore/command/QueuedCommand.java +++ b/src/com/onarandombox/MultiverseCore/command/QueuedCommand.java @@ -31,16 +31,16 @@ public class QueuedCommand { } public CommandSender getSender() { - return sender; + return this.sender; } public boolean execute() { - timeRequested.add(Calendar.SECOND, 10); - if (timeRequested.after(Calendar.getInstance())) { + this.timeRequested.add(Calendar.SECOND, 10); + if (this.timeRequested.after(Calendar.getInstance())) { try { - Method method = plugin.getClass().getMethod(name, paramTypes); + Method method = this.plugin.getClass().getMethod(this.name, this.paramTypes); try { - method.invoke(plugin, args); + method.invoke(this.plugin, this.args); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -65,7 +65,7 @@ public class QueuedCommand { } return true; } else { - sender.sendMessage("This command has expried. Please type the original command again."); + this.sender.sendMessage("This command has expried. Please type the original command again."); } return false; } @@ -75,7 +75,7 @@ public class QueuedCommand { } public String getSuccess() { - return success; + return this.success; } private void setFail(String fail) { @@ -83,6 +83,6 @@ public class QueuedCommand { } public String getFail() { - return fail; + return this.fail; } } diff --git a/src/com/onarandombox/utils/DebugLog.java b/src/com/onarandombox/utils/DebugLog.java index dfa6bc02..6d1d8cd7 100644 --- a/src/com/onarandombox/utils/DebugLog.java +++ b/src/com/onarandombox/utils/DebugLog.java @@ -21,17 +21,17 @@ public class DebugLog { * @param file The file to log to. */ public DebugLog(String logger, String file) { - log = Logger.getLogger(logger); + this.log = Logger.getLogger(logger); try { - fh = new FileHandler(file, true); - log.setUseParentHandlers(false); - for (Handler handler : log.getHandlers()) { - log.removeHandler(handler); + this.fh = new FileHandler(file, true); + this.log.setUseParentHandlers(false); + for (Handler handler : this.log.getHandlers()) { + this.log.removeHandler(handler); } - log.addHandler(fh); - log.setLevel(Level.ALL); - fh.setFormatter(new LogFormatter()); + this.log.addHandler(this.fh); + this.log.setLevel(Level.ALL); + this.fh.setFormatter(new LogFormatter()); } catch (SecurityException e) { e.printStackTrace(); } catch (IOException e) { @@ -44,7 +44,7 @@ public class DebugLog { * @param msg */ public void log(Level level, String msg) { - log.log(level, msg); + this.log.log(level, msg); } private class LogFormatter extends Formatter { @@ -55,7 +55,7 @@ public class DebugLog { StringBuilder builder = new StringBuilder(); Throwable ex = record.getThrown(); - builder.append(date.format(record.getMillis())); + builder.append(this.date.format(record.getMillis())); builder.append(" ["); builder.append(record.getLevel().getLocalizedName().toUpperCase()); builder.append("] "); @@ -73,6 +73,6 @@ public class DebugLog { } public void close() { - fh.close(); + this.fh.close(); } } diff --git a/src/com/onarandombox/utils/Destination.java b/src/com/onarandombox/utils/Destination.java index 2bb3c948..49f6080d 100644 --- a/src/com/onarandombox/utils/Destination.java +++ b/src/com/onarandombox/utils/Destination.java @@ -12,11 +12,11 @@ public class Destination { } public String getName() { - return name; + return this.name; } public DestinationType getType() { - return type; + return this.type; } private static Destination getBadDestination() { diff --git a/src/com/onarandombox/utils/UpdateChecker.java b/src/com/onarandombox/utils/UpdateChecker.java index d3353dc4..4b7314e2 100644 --- a/src/com/onarandombox/utils/UpdateChecker.java +++ b/src/com/onarandombox/utils/UpdateChecker.java @@ -27,7 +27,7 @@ public class UpdateChecker { int delay = 0; // No Delay, fire the first check instantly. int period = 1800; // Delay 30 Minutes - timer.scheduleAtFixedRate(new TimerTask() { + this.timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { checkUpdate(); @@ -37,7 +37,7 @@ public class UpdateChecker { public void checkUpdate() { try { - URL url = new URL("http://bukkit.onarandombox.com/multiverse/version.php?n=" + URLEncoder.encode(name, "UTF-8") + "&v=" + cversion); + URL url = new URL("http://bukkit.onarandombox.com/multiverse/version.php?n=" + URLEncoder.encode(this.name, "UTF-8") + "&v=" + this.cversion); URLConnection conn = url.openConnection(); conn.setReadTimeout(2000); // 2000 = 2 Seconds. @@ -63,12 +63,12 @@ public class UpdateChecker { } String v1 = normalisedVersion(version); - String v2 = normalisedVersion(cversion); + String v2 = normalisedVersion(this.cversion); int compare = v1.compareTo(v2); if (compare > 0) { - log.info("[" + name + "]" + " - Update Available (" + version + ")"); + log.info("[" + this.name + "]" + " - Update Available (" + version + ")"); } rd.close();