mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-09-06 04:58:00 +02:00
Remove 3.x api migration code.
3.x development was moved to different code branch. Removing deprecated warnings, since it would be silly to deprecate ALL classes.
This commit is contained in:
parent
7d5e0352d2
commit
8a9353fd09
@ -1,9 +1,5 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
/**
|
||||
* @deprecated New interface will be IReload in api package
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IConf {
|
||||
public void reloadConfig();
|
||||
}
|
||||
|
@ -12,10 +12,6 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated This will be moved to the api package soon
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IEssentials extends Plugin
|
||||
{
|
||||
void addReloadListener(IConf listener);
|
||||
|
@ -5,10 +5,6 @@ import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated This will be moved to the api package soon
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IUser extends Player
|
||||
{
|
||||
long getLastTeleportTimestamp();
|
||||
|
@ -1,10 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.util.Map;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
|
||||
|
||||
public interface IAlternativeCommandsHandler
|
||||
{
|
||||
Map<String, String> disabledCommands();
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.perm.IPermissionsHandler;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public interface IEssentials extends Plugin, IReload
|
||||
{
|
||||
void addReloadListener(IReload listener);
|
||||
|
||||
IUser getUser(Object base);
|
||||
|
||||
int broadcastMessage(IUser sender, String message);
|
||||
|
||||
II18n getI18n();
|
||||
|
||||
ISettings getSettings();
|
||||
|
||||
IJails getJail();
|
||||
|
||||
IWarps getWarps();
|
||||
|
||||
IWorth getWorth();
|
||||
|
||||
IItemDb getItemDb();
|
||||
|
||||
IUserMap getUserMap();
|
||||
|
||||
IEssentialsEconomy getEconomy();
|
||||
|
||||
World getWorld(String name);
|
||||
|
||||
Methods getPaymentMethod();
|
||||
|
||||
int scheduleAsyncDelayedTask(Runnable run);
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run);
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run, long delay);
|
||||
|
||||
int scheduleSyncRepeatingTask(Runnable run, long delay, long period);
|
||||
|
||||
IPermissionsHandler getPermissionsHandler();
|
||||
|
||||
IAlternativeCommandsHandler getAlternativeCommandsHandler();
|
||||
|
||||
void showCommandError(CommandSender sender, String commandLabel, Throwable exception);
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
|
||||
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;
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.settings.Settings;
|
||||
import com.earth2me.essentials.storage.IStorageObjectHolder;
|
||||
|
||||
|
||||
public interface ISettings extends IStorageObjectHolder<Settings>
|
||||
{
|
||||
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public interface IUser extends Player, IReload
|
||||
{
|
||||
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();
|
||||
|
||||
ITeleport getTeleport();
|
||||
|
||||
void setJail(String jail);
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public interface IUserMap
|
||||
{
|
||||
boolean userExists(final String name);
|
||||
|
||||
IUser getUser(final String name);
|
||||
|
||||
void removeUser(final String name);
|
||||
|
||||
Set<String> getAllUniqueUsers();
|
||||
|
||||
int getUniqueUsers();
|
||||
|
||||
File getUserFile(final String name);
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.util.Collection;
|
||||
import org.bukkit.Location;
|
||||
|
||||
|
||||
public interface IWarps extends IReload
|
||||
{
|
||||
Location getWarp(String warp) throws Exception;
|
||||
|
||||
Collection<String> getWarps();
|
||||
|
||||
void removeWarp(String name) throws Exception;
|
||||
|
||||
void setWarp(String name, Location loc) throws Exception;
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public interface IWorth extends IReload
|
||||
{
|
||||
double getPrice(ItemStack itemStack);
|
||||
|
||||
void setPrice(ItemStack itemStack, double price);
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package com.earth2me.essentials.settings;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Backup implements StorageObject
|
||||
{
|
||||
@Comment("Interval in minutes")
|
||||
private long interval = 60;
|
||||
@Comment("Add a command that backups your data, e.g. 'rdiff-backup World1 backups/World1'")
|
||||
private String command;
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package com.earth2me.essentials.settings;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Chat implements StorageObject
|
||||
{
|
||||
@Comment("The character(s) to prefix all nicknames, so that you know they are not true usernames.")
|
||||
private String nicknamePrefix = "~";
|
||||
@Comment("Disable this if you have any other plugin, that modifies the displayname of a user.")
|
||||
private boolean changeDisplayname = true;
|
||||
private String displaynameFormat = "{PREFIX}{NICKNAMEPREFIX}{NAME}{SUFFIX}";
|
||||
@Comment(
|
||||
{
|
||||
"If EssentialsChat is installed, this will define how far a player's voice travels, in blocks. Set to 0 to make all chat global.",
|
||||
"Note that users with the \"essentials.chat.spy\" permission will hear everything, regardless of this setting.",
|
||||
"Users with essentials.chat.shout can override this by prefixing text with an exclamation mark (!)",
|
||||
"Or with essentials.chat.question can override this by prefixing text with a question mark (?)",
|
||||
"You can add command costs for shout/question by adding chat-shout and chat-question to the command costs section."
|
||||
})
|
||||
private int localRadius = 0;
|
||||
@Comment("Set the default chat format here, it will be overwritten by group specific chat formats.")
|
||||
private String defaultFormat = "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}";
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package com.earth2me.essentials.settings;
|
||||
|
||||
import com.earth2me.essentials.settings.commands.*;
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.ListType;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Commands implements StorageObject
|
||||
{
|
||||
private Afk afk = new Afk();
|
||||
private God god = new God();
|
||||
private Help help = new Help();
|
||||
private Home home = new Home();
|
||||
private Kit kit = new Kit();
|
||||
private Lightning lightning = new Lightning();
|
||||
private Spawnmob spawnmob = new Spawnmob();
|
||||
@ListType
|
||||
@Comment(
|
||||
{
|
||||
"When a command conflicts with another plugin, by default, Essentials will try to force the OTHER plugin to take",
|
||||
"priority. If a command is in this list, Essentials will try to give ITSELF priority. This does not always work:",
|
||||
"usually whichever plugin was updated most recently wins out. However, the full name of the command will always work.",
|
||||
"For example, if WorldGuard and Essentials are both enabled, and WorldGuard takes control over /god, /essentials:god",
|
||||
"will still map to Essentials, whereas it might normally get forced upon WorldGuard. Commands prefixed with an \"e\",",
|
||||
"such as /egod, will always grant Essentials priority.",
|
||||
"We should try to take priority over /god. If this doesn't work, use /essentials:god or /egod.",
|
||||
"If god is set using WorldGuard, use /ungod to remove then use whichever you see fit."
|
||||
})
|
||||
private List<String> overwritten = new ArrayList<String>();
|
||||
@ListType
|
||||
@Comment("Disabled commands will be completelly unavailable on the server.")
|
||||
private List<String> disabled = new ArrayList<String>();
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
package com.earth2me.essentials.settings;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.MapValueType;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Economy implements StorageObject
|
||||
{
|
||||
@Comment("Defines the balance with which new players begin. Defaults to 0.")
|
||||
private double startingBalance = 0.0;
|
||||
@MapValueType(Double.class)
|
||||
@Comment("Defines the cost to use the given commands PER USE")
|
||||
private Map<String, Double> commandCosts = new HashMap<String, Double>();
|
||||
@Comment("Set this to a currency symbol you want to use.")
|
||||
private String currencySymbol = "$";
|
||||
|
||||
public String getCurrencySymbol()
|
||||
{
|
||||
return currencySymbol == null || currencySymbol.isEmpty() ? "$" : currencySymbol.substring(0, 1);
|
||||
}
|
||||
private final transient static double MAXMONEY = 10000000000000.0;
|
||||
@Comment(
|
||||
{
|
||||
"Set the maximum amount of money a player can have",
|
||||
"The amount is always limited to 10 trillions because of the limitations of a java double"
|
||||
})
|
||||
private double maxMoney = MAXMONEY;
|
||||
|
||||
public double getMaxMoney()
|
||||
{
|
||||
return Math.abs(maxMoney) > MAXMONEY ? MAXMONEY : Math.abs(maxMoney);
|
||||
}
|
||||
@Comment("Enable this to log all interactions with trade/buy/sell signs and sell command")
|
||||
private boolean logEnabled = false;
|
||||
private Worth worth = new Worth();
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package com.earth2me.essentials.settings;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class General implements StorageObject
|
||||
{
|
||||
@Comment("Backup runs a command while saving is disabled")
|
||||
private Backup backup = new Backup();
|
||||
@Comment("You can disable the death messages of minecraft.")
|
||||
private boolean deathMessages = true;
|
||||
@Comment("Turn this on, if you want to see more error messages, if something goes wrong.")
|
||||
private boolean debug = false;
|
||||
@Comment(
|
||||
{
|
||||
"Set the locale here, if you want to change the language of Essentials.",
|
||||
"If this is not set, Essentials will use the language of your computer.",
|
||||
"Available locales: da, de, en, fr, nl"
|
||||
})
|
||||
private String locale;
|
||||
@Comment(
|
||||
{
|
||||
"Should we announce to the server when someone logs in for the first time?",
|
||||
"If so, use this format, replacing {DISPLAYNAME} with the player name.",
|
||||
"If not, set to ''"
|
||||
})
|
||||
private String newPlayerAnnouncement = "&dWelcome {DISPLAYNAME} to the server!";
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package com.earth2me.essentials.settings;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class GroupOptions implements StorageObject
|
||||
{
|
||||
@Comment("Message format of chat messages")
|
||||
private String messageFormat;
|
||||
@Comment("Prefix for name")
|
||||
private String prefix;
|
||||
@Comment("Suffix for name")
|
||||
private String suffix;
|
||||
@Comment("Amount of homes a player can have")
|
||||
private Integer homes;
|
||||
@Comment("Cooldown between teleports")
|
||||
private Integer teleportCooldown;
|
||||
@Comment("Delay before teleport")
|
||||
private Integer teleportDelay;
|
||||
@Comment("Cooldown between heals")
|
||||
private Integer healCooldown;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package com.earth2me.essentials.settings;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.MapValueType;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import java.util.LinkedHashMap;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Groups implements StorageObject
|
||||
{
|
||||
public Groups()
|
||||
{
|
||||
GroupOptions defaultOptions = new GroupOptions();
|
||||
groups.put("default", defaultOptions);
|
||||
}
|
||||
@Comment(
|
||||
{
|
||||
"The order of the groups matters, the groups are checked from top to bottom.",
|
||||
"All group names have to be lower case.",
|
||||
"The groups can be connected to users using the permission essentials.groups.groupname"
|
||||
})
|
||||
@MapValueType(GroupOptions.class)
|
||||
private LinkedHashMap<String, GroupOptions> groups = new LinkedHashMap<String, GroupOptions>();
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package com.earth2me.essentials.settings;
|
||||
|
||||
import com.earth2me.essentials.storage.MapValueType;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.bukkit.Location;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Locations implements StorageObject
|
||||
{
|
||||
@MapValueType(Location.class)
|
||||
Map<String, Location> jails = new HashMap<String, Location>();
|
||||
@MapValueType(Location.class)
|
||||
Map<String, Location> warps = new HashMap<String, Location>();
|
||||
@MapValueType(Location.class)
|
||||
Map<String, Location> spawns = new HashMap<String, Location>();
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
package com.earth2me.essentials.settings;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Settings implements StorageObject
|
||||
{
|
||||
@Comment(
|
||||
{
|
||||
"##########################################################",
|
||||
"+------------------------------------------------------+ #",
|
||||
"| General Settings | #",
|
||||
"+------------------------------------------------------+ #",
|
||||
"##########################################################"
|
||||
})
|
||||
private General general = new General();
|
||||
@Comment(
|
||||
{
|
||||
"##########################################################",
|
||||
"+------------------------------------------------------+ #",
|
||||
"| Chat Settings | #",
|
||||
"+------------------------------------------------------+ #",
|
||||
"##########################################################"
|
||||
})
|
||||
private Chat chat = new Chat();
|
||||
@Comment(
|
||||
{
|
||||
"##########################################################",
|
||||
"+------------------------------------------------------+ #",
|
||||
"| Economy Settings | #",
|
||||
"+------------------------------------------------------+ #",
|
||||
"##########################################################"
|
||||
})
|
||||
private Economy economy = new Economy();
|
||||
@Comment(
|
||||
{
|
||||
"##########################################################",
|
||||
"+------------------------------------------------------+ #",
|
||||
"| Commands Settings | #",
|
||||
"+------------------------------------------------------+ #",
|
||||
"##########################################################"
|
||||
})
|
||||
private Commands commands = new Commands();
|
||||
@Comment(
|
||||
{
|
||||
"##########################################################",
|
||||
"+------------------------------------------------------+ #",
|
||||
"| Group Settings | #",
|
||||
"+------------------------------------------------------+ #",
|
||||
"##########################################################"
|
||||
})
|
||||
private Groups groups = new Groups();
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package com.earth2me.essentials.settings;
|
||||
|
||||
import com.earth2me.essentials.storage.EnchantmentLevel;
|
||||
import com.earth2me.essentials.storage.MapKeyType;
|
||||
import com.earth2me.essentials.storage.MapValueType;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Worth implements StorageObject
|
||||
{
|
||||
@MapKeyType(MaterialData.class)
|
||||
@MapValueType(Double.class)
|
||||
private Map<MaterialData, Double> sell = new HashMap<MaterialData, Double>();
|
||||
@MapKeyType(MaterialData.class)
|
||||
@MapValueType(Double.class)
|
||||
private Map<MaterialData, Double> buy = new HashMap<MaterialData, Double>();
|
||||
@MapKeyType(EnchantmentLevel.class)
|
||||
@MapValueType(Double.class)
|
||||
private Map<EnchantmentLevel, Double> enchantmentMultiplier = new HashMap<EnchantmentLevel, Double>();
|
||||
|
||||
public Worth()
|
||||
{
|
||||
sell.put(new MaterialData(Material.APPLE, (byte)0), 1.0);
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package com.earth2me.essentials.settings.commands;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Afk implements StorageObject
|
||||
{
|
||||
@Comment(
|
||||
{
|
||||
"After this timeout in seconds, the user will be set as afk.",
|
||||
"Set to -1 for no timeout."
|
||||
})
|
||||
private int autoAFK = 300;
|
||||
@Comment(
|
||||
{
|
||||
"Auto-AFK Kick",
|
||||
"After this timeout in seconds, the user will be kicked from the server.",
|
||||
"Set to -1 for no timeout."
|
||||
})
|
||||
private int autoAFKKick = -1;
|
||||
@Comment(
|
||||
{
|
||||
"Set this to true, if you want to freeze the player, if he is afk.",
|
||||
"Other players or monsters can't push him out of afk mode then.",
|
||||
"This will also enable temporary god mode for the afk player.",
|
||||
"The player has to use the command /afk to leave the afk mode.",
|
||||
"You have to add a message to your welcome message or help page,",
|
||||
"since the player will not get a message, if he tries to move."
|
||||
})
|
||||
private boolean freezeAFKPlayers = false;
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.earth2me.essentials.settings.commands;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class God implements StorageObject
|
||||
{
|
||||
@Comment("Turn off god mode when people exit")
|
||||
private boolean removeOnDisconnect = false;
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package com.earth2me.essentials.settings.commands;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Help implements StorageObject
|
||||
{
|
||||
@Comment("Show other plugins commands in help")
|
||||
private boolean showNonEssCommandsInHelp = true;
|
||||
@Comment(
|
||||
{
|
||||
"Hide plugins which don't give a permission in their plugin.yml for each command.",
|
||||
"You can override a true value here for a single plugin by adding a permission to a user/group.",
|
||||
"The individual permission is: essentials.help.<plugin>, anyone with essentials.* or '*' will see all help this setting reguardless.",
|
||||
"You can use negative permissions to remove access to just a single plugins help if the following is enabled."
|
||||
})
|
||||
private boolean hidePermissionlessCommands = true;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package com.earth2me.essentials.settings.commands;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Home implements StorageObject
|
||||
{
|
||||
@Comment("When players die, should they respawn at their homes, instead of the spawnpoint?")
|
||||
private boolean respawnAtHome = false;
|
||||
@Comment(
|
||||
{
|
||||
"When a player interacts with a bed, should their home be set to that location?",
|
||||
"If you enable this and remove default player access to the /sethome command, ",
|
||||
"you can make beds the only way for players to set their home location."
|
||||
})
|
||||
private boolean bedSetsHome = false;
|
||||
@Comment("If no home is set, should the player be send to spawn, when /home is used.")
|
||||
private boolean spawnIfNoHome = false;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package com.earth2me.essentials.settings.commands;
|
||||
|
||||
import com.earth2me.essentials.storage.MapValueType;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Kit implements StorageObject
|
||||
{
|
||||
public Kit()
|
||||
{
|
||||
final KitObject kit = new KitObject();
|
||||
kit.setDelay(10.0);
|
||||
kit.getItems().add(new ItemStack(Material.DIAMOND_SPADE, 1));
|
||||
kit.getItems().add(new ItemStack(Material.DIAMOND_PICKAXE, 1));
|
||||
kit.getItems().add(new ItemStack(Material.DIAMOND_AXE, 1));
|
||||
kits.put("tools", kit);
|
||||
}
|
||||
@MapValueType(KitObject.class)
|
||||
private Map<String, KitObject> kits = new HashMap<String, KitObject>();
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package com.earth2me.essentials.settings.commands;
|
||||
|
||||
import com.earth2me.essentials.storage.ListType;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class KitObject implements StorageObject
|
||||
{
|
||||
@ListType(ItemStack.class)
|
||||
private List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
private Double delay;
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.earth2me.essentials.settings.commands;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Lightning implements StorageObject
|
||||
{
|
||||
@Comment("Shall we notify users when using /lightning")
|
||||
private boolean warnPlayer = true;
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.earth2me.essentials.settings.commands;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Spawnmob implements StorageObject
|
||||
{
|
||||
@Comment("The maximum amount of monsters, a player can spawn with a call of /spawnmob.")
|
||||
private int limit = 10;
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
package com.earth2me.essentials.storage;
|
||||
|
||||
import com.earth2me.essentials.user.UserData;
|
||||
|
||||
|
||||
public interface IStorageObjectHolder<T extends StorageObject>
|
||||
{
|
||||
|
@ -1,14 +0,0 @@
|
||||
package com.earth2me.essentials.user;
|
||||
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Ban implements StorageObject
|
||||
{
|
||||
private String reason;
|
||||
private long timeout;
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.earth2me.essentials.user;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
|
||||
public interface IOfflinePlayer
|
||||
{
|
||||
String getName();
|
||||
|
||||
String getDisplayName();
|
||||
|
||||
Location getBedSpawnLocation();
|
||||
|
||||
void setBanned(boolean bln);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package com.earth2me.essentials.user;
|
||||
|
||||
import com.earth2me.essentials.storage.IStorageObjectHolder;
|
||||
|
||||
|
||||
public interface IOfflineUser extends IStorageObjectHolder<UserData>, IOfflinePlayer
|
||||
{
|
||||
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package com.earth2me.essentials.user;
|
||||
|
||||
import com.earth2me.essentials.storage.MapKeyType;
|
||||
import com.earth2me.essentials.storage.MapValueType;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Inventory implements StorageObject
|
||||
{
|
||||
private int size;
|
||||
@MapKeyType(Integer.class)
|
||||
@MapValueType(ItemStack.class)
|
||||
private Map<Integer, ItemStack> items = new HashMap<Integer, ItemStack>();
|
||||
|
||||
public Inventory()
|
||||
{
|
||||
items.put(1, new ItemStack(Material.APPLE, 64));
|
||||
}
|
||||
}
|
@ -1,220 +0,0 @@
|
||||
package com.earth2me.essentials.user;
|
||||
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.IUser;
|
||||
import com.earth2me.essentials.Teleport;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class User extends UserBase implements IUser
|
||||
{
|
||||
public User(final Player base, final IEssentials ess)
|
||||
{
|
||||
super(base, ess);
|
||||
}
|
||||
|
||||
public User(final OfflinePlayer offlinePlayer, final IEssentials ess)
|
||||
{
|
||||
super(offlinePlayer, ess);
|
||||
}
|
||||
|
||||
public void example()
|
||||
{
|
||||
// Cleanup will call close at the end of the function
|
||||
@Cleanup
|
||||
final User user = this;
|
||||
|
||||
// read lock allows to read data from the user
|
||||
user.acquireReadLock();
|
||||
final double money = user.getData().getMoney();
|
||||
|
||||
// write lock allows only one thread to modify the data
|
||||
user.acquireWriteLock();
|
||||
user.getData().setMoney(10 + money);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishRead()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishWrite()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastTeleportTimestamp()
|
||||
{
|
||||
acquireReadLock();
|
||||
try
|
||||
{
|
||||
return getData().getTimestamps().get("lastteleport");
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(String node)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(IEssentialsCommand cmd)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastTeleportTimestamp(long time)
|
||||
{
|
||||
acquireWriteLock();
|
||||
try
|
||||
{
|
||||
getData().getTimestamps().put("lastteleport", time);
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLastLocation()
|
||||
{
|
||||
acquireReadLock();
|
||||
try
|
||||
{
|
||||
return getData().getLastLocation();
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMoney()
|
||||
{
|
||||
acquireReadLock();
|
||||
try
|
||||
{
|
||||
return getData().getMoney();
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void takeMoney(double value)
|
||||
{
|
||||
acquireWriteLock();
|
||||
try
|
||||
{
|
||||
getData().setMoney(getData().getMoney() - value);
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveMoney(double value)
|
||||
{
|
||||
acquireWriteLock();
|
||||
try
|
||||
{
|
||||
getData().setMoney(getData().getMoney() + value);
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastLocation()
|
||||
{
|
||||
acquireWriteLock();
|
||||
try
|
||||
{
|
||||
getData().setLastLocation(base.getLocation());
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getHome(String name) throws Exception
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getHome(Location loc) throws Exception
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Teleport getTeleport()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setJail(final String jail)
|
||||
{
|
||||
acquireWriteLock();
|
||||
try
|
||||
{
|
||||
getData().setJail(jail);
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAfford(final double cost)
|
||||
{
|
||||
final double mon = getMoney();
|
||||
if (isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
return (mon - cost) >= ess.getSettings().getMinMoney();
|
||||
}
|
||||
return cost <= mon;
|
||||
}
|
||||
}
|
@ -1,117 +0,0 @@
|
||||
package com.earth2me.essentials.user;
|
||||
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
|
||||
import java.io.File;
|
||||
import lombok.Delegate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
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;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
|
||||
public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implements Player, IOfflineUser
|
||||
{
|
||||
|
||||
@Delegate(types =
|
||||
{
|
||||
Player.class, Entity.class, CommandSender.class, ServerOperator.class,
|
||||
HumanEntity.class, ConfigurationSerializable.class, LivingEntity.class,
|
||||
Permissible.class
|
||||
},excludes=IOfflinePlayer.class)
|
||||
protected Player base;
|
||||
protected transient OfflinePlayer offlinePlayer;
|
||||
|
||||
public UserBase(final Player base, final IEssentials ess)
|
||||
{
|
||||
super(ess, UserData.class);
|
||||
this.base = base;
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
public UserBase(final OfflinePlayer offlinePlayer, final IEssentials ess)
|
||||
{
|
||||
super(ess, UserData.class);
|
||||
this.offlinePlayer = offlinePlayer;
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
public final Player getBase()
|
||||
{
|
||||
return base;
|
||||
}
|
||||
|
||||
public final Player setBase(final Player base)
|
||||
{
|
||||
return this.base = base;
|
||||
}
|
||||
|
||||
public void update(final Player base)
|
||||
{
|
||||
setBase(base);
|
||||
}
|
||||
|
||||
public void update(final OfflinePlayer offlinePlayer)
|
||||
{
|
||||
this.offlinePlayer = offlinePlayer;
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
this.offlinePlayer = Bukkit.getOfflinePlayer(base.getName());
|
||||
this.base = null;
|
||||
}
|
||||
|
||||
public boolean isOnlineUser() {
|
||||
return base != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
if (isOnlineUser()) {
|
||||
return base.getName();
|
||||
} else {
|
||||
return offlinePlayer.getName();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
if (isOnlineUser()) {
|
||||
return base.getDisplayName();
|
||||
} else {
|
||||
return offlinePlayer.getName();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getBedSpawnLocation()
|
||||
{
|
||||
return base.getBedSpawnLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBanned(boolean bln)
|
||||
{
|
||||
if (isOnlineUser()) {
|
||||
base.setBanned(bln);
|
||||
} else {
|
||||
offlinePlayer.setBanned(bln);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getStorageFile()
|
||||
{
|
||||
return ess.getUserMap().getUserFile(getName());
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package com.earth2me.essentials.user;
|
||||
|
||||
import com.earth2me.essentials.storage.ListType;
|
||||
import com.earth2me.essentials.storage.MapKeyType;
|
||||
import com.earth2me.essentials.storage.MapValueType;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import java.util.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class UserData implements StorageObject
|
||||
{
|
||||
private String nickname;
|
||||
private double money;
|
||||
@MapValueType(Location.class)
|
||||
private Map<String, Location> homes = new HashMap<String, Location>();
|
||||
@ListType(Material.class)
|
||||
private Set<Material> unlimited = new HashSet<Material>();
|
||||
@MapValueType(List.class)
|
||||
@MapKeyType(Material.class)
|
||||
private Map<Material, List<String>> powerTools = new HashMap<Material, List<String>>();
|
||||
private Location lastLocation;
|
||||
@MapValueType(Long.class)
|
||||
private Map<String, Long> timestamps;
|
||||
private String jail;
|
||||
@ListType
|
||||
private List<String> mails;
|
||||
private Inventory inventory;
|
||||
private boolean teleportEnabled;
|
||||
@ListType
|
||||
private Set<String> ignore;
|
||||
private boolean godmode;
|
||||
private boolean muted;
|
||||
private boolean jailed;
|
||||
private Ban ban;
|
||||
private String ipAddress;
|
||||
private boolean afk;
|
||||
private boolean newplayer = true;
|
||||
private String geolocation;
|
||||
private boolean socialspy;
|
||||
private boolean npc;
|
||||
private boolean powertoolsenabled;
|
||||
|
||||
public UserData()
|
||||
{
|
||||
unlimited.add(Material.AIR);
|
||||
unlimited.add(Material.ARROW);
|
||||
unlimited.add(Material.APPLE);
|
||||
powerTools.put(Material.DEAD_BUSH, Collections.singletonList("test"));
|
||||
}
|
||||
}
|
@ -1,128 +0,0 @@
|
||||
package com.earth2me.essentials.user;
|
||||
|
||||
import com.earth2me.essentials.IConf;
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.Util;
|
||||
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.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class UserMap extends CacheLoader<String, User> implements IConf
|
||||
{
|
||||
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(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean userExists(final String name)
|
||||
{
|
||||
return keys.contains(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public User getUser(final String name)
|
||||
{
|
||||
try
|
||||
{
|
||||
return users.get(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
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(name.toLowerCase(Locale.ENGLISH));
|
||||
return new User(player, ess);
|
||||
}
|
||||
}
|
||||
final File userFile = getUserFile(name);
|
||||
if (userFile.exists())
|
||||
{
|
||||
keys.add(name.toLowerCase(Locale.ENGLISH));
|
||||
return new User(Bukkit.getOfflinePlayer(name), ess);
|
||||
}
|
||||
throw new Exception("User not found!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
loadAllUsersAsync(ess);
|
||||
}
|
||||
|
||||
public void removeUser(final String name)
|
||||
{
|
||||
keys.remove(name.toLowerCase(Locale.ENGLISH));
|
||||
users.invalidate(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
@ -1,10 +1,5 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.settings.Settings;
|
||||
import com.earth2me.essentials.storage.ObjectLoadException;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import com.earth2me.essentials.storage.YamlStorageReader;
|
||||
import com.earth2me.essentials.storage.YamlStorageWriter;
|
||||
import java.io.*;
|
||||
import junit.framework.TestCase;
|
||||
import org.bukkit.Location;
|
||||
@ -39,100 +34,6 @@ public class StorageTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
assertTrue(StorageObject.class.isAssignableFrom(Settings.class));
|
||||
ExecuteTimer ext = new ExecuteTimer();
|
||||
ext.start();
|
||||
final ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
|
||||
final Reader reader = new InputStreamReader(bais);
|
||||
final Settings settings = new YamlStorageReader(reader, null).load(Settings.class);
|
||||
ext.mark("load empty settings");
|
||||
final ByteArrayInputStream bais3 = new ByteArrayInputStream(new byte[0]);
|
||||
final Reader reader3 = new InputStreamReader(bais3);
|
||||
final Settings settings3 = new YamlStorageReader(reader3, null).load(Settings.class);
|
||||
ext.mark("load empty settings (class cached)");
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
final PrintWriter writer = new PrintWriter(baos);
|
||||
new YamlStorageWriter(writer).save(settings);
|
||||
writer.close();
|
||||
ext.mark("write settings");
|
||||
byte[] written = baos.toByteArray();
|
||||
System.out.println(new String(written));
|
||||
final ByteArrayInputStream bais2 = new ByteArrayInputStream(written);
|
||||
final Reader reader2 = new InputStreamReader(bais2);
|
||||
final Settings settings2 = new YamlStorageReader(reader2, null).load(Settings.class);
|
||||
System.out.println(settings.toString());
|
||||
System.out.println(settings2.toString());
|
||||
ext.mark("reload settings");
|
||||
System.out.println(ext.end());
|
||||
//assertEquals("Default and rewritten config should be equal", settings, settings2);
|
||||
//that assertion fails, because empty list and maps return as null
|
||||
}
|
||||
catch (ObjectLoadException ex)
|
||||
{
|
||||
fail(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUserdata()
|
||||
{
|
||||
try
|
||||
{
|
||||
FakeServer server = new FakeServer();
|
||||
World world = server.createWorld("testWorld", Environment.NORMAL);
|
||||
ExecuteTimer ext = new ExecuteTimer();
|
||||
ext.start();
|
||||
final ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
|
||||
final Reader reader = new InputStreamReader(bais);
|
||||
final com.earth2me.essentials.user.UserData userdata = new YamlStorageReader(reader, null).load(com.earth2me.essentials.user.UserData.class);
|
||||
ext.mark("load empty user");
|
||||
final ByteArrayInputStream bais3 = new ByteArrayInputStream(new byte[0]);
|
||||
final Reader reader3 = new InputStreamReader(bais3);
|
||||
final com.earth2me.essentials.user.UserData userdata3 = new YamlStorageReader(reader3, null).load(com.earth2me.essentials.user.UserData.class);
|
||||
ext.mark("load empty user (class cached)");
|
||||
|
||||
for (int j = 0; j < 10000; j++)
|
||||
{
|
||||
userdata.getHomes().put("home", new Location(world, j, j, j));
|
||||
}
|
||||
ext.mark("change home 10000 times");
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
final PrintWriter writer = new PrintWriter(baos);
|
||||
new YamlStorageWriter(writer).save(userdata);
|
||||
writer.close();
|
||||
ext.mark("write user");
|
||||
final ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
|
||||
final PrintWriter writer2 = new PrintWriter(baos2);
|
||||
new YamlStorageWriter(writer2).save(userdata);
|
||||
writer2.close();
|
||||
ext.mark("write user (cached)");
|
||||
byte[] written = baos.toByteArray();
|
||||
System.out.println(new String(written));
|
||||
ext.mark("debug output");
|
||||
final ByteArrayInputStream bais2 = new ByteArrayInputStream(written);
|
||||
final Reader reader2 = new InputStreamReader(bais2);
|
||||
final com.earth2me.essentials.user.UserData userdata2 = new YamlStorageReader(reader2, null).load(com.earth2me.essentials.user.UserData.class);
|
||||
ext.mark("reload file");
|
||||
final ByteArrayInputStream bais4 = new ByteArrayInputStream(written);
|
||||
final Reader reader4 = new InputStreamReader(bais4);
|
||||
final com.earth2me.essentials.user.UserData userdata4 = new YamlStorageReader(reader4, null).load(com.earth2me.essentials.user.UserData.class);
|
||||
ext.mark("reload file (cached)");
|
||||
System.out.println(userdata.toString());
|
||||
System.out.println(userdata2.toString());
|
||||
System.out.println(ext.end());
|
||||
}
|
||||
catch (ObjectLoadException ex)
|
||||
{
|
||||
fail(ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOldUserdata()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user