summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZenexer <Zenexer@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-03-30 17:58:00 +0000
committerZenexer <Zenexer@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-03-30 17:58:00 +0000
commit17b3c793d9950fc9f78cff34ca3aedcdc9179926 (patch)
tree0bdbd58b4ef5922d9f8d14b13db0cee24dcf1b3e
parent51251819677c61e379c425a9df04cb1c935987b4 (diff)
downloadEssentials-17b3c793d9950fc9f78cff34ca3aedcdc9179926.tar
Essentials-17b3c793d9950fc9f78cff34ca3aedcdc9179926.tar.gz
Essentials-17b3c793d9950fc9f78cff34ca3aedcdc9179926.tar.lz
Essentials-17b3c793d9950fc9f78cff34ca3aedcdc9179926.tar.xz
Essentials-17b3c793d9950fc9f78cff34ca3aedcdc9179926.zip
Updated for CB 602
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1043 e251c2fe-e539-e718-e476-b85c1f46cddb
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java71
-rw-r--r--Essentials/src/com/earth2me/essentials/Jail.java57
-rw-r--r--Essentials/src/com/earth2me/essentials/OfflinePlayer.java65
-rw-r--r--Essentials/src/com/earth2me/essentials/PlayerWrapper.java89
-rw-r--r--Essentials/src/com/earth2me/essentials/Settings.java5
-rw-r--r--EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java4
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java6
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java1
-rw-r--r--EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java4
-rw-r--r--lib/craftbukkit-0.0.1-SNAPSHOT.jarbin1448182 -> 1458642 bytes
10 files changed, 247 insertions, 55 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
index 9b8c46de6..ff4963ea6 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
@@ -1,6 +1,5 @@
package com.earth2me.essentials;
-import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import net.minecraft.server.InventoryPlayer;
@@ -128,36 +127,52 @@ public class EssentialsPlayerListener extends PlayerListener
}
@Override
- public void onPlayerQuit(PlayerEvent event)
+ public void onPlayerQuit(PlayerQuitEvent event)
{
+ if (!Essentials.getSettings().getReclaimSetting())
+ {
+ return;
+ }
User.get(event.getPlayer()).dispose();
+ Thread thread = new Thread(new Runnable()
+ {
+ @SuppressWarnings("LoggerStringConcat")
+ public void run()
+ {
+ try
+ {
+ Thread.sleep(1000);
+ Runtime rt = Runtime.getRuntime();
+ double mem = rt.freeMemory();
+ rt.runFinalization();
+ rt.gc();
+ mem = rt.freeMemory() - mem;
+ mem /= 1024 * 1024;
+ logger.info("Freed " + mem + " MB.");
+ }
+ catch (InterruptedException ex)
+ {
+ return;
+ }
+ }
+ });
+ thread.setPriority(Thread.MIN_PRIORITY);
+ thread.start();
}
@Override
- public void onPlayerLogin(PlayerLoginEvent event)
+ public void onPlayerJoin(PlayerJoinEvent event)
{
+ Essentials.getStatic().backup.onPlayerJoin();
User user = User.get(event.getPlayer());
- if (event.getResult() != Result.ALLOWED)
- return;
- if (user.isBanned())
- {
- event.disallow(Result.KICK_BANNED, "The Ban Hammer has spoken!");
- return;
- }
-
+ //we do not know the ip address on playerlogin so we need to do this here.
if (user.isIpBanned())
{
user.kickPlayer("The Ban Hammer has spoken!");
return;
}
- if (server.getOnlinePlayers().length >= server.getMaxPlayers() && !user.isOp())
- {
- event.disallow(Result.KICK_FULL, "Server is full");
- return;
- }
-
user.setDisplayName(user.getNick());
if (!Essentials.getSettings().isCommandDisabled("motd") && user.isAuthorized("essentials.motd"))
@@ -175,6 +190,26 @@ public class EssentialsPlayerListener extends PlayerListener
if (mail.isEmpty()) user.sendMessage("§7You have no new mail.");
else user.sendMessage("§cYou have " + mail.size() + " messages!§f Type §7/mail read§f to view your mail.");
}
+ }
+
+ @Override
+ public void onPlayerLogin(PlayerLoginEvent event)
+ {
+ User user = User.get(event.getPlayer());
+ if (event.getResult() != Result.ALLOWED)
+ return;
+
+ if (user.isBanned())
+ {
+ event.disallow(Result.KICK_BANNED, "The Ban Hammer has spoken!");
+ return;
+ }
+
+ if (server.getOnlinePlayers().length >= server.getMaxPlayers() && !user.isOp())
+ {
+ event.disallow(Result.KICK_FULL, "Server is full");
+ return;
+ }
updateCompass(user);
}
@@ -192,7 +227,7 @@ public class EssentialsPlayerListener extends PlayerListener
}
@Override
- public void onPlayerTeleport(PlayerMoveEvent event)
+ public void onPlayerTeleport(PlayerTeleportEvent event)
{
User user = User.get(event.getPlayer());
if (user.currentJail == null || user.currentJail.isEmpty())
diff --git a/Essentials/src/com/earth2me/essentials/Jail.java b/Essentials/src/com/earth2me/essentials/Jail.java
index 0b88cd5cf..63015fecf 100644
--- a/Essentials/src/com/earth2me/essentials/Jail.java
+++ b/Essentials/src/com/earth2me/essentials/Jail.java
@@ -7,24 +7,25 @@ import java.util.Map;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.World;
-import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent;
-import org.bukkit.event.block.BlockInteractEvent;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPlaceEvent;
-import org.bukkit.event.player.PlayerListener;
-public class Jail extends BlockListener implements IConf {
+
+public class Jail extends BlockListener implements IConf
+{
private static final Logger logger = Logger.getLogger("Minecraft");
private EssentialsConf config;
- public Jail(File dataFolder) {
+ public Jail(File dataFolder)
+ {
config = new EssentialsConf(new File(dataFolder, "jail.yml"));
config.load();
}
- public void setJail(Location loc, String jailName) throws Exception {
+ public void setJail(Location loc, String jailName) throws Exception
+ {
Map<String, Object> map = new HashMap<String, Object>();
map.put("world", loc.getWorld().getName());
map.put("x", loc.getX());
@@ -36,8 +37,10 @@ public class Jail extends BlockListener implements IConf {
config.save();
}
- public Location getJail(String jailName) throws Exception {
- if (config.getProperty(jailName.toLowerCase()) == null) {
+ public Location getJail(String jailName) throws Exception
+ {
+ if (config.getProperty(jailName.toLowerCase()) == null)
+ {
throw new Exception("That jail does not exist");
}
@@ -46,10 +49,12 @@ public class Jail extends BlockListener implements IConf {
double x = config.getDouble(jailName + ".x", 0); // wh.spawnX
double y = config.getDouble(jailName + ".y", 0); // wh.spawnY
double z = config.getDouble(jailName + ".z", 0); // wh.spawnZ
- float yaw = (float) config.getDouble(jailName + ".yaw", 0);
- float pitch = (float) config.getDouble(jailName + ".pitch", 0);
- for (World w : Essentials.getStatic().getServer().getWorlds()) {
- if (w.getName().equalsIgnoreCase(world)) {
+ float yaw = (float)config.getDouble(jailName + ".yaw", 0);
+ float pitch = (float)config.getDouble(jailName + ".pitch", 0);
+ for (World w : Essentials.getStatic().getServer().getWorlds())
+ {
+ if (w.getName().equalsIgnoreCase(world))
+ {
jWorld = w;
break;
}
@@ -58,29 +63,34 @@ public class Jail extends BlockListener implements IConf {
return new Location(jWorld, x, y, z, yaw, pitch);
}
- public void sendToJail(User user, String jail) throws Exception {
+ public void sendToJail(User user, String jail) throws Exception
+ {
user.teleportTo(getJail(jail));
user.currentJail = jail;
}
- public void delJail(String jail) throws Exception {
+ public void delJail(String jail) throws Exception
+ {
config.removeProperty(jail.toLowerCase());
config.save();
}
- public List<String> getJails() throws Exception {
+ public List<String> getJails() throws Exception
+ {
return config.getKeys(null);
}
- public void reloadConfig() {
+ public void reloadConfig()
+ {
config.load();
}
-
+
@Override
public void onBlockBreak(BlockBreakEvent event)
{
User user = User.get(event.getPlayer());
- if (user.isJailed()) {
+ if (user.isJailed())
+ {
event.setCancelled(true);
}
}
@@ -89,18 +99,19 @@ public class Jail extends BlockListener implements IConf {
public void onBlockPlace(BlockPlaceEvent event)
{
User user = User.get(event.getPlayer());
- if (user.isJailed()) {
+ if (user.isJailed())
+ {
event.setCancelled(true);
}
}
@Override
- public void onBlockDamage(BlockDamageEvent event) {
+ public void onBlockDamage(BlockDamageEvent event)
+ {
User user = User.get(event.getPlayer());
- if (user.isJailed()) {
+ if (user.isJailed())
+ {
event.setCancelled(true);
}
}
}
-
-
diff --git a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java
index f1bac2ae4..5fffdfa99 100644
--- a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java
+++ b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java
@@ -283,4 +283,69 @@ public class OfflinePlayer implements Player
public void sendRawMessage(String string) {
throw new UnsupportedOperationException("Not supported yet.");
}
+
+ public Location getCompassTarget()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public int getMaximumNoDamageTicks()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void setMaximumNoDamageTicks(int i)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public int getLastDamage()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void setLastDamage(int i)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public int getNoDamageTicks()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void setNoDamageTicks(int i)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public boolean teleport(Location lctn)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public boolean teleport(Entity entity)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public Entity getPassenger()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public boolean setPassenger(Entity entity)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public boolean isEmpty()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public boolean eject()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
}
diff --git a/Essentials/src/com/earth2me/essentials/PlayerWrapper.java b/Essentials/src/com/earth2me/essentials/PlayerWrapper.java
index cf3a6db58..0de6f669e 100644
--- a/Essentials/src/com/earth2me/essentials/PlayerWrapper.java
+++ b/Essentials/src/com/earth2me/essentials/PlayerWrapper.java
@@ -154,15 +154,15 @@ public class PlayerWrapper implements Player
}
@Override
- public void teleportTo(Location lctn)
+ public boolean teleport(Location lctn)
{
- base.teleportTo(lctn);
+ return base.teleport(lctn);
}
@Override
- public void teleportTo(Entity entity)
+ public boolean teleport(Entity entity)
{
- base.teleportTo(entity);
+ return base.teleport(entity);
}
@Override
@@ -329,7 +329,88 @@ public class PlayerWrapper implements Player
return base.getEyeLocation();
}
+ @Override
public void sendRawMessage(String string) {
base.sendRawMessage(string);
}
+
+ @Override
+ public Location getCompassTarget()
+ {
+ return base.getCompassTarget();
+ }
+
+ @Override
+ public int getMaximumNoDamageTicks()
+ {
+ return base.getMaximumNoDamageTicks();
+ }
+
+ @Override
+ public void setMaximumNoDamageTicks(int i)
+ {
+ base.setMaximumNoDamageTicks(i);
+ }
+
+ @Override
+ public int getLastDamage()
+ {
+ return base.getLastDamage();
+ }
+
+ @Override
+ public void setLastDamage(int i)
+ {
+ base.setLastDamage(i);
+ }
+
+ @Override
+ public int getNoDamageTicks()
+ {
+ return base.getNoDamageTicks();
+ }
+
+ @Override
+ public void setNoDamageTicks(int i)
+ {
+ base.setNoDamageTicks(i);
+ }
+
+ @Override
+ public Entity getPassenger()
+ {
+ return base.getPassenger();
+ }
+
+ @Override
+ public boolean setPassenger(Entity entity)
+ {
+ return base.setPassenger(entity);
+ }
+
+ @Override
+ public boolean isEmpty()
+ {
+ return base.isEmpty();
+ }
+
+ @Override
+ public boolean eject()
+ {
+ return base.eject();
+ }
+
+ @Override
+ @Deprecated
+ public void teleportTo(Location lctn)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ @Deprecated
+ public void teleportTo(Entity entity)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
}
diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java
index d2216ee9c..9c774b848 100644
--- a/Essentials/src/com/earth2me/essentials/Settings.java
+++ b/Essentials/src/com/earth2me/essentials/Settings.java
@@ -151,6 +151,11 @@ public class Settings implements IConf
return ChatColor.getByCode(Integer.parseInt(colorName, 16));
}
+ public boolean getReclaimSetting()
+ {
+ return config.getBoolean("reclaim-onlogout", true);
+ }
+
public String getNetherName()
{
return config.getString("nether.folder", "nether");
diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java
index 890187ee3..225c67cb4 100644
--- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java
+++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java
@@ -3,7 +3,7 @@ package com.earth2me.essentials.chat;
import com.earth2me.essentials.Essentials;
import org.bukkit.Server;
import org.bukkit.event.player.PlayerChatEvent;
-import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerRespawnEvent;
@@ -19,7 +19,7 @@ public class EssentialsChatPlayerListener extends PlayerListener
@Override
@SuppressWarnings("CallToThreadDumpStack")
- public void onPlayerJoin(PlayerEvent event)
+ public void onPlayerJoin(PlayerJoinEvent event)
{
try
{
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java
index e96165ecd..be5757364 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java
@@ -2,18 +2,14 @@ package com.earth2me.essentials.protect;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
-import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
-import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockIgniteEvent;
-import org.bukkit.event.block.BlockInteractEvent;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPlaceEvent;
-import org.bukkit.event.block.BlockRightClickEvent;
import org.bukkit.inventory.ItemStack;
@@ -128,7 +124,7 @@ public class EssentialsProtectBlockListener extends BlockListener
}
@Override
- public void onBlockFlow(BlockFromToEvent event)
+ public void onBlockFromTo(BlockFromToEvent event)
{
if (event.isCancelled()) return;
Block block = event.getBlock();
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java
index c75bb6324..ce37dd368 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java
@@ -5,7 +5,6 @@ import com.earth2me.essentials.User;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.event.player.PlayerInteractEvent;
-import org.bukkit.event.player.PlayerItemEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.inventory.ItemStack;
diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
index 1891e87f4..697939daa 100644
--- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
+++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
@@ -4,7 +4,7 @@ import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
import java.util.logging.Level;
import java.util.logging.Logger;
-import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerRespawnEvent;
@@ -32,7 +32,7 @@ public class EssentialsSpawnPlayerListener extends PlayerListener
}
@Override
- public void onPlayerJoin(PlayerEvent event)
+ public void onPlayerJoin(PlayerJoinEvent event)
{
Essentials.loadClasses();
User user = User.get(event.getPlayer());
diff --git a/lib/craftbukkit-0.0.1-SNAPSHOT.jar b/lib/craftbukkit-0.0.1-SNAPSHOT.jar
index cf1f137f1..0ef0225d5 100644
--- a/lib/craftbukkit-0.0.1-SNAPSHOT.jar
+++ b/lib/craftbukkit-0.0.1-SNAPSHOT.jar
Binary files differ