summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2012-07-12 11:26:33 +0200
committersnowleo <schneeleo@gmail.com>2012-07-12 12:30:22 +0200
commit3060a7b259b0d9a097842af117b8163d09e93076 (patch)
tree8bf7d0573efc354d097e99dd62514aa6f81f5988
parent719e1a861fc28823800d56881704efd16edd992c (diff)
downloadEssentials-3060a7b259b0d9a097842af117b8163d09e93076.tar
Essentials-3060a7b259b0d9a097842af117b8163d09e93076.tar.gz
Essentials-3060a7b259b0d9a097842af117b8163d09e93076.tar.lz
Essentials-3060a7b259b0d9a097842af117b8163d09e93076.tar.xz
Essentials-3060a7b259b0d9a097842af117b8163d09e93076.zip
Using the new methods in Essentials to getUser
-rw-r--r--Essentials/src/net/ess3/Essentials.java54
-rw-r--r--Essentials/src/net/ess3/Jails.java3
-rw-r--r--Essentials/src/net/ess3/api/IEssentials.java6
-rw-r--r--Essentials/src/net/ess3/commands/Commandmsg.java2
-rw-r--r--Essentials/src/net/ess3/commands/Commandr.java2
-rw-r--r--Essentials/src/net/ess3/listener/EssentialsPlayerListener.java9
6 files changed, 18 insertions, 58 deletions
diff --git a/Essentials/src/net/ess3/Essentials.java b/Essentials/src/net/ess3/Essentials.java
index 89a1e6460..ec408dbef 100644
--- a/Essentials/src/net/ess3/Essentials.java
+++ b/Essentials/src/net/ess3/Essentials.java
@@ -345,61 +345,17 @@ public class Essentials extends JavaPlugin implements IEssentials
}
@Override
- public IUser getUser(final Object base)
+ public IUser getUser(final Player player)
{
- if (base instanceof Player)
- {
- return getUser((Player)base);
- }
- if (base instanceof String)
- {
- final IUser user = userMap.getUser((String)base);
- if (user != null && user.getBase() instanceof IOfflinePlayer)
- {
- ((IOfflinePlayer)user.getBase()).setName((String)base);
- }
- return user;
- }
- return null;
+ return userMap.getUser(player);
}
- private <T extends Player> IUser getUser(final T base)
+ @Override
+ public IUser getUser(final String playerName)
{
- if (base == null)
- {
- return null;
- }
-
- if (base instanceof IUser)
- {
- return (IUser)base;
- }
- IUser user = userMap.getUser(base.getName());
-
- if (user == null)
- {
- user = new User(base, this);
- }
- else
- {
- //todo - fix this
- user.update(base);
- }
- return user;
+ return userMap.getUser(playerName);
}
- /*@Override
- public IUser getUser(final Player player)
- {
- return userMap.getUser(player);
- }
-
- @Override
- public IUser getUser(final String playerName)
- {
- return userMap.getUser(playerName);
- }
- */
@Override
public World getWorld(final String name)
{
diff --git a/Essentials/src/net/ess3/Jails.java b/Essentials/src/net/ess3/Jails.java
index 244d40853..482b3b3bd 100644
--- a/Essentials/src/net/ess3/Jails.java
+++ b/Essentials/src/net/ess3/Jails.java
@@ -14,6 +14,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
+import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@@ -240,7 +241,7 @@ public class Jails extends AsyncStorageObjectHolder<net.ess3.settings.Jails> imp
final Entity damager = event.getDamager();
if (damager.getType() == EntityType.PLAYER)
{
- final IUser user = ess.getUser(damager);
+ final IUser user = ess.getUser((Player)damager);
if (user != null && user.getData().isJailed())
{
event.setCancelled(true);
diff --git a/Essentials/src/net/ess3/api/IEssentials.java b/Essentials/src/net/ess3/api/IEssentials.java
index 7a8c3ccaf..5372ebc3c 100644
--- a/Essentials/src/net/ess3/api/IEssentials.java
+++ b/Essentials/src/net/ess3/api/IEssentials.java
@@ -7,6 +7,7 @@ import net.ess3.metrics.Metrics;
import java.util.List;
import org.bukkit.World;
+import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@@ -14,7 +15,10 @@ public interface IEssentials extends Plugin
{
void addReloadListener(IReload listener);
- IUser getUser(final Object base);
+ //IUser getUser(final Object base);
+ IUser getUser(final Player player);
+
+ IUser getUser(final String playerName);
int broadcastMessage(IUser sender, String message);
diff --git a/Essentials/src/net/ess3/commands/Commandmsg.java b/Essentials/src/net/ess3/commands/Commandmsg.java
index e4052de89..e9ca1429d 100644
--- a/Essentials/src/net/ess3/commands/Commandmsg.java
+++ b/Essentials/src/net/ess3/commands/Commandmsg.java
@@ -86,7 +86,7 @@ public class Commandmsg extends EssentialsCommand
{
sender.sendMessage(_("msgFormat", translatedMe, matchedPlayer.getDisplayName(), message));
final IUser matchedUser = ess.getUser(matchedPlayer);
- if (sender instanceof Player && (matchedUser.isIgnoringPlayer(ess.getUser(sender)) || matchedUser.isHidden()))
+ if (sender instanceof Player && (matchedUser.isIgnoringPlayer(ess.getUser((Player)sender)) || matchedUser.isHidden()))
{
continue;
}
diff --git a/Essentials/src/net/ess3/commands/Commandr.java b/Essentials/src/net/ess3/commands/Commandr.java
index 6dbebde81..13c488c1e 100644
--- a/Essentials/src/net/ess3/commands/Commandr.java
+++ b/Essentials/src/net/ess3/commands/Commandr.java
@@ -57,7 +57,7 @@ public class Commandr extends EssentialsCommand
if (target instanceof Player)
{
IUser player = ess.getUser((Player)target);
- if (sender instanceof Player && player.isIgnoringPlayer(ess.getUser(sender)))
+ if (sender instanceof Player && player.isIgnoringPlayer(ess.getUser((Player)sender)))
{
return;
}
diff --git a/Essentials/src/net/ess3/listener/EssentialsPlayerListener.java b/Essentials/src/net/ess3/listener/EssentialsPlayerListener.java
index 3baaa6898..b17f94949 100644
--- a/Essentials/src/net/ess3/listener/EssentialsPlayerListener.java
+++ b/Essentials/src/net/ess3/listener/EssentialsPlayerListener.java
@@ -22,7 +22,6 @@ import lombok.Cleanup;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
-import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -463,11 +462,11 @@ public class EssentialsPlayerListener implements Listener
{
if (event.getView().getTopInventory().getType() == InventoryType.PLAYER)
{
- final IUser user = ess.getUser(event.getWhoClicked());
+ final IUser user = ess.getUser((Player)event.getWhoClicked());
final InventoryHolder invHolder = event.getView().getTopInventory().getHolder();
- if (invHolder != null && invHolder instanceof HumanEntity)
+ if (invHolder != null && invHolder instanceof Player)
{
- final IUser invOwner = ess.getUser((HumanEntity)invHolder);
+ final IUser invOwner = ess.getUser((Player)invHolder);
if (user.isInvSee() && (!Permissions.INVSEE_MODIFY.isAuthorized(user)
|| Permissions.INVSEE_PREVENT_MODIFY.isAuthorized(invOwner)
|| !invOwner.isOnline()))
@@ -483,7 +482,7 @@ public class EssentialsPlayerListener implements Listener
{
if (event.getView().getTopInventory().getType() == InventoryType.PLAYER)
{
- final IUser user = ess.getUser(event.getPlayer());
+ final IUser user = ess.getUser((Player)event.getPlayer());
user.setInvSee(false);
}
}