summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-09-15 00:34:29 +0200
committersnowleo <schneeleo@gmail.com>2011-09-15 00:34:29 +0200
commit828f97c9a8e782c7240f404dadb0f7b798f757ac (patch)
tree2bc1f1ad7cf7ce102ce0e112ba1c46511be14bd2
parentd6d47523836e48a8ee0e1769d28cbabe282644c4 (diff)
parent4c6cc5ced03091e7629328b281291e9f12e81c8b (diff)
downloadEssentials-828f97c9a8e782c7240f404dadb0f7b798f757ac.tar
Essentials-828f97c9a8e782c7240f404dadb0f7b798f757ac.tar.gz
Essentials-828f97c9a8e782c7240f404dadb0f7b798f757ac.tar.lz
Essentials-828f97c9a8e782c7240f404dadb0f7b798f757ac.tar.xz
Essentials-828f97c9a8e782c7240f404dadb0f7b798f757ac.zip
Merge branch 'bukkitupdate'
-rw-r--r--Essentials/src/com/earth2me/essentials/BanWorkaround.java157
-rw-r--r--Essentials/src/com/earth2me/essentials/Essentials.java9
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java8
-rw-r--r--Essentials/src/com/earth2me/essentials/FakeWorld.java12
-rw-r--r--Essentials/src/com/earth2me/essentials/IEssentials.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/OfflinePlayer.java31
-rw-r--r--Essentials/src/com/earth2me/essentials/PlayerExtension.java10
-rw-r--r--Essentials/src/com/earth2me/essentials/PlayerWrapper.java24
-rw-r--r--Essentials/src/com/earth2me/essentials/User.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandban.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandbanip.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtempban.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandunban.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandunbanip.java2
-rw-r--r--Essentials/test/com/earth2me/essentials/FakeServer.java67
-rw-r--r--lib/bukkit-0.0.1-SNAPSHOT.jarbin3504783 -> 3540991 bytes
-rw-r--r--lib/craftbukkit-0.0.1-SNAPSHOT.jarbin8540280 -> 8575368 bytes
17 files changed, 141 insertions, 197 deletions
diff --git a/Essentials/src/com/earth2me/essentials/BanWorkaround.java b/Essentials/src/com/earth2me/essentials/BanWorkaround.java
deleted file mode 100644
index bf9c47899..000000000
--- a/Essentials/src/com/earth2me/essentials/BanWorkaround.java
+++ /dev/null
@@ -1,157 +0,0 @@
-package com.earth2me.essentials;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import net.minecraft.server.ServerConfigurationManager;
-import org.bukkit.craftbukkit.CraftServer;
-
-
-public class BanWorkaround implements IConf
-{
- private transient final IEssentials ess;
- private transient final ServerConfigurationManager scm;
- private static final Logger LOGGER = Logger.getLogger("Minecraft");
- private transient final Set<String> bans = new HashSet<String>();
- private transient final Set<String> bannedIps = new HashSet<String>();
-
- public BanWorkaround(final IEssentials ess)
- {
- this.ess = ess;
- this.scm = ((CraftServer)ess.getServer()).getHandle();
- }
-
- public void banByName(final String name)
- {
- scm.a(name);
- reloadConfig();
- }
-
- public void unbanByName(String name)
- {
- scm.b(name);
- reloadConfig();
- }
-
- public void banByIp(final String ip)
- {
- scm.c(ip);
- reloadConfig();
- }
-
- public void unbanByIp(final String ip)
- {
- scm.d(ip);
- reloadConfig();
- }
-
- public boolean isNameBanned(final String name)
- {
- return bans.contains(name.toLowerCase());
- }
-
- public boolean isIpBanned(final String ip)
- {
- return bannedIps.contains(ip.toLowerCase());
- }
-
- public void reloadConfig()
- {
- //I don't like this but it needs to be done until CB fixors
- final File file = new File(ess.getDataFolder().getParentFile().getParentFile(), "banned-players.txt");
- try
- {
- if (!file.exists())
- {
- throw new FileNotFoundException(Util.i18n("bannedPlayersFileNotFound"));
- }
-
- final BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
- try
- {
- bans.clear();
- while (bufferedReader.ready())
- {
-
- final String line = bufferedReader.readLine().trim().toLowerCase();
- if (line.length() > 0 && line.charAt(0) == '#')
- {
- continue;
- }
- bans.add(line);
-
- }
- }
- catch (IOException io)
- {
- LOGGER.log(Level.SEVERE, Util.i18n("bannedPlayersFileError"), io);
- }
- finally
- {
- try
- {
- bufferedReader.close();
- }
- catch (IOException ex)
- {
- LOGGER.log(Level.SEVERE, Util.i18n("bannedPlayersFileError"), ex);
- }
- }
- }
- catch (FileNotFoundException ex)
- {
- LOGGER.log(Level.SEVERE, Util.i18n("bannedPlayersFileError"), ex);
- }
-
- final File ipFile = new File(ess.getDataFolder().getParentFile().getParentFile(), "banned-ips.txt");
- try
- {
- if (!ipFile.exists())
- {
- throw new FileNotFoundException(Util.i18n("bannedIpsFileNotFound"));
- }
-
- final BufferedReader bufferedReader = new BufferedReader(new FileReader(ipFile));
- try
- {
- bannedIps.clear();
- while (bufferedReader.ready())
- {
-
- final String line = bufferedReader.readLine().trim().toLowerCase();
- if (line.length() > 0 && line.charAt(0) == '#')
- {
- continue;
- }
- bannedIps.add(line);
-
- }
- }
- catch (IOException io)
- {
- LOGGER.log(Level.SEVERE, Util.i18n("bannedIpsFileError"), io);
- }
- finally
- {
- try
- {
- bufferedReader.close();
- }
- catch (IOException ex)
- {
- LOGGER.log(Level.SEVERE, Util.i18n("bannedIpsFileError"), ex);
- }
- }
- }
- catch (FileNotFoundException ex)
- {
- LOGGER.log(Level.SEVERE, Util.i18n("bannedIpsFileError"), ex);
- }
- }
-}
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java
index 386e9cc5a..7e6aed108 100644
--- a/Essentials/src/com/earth2me/essentials/Essentials.java
+++ b/Essentials/src/com/earth2me/essentials/Essentials.java
@@ -57,7 +57,6 @@ public class Essentials extends JavaPlugin implements IEssentials
private transient Worth worth;
private transient List<IConf> confList;
private transient Backup backup;
- private transient BanWorkaround bans;
private transient ItemDb itemDb;
private transient EssentialsUpdateTimer updateTimer;
private transient final Methods paymentMethod = new Methods();
@@ -119,8 +118,6 @@ public class Essentials extends JavaPlugin implements IEssentials
confList.add(warps);
worth = new Worth(this.getDataFolder());
confList.add(worth);
- bans = new BanWorkaround(this);
- confList.add(bans);
itemDb = new ItemDb(this);
confList.add(itemDb);
reload();
@@ -676,12 +673,6 @@ public class Essentials extends JavaPlugin implements IEssentials
}
@Override
- public BanWorkaround getBans()
- {
- return bans;
- }
-
- @Override
public ItemDb getItemDb()
{
return itemDb;
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
index c70afa20d..4751c8d85 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
@@ -266,14 +266,6 @@ public class EssentialsPlayerListener extends PlayerListener
ess.getBackup().onPlayerJoin();
final User user = ess.getUser(event.getPlayer());
- //we do not know the ip address on playerlogin so we need to do this here.
- if (user.isIpBanned())
- {
- final String banReason = user.getBanReason();
- user.kickPlayer(banReason != null && !banReason.isEmpty() ? banReason : Util.i18n("defaultBanReason"));
- return;
- }
-
if (ess.getSettings().changeDisplayName())
{
user.setDisplayName(user.getNick());
diff --git a/Essentials/src/com/earth2me/essentials/FakeWorld.java b/Essentials/src/com/earth2me/essentials/FakeWorld.java
index 62b20ed45..8894e8df1 100644
--- a/Essentials/src/com/earth2me/essentials/FakeWorld.java
+++ b/Essentials/src/com/earth2me/essentials/FakeWorld.java
@@ -424,5 +424,17 @@ public class FakeWorld implements World
{
throw new UnsupportedOperationException("Not supported yet.");
}
+
+ @Override
+ public boolean isAutoSave()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setAutoSave(boolean bln)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
}
diff --git a/Essentials/src/com/earth2me/essentials/IEssentials.java b/Essentials/src/com/earth2me/essentials/IEssentials.java
index 0ac8c54d3..9dca96e81 100644
--- a/Essentials/src/com/earth2me/essentials/IEssentials.java
+++ b/Essentials/src/com/earth2me/essentials/IEssentials.java
@@ -53,8 +53,6 @@ public interface IEssentials extends Plugin
int scheduleSyncRepeatingTask(final Runnable run, long delay, long period);
- BanWorkaround getBans();
-
TNTExplodeListener getTNTListener();
PermissionsHandler getPermissionsHandler();
diff --git a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java
index 5f733f0c0..46a2648a2 100644
--- a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java
+++ b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java
@@ -39,22 +39,24 @@ public class OfflinePlayer implements Player
private Location location = new Location(null, 0, 0, 0, 0, 0);
private World world;
private UUID uniqueId = UUID.randomUUID();
+ private org.bukkit.OfflinePlayer base;
public OfflinePlayer(String name, IEssentials ess)
{
this.name = name;
this.ess = ess;
this.world = ess.getServer().getWorlds().get(0);
+ this.base = ess.getServer().getOfflinePlayer(name);
}
public boolean isOnline()
{
- return false;
+ return base.isOnline();
}
public boolean isOp()
{
- return false;
+ return base.isOp();
}
public void sendMessage(String string)
@@ -576,6 +578,7 @@ public class OfflinePlayer implements Player
public void setOp(boolean bln)
{
+ base.setOp(bln);
}
@Override
@@ -583,4 +586,28 @@ public class OfflinePlayer implements Player
{
throw new UnsupportedOperationException("Not supported yet.");
}
+
+ @Override
+ public boolean isBanned()
+ {
+ return base.isBanned();
+ }
+
+ @Override
+ public void setBanned(boolean bln)
+ {
+ base.setBanned(bln);
+ }
+
+ @Override
+ public boolean isWhitelisted()
+ {
+ return base.isWhitelisted();
+ }
+
+ @Override
+ public void setWhitelisted(boolean bln)
+ {
+ base.setWhitelisted(bln);
+ }
}
diff --git a/Essentials/src/com/earth2me/essentials/PlayerExtension.java b/Essentials/src/com/earth2me/essentials/PlayerExtension.java
index e72cf25f4..ef63dacc3 100644
--- a/Essentials/src/com/earth2me/essentials/PlayerExtension.java
+++ b/Essentials/src/com/earth2me/essentials/PlayerExtension.java
@@ -17,16 +17,6 @@ public class PlayerExtension extends PlayerWrapper
this.ess = ess;
}
- public boolean isBanned()
- {
- return ess.getBans().isNameBanned(this.getName());
- }
-
- public boolean isIpBanned()
- {
- return ess.getBans().isIpBanned(getAddress().getAddress().getHostAddress());
- }
-
public float getCorrectedYaw()
{
float angle = (getLocation().getYaw() - 90.0f) % 360.0f;
diff --git a/Essentials/src/com/earth2me/essentials/PlayerWrapper.java b/Essentials/src/com/earth2me/essentials/PlayerWrapper.java
index 391982a1e..0f65970e7 100644
--- a/Essentials/src/com/earth2me/essentials/PlayerWrapper.java
+++ b/Essentials/src/com/earth2me/essentials/PlayerWrapper.java
@@ -617,4 +617,28 @@ public class PlayerWrapper implements Player
{
base.sendMap(mv);
}
+
+ @Override
+ public boolean isBanned()
+ {
+ return base.isBanned();
+ }
+
+ @Override
+ public void setBanned(boolean bln)
+ {
+ base.setBanned(bln);
+ }
+
+ @Override
+ public boolean isWhitelisted()
+ {
+ return base.isWhitelisted();
+ }
+
+ @Override
+ public void setWhitelisted(boolean bln)
+ {
+ base.setWhitelisted(bln);
+ }
}
diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java
index 4a93fa264..2f4fc2951 100644
--- a/Essentials/src/com/earth2me/essentials/User.java
+++ b/Essentials/src/com/earth2me/essentials/User.java
@@ -411,10 +411,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
public void checkBanTimeout(final long currentTime)
{
- if (getBanTimeout() > 0 && getBanTimeout() < currentTime && ess.getBans().isNameBanned(getName()))
+ if (getBanTimeout() > 0 && getBanTimeout() < currentTime && isBanned())
{
setBanTimeout(0);
- ess.getBans().unbanByName(getName());
+ setBanned(false);
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandban.java b/Essentials/src/com/earth2me/essentials/commands/Commandban.java
index 628058c6e..d6387c074 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandban.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandban.java
@@ -52,8 +52,8 @@ public class Commandban extends EssentialsCommand
{
banReason = Util.i18n("defaultBanReason");
}
+ player.setBanned(true);
player.kickPlayer(banReason);
- ess.getBans().banByName(player.getName());
String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
for(Player p : server.getOnlinePlayers())
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java b/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java
index 77c268988..3301afc87 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java
@@ -20,7 +20,7 @@ public class Commandbanip extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
- ess.getBans().banByIp(args[0]);
+ ess.getServer().banIP(args[0]);
sender.sendMessage(Util.i18n("banIpAddress"));
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java
index a20ad067f..bc8442da4 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java
@@ -47,8 +47,8 @@ public class Commandtempban extends EssentialsCommand
final String banReason = Util.format("tempBanned", Util.formatDateDiff(banTimestamp));
player.setBanReason(banReason);
player.setBanTimeout(banTimestamp);
+ player.setBanned(true);
player.kickPlayer(banReason);
- ess.getBans().banByName(player.getName());
String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
for(Player p : server.getOnlinePlayers())
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunban.java b/Essentials/src/com/earth2me/essentials/commands/Commandunban.java
index 2cf4e78d0..8bc921d64 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandunban.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandunban.java
@@ -26,12 +26,12 @@ public class Commandunban extends EssentialsCommand
{
User u = getPlayer(server, args, 0, true);
name = u.getName();
+ u.setBanned(false);
+ sender.sendMessage(Util.i18n("unbannedPlayer"));
}
catch (NoSuchFieldException e)
{
- name = args[0];
+ sender.sendMessage(Util.i18n("playerNotFound"));
}
- ess.getBans().unbanByName(name);
- sender.sendMessage(Util.i18n("unbannedPlayer"));
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunbanip.java b/Essentials/src/com/earth2me/essentials/commands/Commandunbanip.java
index aa6327f49..ea2c88f78 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandunbanip.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandunbanip.java
@@ -20,7 +20,7 @@ public class Commandunbanip extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
- ess.getBans().unbanByIp(args[0]);
+ ess.getServer().unbanIP(args[0]);
sender.sendMessage(Util.i18n("unbannedIP"));
}
}
diff --git a/Essentials/test/com/earth2me/essentials/FakeServer.java b/Essentials/test/com/earth2me/essentials/FakeServer.java
index 159bd7195..5f1f3aa0b 100644
--- a/Essentials/test/com/earth2me/essentials/FakeServer.java
+++ b/Essentials/test/com/earth2me/essentials/FakeServer.java
@@ -4,6 +4,7 @@ import com.avaje.ebean.config.ServerConfig;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
@@ -378,4 +379,70 @@ public class FakeServer implements Server
{
throw new UnsupportedOperationException("Not supported yet.");
}
+
+ @Override
+ public void setWhitelist(boolean bln)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Set<org.bukkit.OfflinePlayer> getWhitelistedPlayers()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void reloadWhitelist()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Player getPlayerExact(String string)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void shutdown()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int broadcast(String string, String string1)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public org.bukkit.OfflinePlayer getOfflinePlayer(String string)
+ {
+ return null;
+ }
+
+ @Override
+ public Set<String> getIPBans()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void banIP(String string)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void unbanIP(String string)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Set<org.bukkit.OfflinePlayer> getBannedPlayers()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
}
diff --git a/lib/bukkit-0.0.1-SNAPSHOT.jar b/lib/bukkit-0.0.1-SNAPSHOT.jar
index 921a7c91d..b6aafd41d 100644
--- a/lib/bukkit-0.0.1-SNAPSHOT.jar
+++ b/lib/bukkit-0.0.1-SNAPSHOT.jar
Binary files differ
diff --git a/lib/craftbukkit-0.0.1-SNAPSHOT.jar b/lib/craftbukkit-0.0.1-SNAPSHOT.jar
index 83565a63e..f3f06d0b6 100644
--- a/lib/craftbukkit-0.0.1-SNAPSHOT.jar
+++ b/lib/craftbukkit-0.0.1-SNAPSHOT.jar
Binary files differ