Small cleanup of things

This commit is contained in:
md_5 2012-04-24 20:30:31 +10:00
parent 27102d1c38
commit 9ca820d45e
7 changed files with 10 additions and 68 deletions

View file

@ -3,7 +3,7 @@ package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Animals;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -60,13 +60,13 @@ public class EssentialsEntityListener implements Listener
}
}
}
else if (eDefend instanceof Animals && eAttack instanceof Player)
else if (eDefend instanceof Ageable && eAttack instanceof Player)
{
final Player player = (Player)eAttack;
final ItemStack hand = player.getItemInHand();
if (hand != null && hand.getType() == Material.MILK_BUCKET)
{
((Animals)eDefend).setAge(-24000);
((Ageable)eDefend).setBaby();
hand.setType(Material.BUCKET);
player.setItemInHand(hand);
player.updateInventory();

View file

@ -421,7 +421,7 @@ public class EssentialsPlayerListener implements Listener
{
final User user = ess.getUser(event.getWhoClicked());
final User invOwner = ess.getUser(event.getView().getPlayer());
if (user.isInvSee() && !user.isAuthorized("essentials.invsee.modify")
if (user.isInvSee() && !user.isAuthorized("essentials.invsee.modify")
|| invOwner.isAuthorized("essentials.invsee.preventmodify"))
{
event.setCancelled(true);

View file

@ -1,10 +1,8 @@
package com.earth2me.essentials;
import com.earth2me.essentials.commands.IEssentialsCommand;
import java.net.InetSocketAddress;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.PlayerInventory;
/**

View file

@ -164,6 +164,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
}
@Override
public boolean canAfford(final double cost)
{
return canAfford(cost, true);
@ -578,6 +579,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return super.isGodModeEnabled();
}
@Override
public String getGroup()
{
return ess.getPermissionsHandler().getGroup(base);

View file

@ -3,9 +3,7 @@ package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.io.File;
import java.util.*;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -14,7 +12,6 @@ public abstract class UserData extends PlayerExtension implements IConf
{
protected final transient IEssentials ess;
private final EssentialsConf config;
private static final Logger logger = Logger.getLogger("Minecraft");
protected UserData(Player base, IEssentials ess)
{
@ -149,7 +146,7 @@ public abstract class UserData extends PlayerExtension implements IConf
public List<String> getHomes()
{
return new ArrayList(homes.keySet());
return new ArrayList<String>(homes.keySet());
}
public void setHome(String name, Location loc)
@ -254,11 +251,13 @@ public abstract class UserData extends PlayerExtension implements IConf
config.save();
}
@SuppressWarnings("unchecked")
public List<String> getPowertool(ItemStack stack)
{
return (List<String>)powertools.get("" + stack.getTypeId());
}
@SuppressWarnings("unchecked")
public List<String> getPowertool(int id)
{
return (List<String>)powertools.get("" + id);

View file

@ -1,52 +0,0 @@
package com.earth2me.essentials.craftbukkit;
import com.earth2me.essentials.IEssentials;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.server.NBTTagCompound;
import net.minecraft.server.WorldNBTStorage;
import org.bukkit.Location;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
public class OfflineBedLocation
{
public static Location getBedLocation(final String playername, final IEssentials ess)
{
try
{
final CraftServer cserver = (CraftServer)ess.getServer();
if (cserver == null)
{
return null;
}
final WorldNBTStorage wnbtStorage = (WorldNBTStorage)cserver.getHandle().playerFileData;
if (wnbtStorage == null)
{
return null;
}
final NBTTagCompound playerStorage = wnbtStorage.getPlayerData(playername);
if (playerStorage == null)
{
return null;
}
if (playerStorage.hasKey("SpawnX") && playerStorage.hasKey("SpawnY") && playerStorage.hasKey("SpawnZ"))
{
String spawnWorld = playerStorage.getString("SpawnWorld");
if ("".equals(spawnWorld))
{
spawnWorld = cserver.getWorlds().get(0).getName();
}
return new Location(cserver.getWorld(spawnWorld), playerStorage.getInt("SpawnX"), playerStorage.getInt("SpawnY"), playerStorage.getInt("SpawnZ"));
}
return null;
}
catch (Throwable ex)
{
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
return null;
}
}
}

View file

@ -1,7 +1,6 @@
package com.earth2me.essentials.user;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.craftbukkit.OfflineBedLocation;
import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
import java.io.File;
import lombok.Delegate;
@ -97,11 +96,7 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
@Override
public Location getBedSpawnLocation()
{
if (isOnlineUser()) {
return base.getBedSpawnLocation();
} else {
return OfflineBedLocation.getBedLocation(base.getName(), ess);
}
return base.getBedSpawnLocation();
}
@Override