diff options
38 files changed, 1657 insertions, 3507 deletions
diff --git a/.gitignore b/.gitignore index 1083defe4..8d1266938 100644 --- a/.gitignore +++ b/.gitignore @@ -38,4 +38,5 @@ /WebPush/nbproject/private /.idea *.iml -/EssentialsSigns/nbproject/private/
\ No newline at end of file +/EssentialsSigns/nbproject/private/ +/Essentials2Compat/nbproject/private/
\ No newline at end of file diff --git a/Essentials/src/com/earth2me/essentials/DescParseTickFormat.java b/Essentials/src/com/earth2me/essentials/DescParseTickFormat.java index bf3037e59..ab8e6d6a3 100644 --- a/Essentials/src/com/earth2me/essentials/DescParseTickFormat.java +++ b/Essentials/src/com/earth2me/essentials/DescParseTickFormat.java @@ -16,9 +16,6 @@ import java.util.*; */ public final class DescParseTickFormat { - // ============================================ - // First some information vars. TODO: Should this be in a config file? - // -------------------------------------------- public static final Map<String, Integer> nameToTicks = new LinkedHashMap<String, Integer>(); public static final Set<String> resetAliases = new HashSet<String>(); public static final int ticksAtMidnight = 18000; diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index e5c64144e..400ef4f81 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -24,6 +24,7 @@ import com.earth2me.essentials.craftbukkit.ItemDupeFix; import com.earth2me.essentials.listener.*; import com.earth2me.essentials.perm.PermissionsHandler; import com.earth2me.essentials.register.payment.Methods; +import com.earth2me.essentials.settings.GroupsHolder; import com.earth2me.essentials.settings.SettingsHolder; import com.earth2me.essentials.user.UserMap; import java.io.File; @@ -65,6 +66,7 @@ public class Essentials extends JavaPlugin implements IEssentials private transient List<IReload> reloadList; private transient IBackup backup; private transient IItemDb itemDb; + private transient IGroups groups; private transient final Methods paymentMethod = new Methods(); private transient PermissionsHandler permissionsHandler; private transient IUserMap userMap; @@ -141,23 +143,25 @@ public class Essentials extends JavaPlugin implements IEssentials execTimer.mark("BukkitCheck"); try { - final EssentialsUpgrade upgrade = new EssentialsUpgrade(this); - upgrade.beforeSettings(); - execTimer.mark("Upgrade"); + //final EssentialsUpgrade upgrade = new EssentialsUpgrade(this); + //upgrade.beforeSettings(); + //execTimer.mark("Upgrade"); reloadList = new ArrayList<IReload>(); settings = new SettingsHolder(this); reloadList.add(settings); execTimer.mark("Settings"); - upgrade.afterSettings(); - execTimer.mark("Upgrade2"); + //upgrade.afterSettings(); + //execTimer.mark("Upgrade2"); i18n.updateLocale(settings.getLocale()); userMap = new UserMap(this); reloadList.add(userMap); execTimer.mark("Init(Usermap)"); + groups = new GroupsHolder(this); + reloadList.add(groups); warps = new Warps(this); reloadList.add(warps); execTimer.mark("Init(Spawn/Warp)"); - worth = new Worth(this.getDataFolder()); + worth = new Worth(this); reloadList.add(worth); itemDb = new ItemDb(this); reloadList.add(itemDb); @@ -429,13 +433,7 @@ public class Essentials extends JavaPlugin implements IEssentials @Override public IGroups getGroups() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public IEssentialsEconomy getEconomy() - { - throw new UnsupportedOperationException("Not supported yet."); + return groups; } @Override diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java deleted file mode 100644 index 12b431bcd..000000000 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ /dev/null @@ -1,156 +0,0 @@ -package com.earth2me.essentials; - -import com.earth2me.essentials.commands.IEssentialsCommand; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.bukkit.ChatColor; -import org.bukkit.event.Event.Priority; - -/*@Deprecated -public interface ISettings extends com.earth2me.essentials.api.ISettings -{ - boolean areSignsDisabled(); - - String format(String format, IUser user); - - String getAnnounceNewPlayerFormat(IUser user); - - boolean getAnnounceNewPlayers(); - - String getBackupCommand(); - - long getBackupInterval(); - - String getChatFormat(String group); - - int getChatRadius(); - - double getCommandCost(IEssentialsCommand cmd); - - double getCommandCost(String label); - - String getCurrencySymbol(); - - int getOversizedStackSize(); - - int getDefaultStackSize(); - - double getHealCooldown(); - - Object getKit(String name); - - Map<String, Object> getKits(); - - String getLocale(); - - String getNewbieSpawn(); - - String getNicknamePrefix(); - - ChatColor getOperatorColor() throws Exception; - - boolean getPerWarpPermission(); - - boolean getProtectBoolean(final String configName, boolean def); - - int getProtectCreeperMaxHeight(); - - List<Integer> getProtectList(final String configName); - - boolean getProtectPreventSpawn(final String creatureName); - - String getProtectString(final String configName); - - boolean getRespawnAtHome(); - - List getMultipleHomes(); - - int getHomeLimit(String set); - - int getHomeLimit(User user); - - boolean getSortListByGroups(); - - int getSpawnMobLimit(); - - int getStartingBalance(); - - double getTeleportCooldown(); - - double getTeleportDelay(); - - boolean hidePermissionlessHelp(); - - boolean isCommandDisabled(final IEssentialsCommand cmd); - - boolean isCommandDisabled(String label); - - boolean isCommandOverridden(String name); - - boolean isCommandRestricted(IEssentialsCommand cmd); - - boolean isCommandRestricted(String label); - - boolean isDebug(); - - boolean isEcoDisabled(); - - boolean isTradeInStacks(int id); - - List<Integer> itemSpawnBlacklist(); - - boolean permissionBasedItemSpawn(); - - boolean showNonEssCommandsInHelp(); - - boolean spawnIfNoHome(); - - boolean warnOnBuildDisallow(); - - boolean warnOnSmite(); - - double getMaxMoney(); - - boolean isEcoLogEnabled(); - - boolean removeGodOnDisconnect(); - - boolean changeDisplayName(); - - boolean isPlayerCommand(String string); - - boolean useBukkitPermissions(); - - boolean addPrefixSuffix(); - - boolean disablePrefix(); - - boolean disableSuffix(); - - long getAutoAfk(); - - long getAutoAfkKick(); - - boolean getFreezeAfkPlayers(); - - boolean areDeathMessagesEnabled(); - - public void setDebug(boolean debug); - - Set<String> getNoGodWorlds(); - - boolean getUpdateBedAtDaytime(); - - boolean getRepairEnchanted(); - - boolean getIsWorldTeleportPermissions(); - - boolean registerBackInListener(); - - public boolean getDisableItemPickupWhileAfk(); - - public Priority getRespawnPriority(); - - long getTpaAcceptCancellation(); -}*/ diff --git a/Essentials/src/com/earth2me/essentials/IUser.java b/Essentials/src/com/earth2me/essentials/IUser.java deleted file mode 100644 index 872e1a6e2..000000000 --- a/Essentials/src/com/earth2me/essentials/IUser.java +++ /dev/null @@ -1,49 +0,0 @@ -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; - - -/** - * @deprecated This will be moved to the api package soon - */ -/*@Deprecated -public interface IUser extends Player, com.earth2me.essentials.api.IUser -{ - long getLastTeleportTimestamp(); - - boolean isAuthorized(String node); - - boolean isAuthorized(IEssentialsCommand cmd); - - boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix); - - void setLastTeleportTimestamp(long time); - - Location getLastLocation(); - - Player getBase(); - - double getMoney(); - - void takeMoney(double value); - - void giveMoney(double value); - - String getGroup(); - - void setLastLocation(); - - Location getHome(String name) throws Exception; - - Location getHome(Location loc) throws Exception; - - boolean isHidden(); - - Teleport getTeleport(); - - void setJail(String jail); -}*/ diff --git a/Essentials/src/com/earth2me/essentials/Kits.java b/Essentials/src/com/earth2me/essentials/Kits.java index a1ea2a8e9..612ea5196 100644 --- a/Essentials/src/com/earth2me/essentials/Kits.java +++ b/Essentials/src/com/earth2me/essentials/Kits.java @@ -16,8 +16,6 @@ import org.bukkit.inventory.ItemStack; public class Kits extends AsyncStorageObjectHolder<com.earth2me.essentials.settings.Kits> implements IKits { - private static final transient Logger LOGGER = Bukkit.getLogger(); - public Kits(final IEssentials ess) { super(ess, com.earth2me.essentials.settings.Kits.class); diff --git a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java deleted file mode 100644 index 42c00ac0a..000000000 --- a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java +++ /dev/null @@ -1,833 +0,0 @@ -package com.earth2me.essentials; - -import com.earth2me.essentials.craftbukkit.OfflineBedLocation; -import static com.earth2me.essentials.I18n._; -import java.net.InetSocketAddress; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.UUID; -import lombok.Delegate; -import org.bukkit.*; -import org.bukkit.block.Block; -import org.bukkit.entity.*; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; -import org.bukkit.map.MapView; -import org.bukkit.permissions.Permission; -import org.bukkit.permissions.PermissionAttachment; -import org.bukkit.permissions.PermissionAttachmentInfo; -import org.bukkit.plugin.Plugin; -import org.bukkit.util.Vector; - - -/*public class OfflinePlayer implements Player -{ - private final transient IEssentials ess; - private transient Location location = new Location(null, 0, 0, 0, 0, 0); - private transient World world; - private final transient UUID uniqueId = UUID.randomUUID(); - @Delegate(types = org.bukkit.OfflinePlayer.class) - private transient org.bukkit.OfflinePlayer base; - - public OfflinePlayer(final String name, final IEssentials ess) - { - this.ess = ess; - this.world = ess.getServer().getWorlds().get(0); - this.base = ess.getServer().getOfflinePlayer(name); - } - - @Override - public void sendMessage(final String string) - { - } - - @Override - public String getDisplayName() - { - return base.getName(); - } - - @Override - public void setDisplayName(String string) - { - } - - @Override - public void setCompassTarget(Location lctn) - { - } - - @Override - public InetSocketAddress getAddress() - { - return null; - } - - @Override - public void kickPlayer(String string) - { - } - - @Override - public PlayerInventory getInventory() - { - return null; - } - - @Override - public ItemStack getItemInHand() - { - return null; - } - - @Override - public void setItemInHand(ItemStack is) - { - } - - @Override - public int getHealth() - { - return 0; - } - - @Override - public void setHealth(int i) - { - } - - @Override - public Egg throwEgg() - { - return null; - } - - @Override - public Snowball throwSnowball() - { - return null; - } - - @Override - public Arrow shootArrow() - { - return null; - } - - @Override - public boolean isInsideVehicle() - { - return false; - } - - @Override - public boolean leaveVehicle() - { - return false; - } - - @Override - public Vehicle getVehicle() - { - return null; - } - - @Override - public Location getLocation() - { - return location; - } - - @Override - public World getWorld() - { - return world; - } - - public void setLocation(Location loc) - { - location = loc; - world = loc.getWorld(); - } - - public void teleportTo(Location lctn) - { - } - - public void teleportTo(Entity entity) - { - } - - @Override - public int getEntityId() - { - return -1; - } - - @Override - public boolean performCommand(String string) - { - return false; - } - - public boolean isPlayer() - { - return false; - } - - @Override - public int getRemainingAir() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void setRemainingAir(int i) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public int getMaximumAir() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void setMaximumAir(int i) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public boolean isSneaking() - { - return false; - } - - @Override - public void setSneaking(boolean bln) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void updateInventory() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void chat(String string) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public double getEyeHeight() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public double getEyeHeight(boolean bln) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public List<Block> getLineOfSight(HashSet<Byte> hs, int i) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public Block getTargetBlock(HashSet<Byte> hs, int i) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public List<Block> getLastTwoTargetBlocks(HashSet<Byte> hs, int i) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public int getFireTicks() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public int getMaxFireTicks() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void setFireTicks(int i) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void remove() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public Server getServer() - { - return ess == null ? null : ess.getServer(); - } - - public Vector getMomentum() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - public void setMomentum(Vector vector) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void setVelocity(Vector vector) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public Vector getVelocity() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void damage(int i) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void damage(int i, Entity entity) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public Location getEyeLocation() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void sendRawMessage(String string) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public Location getCompassTarget() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public int getMaximumNoDamageTicks() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void setMaximumNoDamageTicks(int i) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public int getLastDamage() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void setLastDamage(int i) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public int getNoDamageTicks() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void setNoDamageTicks(int i) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public boolean teleport(Location lctn) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public boolean teleport(Entity entity) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public Entity getPassenger() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public boolean setPassenger(Entity entity) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public boolean isEmpty() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public boolean eject() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void saveData() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void loadData() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public boolean isSleeping() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public int getSleepTicks() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public List<Entity> getNearbyEntities(double d, double d1, double d2) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public boolean isDead() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public float getFallDistance() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void setFallDistance(float f) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void setSleepingIgnored(boolean bln) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public boolean isSleepingIgnored() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void awardAchievement(Achievement a) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void incrementStatistic(Statistic ststc) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void incrementStatistic(Statistic ststc, int i) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void incrementStatistic(Statistic ststc, Material mtrl) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void incrementStatistic(Statistic ststc, Material mtrl, int i) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void playNote(Location lctn, byte b, byte b1) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void sendBlockChange(Location lctn, Material mtrl, byte b) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void sendBlockChange(Location lctn, int i, byte b) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void setLastDamageCause(EntityDamageEvent ede) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public EntityDamageEvent getLastDamageCause() - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public void playEffect(Location lctn, Effect effect, int i) - { - throw new UnsupportedOperationException(_("notSupportedYet")); - } - - @Override - public boolean sendChunkChange(Location lctn, int i, int i1, int i2, byte[] bytes) - { - return true; - } - - @Override - public UUID getUniqueId() - { - return uniqueId; - } - - @Override - public void playNote(Location lctn, Instrument i, Note note) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void setPlayerTime(long l, boolean bln) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public long getPlayerTime() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public long getPlayerTimeOffset() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isPlayerTimeRelative() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void resetPlayerTime() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isPermissionSet(String string) - { - return false; - } - - @Override - public boolean isPermissionSet(Permission prmsn) - { - return false; - } - - @Override - public boolean hasPermission(String string) - { - return false; - } - - @Override - public boolean hasPermission(Permission prmsn) - { - return false; - } - - @Override - public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public PermissionAttachment addAttachment(Plugin plugin) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln, int i) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public PermissionAttachment addAttachment(Plugin plugin, int i) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void removeAttachment(PermissionAttachment pa) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void recalculatePermissions() - { - } - - @Override - public Set<PermissionAttachmentInfo> getEffectivePermissions() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void sendMap(MapView mv) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public GameMode getGameMode() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void setGameMode(GameMode gm) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public int getExperience() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void setExperience(int i) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public int getLevel() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void setLevel(int i) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public int getTotalExperience() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void setTotalExperience(int i) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public float getExhaustion() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void setExhaustion(float f) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public float getSaturation() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void setSaturation(float f) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public int getFoodLevel() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void setFoodLevel(int i) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public Location getBedSpawnLocation() - { - return OfflineBedLocation.getBedLocation(base.getName(), ess); - } - - @Override - public boolean isSprinting() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void setSprinting(boolean bln) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void setPlayerListName(String name) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public String getPlayerListName() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public int getTicksLived() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void setTicksLived(int i) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public int getMaxHealth() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void giveExp(int i) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public float getExp() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void setExp(float f) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean teleport(Location lctn, TeleportCause tc) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean teleport(Entity entity, TeleportCause tc) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public Player getKiller() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - void setName(final String name) - { - if (!this.base.getName().equalsIgnoreCase(name)) { - this.base = ess.getServer().getOfflinePlayer(name); - } - } -} -*/
\ No newline at end of file diff --git a/Essentials/src/com/earth2me/essentials/PlayerExtension.java b/Essentials/src/com/earth2me/essentials/PlayerExtension.java deleted file mode 100644 index a6f7a08c4..000000000 --- a/Essentials/src/com/earth2me/essentials/PlayerExtension.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.earth2me.essentials; - -import lombok.Delegate; -import org.bukkit.command.CommandSender; -import org.bukkit.configuration.serialization.ConfigurationSerializable; -import org.bukkit.entity.Entity; -import org.bukkit.entity.HumanEntity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.permissions.Permissible; -import org.bukkit.permissions.ServerOperator; - - -/*public class PlayerExtension implements Player -{ - @Delegate(types = - { - Player.class, Entity.class, CommandSender.class, ServerOperator.class, - HumanEntity.class, ConfigurationSerializable.class, LivingEntity.class, - Permissible.class - }) - protected Player base; - - public PlayerExtension(final Player base) - { - this.base = base; - } - - public final Player getBase() - { - return base; - } - - public final Player setBase(final Player base) - { - return this.base = base; - } -}*/ diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java deleted file mode 100644 index da3a718b6..000000000 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ /dev/null @@ -1,646 +0,0 @@ -package com.earth2me.essentials; - -import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.commands.IEssentialsCommand; -import java.io.File; -import java.util.*; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.bukkit.ChatColor; -import org.bukkit.event.Event.Priority; -import org.bukkit.inventory.ItemStack; - - -/*public class Settings implements ISettings -{ - private final transient EssentialsConf config; - private final static Logger logger = Logger.getLogger("Minecraft"); - private final transient IEssentials ess; - - public Settings(IEssentials ess) - { - this.ess = ess; - config = new EssentialsConf(new File(ess.getDataFolder(), "config.yml")); - config.setTemplateName("/config.yml"); - reloadConfig(); - } - - @Override - public boolean getRespawnAtHome() - { - return config.getBoolean("respawn-at-home", false); - } - - @Override - public boolean getUpdateBedAtDaytime() - { - return config.getBoolean("update-bed-at-daytime", true); - } - - @Override - public List<String> getMultipleHomes() - { - return config.getKeys("sethome-multiple"); - } - - @Override - public int getHomeLimit(final User user) - { - final List<String> homeList = getMultipleHomes(); - if (homeList == null) - { - //TODO: Replace this code to remove backwards compat, after settings are automatically updated - // return getHomeLimit("default"); - return config.getInt("multiple-homes", 5); - } - int limit = getHomeLimit("default"); - for (String set : homeList) - { - if (user.isAuthorized("essentials.sethome.multiple." + set) && (limit < getHomeLimit(set))) - { - limit = getHomeLimit(set); - } - } - return limit; - } - - @Override - public int getHomeLimit(final String set) - { - return config.getInt("sethome-multiple." + set, config.getInt("sethome-multiple.default", 3)); - } - - @Override - public int getChatRadius() - { - return config.getInt("chat.radius", config.getInt("chat-radius", 0)); - } - - @Override - public double getTeleportDelay() - { - return config.getDouble("teleport-delay", 0); - } - - @Override - public int getOversizedStackSize() - { - return config.getInt("oversized-stacksize", 64); - } - - @Override - public int getDefaultStackSize() - { - return config.getInt("default-stack-size", -1); - } - - @Override - public int getStartingBalance() - { - return config.getInt("starting-balance", 0); - } - - @Override - public boolean isCommandDisabled(final IEssentialsCommand cmd) - { - return isCommandDisabled(cmd.getName()); - } - - @Override - public boolean isCommandDisabled(String label) - { - for (String c : config.getStringList("disabled-commands", new ArrayList<String>(0))) - { - if (!c.equalsIgnoreCase(label)) - { - continue; - } - return true; - } - return config.getBoolean("disable-" + label.toLowerCase(Locale.ENGLISH), false); - } - - @Override - public boolean isCommandRestricted(IEssentialsCommand cmd) - { - return isCommandRestricted(cmd.getName()); - } - - @Override - public boolean isCommandRestricted(String label) - { - for (String c : config.getStringList("restricted-commands", new ArrayList<String>(0))) - { - if (!c.equalsIgnoreCase(label)) - { - continue; - } - return true; - } - return config.getBoolean("restrict-" + label.toLowerCase(Locale.ENGLISH), false); - } - - @Override - public boolean isPlayerCommand(String label) - { - for (String c : config.getStringList("player-commands", new ArrayList<String>(0))) - { - if (!c.equalsIgnoreCase(label)) - { - continue; - } - return true; - } - return false; - } - - @Override - public boolean isCommandOverridden(String name) - { - List<String> defaultList = new ArrayList<String>(1); - defaultList.add("god"); - for (String c : config.getStringList("overridden-commands", defaultList)) - { - if (!c.equalsIgnoreCase(name)) - { - continue; - } - return true; - } - return config.getBoolean("override-" + name.toLowerCase(Locale.ENGLISH), false); - } - - @Override - public double getCommandCost(IEssentialsCommand cmd) - { - return getCommandCost(cmd.getName()); - } - - @Override - public double getCommandCost(String label) - { - double cost = config.getDouble("command-costs." + label, 0.0); - if (cost == 0.0) - { - cost = config.getDouble("cost-" + label, 0.0); - } - return cost; - } - - @Override - public String getNicknamePrefix() - { - return config.getString("nickname-prefix", "~"); - } - - @Override - public double getTeleportCooldown() - { - return config.getDouble("teleport-cooldown", 0); - } - - @Override - public double getHealCooldown() - { - return config.getDouble("heal-cooldown", 0); - } - - @Override - public Object getKit(String name) - { - Map<String, Object> kits = (Map<String, Object>)config.getProperty("kits"); - for (Map.Entry<String, Object> entry : kits.entrySet()) - { - if (entry.getKey().equalsIgnoreCase(name.replace('.', '_').replace('/', '_'))) - { - return entry.getValue(); - } - } - return null; - } - - @Override - public Map<String, Object> getKits() - { - return (Map<String, Object>)config.getProperty("kits"); - } - - @Override - public ChatColor getOperatorColor() throws Exception - { - String colorName = config.getString("ops-name-color", null); - - if (colorName == null) - { - return ChatColor.RED; - } - if ("none".equalsIgnoreCase(colorName) || colorName.isEmpty()) - { - throw new Exception(); - } - - try - { - return ChatColor.valueOf(colorName.toUpperCase(Locale.ENGLISH)); - } - catch (IllegalArgumentException ex) - { - } - - return ChatColor.getByCode(Integer.parseInt(colorName, 16)); - } - - @Override - public int getSpawnMobLimit() - { - return config.getInt("spawnmob-limit", 10); - } - - @Override - public boolean showNonEssCommandsInHelp() - { - return config.getBoolean("non-ess-in-help", true); - } - - @Override - public boolean hidePermissionlessHelp() - { - return config.getBoolean("hide-permissionless-help", true); - } - - @Override - public int getProtectCreeperMaxHeight() - { - return config.getInt("protect.creeper.max-height", -1); - } - - @Override - public boolean areSignsDisabled() - { - return config.getBoolean("signs-disabled", false); - } - - @Override - public long getBackupInterval() - { - return config.getInt("backup.interval", 1440); // 1440 = 24 * 60 - } - - @Override - public String getBackupCommand() - { - return config.getString("backup.command", null); - } - - @Override - public String getChatFormat(String group) - { - return config.getString("chat.group-formats." + (group == null ? "Default" : group), - config.getString("chat.format", "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}")); - } - - @Override - public boolean getAnnounceNewPlayers() - { - return !config.getString("newbies.announce-format", "-").isEmpty(); - } - - @Override - public String getAnnounceNewPlayerFormat(IUser user) - { - return format(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!"), user); - } - - @Override - public String format(String format, IUser user) - { - return format.replace('&', '§').replace("§§", "&").replace("{PLAYER}", user.getDisplayName()).replace("{DISPLAYNAME}", user.getDisplayName()).replace("{GROUP}", user.getGroup()).replace("{USERNAME}", user.getName()).replace("{ADDRESS}", user.getAddress().toString()); - } - - @Override - public String getNewbieSpawn() - { - return config.getString("newbies.spawnpoint", "default"); - } - - @Override - public boolean getPerWarpPermission() - { - return config.getBoolean("per-warp-permission", false); - } - - @Override - public boolean getSortListByGroups() - { - return config.getBoolean("sort-list-by-groups", true); - } - - @Override - public void reloadConfig() - { - config.load(); - noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds", Collections.<String>emptyList())); - } - - @Override - public List<Integer> itemSpawnBlacklist() - { - final List<Integer> epItemSpwn = new ArrayList<Integer>(); - for (String itemName : config.getString("item-spawn-blacklist", "").split(",")) - { - itemName = itemName.trim(); - if (itemName.isEmpty()) - { - continue; - } - ItemStack is; - try - { - is = ess.getItemDb().get(itemName); - epItemSpwn.add(is.getTypeId()); - } - catch (Exception ex) - { - logger.log(Level.SEVERE, _("unknownItemInList", itemName, "item-spawn-blacklist")); - } - } - return epItemSpwn; - } - - @Override - public boolean spawnIfNoHome() - { - return config.getBoolean("spawn-if-no-home", false); - } - - @Override - public boolean warnOnBuildDisallow() - { - return config.getBoolean("protect.disable.warn-on-build-disallow", false); - } - private boolean debug = false; - - @Override - public boolean isDebug() - { - return debug || config.getBoolean("debug", false); - } - - @Override - public boolean warnOnSmite() - { - return config.getBoolean("warn-on-smite", true); - } - - @Override - public boolean permissionBasedItemSpawn() - { - return config.getBoolean("permission-based-item-spawn", false); - } - - @Override - public String getLocale() - { - return config.getString("locale", ""); - } - - @Override - public String getCurrencySymbol() - { - return config.getString("currency-symbol", "$").substring(0, 1).replaceAll("[0-9]", "$"); - } - - @Override - public boolean isTradeInStacks(int id) - { - return config.getBoolean("trade-in-stacks-" + id, false); - } - - @Override - public boolean isEcoDisabled() - { - return config.getBoolean("disable-eco", false); - } - - @Override - public boolean getProtectPreventSpawn(final String creatureName) - { - return config.getBoolean("protect.prevent.spawn." + creatureName, false); - } - - @Override - public List<Integer> getProtectList(final String configName) - { - final List<Integer> list = new ArrayList<Integer>(); - for (String itemName : config.getString(configName, "").split(",")) - { - itemName = itemName.trim(); - if (itemName.isEmpty()) - { - continue; - } - ItemStack itemStack; - try - { - itemStack = ess.getItemDb().get(itemName); - list.add(itemStack.getTypeId()); - } - catch (Exception ex) - { - logger.log(Level.SEVERE, _("unknownItemInList", itemName, configName)); - } - } - return list; - } - - @Override - public String getProtectString(final String configName) - { - return config.getString(configName, null); - } - - @Override - public boolean getProtectBoolean(final String configName, boolean def) - { - return config.getBoolean(configName, def); - } - private final static double MAXMONEY = 10000000000000.0; - - @Override - public double getMaxMoney() - { - double max = config.getDouble("max-money", MAXMONEY); - if (Math.abs(max) > MAXMONEY) - { - max = max < 0 ? -MAXMONEY : MAXMONEY; - } - return max; - } - - @Override - public boolean isEcoLogEnabled() - { - return config.getBoolean("economy-log-enabled", false); - } - - @Override - public boolean removeGodOnDisconnect() - { - return config.getBoolean("remove-god-on-disconnect", false); - } - - @Override - public boolean changeDisplayName() - { - return config.getBoolean("change-displayname", true); - } - - @Override - public boolean useBukkitPermissions() - { - return config.getBoolean("use-bukkit-permissions", false); - } - - @Override - public boolean addPrefixSuffix() - { - return config.getBoolean("add-prefix-suffix", ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat")); - } - - @Override - public boolean disablePrefix() - { - return config.getBoolean("disablePrefix", false); - } - - @Override - public boolean disableSuffix() - { - return config.getBoolean("disableSuffix", false); - } - - @Override - public long getAutoAfk() - { - return config.getLong("auto-afk", 300); - } - - @Override - public long getAutoAfkKick() - { - return config.getLong("auto-afk-kick", -1); - } - - @Override - public boolean getFreezeAfkPlayers() - { - return config.getBoolean("freeze-afk-players", false); - } - - @Override - public boolean areDeathMessagesEnabled() - { - return config.getBoolean("death-messages", true); - } - Set<String> noGodWorlds = new HashSet<String>(); - - @Override - public Set<String> getNoGodWorlds() - { - return noGodWorlds; - } - - @Override - public void setDebug(final boolean debug) - { - this.debug = debug; - } - - @Override - public boolean getRepairEnchanted() - { - return config.getBoolean("repair-enchanted", true); - } - - @Override - public boolean getIsWorldTeleportPermissions() - { - return config.getBoolean("world-teleport-permissions", false); - } - - @Override - public boolean registerBackInListener() - { - return config.getBoolean("register-back-in-listener", false); - } - - @Override - public boolean getDisableItemPickupWhileAfk() - { - return config.getBoolean("disable-item-pickup-while-afk", true); - } - - @Override - public Priority getRespawnPriority() - { - String priority = config.getString("respawn-listener-priority", "normal").toLowerCase(Locale.ENGLISH); - if ("lowest".equals(priority)) - { - return Priority.Lowest; - } - if ("low".equals(priority)) - { - return Priority.Low; - } - if ("normal".equals(priority)) - { - return Priority.Normal; - } - if ("high".equals(priority)) - { - return Priority.High; - } - if ("highest".equals(priority)) - { - return Priority.Highest; - } - return Priority.Normal; - } - - @Override - public long getTpaAcceptCancellation() - { - return config.getLong("tpa-accept-cancellation", 0); - } - - @Override - public com.earth2me.essentials.settings.Settings getData() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void acquireReadLock() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void acquireWriteLock() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void close() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void unlock() - { - throw new UnsupportedOperationException("Not supported yet."); - } -} -*/
\ No newline at end of file diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java deleted file mode 100644 index cc60ec009..000000000 --- a/Essentials/src/com/earth2me/essentials/User.java +++ /dev/null @@ -1,597 +0,0 @@ -package com.earth2me.essentials; - -import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.commands.IEssentialsCommand; -import com.earth2me.essentials.register.payment.Method; -import com.earth2me.essentials.user.CooldownException; -import com.earth2me.essentials.user.UserData.TimestampType; -import java.util.Calendar; -import java.util.GregorianCalendar; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -/*@Deprecated -public class User extends UserData implements Comparable<User>, IReplyTo, IUser -{ - private CommandSender replyTo = null; - private transient User teleportRequester; - private transient boolean teleportRequestHere; - private transient final Teleport teleport; - private transient long teleportRequestTime; - private transient long lastOnlineActivity; - private transient long lastActivity = System.currentTimeMillis(); - private boolean hidden = false; - private transient Location afkPosition; - private static final Logger logger = Logger.getLogger("Minecraft"); - - User(final Player base, final IEssentials ess) - { - super(base, ess); - teleport = new Teleport(this, ess); - afkPosition = getLocation(); - } - - User update(final Player base) - { - setBase(base); - return this; - } - - @Override - public boolean isAuthorized(final IEssentialsCommand cmd) - { - return isAuthorized(cmd, "essentials."); - } - - @Override - public boolean isAuthorized(final IEssentialsCommand cmd, final String permissionPrefix) - { - return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName())); - } - - @Override - public boolean isAuthorized(final String node) - { - if (base instanceof OfflinePlayer) - { - return false; - } - - if (isOp()) - { - return true; - } - - if (isJailed()) - { - return false; - } - - return ess.getPermissionsHandler().hasPermission(base, node); - } - - public void healCooldown() throws Exception - { - final Calendar now = new GregorianCalendar(); - if (getLastHealTimestamp() > 0) - { - final double cooldown = ess.getSettings().getHealCooldown(); - final Calendar cooldownTime = new GregorianCalendar(); - cooldownTime.setTimeInMillis(getLastHealTimestamp()); - cooldownTime.add(Calendar.SECOND, (int)cooldown); - cooldownTime.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0)); - if (cooldownTime.after(now) && !isAuthorized("essentials.heal.cooldown.bypass")) - { - throw new Exception(_("timeBeforeHeal", Util.formatDateDiff(cooldownTime.getTimeInMillis()))); - } - } - setLastHealTimestamp(now.getTimeInMillis()); - } - - @Override - public void giveMoney(final double value) - { - giveMoney(value, null); - } - - public void giveMoney(final double value, final CommandSender initiator) - { - if (value == 0) - { - return; - } - setMoney(getMoney() + value); - sendMessage(_("addedToAccount", Util.formatCurrency(value, ess))); - if (initiator != null) - { - initiator.sendMessage(_("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName())); - } - } - - public void payUser(final User reciever, final double value) throws Exception - { - if (value == 0) - { - return; - } - if (canAfford(value)) - { - setMoney(getMoney() - value); - reciever.setMoney(reciever.getMoney() + value); - sendMessage(_("moneySentTo", Util.formatCurrency(value, ess), reciever.getDisplayName())); - reciever.sendMessage(_("moneyRecievedFrom", Util.formatCurrency(value, ess), getDisplayName())); - } - else - { - throw new Exception(_("notEnoughMoney")); - } - } - - @Override - public void takeMoney(final double value) - { - takeMoney(value, null); - } - - public void takeMoney(final double value, final CommandSender initiator) - { - if (value == 0) - { - return; - } - setMoney(getMoney() - value); - sendMessage(_("takenFromAccount", Util.formatCurrency(value, ess))); - if (initiator != null) - { - initiator.sendMessage(_("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName())); - } - } - - public boolean canAfford(final double cost) - { - final double mon = getMoney(); - return mon >= cost || isAuthorized("essentials.eco.loan"); - } - - public void dispose() - { - this.base = new OfflinePlayer(getName(), ess); - } - - @Override - public void setReplyTo(final CommandSender user) - { - replyTo = user; - } - - @Override - public CommandSender getReplyTo() - { - return replyTo; - } - - @Override - public int compareTo(final User other) - { - return Util.stripColor(this.getDisplayName()).compareToIgnoreCase(Util.stripColor(other.getDisplayName())); - } - - @Override - public boolean equals(final Object object) - { - if (!(object instanceof User)) - { - return false; - } - return this.getName().equalsIgnoreCase(((User)object).getName()); - - } - - @Override - public int hashCode() - { - return this.getName().hashCode(); - } - - public Boolean canSpawnItem(final int itemId) - { - return !ess.getSettings().itemSpawnBlacklist().contains(itemId); - } - - public Location getHome() throws Exception - { - return getHome(getHomes().get(0)); - } - - public void setHome() - { - setHome("home", getLocation()); - } - - public void setHome(final String name) - { - setHome(name, getLocation()); - } - - @Override - public void setLastLocation() - { - setLastLocation(getLocation()); - } - - public void requestTeleport(final User player, final boolean here) - { - teleportRequestTime = System.currentTimeMillis(); - teleportRequester = player; - teleportRequestHere = here; - } - - public User getTeleportRequest() - { - return teleportRequester; - } - - public boolean isTeleportRequestHere() - { - return teleportRequestHere; - } - - public String getNick(boolean addprefixsuffix) - { - final StringBuilder nickname = new StringBuilder(); - final String nick = getNickname(); - if (ess.getSettings().isCommandDisabled("nick") || nick == null || nick.isEmpty() || nick.equals(getName())) - { - nickname.append(getName()); - } - else - { - nickname.append(ess.getSettings().getNicknamePrefix()).append(nick); - } - if (isOp()) - { - try - { - nickname.insert(0, ess.getSettings().getOperatorColor().toString()); - nickname.append("§f"); - } - catch (Exception e) - { - } - } - - if (addprefixsuffix && ess.getSettings().addPrefixSuffix()) - { - if (!ess.getSettings().disablePrefix()) - { - final String prefix = ess.getPermissionsHandler().getPrefix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName()); - nickname.insert(0, prefix); - } - if (!ess.getSettings().disableSuffix()) - { - final String suffix = ess.getPermissionsHandler().getSuffix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName()); - nickname.append(suffix); - if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§")) - { - nickname.append("§f"); - } - } - else - { - nickname.append("§f"); - } - } - - return nickname.toString(); - } - - public void setDisplayNick() - { - String name = getNick(true); - setDisplayName(name); - if (name.length() > 16) - { - name = getNick(false); - } - if (name.length() > 16) - { - name = name.substring(0, name.charAt(15) == '§' ? 15 : 16); - } - try - { - setPlayerListName(name); - } - catch (IllegalArgumentException e) - { - logger.log(Level.INFO, "Playerlist for " + name + " was not updated. Use a shorter displayname prefix."); - } - } - - @Override - public String getDisplayName() - { - if (!(base instanceof OfflinePlayer) && ess.getSettings().changeDisplayName()) - { - setDisplayNick(); - } - return super.getDisplayName() == null ? super.getName() : super.getDisplayName(); - } - - public Teleport getTeleport() - { - return teleport; - } - - public long getLastOnlineActivity() - { - return lastOnlineActivity; - } - - public void setLastOnlineActivity(final long timestamp) - { - lastOnlineActivity = timestamp; - } - - @Override - public double getMoney() - { - if (ess.getPaymentMethod().hasMethod()) - { - try - { - final Method method = ess.getPaymentMethod().getMethod(); - if (!method.hasAccount(this.getName())) - { - throw new Exception(); - } - final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName()); - return account.balance(); - } - catch (Throwable ex) - { - } - } - return super.getMoney(); - } - - @Override - public void setMoney(final double value) - { - if (ess.getPaymentMethod().hasMethod()) - { - try - { - final Method method = ess.getPaymentMethod().getMethod(); - if (!method.hasAccount(this.getName())) - { - throw new Exception(); - } - final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName()); - account.set(value); - } - catch (Throwable ex) - { - } - } - super.setMoney(value); - } - - @Override - public void setAfk(final boolean set) - { - this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set); - if (set && !isAfk()) - { - afkPosition = getLocation(); - } - super.setAfk(set); - } - - @Override - public boolean toggleAfk() - { - final boolean now = super.toggleAfk(); - this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : now); - return now; - } - - @Override - public boolean isHidden() - { - return hidden; - } - - public void setHidden(final boolean hidden) - { - this.hidden = hidden; - } - - //Returns true if status expired during this check - public boolean checkJailTimeout(final long currentTime) - { - if (getJailTimeout() > 0 && getJailTimeout() < currentTime && isJailed()) - { - setJailTimeout(0); - setJailed(false); - sendMessage(_("haveBeenReleased")); - setJail(null); - try - { - getTeleport().back(); - } - catch (Exception ex) - { - } - return true; - } - return false; - } - - //Returns true if status expired during this check - public boolean checkMuteTimeout(final long currentTime) - { - if (getMuteTimeout() > 0 && getMuteTimeout() < currentTime && isMuted()) - { - setMuteTimeout(0); - sendMessage(_("canTalkAgain")); - setMuted(false); - return true; - } - return false; - } - - //Returns true if status expired during this check - public boolean checkBanTimeout(final long currentTime) - { - if (getBanTimeout() > 0 && getBanTimeout() < currentTime && isBanned()) - { - setBanTimeout(0); - setBanned(false); - return true; - } - return false; - } - - public void updateActivity(final boolean broadcast) - { - if (isAfk()) - { - setAfk(false); - if (broadcast && !isHidden()) - { - ess.broadcastMessage(this, _("userIsNotAway", getDisplayName())); - } - } - lastActivity = System.currentTimeMillis(); - } - - public void checkActivity() - { - final long autoafkkick = ess.getSettings().getAutoAfkKick(); - if (autoafkkick > 0 && lastActivity > 0 && (lastActivity + (autoafkkick * 1000)) < System.currentTimeMillis() - && !isHidden() && !isAuthorized("essentials.kick.exempt") && !isAuthorized("essentials.afk.kickexempt")) - { - final String kickReason = _("autoAfkKickReason", autoafkkick / 60.0); - lastActivity = 0; - kickPlayer(kickReason); - - - for (Player player : ess.getServer().getOnlinePlayers()) - { - final User user = ess.getUser(player); - if (user.isAuthorized("essentials.kick.notify")) - { - player.sendMessage(_("playerKicked", Console.NAME, getName(), kickReason)); - } - } - } - final long autoafk = ess.getSettings().getAutoAfk(); - if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis() && isAuthorized("essentials.afk")) - { - setAfk(true); - if (!isHidden()) - { - ess.broadcastMessage(this, _("userIsAway", getDisplayName())); - } - } - } - - public Location getAfkPosition() - { - return afkPosition; - } - - @Override - public boolean toggleGodModeEnabled() - { - if (!isGodModeEnabled()) - { - setFoodLevel(20); - } - return super.toggleGodModeEnabled(); - } - - @Override - public boolean isGodModeEnabled() - { - return (super.isGodModeEnabled() && !ess.getSettings().getNoGodWorlds().contains(getLocation().getWorld().getName())) - || (isAfk() && ess.getSettings().getFreezeAfkPlayers()); - } - - public boolean isGodModeEnabledRaw() - { - return super.isGodModeEnabled(); - } - - public String getGroup() - { - return ess.getPermissionsHandler().getGroup(base); - } - - public boolean inGroup(final String group) - { - return ess.getPermissionsHandler().inGroup(base, group); - } - - public boolean canBuild() - { - return ess.getPermissionsHandler().canBuild(base, getGroup()); - } - - public long getTeleportRequestTime() - { - return teleportRequestTime; - } - - @Override - public void onReload() - { - reloadConfig(); - } - - @Override - public void checkCooldown(TimestampType cooldownType, double cooldown, boolean set, String bypassPermission) throws CooldownException - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public com.earth2me.essentials.user.UserData getData() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void acquireReadLock() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void acquireWriteLock() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void close() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void unlock() - { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void updateDisplayName() - { - throw new UnsupportedOperationException("Not supported yet."); - } -}*/ diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java deleted file mode 100644 index 85e7cd04e..000000000 --- a/Essentials/src/com/earth2me/essentials/UserData.java +++ /dev/null @@ -1,863 +0,0 @@ -package com.earth2me.essentials; - -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; - -/*@Deprecated -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) - { - super(base); - this.ess = ess; - File folder = new File(ess.getDataFolder(), "userdata"); - if (!folder.exists()) - { - folder.mkdirs(); - } - config = new EssentialsConf(new File(folder, Util.sanitizeFileName(base.getName()) + ".yml")); - reloadConfig(); - } - - @Override - public final void reloadConfig() - { - config.load(); - money = _getMoney(); - unlimited = _getUnlimited(); - powertools = _getPowertools(); - homes = _getHomes(); - lastLocation = _getLastLocation(); - lastTeleportTimestamp = _getLastTeleportTimestamp(); - lastHealTimestamp = _getLastHealTimestamp(); - jail = _getJail(); - mails = _getMails(); - savedInventory = _getSavedInventory(); - teleportEnabled = getTeleportEnabled(); - ignoredPlayers = getIgnoredPlayers(); - godmode = getGodModeEnabled(); - muted = getMuted(); - muteTimeout = _getMuteTimeout(); - jailed = getJailed(); - jailTimeout = _getJailTimeout(); - lastLogin = _getLastLogin(); - lastLogout = _getLastLogout(); - lastLoginAddress = _getLastLoginAddress(); - afk = getAfk(); - geolocation = _getGeoLocation(); - isSocialSpyEnabled = _isSocialSpyEnabled(); - isNPC = _isNPC(); - arePowerToolsEnabled = _arePowerToolsEnabled(); - kitTimestamps = _getKitTimestamps(); - } - private double money; - - private double _getMoney() - { - double money = ess.getSettings().getStartingBalance(); - if (config.hasProperty("money")) - { - money = config.getDouble("money", money); - } - if (Math.abs(money) > ess.getSettings().getMaxMoney()) - { - money = money < 0 ? -ess.getSettings().getMaxMoney() : ess.getSettings().getMaxMoney(); - } - return money; - } - - public double getMoney() - { - return money; - } - - public void setMoney(double value) - { - money = value; - if (Math.abs(money) > ess.getSettings().getMaxMoney()) - { - money = money < 0 ? -ess.getSettings().getMaxMoney() : ess.getSettings().getMaxMoney(); - } - config.setProperty("money", value); - config.save(); - } - private Map<String, Object> homes; - - private Map<String, Object> _getHomes() - { - Object o = config.getProperty("homes"); - - if (o instanceof Map) - { - return (Map<String, Object>)o; - } - else - { - return new HashMap<String, Object>(); - } - - } - - public Location getHome(String name) throws Exception - { - Location loc = config.getLocation("homes." + name, getServer()); - if (loc == null) - { - try - { - loc = config.getLocation("homes." + getHomes().get(Integer.parseInt(name) - 1), getServer()); - } - catch (IndexOutOfBoundsException e) - { - return null; - } - catch (NumberFormatException e) - { - return null; - } - } - - return loc; - } - - public Location getHome(final Location world) - { - try - { - Location loc; - for (String home : getHomes()) - { - loc = config.getLocation("homes." + home, getServer()); - if (world.getWorld() == loc.getWorld()) - { - return loc; - } - - } - loc = config.getLocation("homes." + getHomes().get(0), getServer()); - return loc; - } - catch (Exception ex) - { - return null; - } - } - - public List<String> getHomes() - { - return new ArrayList(homes.keySet()); - } - - public void setHome(String name, Location loc) - { - //Invalid names will corrupt the yaml - name = Util.sanitizeFileName(name); - homes.put(name, loc); - config.setProperty("homes." + name, loc); - config.save(); - } - - public void delHome(String name) throws Exception - { - String search = name; - if (!homes.containsKey(search)) - { - search = Util.sanitizeFileName(name); - } - if (homes.containsKey(search)) - { - homes.remove(name); - config.removeProperty("homes." + name); - config.save(); - } - else - { - //TODO: move this message to messages file - throw new Exception("Home " + name + " doesn't exist"); - } - } - - public boolean hasHome() - { - if (config.hasProperty("home")) - { - return true; - } - return false; - } - - public String getNickname() - { - return config.getString("nickname"); - } - - public void setNickname(String nick) - { - config.setProperty("nickname", nick); - config.save(); - } - private List<Integer> unlimited; - - private List<Integer> _getUnlimited() - { - return config.getIntList("unlimited", new ArrayList<Integer>()); - } - - public List<Integer> getUnlimited() - { - return unlimited; - } - - public boolean hasUnlimited(ItemStack stack) - { - return unlimited.contains(stack.getTypeId()); - } - - public void setUnlimited(ItemStack stack, boolean state) - { - if (unlimited.contains(stack.getTypeId())) - { - unlimited.remove(Integer.valueOf(stack.getTypeId())); - } - if (state) - { - unlimited.add(stack.getTypeId()); - } - config.setProperty("unlimited", unlimited); - config.save(); - } - private Map<Integer, Object> powertools; - - @SuppressWarnings("unchecked") - private Map<Integer, Object> _getPowertools() - { - Object o = config.getProperty("powertools"); - - if (o instanceof Map) - { - return (Map<Integer, Object>)o; - } - else - { - return new HashMap<Integer, Object>(); - } - - } - - public void clearAllPowertools() - { - powertools.clear(); - config.setProperty("powertools", powertools); - config.save(); - } - - public List<String> getPowertool(ItemStack stack) - { - return (List<String>)powertools.get(stack.getTypeId()); - } - - public List<String> getPowertool(int id) - { - return (List<String>)powertools.get(id); - } - - public void setPowertool(ItemStack stack, List<String> commandList) - { - if (commandList == null || commandList.isEmpty()) - { - powertools.remove(stack.getTypeId()); - } - else - { - powertools.put(stack.getTypeId(), commandList); - } - config.setProperty("powertools", powertools); - config.save(); - } - - public boolean hasPowerTools() - { - return !powertools.isEmpty(); - } - private Location lastLocation; - - private Location _getLastLocation() - { - try - { - return config.getLocation("lastlocation", getServer()); - } - catch (Exception e) - { - return null; - } - } - - public Location getLastLocation() - { - return lastLocation; - } - - public void setLastLocation(Location loc) - { - if (loc == null || loc.getWorld() == null) - { - return; - } - lastLocation = loc; - config.setProperty("lastlocation", loc); - config.save(); - } - private long lastTeleportTimestamp; - - private long _getLastTeleportTimestamp() - { - return config.getLong("timestamps.lastteleport", 0); - } - - public long getLastTeleportTimestamp() - { - return lastTeleportTimestamp; - } - - public void setLastTeleportTimestamp(long time) - { - lastTeleportTimestamp = time; - config.setProperty("timestamps.lastteleport", time); - config.save(); - } - private long lastHealTimestamp; - - private long _getLastHealTimestamp() - { - return config.getLong("timestamps.lastheal", 0); - } - - public long getLastHealTimestamp() - { - return lastHealTimestamp; - } - - public void setLastHealTimestamp(long time) - { - lastHealTimestamp = time; - config.setProperty("timestamps.lastheal", time); - config.save(); - } - private String jail; - - private String _getJail() - { - return config.getString("jail"); - } - - public String getJail() - { - return jail; - } - - public void setJail(String jail) - { - if (jail == null || jail.isEmpty()) - { - this.jail = null; - config.removeProperty("jail"); - } - else - { - this.jail = jail; - config.setProperty("jail", jail); - } - config.save(); - } - private List<String> mails; - - private List<String> _getMails() - { - return config.getStringList("mail", new ArrayList<String>()); - } - - public List<String> getMails() - { - return mails; - } - - public void setMails(List<String> mails) - { - if (mails == null) - { - config.removeProperty("mail"); - mails = _getMails(); - } - else - { - config.setProperty("mail", mails); - } - this.mails = mails; - config.save(); - } - - public void addMail(String mail) - { - mails.add(mail); - setMails(mails); - } - private ItemStack[] savedInventory; - - public ItemStack[] getSavedInventory() - { - return savedInventory; - } - - private ItemStack[] _getSavedInventory() - { - int size = config.getInt("inventory.size", 0); - if (size < 1 || (getInventory() != null && size > getInventory().getSize())) - { - return null; - } - ItemStack[] is = new ItemStack[size]; - for (int i = 0; i < size; i++) - { - is[i] = config.getItemStack("inventory." + i); - } - return is; - } - - public void setSavedInventory(ItemStack[] is) - { - if (is == null || is.length == 0) - { - savedInventory = null; - config.removeProperty("inventory"); - } - else - { - savedInventory = is; - config.setProperty("inventory.size", is.length); - for (int i = 0; i < is.length; i++) - { - if (is[i] == null || is[i].getType() == Material.AIR) - { - continue; - } - config.setProperty("inventory." + i, is[i]); - } - } - config.save(); - } - private boolean teleportEnabled; - - private boolean getTeleportEnabled() - { - return config.getBoolean("teleportenabled", true); - } - - public boolean isTeleportEnabled() - { - return teleportEnabled; - } - - public void setTeleportEnabled(boolean set) - { - teleportEnabled = set; - config.setProperty("teleportenabled", set); - config.save(); - } - - public boolean toggleTeleportEnabled() - { - boolean ret = !isTeleportEnabled(); - setTeleportEnabled(ret); - return ret; - } - - public boolean toggleSocialSpy() - { - boolean ret = !isSocialSpyEnabled(); - setSocialSpyEnabled(ret); - return ret; - } - private List<String> ignoredPlayers; - - public List<String> getIgnoredPlayers() - { - return config.getStringList("ignore", new ArrayList<String>()); - } - - public void setIgnoredPlayers(List<String> players) - { - if (players == null || players.isEmpty()) - { - ignoredPlayers = new ArrayList<String>(); - config.removeProperty("ignore"); - } - else - { - ignoredPlayers = players; - config.setProperty("ignore", players); - } - config.save(); - } - - public boolean isIgnoredPlayer(String name) - { - return ignoredPlayers.contains(name.toLowerCase(Locale.ENGLISH)); - } - - public void setIgnoredPlayer(String name, boolean set) - { - if (set) - { - ignoredPlayers.add(name.toLowerCase(Locale.ENGLISH)); - } - else - { - ignoredPlayers.remove(name.toLowerCase(Locale.ENGLISH)); - } - setIgnoredPlayers(ignoredPlayers); - } - private boolean godmode; - - private boolean getGodModeEnabled() - { - return config.getBoolean("godmode", false); - } - - public boolean isGodModeEnabled() - { - return godmode; - } - - public void setGodModeEnabled(boolean set) - { - godmode = set; - config.setProperty("godmode", set); - config.save(); - } - - public boolean toggleGodModeEnabled() - { - boolean ret = !isGodModeEnabled(); - setGodModeEnabled(ret); - return ret; - } - private boolean muted; - - private boolean getMuted() - { - return config.getBoolean("muted", false); - } - - public boolean isMuted() - { - return muted; - } - - public void setMuted(boolean set) - { - muted = set; - config.setProperty("muted", set); - config.save(); - } - - public boolean toggleMuted() - { - boolean ret = !isMuted(); - setMuted(ret); - return ret; - } - private long muteTimeout; - - private long _getMuteTimeout() - { - return config.getLong("timestamps.mute", 0); - } - - public long getMuteTimeout() - { - return muteTimeout; - } - - public void setMuteTimeout(long time) - { - muteTimeout = time; - config.setProperty("timestamps.mute", time); - config.save(); - } - private boolean jailed; - - private boolean getJailed() - { - return config.getBoolean("jailed", false); - } - - public boolean isJailed() - { - return jailed; - } - - public void setJailed(boolean set) - { - jailed = set; - config.setProperty("jailed", set); - config.save(); - } - - public boolean toggleJailed() - { - boolean ret = !isJailed(); - setJailed(ret); - return ret; - } - private long jailTimeout; - - private long _getJailTimeout() - { - return config.getLong("timestamps.jail", 0); - } - - public long getJailTimeout() - { - return jailTimeout; - } - - public void setJailTimeout(long time) - { - jailTimeout = time; - config.setProperty("timestamps.jail", time); - config.save(); - } - - public String getBanReason() - { - return config.getString("ban.reason"); - } - - public void setBanReason(String reason) - { - config.setProperty("ban.reason", reason); - config.save(); - } - - public long getBanTimeout() - { - return config.getLong("ban.timeout", 0); - } - - public void setBanTimeout(long time) - { - config.setProperty("ban.timeout", time); - config.save(); - } - private long lastLogin; - - private long _getLastLogin() - { - return config.getLong("timestamps.login", 0); - } - - public long getLastLogin() - { - return lastLogin; - } - - public void setLastLogin(long time) - { - lastLogin = time; - config.setProperty("timestamps.login", time); - config.save(); - } - private long lastLogout; - - private long _getLastLogout() - { - return config.getLong("timestamps.logout", 0); - } - - public long getLastLogout() - { - return lastLogout; - } - - public void setLastLogout(long time) - { - lastLogout = time; - config.setProperty("timestamps.logout", time); - config.save(); - } - private String lastLoginAddress; - - private String _getLastLoginAddress() - { - return config.getString("ipAddress", ""); - } - - public String getLastLoginAddress() - { - return lastLoginAddress; - } - - public void setLastLoginAddress(String address) - { - lastLoginAddress = address; - config.setProperty("ipAddress", address); - config.save(); - } - private boolean afk; - - private boolean getAfk() - { - return config.getBoolean("afk", false); - } - - public boolean isAfk() - { - return afk; - } - - public void setAfk(boolean set) - { - afk = set; - config.setProperty("afk", set); - config.save(); - } - - public boolean toggleAfk() - { - boolean ret = !isAfk(); - setAfk(ret); - return ret; - } - private boolean newplayer; - - private String geolocation; - - private String _getGeoLocation() - { - return config.getString("geolocation"); - } - - public String getGeoLocation() - { - return geolocation; - } - - public void setGeoLocation(String geolocation) - { - if (geolocation == null || geolocation.isEmpty()) - { - this.geolocation = null; - config.removeProperty("geolocation"); - } - else - { - this.geolocation = geolocation; - config.setProperty("geolocation", geolocation); - } - config.save(); - } - private boolean isSocialSpyEnabled; - - private boolean _isSocialSpyEnabled() - { - return config.getBoolean("socialspy", false); - } - - public boolean isSocialSpyEnabled() - { - return isSocialSpyEnabled; - } - - public void setSocialSpyEnabled(boolean status) - { - isSocialSpyEnabled = status; - config.setProperty("socialspy", status); - config.save(); - } - private boolean isNPC; - - private boolean _isNPC() - { - return config.getBoolean("npc", false); - } - - public boolean isNPC() - { - return isNPC; - } - - public void setNPC(boolean set) - { - isNPC = set; - config.setProperty("npc", set); - config.save(); - } - private boolean arePowerToolsEnabled; - - public boolean arePowerToolsEnabled() - { - return arePowerToolsEnabled; - } - - public void setPowerToolsEnabled(boolean set) - { - arePowerToolsEnabled = set; - config.setProperty("powertoolsenabled", set); - config.save(); - } - - public boolean togglePowerToolsEnabled() - { - boolean ret = !arePowerToolsEnabled(); - setPowerToolsEnabled(ret); - return ret; - } - - private boolean _arePowerToolsEnabled() - { - return config.getBoolean("powertoolsenabled", true); - } - private Map<String, Object> kitTimestamps; - - private Map<String, Object> _getKitTimestamps() - { - final Object map = config.getProperty("timestamps.kits"); - - if (map instanceof Map) - { - return (Map<String, Object>)map; - } - else - { - return new HashMap<String, Object>(); - } - } - - public Long getKitTimestamp(final String name) - { - final Number num = (Number)kitTimestamps.get(name.toLowerCase(Locale.ENGLISH)); - return num == null ? null : num.longValue(); - } - - public void setKitTimestamp(final String name, final long time) - { - kitTimestamps.put(name.toLowerCase(Locale.ENGLISH), time); - config.setProperty("timestamps.kits", kitTimestamps); - config.save(); - } - - public void save() - { - config.save(); - } -}*/ diff --git a/Essentials/src/com/earth2me/essentials/UserMap.java b/Essentials/src/com/earth2me/essentials/UserMap.java deleted file mode 100644 index 7f7c5c056..000000000 --- a/Essentials/src/com/earth2me/essentials/UserMap.java +++ /dev/null @@ -1,130 +0,0 @@ -package com.earth2me.essentials; - -import com.earth2me.essentials.api.IUserMap; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.util.concurrent.UncheckedExecutionException; -import java.io.File; -import java.util.Collections; -import java.util.Set; -import java.util.concurrent.ConcurrentSkipListSet; -import java.util.concurrent.ExecutionException; -import org.bukkit.entity.Player; - -/*@Deprecated -public class UserMap extends CacheLoader<String, User> implements IConf, IUserMap -{ - private final transient IEssentials ess; - private final transient Cache<String, User> users = CacheBuilder.newBuilder().softValues().build(this); - private final transient ConcurrentSkipListSet<String> keys = new ConcurrentSkipListSet<String>(); - - public UserMap(final IEssentials ess) - { - super(); - this.ess = ess; - loadAllUsersAsync(ess); - } - - private void loadAllUsersAsync(final IEssentials ess) - { - ess.scheduleAsyncDelayedTask(new Runnable() - { - @Override - public void run() - { - final File userdir = new File(ess.getDataFolder(), "userdata"); - if (!userdir.exists()) - { - return; - } - keys.clear(); - users.invalidateAll(); - for (String string : userdir.list()) - { - if (!string.endsWith(".yml")) - { - continue; - } - final String name = string.substring(0, string.length() - 4); - keys.add(Util.sanitizeFileName(name)); - } - } - }); - } - - public boolean userExists(final String name) - { - return keys.contains(Util.sanitizeFileName(name)); - } - - public User getUser(final String name) - { - try - { - return users.get(Util.sanitizeFileName(name)); - } - catch (ExecutionException ex) - { - return null; - } - catch (UncheckedExecutionException ex) - { - return null; - } - } - - @Override - public User load(final String name) throws Exception - { - for (Player player : ess.getServer().getOnlinePlayers()) - { - if (player.getName().equalsIgnoreCase(name)) - { - keys.add(Util.sanitizeFileName(name)); - return new User(player, ess); - } - } - final File userFile = getUserFile(name); - if (userFile.exists()) - { - keys.add(Util.sanitizeFileName(name)); - return new User(new OfflinePlayer(name, ess), ess); - } - throw new Exception("User not found!"); - } - - @Override - public void reloadConfig() - { - loadAllUsersAsync(ess); - } - - public void removeUser(final String name) - { - keys.remove(Util.sanitizeFileName(name)); - users.invalidate(Util.sanitizeFileName(name)); - } - - public Set<String> getAllUniqueUsers() - { - return Collections.unmodifiableSet(keys); - } - - public int getUniqueUsers() - { - return keys.size(); - } - - public File getUserFile(final String name) - { - final File userFolder = new File(ess.getDataFolder(), "userdata"); - return new File(userFolder, Util.sanitizeFileName(name) + ".yml"); - } - - @Override - public void onReload() - { - loadAllUsersAsync(ess); - } -}*/ diff --git a/Essentials/src/com/earth2me/essentials/Worth.java b/Essentials/src/com/earth2me/essentials/Worth.java index e970f2757..6b56850b1 100644 --- a/Essentials/src/com/earth2me/essentials/Worth.java +++ b/Essentials/src/com/earth2me/essentials/Worth.java @@ -1,62 +1,86 @@ package com.earth2me.essentials; +import com.earth2me.essentials.api.IEssentials; import com.earth2me.essentials.api.IWorth; +import com.earth2me.essentials.storage.AsyncStorageObjectHolder; +import com.earth2me.essentials.storage.EnchantmentLevel; import java.io.File; -import java.util.Locale; -import java.util.logging.Logger; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; +import org.bukkit.material.MaterialData; -public class Worth implements IWorth +public class Worth extends AsyncStorageObjectHolder<com.earth2me.essentials.settings.Worth> implements IWorth { - private static final Logger logger = Logger.getLogger("Minecraft"); - private final EssentialsConf config; - - public Worth(File dataFolder) + public Worth(final IEssentials ess) { - config = new EssentialsConf(new File(dataFolder, "worth.yml")); - config.setTemplateName("/worth.yml"); - config.load(); + super(ess, com.earth2me.essentials.settings.Worth.class); + onReload(false); } - public double getPrice(ItemStack itemStack) + @Override + public double getPrice(final ItemStack itemStack) { - String itemname = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""); - double result; - result = config.getDouble("worth." + itemname + "." + itemStack.getDurability(), Double.NaN); - if (Double.isNaN(result)) - { - result = config.getDouble("worth." + itemname + ".0", Double.NaN); - } - if (Double.isNaN(result)) + this.acquireReadLock(); + try { - result = config.getDouble("worth." + itemname, Double.NaN); + final Map<MaterialData, Double> prices = this.getData().getSell(); + if (prices == null || itemStack == null) + { + return Double.NaN; + } + final Double basePrice = prices.get(itemStack.getData()); + if (basePrice == null || Double.isNaN(basePrice)) + { + return Double.NaN; + } + double multiplier = 1.0; + if (itemStack.getType().getMaxDurability() > 0) { + multiplier *= (double)itemStack.getDurability() / (double)itemStack.getType().getMaxDurability(); + } + if (itemStack.getEnchantments() != null && !itemStack.getEnchantments().isEmpty()) + { + final Map<EnchantmentLevel, Double> enchantmentMultipliers = this.getData().getEnchantmentMultiplier(); + if (enchantmentMultipliers != null) + { + for (Map.Entry<Enchantment, Integer> entry : itemStack.getEnchantments().entrySet()) + { + final Double enchMult = enchantmentMultipliers.get(new EnchantmentLevel(entry.getKey(), entry.getValue())); + if (enchMult != null) + { + multiplier *= enchMult; + } + } + } + } + return basePrice * multiplier; } - if (Double.isNaN(result)) + finally { - result = config.getDouble("worth-" + itemStack.getTypeId(), Double.NaN); + this.unlock(); } - return result; } - public void setPrice(ItemStack itemStack, double price) + @Override + public void setPrice(final ItemStack itemStack, final double price) { - if (itemStack.getType().getData() == null) - { - config.setProperty("worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""), price); - } - else - { - // Bukkit-bug: getDurability still contains the correct value, while getData().getData() is 0. - config.setProperty("worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "") + "." + itemStack.getDurability(), price); + acquireWriteLock(); + try { + if (getData().getSell() == null) { + getData().setSell(new HashMap<MaterialData, Double>()); + } + getData().getSell().put(itemStack.getData(), price); + } finally { + unlock(); } - config.removeProperty("worth-" + itemStack.getTypeId()); - config.save(); } @Override - public void onReload() + public File getStorageFile() throws IOException { - config.load(); + return new File(ess.getDataFolder(), "worth.yml"); } } diff --git a/Essentials/src/com/earth2me/essentials/ChargeException.java b/Essentials/src/com/earth2me/essentials/api/ChargeException.java index 2fa4c7289..2fa4c7289 100644 --- a/Essentials/src/com/earth2me/essentials/ChargeException.java +++ b/Essentials/src/com/earth2me/essentials/api/ChargeException.java diff --git a/Essentials/src/com/earth2me/essentials/api/IEssentials.java b/Essentials/src/com/earth2me/essentials/api/IEssentials.java index eba74e9fa..9da294ca0 100644 --- a/Essentials/src/com/earth2me/essentials/api/IEssentials.java +++ b/Essentials/src/com/earth2me/essentials/api/IEssentials.java @@ -37,8 +37,6 @@ public interface IEssentials extends Plugin IUserMap getUserMap(); IBackup getBackup(); - - IEssentialsEconomy getEconomy(); ICommandHandler getCommandHandler(); diff --git a/Essentials/src/com/earth2me/essentials/api/IEssentialsEconomy.java b/Essentials/src/com/earth2me/essentials/api/IEssentialsEconomy.java deleted file mode 100644 index f94a150de..000000000 --- a/Essentials/src/com/earth2me/essentials/api/IEssentialsEconomy.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.earth2me.essentials.api; - -//TODO: Decide on this files fate -public interface IEssentialsEconomy -{ - double getMoney(String name) throws UserDoesNotExistException; - - void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException; - - void add(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException; - - void subtract(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException; - - void divide(String name, double value) throws UserDoesNotExistException, NoLoanPermittedException; - - void multiply(String name, double value) throws UserDoesNotExistException, NoLoanPermittedException; - - void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException; - - boolean hasEnough(String name, double amount) throws UserDoesNotExistException; - - boolean hasMore(String name, double amount) throws UserDoesNotExistException; - - boolean hasLess(String name, double amount) throws UserDoesNotExistException; - - boolean isNegative(String name) throws UserDoesNotExistException; - - String format(double amount); - - boolean playerExists(String name); - - boolean isNPC(String name) throws UserDoesNotExistException; - - boolean createNPC(String name); - - void removeNPC(String name) throws UserDoesNotExistException; -} diff --git a/Essentials/src/com/earth2me/essentials/settings/geoip/Database.java b/Essentials/src/com/earth2me/essentials/settings/geoip/Database.java new file mode 100644 index 000000000..0e883d0bd --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/settings/geoip/Database.java @@ -0,0 +1,16 @@ +package com.earth2me.essentials.settings.geoip; + +import com.earth2me.essentials.storage.StorageObject; +import lombok.Data; +import lombok.EqualsAndHashCode; + + +@Data +@EqualsAndHashCode(callSuper = false) +public class Database implements StorageObject +{ + boolean showCities = false; + boolean downloadIfMissing = true; + String downloadUrlCity = "http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz"; + String downloadUrl = "http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz"; +} diff --git a/Essentials/src/com/earth2me/essentials/settings/geoip/GeoIP.java b/Essentials/src/com/earth2me/essentials/settings/geoip/GeoIP.java new file mode 100644 index 000000000..65a909ed4 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/settings/geoip/GeoIP.java @@ -0,0 +1,15 @@ +package com.earth2me.essentials.settings.geoip; + +import com.earth2me.essentials.storage.StorageObject; +import lombok.Data; +import lombok.EqualsAndHashCode; + + +@Data +@EqualsAndHashCode(callSuper = false) +public class GeoIP implements StorageObject +{ + private Database database = new Database(); + boolean showOnWhois = true; + boolean showOnLogin = true; +} diff --git a/Essentials/src/com/earth2me/essentials/ManagedFile.java b/Essentials/src/com/earth2me/essentials/storage/ManagedFile.java index 0a2443f29..0a2443f29 100644 --- a/Essentials/src/com/earth2me/essentials/ManagedFile.java +++ b/Essentials/src/com/earth2me/essentials/storage/ManagedFile.java diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index 4c5a49ed2..c78091ea4 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -1,5 +1,5 @@ # This determines the command prefix when there are conflicts (/name:home, /name:help, etc.) -name: Essentials +name: Essentials3 main: com.earth2me.essentials.Essentials # Note to developers: This next line cannot change, or the automatic versioning system will break. version: TeamCity diff --git a/Essentials2Compat/build.xml b/Essentials2Compat/build.xml new file mode 100644 index 000000000..2a6d21a52 --- /dev/null +++ b/Essentials2Compat/build.xml @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- You may freely edit this file. See commented blocks below for --> +<!-- some examples of how to customize the build. --> +<!-- (If you delete it and reopen the project it will be recreated.) --> +<!-- By default, only the Clean and Build commands use this build script. --> +<!-- Commands such as Run, Debug, and Test only use this build script if --> +<!-- the Compile on Save feature is turned off for the project. --> +<!-- You can turn off the Compile on Save (or Deploy on Save) setting --> +<!-- in the project's Project Properties dialog box.--> +<project name="Essentials2Compat" default="default" basedir="."> + <description>Builds, tests, and runs the project Essentials2Compat.</description> + <import file="nbproject/build-impl.xml"/> + <!-- + + There exist several targets which are by default empty and which can be + used for execution of your tasks. These targets are usually executed + before and after some main targets. They are: + + -pre-init: called before initialization of project properties + -post-init: called after initialization of project properties + -pre-compile: called before javac compilation + -post-compile: called after javac compilation + -pre-compile-single: called before javac compilation of single file + -post-compile-single: called after javac compilation of single file + -pre-compile-test: called before javac compilation of JUnit tests + -post-compile-test: called after javac compilation of JUnit tests + -pre-compile-test-single: called before javac compilation of single JUnit test + -post-compile-test-single: called after javac compilation of single JUunit test + -pre-jar: called before JAR building + -post-jar: called after JAR building + -post-clean: called after cleaning build products + + (Targets beginning with '-' are not intended to be called on their own.) + + Example of inserting an obfuscator after compilation could look like this: + + <target name="-post-compile"> + <obfuscate> + <fileset dir="${build.classes.dir}"/> + </obfuscate> + </target> + + For list of available properties check the imported + nbproject/build-impl.xml file. + + + Another way to customize the build is by overriding existing main targets. + The targets of interest are: + + -init-macrodef-javac: defines macro for javac compilation + -init-macrodef-junit: defines macro for junit execution + -init-macrodef-debug: defines macro for class debugging + -init-macrodef-java: defines macro for class execution + -do-jar-with-manifest: JAR building (if you are using a manifest) + -do-jar-without-manifest: JAR building (if you are not using a manifest) + run: execution of project + -javadoc-build: Javadoc generation + test-report: JUnit report generation + + An example of overriding the target for project execution could look like this: + + <target name="run" depends="Essentials2Compat-impl.jar"> + <exec dir="bin" executable="launcher.exe"> + <arg file="${dist.jar}"/> + </exec> + </target> + + Notice that the overridden target depends on the jar target and not only on + the compile target as the regular run target does. Again, for a list of available + properties which you can use, check the target you are overriding in the + nbproject/build-impl.xml file. + + --> +</project> diff --git a/Essentials2Compat/manifest.mf b/Essentials2Compat/manifest.mf new file mode 100644 index 000000000..328e8e5bc --- /dev/null +++ b/Essentials2Compat/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/Essentials2Compat/nbproject/build-impl.xml b/Essentials2Compat/nbproject/build-impl.xml new file mode 100644 index 000000000..117d471db --- /dev/null +++ b/Essentials2Compat/nbproject/build-impl.xml @@ -0,0 +1,1092 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +*** GENERATED FROM project.xml - DO NOT EDIT *** +*** EDIT ../build.xml INSTEAD *** + +For the purpose of easier reading the script +is divided into following sections: + + - initialization + - compilation + - jar + - execution + - debugging + - javadoc + - junit compilation + - junit execution + - junit debugging + - applet + - cleanup + + --> +<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="Essentials2Compat-impl"> + <fail message="Please build using Ant 1.8.0 or higher."> + <condition> + <not> + <antversion atleast="1.8.0"/> + </not> + </condition> + </fail> + <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/> + <!-- + ====================== + INITIALIZATION SECTION + ====================== + --> + <target name="-pre-init"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="-pre-init" name="-init-private"> + <property file="nbproject/private/config.properties"/> + <property file="nbproject/private/configs/${config}.properties"/> + <property file="nbproject/private/private.properties"/> + </target> + <target name="-pre-init-libraries"> + <property location="../lib/nblibraries.properties" name="libraries.path"/> + <dirname file="${libraries.path}" property="libraries.dir.nativedirsep"/> + <pathconvert dirsep="/" property="libraries.dir"> + <path path="${libraries.dir.nativedirsep}"/> + </pathconvert> + <basename file="${libraries.path}" property="libraries.basename" suffix=".properties"/> + <available file="${libraries.dir}/${libraries.basename}-private.properties" property="private.properties.available"/> + </target> + <target depends="-pre-init-libraries" if="private.properties.available" name="-init-private-libraries"> + <loadproperties encoding="ISO-8859-1" srcfile="${libraries.dir}/${libraries.basename}-private.properties"> + <filterchain> + <replacestring from="$${base}" to="${libraries.dir}"/> + <escapeunicode/> + </filterchain> + </loadproperties> + </target> + <target depends="-pre-init,-init-private,-init-private-libraries" name="-init-libraries"> + <loadproperties encoding="ISO-8859-1" srcfile="${libraries.path}"> + <filterchain> + <replacestring from="$${base}" to="${libraries.dir}"/> + <escapeunicode/> + </filterchain> + </loadproperties> + </target> + <target depends="-pre-init,-init-private,-init-libraries" name="-init-user"> + <property file="${user.properties.file}"/> + <!-- The two properties below are usually overridden --> + <!-- by the active platform. Just a fallback. --> + <property name="default.javac.source" value="1.4"/> + <property name="default.javac.target" value="1.4"/> + </target> + <target depends="-pre-init,-init-private,-init-libraries,-init-user" name="-init-project"> + <property file="nbproject/configs/${config}.properties"/> + <property file="nbproject/project.properties"/> + </target> + <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-init-macrodef-property" name="-do-init"> + <available file="${manifest.file}" property="manifest.available"/> + <condition property="splashscreen.available"> + <and> + <not> + <equals arg1="${application.splash}" arg2="" trim="true"/> + </not> + <available file="${application.splash}"/> + </and> + </condition> + <condition property="main.class.available"> + <and> + <isset property="main.class"/> + <not> + <equals arg1="${main.class}" arg2="" trim="true"/> + </not> + </and> + </condition> + <condition property="manifest.available+main.class"> + <and> + <isset property="manifest.available"/> + <isset property="main.class.available"/> + </and> + </condition> + <condition property="do.archive"> + <not> + <istrue value="${jar.archive.disabled}"/> + </not> + </condition> + <condition property="do.mkdist"> + <and> + <isset property="do.archive"/> + <isset property="libs.CopyLibs.classpath"/> + <not> + <istrue value="${mkdist.disabled}"/> + </not> + </and> + </condition> + <condition property="manifest.available+main.class+mkdist.available"> + <and> + <istrue value="${manifest.available+main.class}"/> + <isset property="do.mkdist"/> + </and> + </condition> + <condition property="do.archive+manifest.available"> + <and> + <isset property="manifest.available"/> + <istrue value="${do.archive}"/> + </and> + </condition> + <condition property="do.archive+main.class.available"> + <and> + <isset property="main.class.available"/> + <istrue value="${do.archive}"/> + </and> + </condition> + <condition property="do.archive+splashscreen.available"> + <and> + <isset property="splashscreen.available"/> + <istrue value="${do.archive}"/> + </and> + </condition> + <condition property="do.archive+manifest.available+main.class"> + <and> + <istrue value="${manifest.available+main.class}"/> + <istrue value="${do.archive}"/> + </and> + </condition> + <condition property="manifest.available-mkdist.available"> + <or> + <istrue value="${manifest.available}"/> + <isset property="do.mkdist"/> + </or> + </condition> + <condition property="manifest.available+main.class-mkdist.available"> + <or> + <istrue value="${manifest.available+main.class}"/> + <isset property="do.mkdist"/> + </or> + </condition> + <condition property="have.tests"> + <or> + <available file="${test.src.dir}"/> + </or> + </condition> + <condition property="have.sources"> + <or> + <available file="${src.dir}"/> + </or> + </condition> + <condition property="netbeans.home+have.tests"> + <and> + <isset property="netbeans.home"/> + <isset property="have.tests"/> + </and> + </condition> + <condition property="no.javadoc.preview"> + <and> + <isset property="javadoc.preview"/> + <isfalse value="${javadoc.preview}"/> + </and> + </condition> + <property name="run.jvmargs" value=""/> + <property name="javac.compilerargs" value=""/> + <property name="work.dir" value="${basedir}"/> + <condition property="no.deps"> + <and> + <istrue value="${no.dependencies}"/> + </and> + </condition> + <property name="javac.debug" value="true"/> + <property name="javadoc.preview" value="true"/> + <property name="application.args" value=""/> + <property name="source.encoding" value="${file.encoding}"/> + <property name="runtime.encoding" value="${source.encoding}"/> + <condition property="javadoc.encoding.used" value="${javadoc.encoding}"> + <and> + <isset property="javadoc.encoding"/> + <not> + <equals arg1="${javadoc.encoding}" arg2=""/> + </not> + </and> + </condition> + <property name="javadoc.encoding.used" value="${source.encoding}"/> + <property name="includes" value="**"/> + <property name="excludes" value=""/> + <property name="do.depend" value="false"/> + <condition property="do.depend.true"> + <istrue value="${do.depend}"/> + </condition> + <path id="endorsed.classpath.path" path="${endorsed.classpath}"/> + <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'"> + <length length="0" string="${endorsed.classpath}" when="greater"/> + </condition> + <condition else="false" property="jdkBug6558476"> + <and> + <matches pattern="1\.[56]" string="${java.specification.version}"/> + <not> + <os family="unix"/> + </not> + </and> + </condition> + <property name="javac.fork" value="${jdkBug6558476}"/> + <property name="jar.index" value="false"/> + <property name="jar.index.metainf" value="${jar.index}"/> + <property name="copylibs.rebase" value="true"/> + <available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/> + </target> + <target name="-post-init"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init" name="-init-check"> + <fail unless="src.dir">Must set src.dir</fail> + <fail unless="test.src.dir">Must set test.src.dir</fail> + <fail unless="build.dir">Must set build.dir</fail> + <fail unless="dist.dir">Must set dist.dir</fail> + <fail unless="build.classes.dir">Must set build.classes.dir</fail> + <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail> + <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail> + <fail unless="build.test.results.dir">Must set build.test.results.dir</fail> + <fail unless="build.classes.excludes">Must set build.classes.excludes</fail> + <fail unless="dist.jar">Must set dist.jar</fail> + </target> + <target name="-init-macrodef-property"> + <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1"> + <attribute name="name"/> + <attribute name="value"/> + <sequential> + <property name="@{name}" value="${@{value}}"/> + </sequential> + </macrodef> + </target> + <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-macrodef-javac-with-processors"> + <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${src.dir}" name="srcdir"/> + <attribute default="${build.classes.dir}" name="destdir"/> + <attribute default="${javac.classpath}" name="classpath"/> + <attribute default="${javac.processorpath}" name="processorpath"/> + <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/> + <attribute default="${includes}" name="includes"/> + <attribute default="${excludes}" name="excludes"/> + <attribute default="${javac.debug}" name="debug"/> + <attribute default="${empty.dir}" name="sourcepath"/> + <attribute default="${empty.dir}" name="gensrcdir"/> + <element name="customize" optional="true"/> + <sequential> + <property location="${build.dir}/empty" name="empty.dir"/> + <mkdir dir="${empty.dir}"/> + <mkdir dir="@{apgeneratedsrcdir}"/> + <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}"> + <src> + <dirset dir="@{gensrcdir}" erroronmissingdir="false"> + <include name="*"/> + </dirset> + </src> + <classpath> + <path path="@{classpath}"/> + </classpath> + <compilerarg line="${endorsed.classpath.cmd.line.arg}"/> + <compilerarg line="${javac.compilerargs}"/> + <compilerarg value="-processorpath"/> + <compilerarg path="@{processorpath}:${empty.dir}"/> + <compilerarg line="${ap.processors.internal}"/> + <compilerarg line="${annotation.processing.processor.options}"/> + <compilerarg value="-s"/> + <compilerarg path="@{apgeneratedsrcdir}"/> + <compilerarg line="${ap.proc.none.internal}"/> + <customize/> + </javac> + </sequential> + </macrodef> + </target> + <target depends="-init-ap-cmdline-properties" name="-init-macrodef-javac-without-processors" unless="ap.supported.internal"> + <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${src.dir}" name="srcdir"/> + <attribute default="${build.classes.dir}" name="destdir"/> + <attribute default="${javac.classpath}" name="classpath"/> + <attribute default="${javac.processorpath}" name="processorpath"/> + <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/> + <attribute default="${includes}" name="includes"/> + <attribute default="${excludes}" name="excludes"/> + <attribute default="${javac.debug}" name="debug"/> + <attribute default="${empty.dir}" name="sourcepath"/> + <attribute default="${empty.dir}" name="gensrcdir"/> + <element name="customize" optional="true"/> + <sequential> + <property location="${build.dir}/empty" name="empty.dir"/> + <mkdir dir="${empty.dir}"/> + <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}"> + <src> + <dirset dir="@{gensrcdir}" erroronmissingdir="false"> + <include name="*"/> + </dirset> + </src> + <classpath> + <path path="@{classpath}"/> + </classpath> + <compilerarg line="${endorsed.classpath.cmd.line.arg}"/> + <compilerarg line="${javac.compilerargs}"/> + <customize/> + </javac> + </sequential> + </macrodef> + </target> + <target depends="-init-macrodef-javac-with-processors,-init-macrodef-javac-without-processors" name="-init-macrodef-javac"> + <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${src.dir}" name="srcdir"/> + <attribute default="${build.classes.dir}" name="destdir"/> + <attribute default="${javac.classpath}" name="classpath"/> + <sequential> + <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}"> + <classpath> + <path path="@{classpath}"/> + </classpath> + </depend> + </sequential> + </macrodef> + <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${build.classes.dir}" name="destdir"/> + <sequential> + <fail unless="javac.includes">Must set javac.includes</fail> + <pathconvert pathsep="${line.separator}" property="javac.includes.binary"> + <path> + <filelist dir="@{destdir}" files="${javac.includes}"/> + </path> + <globmapper from="*.java" to="*.class"/> + </pathconvert> + <tempfile deleteonexit="true" property="javac.includesfile.binary"/> + <echo file="${javac.includesfile.binary}" message="${javac.includes.binary}"/> + <delete> + <files includesfile="${javac.includesfile.binary}"/> + </delete> + <delete> + <fileset file="${javac.includesfile.binary}"/> + </delete> + </sequential> + </macrodef> + </target> + <target name="-init-macrodef-junit"> + <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${includes}" name="includes"/> + <attribute default="${excludes}" name="excludes"/> + <attribute default="**" name="testincludes"/> + <sequential> + <property name="junit.forkmode" value="perTest"/> + <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}"> + <batchtest todir="${build.test.results.dir}"> + <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}"> + <filename name="@{testincludes}"/> + </fileset> + </batchtest> + <classpath> + <path path="${run.test.classpath}"/> + </classpath> + <syspropertyset> + <propertyref prefix="test-sys-prop."/> + <mapper from="test-sys-prop.*" to="*" type="glob"/> + </syspropertyset> + <formatter type="brief" usefile="false"/> + <formatter type="xml"/> + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/> + <jvmarg value="-ea"/> + <jvmarg line="${run.jvmargs}"/> + </junit> + </sequential> + </macrodef> + </target> + <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" name="profile-init"/> + <target name="-profile-pre-init"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target name="-profile-post-init"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target name="-profile-init-macrodef-profile"> + <macrodef name="resolve"> + <attribute name="name"/> + <attribute name="value"/> + <sequential> + <property name="@{name}" value="${env.@{value}}"/> + </sequential> + </macrodef> + <macrodef name="profile"> + <attribute default="${main.class}" name="classname"/> + <element name="customize" optional="true"/> + <sequential> + <property environment="env"/> + <resolve name="profiler.current.path" value="${profiler.info.pathvar}"/> + <java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}"> + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/> + <jvmarg value="${profiler.info.jvmargs.agent}"/> + <jvmarg line="${profiler.info.jvmargs}"/> + <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/> + <arg line="${application.args}"/> + <classpath> + <path path="${run.classpath}"/> + </classpath> + <syspropertyset> + <propertyref prefix="run-sys-prop."/> + <mapper from="run-sys-prop.*" to="*" type="glob"/> + </syspropertyset> + <customize/> + </java> + </sequential> + </macrodef> + </target> + <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile" name="-profile-init-check"> + <fail unless="profiler.info.jvm">Must set JVM to use for profiling in profiler.info.jvm</fail> + <fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail> + </target> + <target depends="-init-debug-args" name="-init-macrodef-nbjpda"> + <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1"> + <attribute default="${main.class}" name="name"/> + <attribute default="${debug.classpath}" name="classpath"/> + <attribute default="" name="stopclassname"/> + <sequential> + <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}"> + <classpath> + <path path="@{classpath}"/> + </classpath> + </nbjpdastart> + </sequential> + </macrodef> + <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1"> + <attribute default="${build.classes.dir}" name="dir"/> + <sequential> + <nbjpdareload> + <fileset dir="@{dir}" includes="${fix.classes}"> + <include name="${fix.includes}*.class"/> + </fileset> + </nbjpdareload> + </sequential> + </macrodef> + </target> + <target name="-init-debug-args"> + <property name="version-output" value="java version "${ant.java.version}"/> + <condition property="have-jdk-older-than-1.4"> + <or> + <contains string="${version-output}" substring="java version "1.0"/> + <contains string="${version-output}" substring="java version "1.1"/> + <contains string="${version-output}" substring="java version "1.2"/> + <contains string="${version-output}" substring="java version "1.3"/> + </or> + </condition> + <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none"> + <istrue value="${have-jdk-older-than-1.4}"/> + </condition> + <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem"> + <os family="windows"/> + </condition> + <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}"> + <isset property="debug.transport"/> + </condition> + </target> + <target depends="-init-debug-args" name="-init-macrodef-debug"> + <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${main.class}" name="classname"/> + <attribute default="${debug.classpath}" name="classpath"/> + <element name="customize" optional="true"/> + <sequential> + <java classname="@{classname}" dir="${work.dir}" fork="true"> + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/> + <jvmarg line="${debug-args-line}"/> + <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/> + <jvmarg value="-Dfile.encoding=${runtime.encoding}"/> + <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/> + <jvmarg line="${run.jvmargs}"/> + <classpath> + <path path="@{classpath}"/> + </classpath> + <syspropertyset> + <propertyref prefix="run-sys-prop."/> + <mapper from="run-sys-prop.*" to="*" type="glob"/> + </syspropertyset> + <customize/> + </java> + </sequential> + </macrodef> + </target> + <target name="-init-macrodef-java"> + <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1"> + <attribute default="${main.class}" name="classname"/> + <attribute default="${run.classpath}" name="classpath"/> + <element name="customize" optional="true"/> + <sequential> + <java classname="@{classname}" dir="${work.dir}" fork="true"> + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/> + <jvmarg value="-Dfile.encoding=${runtime.encoding}"/> + <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/> + <jvmarg line="${run.jvmargs}"/> + <classpath> + <path path="@{classpath}"/> + </classpath> + <syspropertyset> + <propertyref prefix="run-sys-prop."/> + <mapper from="run-sys-prop.*" to="*" type="glob"/> + </syspropertyset> + <customize/> + </java> + </sequential> + </macrodef> + </target> + <target name="-init-macrodef-copylibs"> + <macrodef name="copylibs" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${manifest.file}" name="manifest"/> + <element name="customize" optional="true"/> + <sequential> + <property location="${build.classes.dir}" name="build.classes.dir.resolved"/> + <pathconvert property="run.classpath.without.build.classes.dir"> + <path path="${run.classpath}"/> + <map from="${build.classes.dir.resolved}" to=""/> + </pathconvert> + <pathconvert pathsep=" " property="jar.classpath"> + <path path="${run.classpath.without.build.classes.dir}"/> + <chainedmapper> + <flattenmapper/> + <globmapper from="*" to="lib/*"/> + </chainedmapper> + </pathconvert> + <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/> + <copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}"> + <fileset dir="${build.classes.dir}"/> + <manifest> + <attribute name="Class-Path" value="${jar.classpath}"/> + <customize/> + </manifest> + </copylibs> + </sequential> + </macrodef> + </target> + <target name="-init-presetdef-jar"> + <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1"> + <jar compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}"> + <j2seproject1:fileset dir="${build.classes.dir}"/> + </jar> + </presetdef> + </target> + <target name="-init-ap-cmdline-properties"> + <property name="annotation.processing.enabled" value="true"/> + <property name="annotation.processing.processors.list" value=""/> + <property name="annotation.processing.processor.options" value=""/> + <property name="annotation.processing.run.all.processors" value="true"/> + <property name="javac.processorpath" value="${javac.classpath}"/> + <property name="javac.test.processorpath" value="${javac.test.classpath}"/> + <condition property="ap.supported.internal" value="true"> + <not> + <matches pattern="1\.[0-5](\..*)?" string="${javac.source}"/> + </not> + </condition> + </target> + <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-ap-cmdline-supported"> + <condition else="" property="ap.processors.internal" value="-processor ${annotation.processing.processors.list}"> + <isfalse value="${annotation.processing.run.all.processors}"/> + </condition> + <condition else="" property="ap.proc.none.internal" value="-proc:none"> + <isfalse value="${annotation.processing.enabled}"/> + </condition> + </target> + <target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline"> + <property name="ap.cmd.line.internal" value=""/> + </target> + <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/> + <!-- + =================== + COMPILATION SECTION + =================== + --> + <target name="-deps-jar-init" unless="built-jar.properties"> + <property location="${build.dir}/built-jar.properties" name="built-jar.properties"/> + <delete file="${built-jar.properties}" quiet="true"/> + </target> + <target if="already.built.jar.${basedir}" name="-warn-already-built-jar"> + <echo level="warn" message="Cycle detected: Essentials2Compat was already built"/> + </target> + <target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps"> + <mkdir dir="${build.dir}"/> + <touch file="${built-jar.properties}" verbose="false"/> + <property file="${built-jar.properties}" prefix="already.built.jar."/> + <antcall target="-warn-already-built-jar"/> + <propertyfile file="${built-jar.properties}"> + <entry key="${basedir}" value=""/> + </propertyfile> + <antcall target="-maybe-call-dep"> + <param name="call.built.properties" value="${built-jar.properties}"/> + <param location="${project.Essentials}" name="call.subproject"/> + <param location="${project.Essentials}/build.xml" name="call.script"/> + <param name="call.target" value="jar"/> + <param name="transfer.built-jar.properties" value="${built-jar.properties}"/> + </antcall> + </target> + <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/> + <target depends="init" name="-check-automatic-build"> + <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/> + </target> + <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build"> + <antcall target="clean"/> + </target> + <target depends="init,deps-jar" name="-pre-pre-compile"> + <mkdir dir="${build.classes.dir}"/> + </target> + <target name="-pre-compile"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target if="do.depend.true" name="-compile-depend"> + <pathconvert property="build.generated.subdirs"> + <dirset dir="${build.generated.sources.dir}" erroronmissingdir="false"> + <include name="*"/> + </dirset> + </pathconvert> + <j2seproject3:depend srcdir="${src.dir}:${build.generated.subdirs}"/> + </target> + <target depends="init,deps-jar,-pre-pre-compile,-pre-compile, -copy-persistence-xml,-compile-depend" if="have.sources" name="-do-compile"> + <j2seproject3:javac gensrcdir="${build.generated.sources.dir}"/> + <copy todir="${build.classes.dir}"> + <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/> + </copy> + </target> + <target if="has.persistence.xml" name="-copy-persistence-xml"> + <mkdir dir="${build.classes.dir}/META-INF"/> + <copy todir="${build.classes.dir}/META-INF"> + <fileset dir="${meta.inf.dir}" includes="persistence.xml"/> + </copy> + </target> + <target name="-post-compile"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/> + <target name="-pre-compile-single"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single"> + <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail> + <j2seproject3:force-recompile/> + <j2seproject3:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}" sourcepath="${src.dir}"/> + </target> + <target name="-post-compile-single"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/> + <!-- + ==================== + JAR BUILDING SECTION + ==================== + --> + <target depends="init" name="-pre-pre-jar"> + <dirname file="${dist.jar}" property="dist.jar.dir"/> + <mkdir dir="${dist.jar.dir}"/> + </target> + <target name="-pre-jar"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive" name="-do-jar-without-manifest" unless="manifest.available-mkdist.available"> + <j2seproject1:jar/> + </target> + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive+manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class-mkdist.available"> + <j2seproject1:jar manifest="${manifest.file}"/> + </target> + <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive+manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available"> + <j2seproject1:jar manifest="${manifest.file}"> + <j2seproject1:manifest> + <j2seproject1:attribute name="Main-Class" value="${main.class}"/> + </j2seproject1:manifest> + </j2seproject1:jar> + <echo level="info">To run this application from the command line without Ant, try:</echo> + <property location="${build.classes.dir}" name="build.classes.dir.resolved"/> + <property location="${dist.jar}" name="dist.jar.resolved"/> + <pathconvert property="run.classpath.with.dist.jar"> + <path path="${run.classpath}"/> + <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/> + </pathconvert> + <echo level="info">java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo> + </target> + <target depends="init" if="do.archive" name="-do-jar-with-libraries-create-manifest" unless="manifest.available"> + <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/> + <touch file="${tmp.manifest.file}" verbose="false"/> + </target> + <target depends="init" if="do.archive+manifest.available" name="-do-jar-with-libraries-copy-manifest"> + <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/> + <copy file="${manifest.file}" tofile="${tmp.manifest.file}"/> + </target> + <target depends="init,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest" if="do.archive+main.class.available" name="-do-jar-with-libraries-set-main"> + <manifest file="${tmp.manifest.file}" mode="update"> + <attribute name="Main-Class" value="${main.class}"/> + </manifest> + </target> + <target depends="init,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest" if="do.archive+splashscreen.available" name="-do-jar-with-libraries-set-splashscreen"> + <basename file="${application.splash}" property="splashscreen.basename"/> + <mkdir dir="${build.classes.dir}/META-INF"/> + <copy failonerror="false" file="${application.splash}" todir="${build.classes.dir}/META-INF"/> + <manifest file="${tmp.manifest.file}" mode="update"> + <attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/> + </manifest> + </target> + <target depends="init,-init-macrodef-copylibs,compile,-pre-pre-jar,-pre-jar,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest,-do-jar-with-libraries-set-main,-do-jar-with-libraries-set-splashscreen" if="do.mkdist" name="-do-jar-with-libraries-pack"> + <j2seproject3:copylibs manifest="${tmp.manifest.file}"/> + <echo level="info">To run this application from the command line without Ant, try:</echo> + <property location="${dist.jar}" name="dist.jar.resolved"/> + <echo level="info">java -jar "${dist.jar.resolved}"</echo> + </target> + <target depends="-do-jar-with-libraries-pack" if="do.archive" name="-do-jar-with-libraries-delete-manifest"> + <delete> + <fileset file="${tmp.manifest.file}"/> + </delete> + </target> + <target depends="init,compile,-pre-pre-jar,-pre-jar,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest,-do-jar-with-libraries-set-main,-do-jar-with-libraries-set-splashscreen,-do-jar-with-libraries-pack,-do-jar-with-libraries-delete-manifest" name="-do-jar-with-libraries"/> + <target name="-post-jar"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/> + <!-- + ================= + EXECUTION SECTION + ================= + --> + <target depends="init,compile" description="Run a main class." name="run"> + <j2seproject1:java> + <customize> + <arg line="${application.args}"/> + </customize> + </j2seproject1:java> + </target> + <target name="-do-not-recompile"> + <property name="javac.includes.binary" value=""/> + </target> + <target depends="init,compile-single" name="run-single"> + <fail unless="run.class">Must select one file in the IDE or set run.class</fail> + <j2seproject1:java classname="${run.class}"/> + </target> + <target depends="init,compile-test-single" name="run-test-with-main"> + <fail unless="run.class">Must select one file in the IDE or set run.class</fail> + <j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/> + </target> + <!-- + ================= + DEBUGGING SECTION + ================= + --> + <target depends="init" if="netbeans.home" name="-debug-start-debugger"> + <j2seproject1:nbjpdastart name="${debug.class}"/> + </target> + <target depends="init" if="netbeans.home" name="-debug-start-debugger-main-test"> + <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${debug.class}"/> + </target> + <target depends="init,compile" name="-debug-start-debuggee"> + <j2seproject3:debug> + <customize> + <arg line="${application.args}"/> + </customize> + </j2seproject3:debug> + </target> + <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/> + <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto"> + <j2seproject1:nbjpdastart stopclassname="${main.class}"/> + </target> + <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/> + <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single"> + <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail> + <j2seproject3:debug classname="${debug.class}"/> + </target> + <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/> + <target depends="init,compile-test-single" if="netbeans.home" name="-debug-start-debuggee-main-test"> + <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail> + <j2seproject3:debug classname="${debug.class}" classpath="${debug.test.classpath}"/> + </target> + <target depends="init,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/> + <target depends="init" name="-pre-debug-fix"> + <fail unless="fix.includes">Must set fix.includes</fail> + <property name="javac.includes" value="${fix.includes}.java"/> + </target> + <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix"> + <j2seproject1:nbjpdareload/> + </target> + <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/> + <!-- + ================= + PROFILING SECTION + ================= + --> + <target depends="profile-init,compile" description="Profile a project in the IDE." if="netbeans.home" name="profile"> + <nbprofiledirect> + <classpath> + <path path="${run.classpath}"/> + </classpath> + </nbprofiledirect> + <profile/> + </target> + <target depends="profile-init,compile-single" description="Profile a selected class in the IDE." if="netbeans.home" name="profile-single"> + <fail unless="profile.class">Must select one file in the IDE or set profile.class</fail> + <nbprofiledirect> + <classpath> + <path path="${run.classpath}"/> + </classpath> + </nbprofiledirect> + <profile classname="${profile.class}"/> + </target> + <!-- + ========================= + APPLET PROFILING SECTION + ========================= + --> + <target depends="profile-init,compile-single" if="netbeans.home" name="profile-applet"> + <nbprofiledirect> + <classpath> + <path path="${run.classpath}"/> + </classpath> + </nbprofiledirect> + <profile classname="sun.applet.AppletViewer"> + <customize> + <arg value="${applet.url}"/> + </customize> + </profile> + </target> + <!-- + ========================= + TESTS PROFILING SECTION + ========================= + --> + <target depends="profile-init,compile-test-single" if="netbeans.home" name="profile-test-single"> + <nbprofiledirect> + <classpath> + <path path="${run.test.classpath}"/> + </classpath> + </nbprofiledirect> + <junit dir="${profiler.info.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" jvm="${profiler.info.jvm}" showoutput="true"> + <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/> + <jvmarg value="${profiler.info.jvmargs.agent}"/> + <jvmarg line="${profiler.info.jvmargs}"/> + <test name="${profile.class}"/> + <classpath> + <path path="${run.test.classpath}"/> + </classpath> + <syspropertyset> + <propertyref prefix="test-sys-prop."/> + <mapper from="test-sys-prop.*" to="*" type="glob"/> + </syspropertyset> + <formatter type="brief" usefile="false"/> + <formatter type="xml"/> + </junit> + </target> + <!-- + =============== + JAVADOC SECTION + =============== + --> + <target depends="init" if="have.sources" name="-javadoc-build"> + <mkdir dir="${dist.javadoc.dir}"/> + <condition else="" property="javadoc.endorsed.classpath.cmd.line.arg" value="-J${endorsed.classpath.cmd.line.arg}"> + <and> + <isset property="endorsed.classpath.cmd.line.arg"/> + <not> + <equals arg1="${endorsed.classpath.cmd.line.arg}" arg2=""/> + </not> + </and> + </condition> + <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}"> + <classpath> + <path path="${javac.classpath}"/> + </classpath> + <fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}"> + <filename name="**/*.java"/> + </fileset> + <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false"> + <include name="**/*.java"/> + <exclude name="*.java"/> + </fileset> + <arg line="${javadoc.endorsed.classpath.cmd.line.arg}"/> + </javadoc> + <copy todir="${dist.javadoc.dir}"> + <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}"> + <filename name="**/doc-files/**"/> + </fileset> + <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false"> + <include name="**/doc-files/**"/> + </fileset> + </copy> + </target> + <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview"> + <nbbrowse file="${dist.javadoc.dir}/index.html"/> + </target> + <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/> + <!-- + ========================= + JUNIT COMPILATION SECTION + ========================= + --> + <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test"> + <mkdir dir="${build.test.classes.dir}"/> + </target> + <target name="-pre-compile-test"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target if="do.depend.true" name="-compile-test-depend"> + <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/> + </target> + <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test"> + <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir="${test.src.dir}"/> + <copy todir="${build.test.classes.dir}"> + <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/> + </copy> + </target> + <target name="-post-compile-test"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/> + <target name="-pre-compile-test-single"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single"> + <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail> + <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/> + <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" processorpath="${javac.test.processorpath}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/> + <copy todir="${build.test.classes.dir}"> + <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/> + </copy> + </target> + <target name="-post-compile-test-single"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/> + <!-- + ======================= + JUNIT EXECUTION SECTION + ======================= + --> + <target depends="init" if="have.tests" name="-pre-test-run"> + <mkdir dir="${build.test.results.dir}"/> + </target> + <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run"> + <j2seproject3:junit testincludes="**/*Test.java"/> + </target> + <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run"> + <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail> + </target> + <target depends="init" if="have.tests" name="test-report"/> + <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/> + <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/> + <target depends="init" if="have.tests" name="-pre-test-run-single"> + <mkdir dir="${build.test.results.dir}"/> + </target> + <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single"> + <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail> + <j2seproject3:junit excludes="" includes="${test.includes}"/> + </target> + <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single"> + <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail> + </target> + <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/> + <!-- + ======================= + JUNIT DEBUGGING SECTION + ======================= + --> + <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test"> + <fail unless="test.class">Must select one file in the IDE or set test.class</fail> + <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/> + <delete file="${test.report.file}"/> + <mkdir dir="${build.test.results.dir}"/> + <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}"> + <customize> + <syspropertyset> + <propertyref prefix="test-sys-prop."/> + <mapper from="test-sys-prop.*" to="*" type="glob"/> + </syspropertyset> + <arg value="${test.class}"/> + <arg value="showoutput=true"/> + <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/> + <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/> + </customize> + </j2seproject3:debug> + </target> + <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test"> + <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/> + </target> + <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/> + <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test"> + <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/> + </target> + <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/> + <!-- + ========================= + APPLET EXECUTION SECTION + ========================= + --> + <target depends="init,compile-single" name="run-applet"> + <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail> + <j2seproject1:java classname="sun.applet.AppletViewer"> + <customize> + <arg value="${applet.url}"/> + </customize> + </j2seproject1:java> + </target> + <!-- + ========================= + APPLET DEBUGGING SECTION + ========================= + --> + <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet"> + <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail> + <j2seproject3:debug classname="sun.applet.AppletViewer"> + <customize> + <arg value="${applet.url}"/> + </customize> + </j2seproject3:debug> + </target> + <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/> + <!-- + =============== + CLEANUP SECTION + =============== + --> + <target name="-deps-clean-init" unless="built-clean.properties"> + <property location="${build.dir}/built-clean.properties" name="built-clean.properties"/> + <delete file="${built-clean.properties}" quiet="true"/> + </target> + <target if="already.built.clean.${basedir}" name="-warn-already-built-clean"> + <echo level="warn" message="Cycle detected: Essentials2Compat was already built"/> + </target> + <target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps"> + <mkdir dir="${build.dir}"/> + <touch file="${built-clean.properties}" verbose="false"/> + <property file="${built-clean.properties}" prefix="already.built.clean."/> + <antcall target="-warn-already-built-clean"/> + <propertyfile file="${built-clean.properties}"> + <entry key="${basedir}" value=""/> + </propertyfile> + <antcall target="-maybe-call-dep"> + <param name="call.built.properties" value="${built-clean.properties}"/> + <param location="${project.Essentials}" name="call.subproject"/> + <param location="${project.Essentials}/build.xml" name="call.script"/> + <param name="call.target" value="clean"/> + <param name="transfer.built-clean.properties" value="${built-clean.properties}"/> + </antcall> + </target> + <target depends="init" name="-do-clean"> + <delete dir="${build.dir}"/> + <delete dir="${dist.dir}" followsymlinks="false" includeemptydirs="true"/> + </target> + <target name="-post-clean"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/> + <target name="-check-call-dep"> + <property file="${call.built.properties}" prefix="already.built."/> + <condition property="should.call.dep"> + <not> + <isset property="already.built.${call.subproject}"/> + </not> + </condition> + </target> + <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep"> + <ant antfile="${call.script}" inheritall="false" target="${call.target}"> + <propertyset> + <propertyref prefix="transfer."/> + <mapper from="transfer.*" to="*" type="glob"/> + </propertyset> + </ant> + </target> +</project> diff --git a/Essentials2Compat/nbproject/genfiles.properties b/Essentials2Compat/nbproject/genfiles.properties new file mode 100644 index 000000000..ab97b0ef6 --- /dev/null +++ b/Essentials2Compat/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=cfe919e8 +build.xml.script.CRC32=ec95d082 +build.xml.stylesheet.CRC32=28e38971@1.50.1.46 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=cfe919e8 +nbproject/build-impl.xml.script.CRC32=9b7e0383 +nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46 diff --git a/Essentials2Compat/nbproject/project.properties b/Essentials2Compat/nbproject/project.properties new file mode 100644 index 000000000..99a18a932 --- /dev/null +++ b/Essentials2Compat/nbproject/project.properties @@ -0,0 +1,126 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=Essentials2Compat +application.vendor= +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=2 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=2 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=2 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=120 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAnnotationArgs=true +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineArrayInit=true +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAssignment=true +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineBinaryOp=true +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineCallArgs=true +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineDisjunctiveCatchTypes=true +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineFor=true +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineImplements=true +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineMethodParams=true +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineParenthesized=true +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTernaryOp=true +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineThrows=true +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTryResources=true +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesAfterClassHeader=0 +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesBeforeClass=2 +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement=NEW_LINE +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.expand-tabs=false +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.importGroupsOrder=* +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width=4 +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indentCasesFromSwitch=false +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement=NEW_LINE +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement=NEW_LINE +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeCatchOnNewLine=true +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeElseOnNewLine=true +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeFinallyOnNewLine=true +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeWhileOnNewLine=true +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.separateImportGroups=false +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceAfterTypeCast=false +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaces-per-tab=4 +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.tab-size=4 +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/Essentials2Compat.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +file.reference.bukkit.jar=../lib/bukkit.jar +includes=** +jar.archive.disabled=${jnlp.enabled} +jar.compress=true +jar.index=${jnlp.enabled} +javac.classpath=\ + ${file.reference.bukkit.jar}:\ + ${reference.Essentials.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.6 +javac.target=1.6 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +jnlp.codebase.type=no.codebase +jnlp.descriptor=application +jnlp.enabled=false +jnlp.mixed.code=default +jnlp.offline-allowed=false +jnlp.signed=false +jnlp.signing= +jnlp.signing.alias= +jnlp.signing.keystore= +main.class= +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +project.Essentials=../Essentials +reference.Essentials.jar=${project.Essentials}/dist/Essentials.jar +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/Essentials2Compat/nbproject/project.xml b/Essentials2Compat/nbproject/project.xml new file mode 100644 index 000000000..244dc59a9 --- /dev/null +++ b/Essentials2Compat/nbproject/project.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://www.netbeans.org/ns/project/1"> + <type>org.netbeans.modules.java.j2seproject</type> + <configuration> + <data xmlns="http://www.netbeans.org/ns/j2se-project/3"> + <name>Essentials2Compat</name> + <source-roots> + <root id="src.dir"/> + </source-roots> + <test-roots> + <root id="test.src.dir"/> + </test-roots> + </data> + <libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1"> + <definitions>../lib/nblibraries.properties</definitions> + </libraries> + <references xmlns="http://www.netbeans.org/ns/ant-project-references/1"> + <reference> + <foreign-project>Essentials</foreign-project> + <artifact-type>jar</artifact-type> + <script>build.xml</script> + <target>jar</target> + <clean-target>clean</clean-target> + <id>jar</id> + </reference> + </references> + </configuration> +</project> diff --git a/Essentials2Compat/src/com/earth2me/essentials/Essentials.java b/Essentials2Compat/src/com/earth2me/essentials/Essentials.java new file mode 100644 index 000000000..dc612e8d6 --- /dev/null +++ b/Essentials2Compat/src/com/earth2me/essentials/Essentials.java @@ -0,0 +1,22 @@ +package com.earth2me.essentials; + +import org.bukkit.Bukkit; +import org.bukkit.plugin.java.JavaPlugin; + + +public class Essentials extends JavaPlugin +{ + @Override + public void onEnable() + { + Bukkit.getLogger().info("You can remove this compatibility plugin, when all plugins are updated to Essentials 3"); + //TODO: Update files to new 3.0 format + //TODO: Move Eco Api here + } + + @Override + public void onDisable() + { + throw new UnsupportedOperationException("Not supported yet."); + } +} diff --git a/Essentials/src/com/earth2me/essentials/EssentialsConf.java b/Essentials2Compat/src/com/earth2me/essentials/EssentialsConf.java index 3a37f04b0..3a37f04b0 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsConf.java +++ b/Essentials2Compat/src/com/earth2me/essentials/EssentialsConf.java diff --git a/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java b/Essentials2Compat/src/com/earth2me/essentials/EssentialsUpgrade.java index eef473783..05a5d4797 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java +++ b/Essentials2Compat/src/com/earth2me/essentials/EssentialsUpgrade.java @@ -18,7 +18,7 @@ import org.bukkit.Material; import org.bukkit.World; import org.bukkit.inventory.ItemStack; - +@Deprecated public class EssentialsUpgrade { private final static Logger LOGGER = Logger.getLogger("Minecraft"); @@ -51,7 +51,7 @@ public class EssentialsUpgrade } final EssentialsConf conf = new EssentialsConf(configFile); conf.load(); - final Worth worth = new Worth(ess.getDataFolder()); + final Worth worth = new Worth(ess); boolean found = false; for (Material mat : Material.values()) { diff --git a/Essentials2Compat/src/plugin.yml b/Essentials2Compat/src/plugin.yml new file mode 100644 index 000000000..e3d9afe83 --- /dev/null +++ b/Essentials2Compat/src/plugin.yml @@ -0,0 +1,6 @@ +name: Essentials +main: com.earth2me.essentials.Essentials +version: 2.9 +website: http://tiny.cc/EssentialsWiki +description: Compatibility plugin for older plugins +authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits] diff --git a/EssentialsGeoIP/src/com/earth2me/essentials/geoip/ConfigHolder.java b/EssentialsGeoIP/src/com/earth2me/essentials/geoip/ConfigHolder.java new file mode 100644 index 000000000..e2d82d644 --- /dev/null +++ b/EssentialsGeoIP/src/com/earth2me/essentials/geoip/ConfigHolder.java @@ -0,0 +1,27 @@ +package com.earth2me.essentials.geoip; + +import com.earth2me.essentials.api.IEssentials; +import com.earth2me.essentials.settings.geoip.GeoIP; +import com.earth2me.essentials.storage.AsyncStorageObjectHolder; +import java.io.File; +import java.io.IOException; +import org.bukkit.plugin.Plugin; + +public class ConfigHolder extends AsyncStorageObjectHolder<GeoIP> +{ + private final transient Plugin geoip; + + public ConfigHolder(final IEssentials ess, final Plugin geoip) + { + super(ess, GeoIP.class); + this.geoip = geoip; + onReload(); + } + + @Override + public File getStorageFile() throws IOException + { + return new File(geoip.getDataFolder(), "config.yml"); + } + +} diff --git a/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIP.java b/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIP.java index f9436d7f0..783684ef8 100644 --- a/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIP.java +++ b/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIP.java @@ -36,8 +36,9 @@ public class EssentialsGeoIP extends JavaPlugin this.setEnabled(false); return; } - final EssentialsGeoIPPlayerListener playerListener = new EssentialsGeoIPPlayerListener(getDataFolder(), ess); + final EssentialsGeoIPPlayerListener playerListener = new EssentialsGeoIPPlayerListener(this, ess); pm.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Monitor, this); + ess.addReloadListener(playerListener); logger.info(_("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), "essentials team")); diff --git a/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java b/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java index 5a33fecc9..aa54dbf25 100644 --- a/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java +++ b/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java @@ -1,9 +1,8 @@ package com.earth2me.essentials.geoip; -import com.earth2me.essentials.EssentialsConf; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.api.IReload; import com.earth2me.essentials.api.IEssentials; +import com.earth2me.essentials.api.IReload; import com.earth2me.essentials.api.IUser; import com.maxmind.geoip.Location; import com.maxmind.geoip.LookupService; @@ -19,165 +18,205 @@ import java.util.zip.GZIPInputStream; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerListener; +import org.bukkit.plugin.Plugin; public class EssentialsGeoIPPlayerListener extends PlayerListener implements IReload { - LookupService ls = null; - private static final Logger logger = Logger.getLogger("Minecraft"); - File databaseFile; - File dataFolder; - EssentialsConf config; + private transient LookupService ls = null; + private static final Logger LOGGER = Logger.getLogger("Minecraft"); + private transient File databaseFile; + private final transient ConfigHolder config; private final transient IEssentials ess; + private final transient Plugin geoip; - public EssentialsGeoIPPlayerListener(File dataFolder, IEssentials ess) + public EssentialsGeoIPPlayerListener(final Plugin geoip, final IEssentials ess) { + super(); this.ess = ess; - this.dataFolder = dataFolder; - this.config = new EssentialsConf(new File(dataFolder, "config.yml")); - config.setTemplateName("/config.yml", EssentialsGeoIP.class); + this.geoip = geoip; + this.config = new ConfigHolder(ess, geoip); onReload(); } @Override - public void onPlayerJoin(PlayerJoinEvent event) + public void onPlayerJoin(final PlayerJoinEvent event) { - IUser u = ess.getUser(event.getPlayer()); + final IUser u = ess.getUser(event.getPlayer()); if (u.isAuthorized("essentials.geoip.hide")) { return; } - InetAddress address = event.getPlayer().getAddress().getAddress(); - StringBuilder sb = new StringBuilder(); - if (config.getBoolean("database.show-cities", false)) + config.acquireReadLock(); + try { - Location loc = ls.getLocation(address); - if (loc == null) - { - return; - } - if (loc.city != null) + final InetAddress address = event.getPlayer().getAddress().getAddress(); + final StringBuilder builder = new StringBuilder(); + if (config.getData().getDatabase().isShowCities()) { - sb.append(loc.city).append(", "); - } - String region = regionName.regionNameByCode(loc.countryCode, loc.region); - if (region != null) - { - sb.append(region).append(", "); + final Location loc = ls.getLocation(address); + if (loc == null) + { + return; + } + if (loc.city != null) + { + builder.append(loc.city).append(", "); + } + final String region = regionName.regionNameByCode(loc.countryCode, loc.region); + if (region != null) + { + builder.append(region).append(", "); + } + builder.append(loc.countryName); } - sb.append(loc.countryName); - } - else - { - sb.append(ls.getCountry(address).getName()); - } - if (config.getBoolean("show-on-whois", true)) - { - u.acquireWriteLock(); - try + else { - u.getData().setGeolocation(sb.toString()); + builder.append(ls.getCountry(address).getName()); } - finally + if (config.getData().isShowOnWhois()) { - u.unlock(); + u.acquireWriteLock(); + try + { + u.getData().setGeolocation(builder.toString()); + } + finally + { + u.unlock(); + } } - } - if (config.getBoolean("show-on-login", true) && !u.isHidden()) - { - for (Player player : event.getPlayer().getServer().getOnlinePlayers()) + if (config.getData().isShowOnLogin() && !u.isHidden()) { - IUser user = ess.getUser(player); - if (user.isAuthorized("essentials.geoip.show")) + for (Player player : event.getPlayer().getServer().getOnlinePlayers()) { - user.sendMessage(_("geoipJoinFormat", u.getDisplayName(), sb.toString())); + final IUser user = ess.getUser(player); + if (user.isAuthorized("essentials.geoip.show")) + { + user.sendMessage(_("geoipJoinFormat", user.getDisplayName(), builder.toString())); + } } } } + finally + { + config.unlock(); + } } @Override public final void onReload() { - config.load(); - - if (config.getBoolean("database.show-cities", false)) - { - databaseFile = new File(dataFolder, "GeoIPCity.dat"); - } - else - { - databaseFile = new File(dataFolder, "GeoIP.dat"); - } - if (!databaseFile.exists()) + config.onReload(); + config.acquireReadLock(); + try { - if (config.getBoolean("database.download-if-missing", true)) + if (config.getData().getDatabase().isShowCities()) { - downloadDatabase(); + databaseFile = new File(geoip.getDataFolder(), "GeoIPCity.dat"); } else { - logger.log(Level.SEVERE, _("cantFindGeoIpDB")); - return; + databaseFile = new File(geoip.getDataFolder(), "GeoIP.dat"); + } + if (!databaseFile.exists()) + { + if (config.getData().getDatabase().isDownloadIfMissing()) + { + if (config.getData().getDatabase().isShowCities()) + { + downloadDatabase(config.getData().getDatabase().getDownloadUrlCity()); + } + else + { + downloadDatabase(config.getData().getDatabase().getDownloadUrl()); + } + } + else + { + LOGGER.log(Level.SEVERE, _("cantFindGeoIpDB")); + return; + } + } + try + { + ls = new LookupService(databaseFile); + } + catch (IOException ex) + { + LOGGER.log(Level.SEVERE, _("cantReadGeoIpDB"), ex); } } - try - { - ls = new LookupService(databaseFile); - } - catch (IOException ex) + finally { - logger.log(Level.SEVERE, _("cantReadGeoIpDB"), ex); + config.unlock(); } } - private void downloadDatabase() + private void downloadDatabase(final String url) { + if (url == null || url.isEmpty()) + { + LOGGER.log(Level.SEVERE, _("geoIpUrlEmpty")); + return; + } + InputStream input = null; + OutputStream output = null; try { - String url; - if (config.getBoolean("database.show-cities", false)) - { - url = config.getString("database.download-url-city"); - } - else - { - url = config.getString("database.download-url"); - } - if (url == null || url.isEmpty()) - { - logger.log(Level.SEVERE, _("geoIpUrlEmpty")); - return; - } - logger.log(Level.INFO, _("downloadingGeoIp")); - URL downloadUrl = new URL(url); - URLConnection conn = downloadUrl.openConnection(); + LOGGER.log(Level.INFO, _("downloadingGeoIp")); + final URL downloadUrl = new URL(url); + final URLConnection conn = downloadUrl.openConnection(); conn.setConnectTimeout(10000); conn.connect(); - InputStream input = conn.getInputStream(); + input = conn.getInputStream(); if (url.endsWith(".gz")) { input = new GZIPInputStream(input); } - OutputStream output = new FileOutputStream(databaseFile); - byte[] buffer = new byte[2048]; + output = new FileOutputStream(databaseFile); + final byte[] buffer = new byte[2048]; int length = input.read(buffer); while (length >= 0) { output.write(buffer, 0, length); length = input.read(buffer); } - output.close(); input.close(); + output.close(); } catch (MalformedURLException ex) { - logger.log(Level.SEVERE, _("geoIpUrlInvalid"), ex); - return; + LOGGER.log(Level.SEVERE, _("geoIpUrlInvalid"), ex); } catch (IOException ex) { - logger.log(Level.SEVERE, _("connectionFailed"), ex); + LOGGER.log(Level.SEVERE, _("connectionFailed"), ex); + } + finally + { + if (output != null) + { + try + { + output.close(); + } + catch (IOException ex) + { + LOGGER.log(Level.SEVERE, _("connectionFailed"), ex); + } + } + if (input != null) + { + try + { + input.close(); + } + catch (IOException ex) + { + LOGGER.log(Level.SEVERE, _("connectionFailed"), ex); + } + } } } } diff --git a/EssentialsXMPP/nbproject/build-impl.xml b/EssentialsXMPP/nbproject/build-impl.xml index 3293bd709..239c397bf 100644 --- a/EssentialsXMPP/nbproject/build-impl.xml +++ b/EssentialsXMPP/nbproject/build-impl.xml @@ -610,6 +610,13 @@ is divided into following sections: <param name="call.target" value="jar"/> <param name="transfer.built-jar.properties" value="${built-jar.properties}"/> </antcall> + <antcall target="-maybe-call-dep"> + <param name="call.built.properties" value="${built-jar.properties}"/> + <param location="${project.Essentials2Compat}" name="call.subproject"/> + <param location="${project.Essentials2Compat}/build.xml" name="call.script"/> + <param name="call.target" value="jar"/> + <param name="transfer.built-jar.properties" value="${built-jar.properties}"/> + </antcall> </target> <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/> <target depends="init" name="-check-automatic-build"> @@ -1063,6 +1070,13 @@ is divided into following sections: <param name="call.target" value="clean"/> <param name="transfer.built-clean.properties" value="${built-clean.properties}"/> </antcall> + <antcall target="-maybe-call-dep"> + <param name="call.built.properties" value="${built-clean.properties}"/> + <param location="${project.Essentials2Compat}" name="call.subproject"/> + <param location="${project.Essentials2Compat}/build.xml" name="call.script"/> + <param name="call.target" value="clean"/> + <param name="transfer.built-clean.properties" value="${built-clean.properties}"/> + </antcall> </target> <target depends="init" name="-do-clean"> <delete dir="${build.dir}"/> diff --git a/EssentialsXMPP/nbproject/genfiles.properties b/EssentialsXMPP/nbproject/genfiles.properties index ae2a6f962..bb9779474 100644 --- a/EssentialsXMPP/nbproject/genfiles.properties +++ b/EssentialsXMPP/nbproject/genfiles.properties @@ -3,6 +3,6 @@ build.xml.script.CRC32=db2fb22f build.xml.stylesheet.CRC32=28e38971@1.42.1.45 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=1012a5dd -nbproject/build-impl.xml.script.CRC32=8cccbe45 +nbproject/build-impl.xml.data.CRC32=6a299da6 +nbproject/build-impl.xml.script.CRC32=a83e8167 nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46 diff --git a/EssentialsXMPP/nbproject/project.properties b/EssentialsXMPP/nbproject/project.properties index 66d780451..dd7aa95e3 100644 --- a/EssentialsXMPP/nbproject/project.properties +++ b/EssentialsXMPP/nbproject/project.properties @@ -72,7 +72,8 @@ jar.index=${jnlp.enabled} javac.classpath=\ ${reference.Essentials.jar}:\ ${file.reference.smack-3.2.1.jar}:\ - ${file.reference.bukkit.jar} + ${file.reference.bukkit.jar}:\ + ${reference.Essentials2Compat.jar} # Space-separated list of extra javac options javac.compilerargs=-Xlint:unchecked javac.deprecation=false @@ -112,7 +113,9 @@ meta.inf.dir=${src.dir}/META-INF mkdist.disabled=true platform.active=default_platform project.Essentials=../Essentials +project.Essentials2Compat=../Essentials2Compat reference.Essentials.jar=${project.Essentials}/dist/Essentials.jar +reference.Essentials2Compat.jar=${project.Essentials2Compat}/dist/Essentials2Compat.jar run.classpath=\ ${javac.classpath}:\ ${build.classes.dir} diff --git a/EssentialsXMPP/nbproject/project.xml b/EssentialsXMPP/nbproject/project.xml index 5c9eee1dd..e5ee6cd11 100644 --- a/EssentialsXMPP/nbproject/project.xml +++ b/EssentialsXMPP/nbproject/project.xml @@ -23,6 +23,14 @@ <clean-target>clean</clean-target> <id>jar</id> </reference> + <reference> + <foreign-project>Essentials2Compat</foreign-project> + <artifact-type>jar</artifact-type> + <script>build.xml</script> + <target>jar</target> + <clean-target>clean</clean-target> + <id>jar</id> + </reference> </references> </configuration> </project> @@ -14,6 +14,7 @@ <ant dir="Essentials" antfile="build.xml"/> </target> <target name="buildRest" depends="buildEss"> + <ant dir="Essentials2Compat" antfile="build.xml"/> <ant dir="EssentialsChat" antfile="build.xml"/> <ant dir="EssentialsSpawn" antfile="build.xml"/> <ant dir="EssentialsProtect" antfile="build.xml"/> |