mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 04:20:41 +00:00
Small cleanup of things
This commit is contained in:
parent
27102d1c38
commit
9ca820d45e
7 changed files with 10 additions and 68 deletions
|
@ -3,7 +3,7 @@ package com.earth2me.essentials;
|
||||||
import static com.earth2me.essentials.I18n._;
|
import static com.earth2me.essentials.I18n._;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Animals;
|
import org.bukkit.entity.Ageable;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
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 Player player = (Player)eAttack;
|
||||||
final ItemStack hand = player.getItemInHand();
|
final ItemStack hand = player.getItemInHand();
|
||||||
if (hand != null && hand.getType() == Material.MILK_BUCKET)
|
if (hand != null && hand.getType() == Material.MILK_BUCKET)
|
||||||
{
|
{
|
||||||
((Animals)eDefend).setAge(-24000);
|
((Ageable)eDefend).setBaby();
|
||||||
hand.setType(Material.BUCKET);
|
hand.setType(Material.BUCKET);
|
||||||
player.setItemInHand(hand);
|
player.setItemInHand(hand);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
|
|
|
@ -421,7 +421,7 @@ public class EssentialsPlayerListener implements Listener
|
||||||
{
|
{
|
||||||
final User user = ess.getUser(event.getWhoClicked());
|
final User user = ess.getUser(event.getWhoClicked());
|
||||||
final User invOwner = ess.getUser(event.getView().getPlayer());
|
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"))
|
|| invOwner.isAuthorized("essentials.invsee.preventmodify"))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -164,6 +164,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean canAfford(final double cost)
|
public boolean canAfford(final double cost)
|
||||||
{
|
{
|
||||||
return canAfford(cost, true);
|
return canAfford(cost, true);
|
||||||
|
@ -578,6 +579,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||||
return super.isGodModeEnabled();
|
return super.isGodModeEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getGroup()
|
public String getGroup()
|
||||||
{
|
{
|
||||||
return ess.getPermissionsHandler().getGroup(base);
|
return ess.getPermissionsHandler().getGroup(base);
|
||||||
|
|
|
@ -3,9 +3,7 @@ package com.earth2me.essentials;
|
||||||
import static com.earth2me.essentials.I18n._;
|
import static com.earth2me.essentials.I18n._;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Logger;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
@ -14,7 +12,6 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||||
{
|
{
|
||||||
protected final transient IEssentials ess;
|
protected final transient IEssentials ess;
|
||||||
private final EssentialsConf config;
|
private final EssentialsConf config;
|
||||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
|
||||||
|
|
||||||
protected UserData(Player base, IEssentials ess)
|
protected UserData(Player base, IEssentials ess)
|
||||||
{
|
{
|
||||||
|
@ -149,7 +146,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||||
|
|
||||||
public List<String> getHomes()
|
public List<String> getHomes()
|
||||||
{
|
{
|
||||||
return new ArrayList(homes.keySet());
|
return new ArrayList<String>(homes.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHome(String name, Location loc)
|
public void setHome(String name, Location loc)
|
||||||
|
@ -254,11 +251,13 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||||
config.save();
|
config.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public List<String> getPowertool(ItemStack stack)
|
public List<String> getPowertool(ItemStack stack)
|
||||||
{
|
{
|
||||||
return (List<String>)powertools.get("" + stack.getTypeId());
|
return (List<String>)powertools.get("" + stack.getTypeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public List<String> getPowertool(int id)
|
public List<String> getPowertool(int id)
|
||||||
{
|
{
|
||||||
return (List<String>)powertools.get("" + id);
|
return (List<String>)powertools.get("" + id);
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.earth2me.essentials.user;
|
package com.earth2me.essentials.user;
|
||||||
|
|
||||||
import com.earth2me.essentials.IEssentials;
|
import com.earth2me.essentials.IEssentials;
|
||||||
import com.earth2me.essentials.craftbukkit.OfflineBedLocation;
|
|
||||||
import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
|
import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import lombok.Delegate;
|
import lombok.Delegate;
|
||||||
|
@ -97,11 +96,7 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
|
||||||
@Override
|
@Override
|
||||||
public Location getBedSpawnLocation()
|
public Location getBedSpawnLocation()
|
||||||
{
|
{
|
||||||
if (isOnlineUser()) {
|
return base.getBedSpawnLocation();
|
||||||
return base.getBedSpawnLocation();
|
|
||||||
} else {
|
|
||||||
return OfflineBedLocation.getBedLocation(base.getName(), ess);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue