diff --git a/mcMMO/com/gmail/nossr50/mcMMO.java b/mcMMO/com/gmail/nossr50/mcMMO.java index c448b1707..aff0ff5e2 100644 --- a/mcMMO/com/gmail/nossr50/mcMMO.java +++ b/mcMMO/com/gmail/nossr50/mcMMO.java @@ -30,6 +30,7 @@ public class mcMMO extends JavaPlugin { private final mcPlayerListener playerListener = new mcPlayerListener(this); private final mcBlockListener blockListener = new mcBlockListener(this); private final mcEntityListener entityListener = new mcEntityListener(this); + private final mcServerListener serverListener = new mcServerListener(this); private final HashMap debugees = new HashMap(); private final String name = "mcMMO"; public static PermissionHandler PermissionsHandler = null; @@ -53,27 +54,6 @@ public class mcMMO extends JavaPlugin { FileWriter writer = null; try { writer = new FileWriter(Properties); - writer.append("#Turn this setting to false to disable pvp interactions completely"); - writer.append("pvp=true"); - writer.append("#Excavation Loot Toggles"); - writer.append("eggs=true"); - writer.append("apples=true"); - writer.append("cake=true"); - writer.append("music=true"); - writer.append("diamond=true"); - writer.append("glowstone=true"); - writer.append("slowsand=true"); - writer.append("netherrack=true"); - writer.append("bones=true"); - writer.append("sulphur=true"); - writer.append("coal=true"); - writer.append("mcmmo=mcmmo"); - writer.append("mcc=mcc"); - writer.append("stats=stats"); - writer.append("clay=true"); - writer.append("anvilmessages=true"); - writer.append("xpmodifier=2"); - writer.append("#Appreciate the plugin? Send me a donation via paypal nossr50@gmail.com\r\n"); } catch (Exception e) { log.log(Level.SEVERE, "Exception while creating " + Properties, e); } finally { @@ -91,15 +71,17 @@ public class mcMMO extends JavaPlugin { } } //Load the file + //sup mcLoadProperties.loadMain(); mcUsers.getInstance().loadUsers(); PluginManager pm = getServer().getPluginManager(); pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this); + pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_DROP_ITEM, playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this); - pm.registerEvent(Event.Type.PLAYER_COMMAND, playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_CHAT, playerListener, Priority.Monitor, this); + pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.ENTITY_DEATH, entityListener, Priority.Normal, this); pm.registerEvent(Event.Type.BLOCK_FLOW, blockListener, Priority.Normal, this); pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this); diff --git a/mcMMO/com/gmail/nossr50/mcPlayerListener.java b/mcMMO/com/gmail/nossr50/mcPlayerListener.java index 021f646c9..2a6bc1c8c 100644 --- a/mcMMO/com/gmail/nossr50/mcPlayerListener.java +++ b/mcMMO/com/gmail/nossr50/mcPlayerListener.java @@ -14,6 +14,7 @@ import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerItemEvent; import org.bukkit.event.player.PlayerItemHeldEvent; import org.bukkit.event.player.PlayerListener; +import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.plugin.*; import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.inventory.ItemStack; @@ -85,9 +86,12 @@ public class mcPlayerListener extends PlayerListener { } } } - public void onPlayerJoin(PlayerEvent event) { + public void onPlayerLogin(PlayerLoginEvent event) { Player player = event.getPlayer(); mcUsers.addUser(player); + } + public void onPlayerJoin(PlayerEvent event) { + Player player = event.getPlayer(); if(mcPermissions.getInstance().motd(player)){ player.sendMessage(ChatColor.BLUE + "This server is running mcMMO "+plugin.getDescription().getVersion()+" type /"+ChatColor.YELLOW+mcLoadProperties.mcmmo+ChatColor.BLUE+ " for help."); } @@ -109,8 +113,7 @@ public class mcPlayerListener extends PlayerListener { mcm.getInstance().repairCheck(player, is, block); } } - - public void onPlayerCommand(PlayerChatEvent event) { + public void onPlayerCommandPreprocess(PlayerChatEvent event) { Player player = event.getPlayer(); String[] split = event.getMessage().split(" "); String playerName = player.getName(); @@ -448,8 +451,7 @@ public class mcPlayerListener extends PlayerListener { } } public void onPlayerChat(PlayerChatEvent event) { - Player player = event.getPlayer(); - String[] split = event.getMessage().split(" "); + Player player = event.getPlayer(); String x = ChatColor.GREEN + "(" + ChatColor.WHITE + player.getName() + ChatColor.GREEN + ") "; String y = ChatColor.AQUA + "{" + ChatColor.WHITE + player.getName() + ChatColor.AQUA + "} "; if(mcConfig.getInstance().isPartyToggled(player.getName())){ diff --git a/mcMMO/com/gmail/nossr50/mcServerListener.java b/mcMMO/com/gmail/nossr50/mcServerListener.java new file mode 100644 index 000000000..840283d55 --- /dev/null +++ b/mcMMO/com/gmail/nossr50/mcServerListener.java @@ -0,0 +1,19 @@ +package com.gmail.nossr50; + +import java.util.logging.Logger; + +import org.bukkit.Location; +import org.bukkit.event.server.ServerCommandEvent; +import org.bukkit.event.server.ServerListener; + +public class mcServerListener extends ServerListener{ + protected static final Logger log = Logger.getLogger("Minecraft"); + public Location spawn = null; + private mcMMO plugin; + + public mcServerListener(mcMMO instance) { + plugin = instance; + } + public void onServerCommand(ServerCommandEvent event) { + } +} diff --git a/mcMMO/com/gmail/nossr50/mcTimer.java b/mcMMO/com/gmail/nossr50/mcTimer.java index 0cab3d457..0685ea302 100644 --- a/mcMMO/com/gmail/nossr50/mcTimer.java +++ b/mcMMO/com/gmail/nossr50/mcTimer.java @@ -18,8 +18,6 @@ public class mcTimer extends TimerTask{ public void run() { if(thecount == 5 || thecount == 10 || thecount == 15 || thecount == 20){ for(Player player : plugin.getServer().getOnlinePlayers()){ - //Add the user to the file so we don't create null exception error - mcUsers.addUser(player); if(player != null && player.getHealth() > 0 && player.getHealth() < 20 && mcUsers.getProfile(player).getPowerLevel() >= 1000 @@ -52,6 +50,11 @@ public class mcTimer extends TimerTask{ } } } + for(Player player : plugin.getServer().getOnlinePlayers()){ + if(player != null){ + mcUsers.getProfile(player).decreaseLastHurt(); + } + } /* * RESET THE COUNT */ @@ -60,13 +63,6 @@ public class mcTimer extends TimerTask{ } else { thecount = 1; } - for(Player player : plugin.getServer().getOnlinePlayers()){ - if(player == null) - continue; - if(player != null - && mcUsers.getProfile(player).getRecentlyHurt() >= 1) - mcUsers.getProfile(player).decreaseLastHurt(); - } mcm.getInstance().bleedSimulate(plugin); } } diff --git a/mcMMO/plugin.yml b/mcMMO/plugin.yml index 1e3f4dba0..665357d7d 100644 --- a/mcMMO/plugin.yml +++ b/mcMMO/plugin.yml @@ -1,3 +1,3 @@ name: mcMMO main: com.gmail.nossr50.mcMMO -version: 0.8.4 \ No newline at end of file +version: 0.8.5 \ No newline at end of file