mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-11 02:47:52 +01:00
Merge branch '2.x' into create-afk-message
This commit is contained in:
commit
3a439bcdb5
@ -4,6 +4,7 @@ import com.earth2me.essentials.textreader.IText;
|
||||
import com.earth2me.essentials.textreader.KeywordReplacer;
|
||||
import com.earth2me.essentials.textreader.TextInput;
|
||||
import com.earth2me.essentials.textreader.TextPager;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import com.earth2me.essentials.utils.LocationUtil;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.GameMode;
|
||||
@ -26,11 +27,15 @@ import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
@ -399,16 +404,58 @@ public class EssentialsPlayerListener implements Listener {
|
||||
broadcast = false;
|
||||
}
|
||||
}
|
||||
final User user = ess.getUser(player);
|
||||
if (update) {
|
||||
final User user = ess.getUser(player);
|
||||
user.updateActivity(broadcast);
|
||||
}
|
||||
|
||||
if (ess.getSettings().isCommandCooldownsEnabled() && pluginCommand != null
|
||||
&& !user.isAuthorized("essentials.commandcooldowns.bypass")) {
|
||||
int argStartIndex = event.getMessage().indexOf(" ");
|
||||
String args = argStartIndex == -1 ? event.getMessage() // No arguments present
|
||||
: event.getMessage().substring(argStartIndex); // arguments start at argStartIndex; substring from there.
|
||||
String fullCommand = pluginCommand.getName() + " " + args;
|
||||
|
||||
// Used to determine whether a user already has an existing cooldown
|
||||
// If so, no need to check for (and write) new ones.
|
||||
boolean cooldownFound = false;
|
||||
|
||||
// Iterate over a copy of getCommandCooldowns in case of concurrent modifications
|
||||
for (Entry<Pattern, Long> entry : new HashMap<>(user.getCommandCooldowns()).entrySet()) {
|
||||
// Remove any expired cooldowns
|
||||
if (entry.getValue() <= System.currentTimeMillis()) {
|
||||
user.clearCommandCooldown(entry.getKey());
|
||||
// Don't break in case there are other command cooldowns left to clear.
|
||||
} else if (entry.getKey().matcher(fullCommand).matches()) {
|
||||
// User's current cooldown hasn't expired, inform and terminate cooldown code.
|
||||
if (entry.getValue() > System.currentTimeMillis()) {
|
||||
String commandCooldownTime = DateUtil.formatDateDiff(entry.getValue());
|
||||
user.sendMessage(tl("commandCooldown", commandCooldownTime));
|
||||
cooldownFound = true;
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!cooldownFound) {
|
||||
Entry<Pattern, Long> cooldownEntry = ess.getSettings().getCommandCooldownEntry(fullCommand);
|
||||
|
||||
if (cooldownEntry != null) {
|
||||
Date expiry = new Date(System.currentTimeMillis() + cooldownEntry.getValue());
|
||||
user.addCommandCooldown(cooldownEntry.getKey(), expiry, ess.getSettings().isCommandCooldownPersistent(fullCommand));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerChangedWorldFlyReset(final PlayerChangedWorldEvent event) {
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.getBase().getGameMode() != GameMode.CREATIVE && !user.isAuthorized("essentials.fly")) {
|
||||
if (user.getBase().getGameMode() != GameMode.CREATIVE
|
||||
// COMPAT: String compare for 1.7.10
|
||||
&& !user.getBase().getGameMode().name().equals("SPECTATOR")
|
||||
&& !user.isAuthorized("essentials.fly")) {
|
||||
user.getBase().setFallDistance(0f);
|
||||
user.getBase().setAllowFlight(false);
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ import java.util.logging.Level;
|
||||
|
||||
public class EssentialsTimer implements Runnable {
|
||||
private final transient IEssentials ess;
|
||||
private final transient Set<UUID> onlineUsers = new HashSet<UUID>();
|
||||
private final transient Set<UUID> onlineUsers = new HashSet<>(); // Field is necessary for hidden users
|
||||
private transient long lastPoll = System.nanoTime();
|
||||
private final LinkedList<Double> history = new LinkedList<Double>();
|
||||
private final LinkedList<Double> history = new LinkedList<>();
|
||||
private int skip1 = 0;
|
||||
private int skip2 = 0;
|
||||
private final long maxTime = 10 * 1000000;
|
||||
@ -76,6 +76,11 @@ public class EssentialsTimer implements Runnable {
|
||||
}
|
||||
}
|
||||
final User user = ess.getUser(iterator.next());
|
||||
// Not sure why this would happen, but it does
|
||||
if (user == null) {
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
if (user.getLastOnlineActivity() < currentTime && user.getLastOnlineActivity() > user.getLastLogout()) {
|
||||
if (!user.isHidden()) {
|
||||
user.setLastLogout(user.getLastOnlineActivity());
|
||||
|
@ -3,14 +3,18 @@ package com.earth2me.essentials;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.signs.EssentialsSign;
|
||||
import com.earth2me.essentials.textreader.IText;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
public interface ISettings extends IConf {
|
||||
@ -231,9 +235,9 @@ public interface ISettings extends IConf {
|
||||
boolean isNotifyNoNewMail();
|
||||
|
||||
boolean isDropItemsIfFull();
|
||||
|
||||
|
||||
boolean isLastMessageReplyRecipient();
|
||||
|
||||
|
||||
BigDecimal getMinimumPayAmount();
|
||||
|
||||
long getLastMessageReplyRecipientTimeout();
|
||||
@ -241,6 +245,24 @@ public interface ISettings extends IConf {
|
||||
boolean isMilkBucketEasterEggEnabled();
|
||||
|
||||
boolean isSendFlyEnableOnJoin();
|
||||
|
||||
|
||||
boolean isWorldTimePermissions();
|
||||
|
||||
boolean isSpawnOnJoin();
|
||||
|
||||
boolean isTeleportToCenterLocation();
|
||||
|
||||
boolean isCommandCooldownsEnabled();
|
||||
|
||||
long getCommandCooldownMs(String label);
|
||||
|
||||
Entry<Pattern, Long> getCommandCooldownEntry(String label);
|
||||
|
||||
boolean isCommandCooldownPersistent(String label);
|
||||
|
||||
boolean isNpcsInBalanceRanking();
|
||||
|
||||
NumberFormat getCurrencyFormat();
|
||||
|
||||
List<EssentialsSign> getUnprotectedSignNames();
|
||||
}
|
||||
|
@ -7,9 +7,11 @@ import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
public interface IUser {
|
||||
@ -138,6 +140,14 @@ public interface IUser {
|
||||
Map<String, Object> getConfigMap();
|
||||
|
||||
Map<String, Object> getConfigMap(String node);
|
||||
|
||||
Map<Pattern, Long> getCommandCooldowns();
|
||||
|
||||
Date getCommandCooldownExpiry(String label);
|
||||
|
||||
void addCommandCooldown(Pattern pattern, Date expiresAt, boolean save);
|
||||
|
||||
boolean clearCommandCooldown(Pattern pattern);
|
||||
|
||||
/*
|
||||
* PlayerExtension
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -6,6 +6,8 @@ import com.earth2me.essentials.signs.Signs;
|
||||
import com.earth2me.essentials.textreader.IText;
|
||||
import com.earth2me.essentials.textreader.SimpleTextInput;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -14,12 +16,24 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.*;
|
||||
import java.util.Locale.Category;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
|
||||
public class Settings implements net.ess3.api.ISettings {
|
||||
@ -532,6 +546,10 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
customQuitMessage = _getCustomQuitMessage();
|
||||
isCustomQuitMessage = !customQuitMessage.equals("none");
|
||||
muteCommands = _getMuteCommands();
|
||||
commandCooldowns = _getCommandCooldowns();
|
||||
npcsInBalanceRanking = _isNpcsInBalanceRanking();
|
||||
currencyFormat = _getCurrencyFormat();
|
||||
unprotectedSigns = _getUnprotectedSign();
|
||||
}
|
||||
|
||||
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
|
||||
@ -1163,4 +1181,177 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
public boolean isWorldTimePermissions() {
|
||||
return config.getBoolean("world-time-permissions", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpawnOnJoin() {
|
||||
return config.getBoolean("spawn-on-join", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTeleportToCenterLocation() {
|
||||
return config.getBoolean("teleport-to-center", true);
|
||||
}
|
||||
|
||||
private Map<Pattern, Long> commandCooldowns;
|
||||
|
||||
private Map<Pattern, Long> _getCommandCooldowns() {
|
||||
if (!config.isConfigurationSection("command-cooldowns")) {
|
||||
return null;
|
||||
}
|
||||
ConfigurationSection section = config.getConfigurationSection("command-cooldowns");
|
||||
Map<Pattern, Long> result = new LinkedHashMap<>();
|
||||
for (String cmdEntry : section.getKeys(false)) {
|
||||
Pattern pattern = null;
|
||||
|
||||
/* ================================
|
||||
* >> Regex
|
||||
* ================================ */
|
||||
if (cmdEntry.startsWith("^")) {
|
||||
try {
|
||||
pattern = Pattern.compile(cmdEntry.substring(1));
|
||||
} catch (PatternSyntaxException e) {
|
||||
ess.getLogger().warning("Command cooldown error: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
// Escape above Regex
|
||||
if (cmdEntry.startsWith("\\^")) {
|
||||
cmdEntry = cmdEntry.substring(1);
|
||||
}
|
||||
String cmd = cmdEntry
|
||||
.replaceAll("\\*", ".*"); // Wildcards are accepted as asterisk * as known universally.
|
||||
pattern = Pattern.compile(cmd + "( .*)?"); // This matches arguments, if present, to "ignore" them from the feature.
|
||||
}
|
||||
|
||||
/* ================================
|
||||
* >> Process cooldown value
|
||||
* ================================ */
|
||||
Object value = section.get(cmdEntry);
|
||||
if (!(value instanceof Number) && value instanceof String) {
|
||||
try {
|
||||
value = Double.parseDouble(value.toString());
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
if (!(value instanceof Number)) {
|
||||
ess.getLogger().warning("Command cooldown error: '" + value + "' is not a valid cooldown");
|
||||
continue;
|
||||
}
|
||||
double cooldown = ((Number) value).doubleValue();
|
||||
if (cooldown < 1) {
|
||||
ess.getLogger().warning("Command cooldown with very short " + cooldown + " cooldown.");
|
||||
}
|
||||
|
||||
result.put(pattern, (long) cooldown * 1000); // convert to milliseconds
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandCooldownsEnabled() {
|
||||
return commandCooldowns != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCommandCooldownMs(String label) {
|
||||
Entry<Pattern, Long> result = getCommandCooldownEntry(label);
|
||||
return result != null ? result.getValue() : -1; // return cooldown in milliseconds
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entry<Pattern, Long> getCommandCooldownEntry(String label) {
|
||||
if (isCommandCooldownsEnabled()) {
|
||||
for (Entry<Pattern, Long> entry : this.commandCooldowns.entrySet()) {
|
||||
// Check if label matches current pattern (command-cooldown in config)
|
||||
if (entry.getKey().matcher(label).matches()) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandCooldownPersistent(String label) {
|
||||
// TODO: enable per command cooldown specification for persistence.
|
||||
return config.getBoolean("command-cooldown-persistence", true);
|
||||
}
|
||||
|
||||
private boolean npcsInBalanceRanking = false;
|
||||
|
||||
private boolean _isNpcsInBalanceRanking() {
|
||||
return config.getBoolean("npcs-in-balance-ranking", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNpcsInBalanceRanking() {
|
||||
return npcsInBalanceRanking;
|
||||
}
|
||||
|
||||
private NumberFormat currencyFormat;
|
||||
|
||||
private NumberFormat _getCurrencyFormat() {
|
||||
String currencyFormatString = config.getString("currency-format", "#,##0.00");
|
||||
|
||||
String symbolLocaleString = config.getString("currency-symbol-format-locale");
|
||||
DecimalFormatSymbols decimalFormatSymbols;
|
||||
if (symbolLocaleString != null) {
|
||||
decimalFormatSymbols = DecimalFormatSymbols.getInstance(Locale.forLanguageTag(symbolLocaleString));
|
||||
} else {
|
||||
// Fallback to the JVM's default locale
|
||||
decimalFormatSymbols = DecimalFormatSymbols.getInstance();
|
||||
}
|
||||
|
||||
DecimalFormat currencyFormat = new DecimalFormat(currencyFormatString, decimalFormatSymbols);
|
||||
currencyFormat.setRoundingMode(RoundingMode.FLOOR);
|
||||
|
||||
// Updates NumberUtil#PRETTY_FORMAT field so that all of Essentials
|
||||
// can follow a single format.
|
||||
try {
|
||||
Field field = NumberUtil.class.getDeclaredField("PRETTY_FORMAT");
|
||||
field.setAccessible(true);
|
||||
Field modifiersField = Field.class.getDeclaredField("modifiers");
|
||||
modifiersField.setAccessible(true);
|
||||
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
|
||||
field.set(null, currencyFormat);
|
||||
modifiersField.setAccessible(false);
|
||||
field.setAccessible(false);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
ess.getLogger().severe("Failed to apply custom currency format: " + e.getMessage());
|
||||
if (isDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return currencyFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NumberFormat getCurrencyFormat() {
|
||||
return this.currencyFormat;
|
||||
}
|
||||
|
||||
private List<EssentialsSign> unprotectedSigns = Collections.emptyList();
|
||||
|
||||
@Override
|
||||
public List<EssentialsSign> getUnprotectedSignNames() {
|
||||
return this.unprotectedSigns;
|
||||
}
|
||||
|
||||
private List<EssentialsSign> _getUnprotectedSign() {
|
||||
List<EssentialsSign> newSigns = new ArrayList<>();
|
||||
|
||||
for (String signName : config.getStringList("unprotected-sign-names")) {
|
||||
signName = signName.trim().toUpperCase(Locale.ENGLISH);
|
||||
if (signName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
newSigns.add(Signs.valueOf(signName).getSign());
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, tl("unknownItemInList", signName, "unprotected-sign-names"));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return newSigns;
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public class Teleport implements net.ess3.api.ITeleport {
|
||||
protected void now(IUser teleportee, ITarget target, TeleportCause cause) throws Exception {
|
||||
cancel(false);
|
||||
teleportee.setLastLocation();
|
||||
final Location loc = target.getLocation();
|
||||
Location loc = target.getLocation();
|
||||
|
||||
if (LocationUtil.isBlockUnsafeForUser(teleportee, loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) {
|
||||
if (ess.getSettings().isTeleportSafetyEnabled()) {
|
||||
@ -127,7 +127,7 @@ public class Teleport implements net.ess3.api.ITeleport {
|
||||
if (ess.getSettings().isForceDisableTeleportSafety()) {
|
||||
teleportee.getBase().teleport(loc, cause);
|
||||
} else {
|
||||
teleportee.getBase().teleport(LocationUtil.getSafeDestination(teleportee, loc), cause);
|
||||
teleportee.getBase().teleport(LocationUtil.getSafeDestination(ess, teleportee, loc), cause);
|
||||
}
|
||||
} else {
|
||||
throw new Exception(tl("unsafeTeleportDestination", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
@ -139,7 +139,10 @@ public class Teleport implements net.ess3.api.ITeleport {
|
||||
if (ess.getSettings().isForceDisableTeleportSafety()) {
|
||||
teleportee.getBase().teleport(loc, cause);
|
||||
} else {
|
||||
teleportee.getBase().teleport(LocationUtil.getRoundedDestination(loc), cause);
|
||||
if (ess.getSettings().isTeleportToCenterLocation()) {
|
||||
loc = LocationUtil.getRoundedDestination(loc);
|
||||
}
|
||||
teleportee.getBase().teleport(loc, cause);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ import net.ess3.api.MaxMoneyException;
|
||||
import net.ess3.api.events.AfkStatusChangeEvent;
|
||||
import net.ess3.api.events.JailStatusChangeEvent;
|
||||
import net.ess3.api.events.UserBalanceUpdateEvent;
|
||||
import net.ess3.nms.refl.ReflUtil;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -257,7 +259,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
} else if (nick.equalsIgnoreCase(getName())) {
|
||||
nickname = nick;
|
||||
} else {
|
||||
nickname = ess.getSettings().getNicknamePrefix() + nick;
|
||||
nickname = FormatUtil.replaceFormat(ess.getSettings().getNicknamePrefix()) + nick;
|
||||
suffix = "§r";
|
||||
}
|
||||
|
||||
@ -306,7 +308,10 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
if (base.isOnline() && ess.getSettings().changeDisplayName()) {
|
||||
this.getBase().setDisplayName(getNick(true));
|
||||
if (ess.getSettings().changePlayerListName()) {
|
||||
String name = getNick(false);
|
||||
// 1.8 enabled player list-names longer than 16 characters.
|
||||
// If the server is on 1.8 or higher, provide that functionality. Otherwise, keep prior functionality.
|
||||
boolean higherOrEqualTo1_8 = ReflUtil.getNmsVersionObject().isHigherThanOrEqualTo(ReflUtil.V1_8_R1);
|
||||
String name = getNick(higherOrEqualTo1_8);
|
||||
try {
|
||||
this.getBase().setPlayerListName(name);
|
||||
} catch (IllegalArgumentException e) {
|
||||
@ -376,6 +381,11 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
return;
|
||||
}
|
||||
final BigDecimal oldBalance = _getMoney();
|
||||
|
||||
UserBalanceUpdateEvent updateEvent = new UserBalanceUpdateEvent(this.getBase(), oldBalance, value);
|
||||
ess.getServer().getPluginManager().callEvent(updateEvent);
|
||||
BigDecimal newBalance = updateEvent.getNewBalance();
|
||||
|
||||
if (Methods.hasMethod()) {
|
||||
try {
|
||||
final Method method = Methods.getMethod();
|
||||
@ -383,13 +393,12 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
throw new Exception();
|
||||
}
|
||||
final Method.MethodAccount account = Methods.getMethod().getAccount(this.getName());
|
||||
account.set(value.doubleValue());
|
||||
account.set(newBalance.doubleValue());
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
super.setMoney(value, true);
|
||||
ess.getServer().getPluginManager().callEvent(new UserBalanceUpdateEvent(this.getBase(), oldBalance, value));
|
||||
Trade.log("Update", "Set", "API", getName(), new Trade(value, ess), null, null, null, ess);
|
||||
super.setMoney(newBalance, true);
|
||||
Trade.log("Update", "Set", "API", getName(), new Trade(newBalance, ess), null, null, null, ess);
|
||||
}
|
||||
|
||||
public void updateMoneyCache(final BigDecimal value) {
|
||||
|
@ -2,6 +2,7 @@ package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.InvalidWorldException;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
@ -13,6 +14,8 @@ import org.bukkit.inventory.ItemStack;
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
@ -85,6 +88,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
||||
ignoredPlayers = _getIgnoredPlayers();
|
||||
logoutLocation = _getLogoutLocation();
|
||||
lastAccountName = _getLastAccountName();
|
||||
commandCooldowns = _getCommandCooldowns();
|
||||
}
|
||||
|
||||
private BigDecimal money;
|
||||
@ -93,6 +97,11 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
||||
BigDecimal result = ess.getSettings().getStartingBalance();
|
||||
BigDecimal maxMoney = ess.getSettings().getMaxMoney();
|
||||
BigDecimal minMoney = ess.getSettings().getMinMoney();
|
||||
|
||||
// NPC banks are not actual player banks, as such they do not have player starting balance.
|
||||
if (isNPC()) {
|
||||
result = BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
if (config.hasProperty("money")) {
|
||||
result = config.getBigDecimal("money", result);
|
||||
@ -787,6 +796,89 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
// Pattern, Date. Pattern for less pattern creations
|
||||
private Map<Pattern, Long> commandCooldowns;
|
||||
|
||||
private Map<Pattern, Long> _getCommandCooldowns() {
|
||||
if (!config.isConfigurationSection("timestamps.command-cooldowns")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// See saveCommandCooldowns() for deserialization explanation
|
||||
List<Map<?, ?>> section = config.getMapList("timestamps.command-cooldowns");
|
||||
HashMap<Pattern, Long> result = new HashMap<>();
|
||||
for (Map<?, ?> map : section) {
|
||||
Pattern pattern = Pattern.compile(map.get("pattern").toString());
|
||||
long expiry = ((Number) map.get("expiry")).longValue();
|
||||
result.put(pattern, expiry);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public Map<Pattern, Long> getCommandCooldowns() {
|
||||
if (this.commandCooldowns == null) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
return Collections.unmodifiableMap(this.commandCooldowns);
|
||||
}
|
||||
|
||||
public Date getCommandCooldownExpiry(String label) {
|
||||
if (commandCooldowns != null) {
|
||||
for (Entry<Pattern, Long> entry : this.commandCooldowns.entrySet()) {
|
||||
if (entry.getKey().matcher(label).matches()) {
|
||||
return new Date(entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addCommandCooldown(Pattern pattern, Date expiresAt, boolean save) {
|
||||
if (this.commandCooldowns == null) {
|
||||
this.commandCooldowns = new HashMap<>();
|
||||
}
|
||||
this.commandCooldowns.put(pattern, expiresAt.getTime());
|
||||
if (save) {
|
||||
saveCommandCooldowns();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean clearCommandCooldown(Pattern pattern) {
|
||||
if (this.commandCooldowns == null) {
|
||||
return false; // false for no modification
|
||||
}
|
||||
|
||||
if(this.commandCooldowns.remove(pattern) != null) {
|
||||
saveCommandCooldowns();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void saveCommandCooldowns() {
|
||||
// Serialization explanation:
|
||||
//
|
||||
// Serialization is done as a map list instead of a config section due to limitations.
|
||||
// When serializing patterns (which commonly include full stops .) Bukkit/Essentials config framework
|
||||
// interprets it as a path separator, thus it breaks up the regex into sub nodes causing invalid syntax.
|
||||
// Thus each command cooldown is instead stored as a Map of {pattern: .., expiry: ..} to work around this.
|
||||
List<Object> serialized = new ArrayList<>();
|
||||
for (Entry<Pattern, Long> entry : this.commandCooldowns.entrySet()) {
|
||||
// Don't save expired cooldowns
|
||||
if (entry.getValue() < System.currentTimeMillis()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Map<?, ?> map = ImmutableMap.builder()
|
||||
.put("pattern", entry.getKey().pattern())
|
||||
.put("expiry", entry.getValue())
|
||||
.build();
|
||||
serialized.add(map);
|
||||
}
|
||||
config.setProperty("timestamps.command-cooldowns", serialized);
|
||||
save();
|
||||
}
|
||||
|
||||
public UUID getConfigUUID() {
|
||||
return config.uuid;
|
||||
}
|
||||
|
@ -97,6 +97,10 @@ public class Commandbalancetop extends EssentialsCommand {
|
||||
for (UUID u : ess.getUserMap().getAllUniqueUsers()) {
|
||||
final User user = ess.getUserMap().getUser(u);
|
||||
if (user != null) {
|
||||
if (!ess.getSettings().isNpcsInBalanceRanking() && user.isNPC()) {
|
||||
// Don't list NPCs in output
|
||||
continue;
|
||||
}
|
||||
final BigDecimal userMoney = user.getMoney();
|
||||
user.updateMoneyCache(userMoney);
|
||||
totalMoney = totalMoney.add(userMoney);
|
||||
|
@ -38,9 +38,9 @@ public class Commandtp extends EssentialsCommand {
|
||||
if (!user.isAuthorized("essentials.tp.position")) {
|
||||
throw new Exception(tl("noPerm", "essentials.tp.position"));
|
||||
}
|
||||
final double x2 = args[0].startsWith("~") ? user.getLocation().getX() + (args[0].length() > 1 ? Integer.parseInt(args[0].substring(1)) : 0) : Integer.parseInt(args[0]);
|
||||
final double y2 = args[1].startsWith("~") ? user.getLocation().getY() + (args[1].length() > 1 ? Integer.parseInt(args[1].substring(1)) : 0) : Integer.parseInt(args[1]);
|
||||
final double z2 = args[2].startsWith("~") ? user.getLocation().getZ() + (args[2].length() > 1 ? Integer.parseInt(args[2].substring(1)) : 0) : Integer.parseInt(args[2]);
|
||||
final double x2 = args[0].startsWith("~") ? user.getLocation().getX() + (args[0].length() > 1 ? Double.parseDouble(args[0].substring(1)) : 0) : Double.parseDouble(args[0]);
|
||||
final double y2 = args[1].startsWith("~") ? user.getLocation().getY() + (args[1].length() > 1 ? Double.parseDouble(args[1].substring(1)) : 0) : Double.parseDouble(args[1]);
|
||||
final double z2 = args[2].startsWith("~") ? user.getLocation().getZ() + (args[2].length() > 1 ? Double.parseDouble(args[2].substring(1)) : 0) : Double.parseDouble(args[2]);
|
||||
if (x2 > 30000000 || y2 > 30000000 || z2 > 30000000 || x2 < -30000000 || y2 < -30000000 || z2 < -30000000) {
|
||||
throw new NotEnoughArgumentsException(tl("teleportInvalidLocation"));
|
||||
}
|
||||
@ -56,9 +56,9 @@ public class Commandtp extends EssentialsCommand {
|
||||
throw new Exception(tl("noPerm", "essentials.tp.position"));
|
||||
}
|
||||
final User target2 = getPlayer(server, user, args, 0);
|
||||
final double x = args[1].startsWith("~") ? target2.getLocation().getX() + (args[1].length() > 1 ? Integer.parseInt(args[1].substring(1)) : 0) : Integer.parseInt(args[1]);
|
||||
final double y = args[2].startsWith("~") ? target2.getLocation().getY() + (args[2].length() > 1 ? Integer.parseInt(args[2].substring(1)) : 0) : Integer.parseInt(args[2]);
|
||||
final double z = args[3].startsWith("~") ? target2.getLocation().getZ() + (args[3].length() > 1 ? Integer.parseInt(args[3].substring(1)) : 0) : Integer.parseInt(args[3]);
|
||||
final double x = args[1].startsWith("~") ? target2.getLocation().getX() + (args[1].length() > 1 ? Double.parseDouble(args[1].substring(1)) : 0) : Double.parseDouble(args[1]);
|
||||
final double y = args[2].startsWith("~") ? target2.getLocation().getY() + (args[2].length() > 1 ? Double.parseDouble(args[2].substring(1)) : 0) : Double.parseDouble(args[2]);
|
||||
final double z = args[3].startsWith("~") ? target2.getLocation().getZ() + (args[3].length() > 1 ? Double.parseDouble(args[3].substring(1)) : 0) : Double.parseDouble(args[3]);
|
||||
if (x > 30000000 || y > 30000000 || z > 30000000 || x < -30000000 || y < -30000000 || z < -30000000) {
|
||||
throw new NotEnoughArgumentsException(tl("teleportInvalidLocation"));
|
||||
}
|
||||
@ -104,9 +104,9 @@ public class Commandtp extends EssentialsCommand {
|
||||
target.sendMessage(tl("teleportAtoB", Console.NAME, toPlayer.getDisplayName()));
|
||||
target.getTeleport().now(toPlayer.getBase(), false, TeleportCause.COMMAND);
|
||||
} else if (args.length > 3) {
|
||||
final double x = args[1].startsWith("~") ? target.getLocation().getX() + (args[1].length() > 1 ? Integer.parseInt(args[1].substring(1)) : 0) : Integer.parseInt(args[1]);
|
||||
final double y = args[2].startsWith("~") ? target.getLocation().getY() + (args[2].length() > 1 ? Integer.parseInt(args[2].substring(1)) : 0) : Integer.parseInt(args[2]);
|
||||
final double z = args[3].startsWith("~") ? target.getLocation().getZ() + (args[3].length() > 1 ? Integer.parseInt(args[3].substring(1)) : 0) : Integer.parseInt(args[3]);
|
||||
final double x = args[1].startsWith("~") ? target.getLocation().getX() + (args[1].length() > 1 ? Double.parseDouble(args[1].substring(1)) : 0) : Double.parseDouble(args[1]);
|
||||
final double y = args[2].startsWith("~") ? target.getLocation().getY() + (args[2].length() > 1 ? Double.parseDouble(args[2].substring(1)) : 0) : Double.parseDouble(args[2]);
|
||||
final double z = args[3].startsWith("~") ? target.getLocation().getZ() + (args[3].length() > 1 ? Double.parseDouble(args[3].substring(1)) : 0) : Double.parseDouble(args[3]);
|
||||
if (x > 30000000 || y > 30000000 || z > 30000000 || x < -30000000 || y < -30000000 || z < -30000000) {
|
||||
throw new NotEnoughArgumentsException(tl("teleportInvalidLocation"));
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import org.bukkit.Server;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
import net.ess3.api.events.VanishStatusChangeEvent;
|
||||
|
||||
|
||||
public class Commandvanish extends EssentialsToggleCommand {
|
||||
public Commandvanish() {
|
||||
@ -28,6 +30,13 @@ public class Commandvanish extends EssentialsToggleCommand {
|
||||
enabled = !user.isVanished();
|
||||
}
|
||||
|
||||
final User controller = sender.isPlayer() ? ess.getUser(sender.getPlayer()) : null;
|
||||
VanishStatusChangeEvent vanishEvent = new VanishStatusChangeEvent(controller, user, enabled);
|
||||
ess.getServer().getPluginManager().callEvent(vanishEvent);
|
||||
if (vanishEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
user.setVanished(enabled);
|
||||
user.sendMessage(tl("vanish", user.getDisplayName(), enabled ? tl("enabled") : tl("disabled")));
|
||||
|
||||
@ -38,4 +47,4 @@ public class Commandvanish extends EssentialsToggleCommand {
|
||||
sender.sendMessage(tl("vanish", user.getDisplayName(), enabled ? tl("enabled") : tl("disabled")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,8 +125,8 @@ public class PermissionsHandler implements IPermissionsHandler {
|
||||
lastHandler = handlerClass;
|
||||
|
||||
// output handler info
|
||||
if (handler instanceof GenericVaultHandler) {
|
||||
String enabledPermsPlugin = ((GenericVaultHandler) handler).getEnabledPermsPlugin();
|
||||
if (handler instanceof AbstractVaultHandler) {
|
||||
String enabledPermsPlugin = ((AbstractVaultHandler) handler).getEnabledPermsPlugin();
|
||||
if (enabledPermsPlugin == null) enabledPermsPlugin = "generic";
|
||||
ess.getLogger().info("Using Vault based permissions (" + enabledPermsPlugin + ")");
|
||||
} else if (handler.getClass() == SuperpermsHandler.class) {
|
||||
|
@ -45,6 +45,9 @@ public class EssentialsSign {
|
||||
final SignCreateEvent signEvent = new SignCreateEvent(sign, this, user);
|
||||
ess.getServer().getPluginManager().callEvent(signEvent);
|
||||
if (signEvent.isCancelled()) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().info("SignCreateEvent cancelled for sign " + signEvent.getEssentialsSign().getName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -91,11 +91,18 @@ public class SignBlockListener implements Listener {
|
||||
//We loop through all sign types here to prevent clashes with preexisting signs later
|
||||
for (Signs signs : Signs.values()) {
|
||||
final EssentialsSign sign = signs.getSign();
|
||||
// If the top line contains any of the success name (excluding colors), just remove all colours from the first line.
|
||||
// If the top sign line contains any of the success name (excluding colors), just remove all colours from the first line.
|
||||
// This is to ensure we are only modifying possible Essentials Sign and not just removing colors from the first line of all signs.
|
||||
// Top line and sign#getSuccessName() are both lowercased since contains is case-sensitive.
|
||||
String lSuccessName = ChatColor.stripColor(sign.getSuccessName().toLowerCase());
|
||||
if (lColorlessTopLine.contains(lSuccessName)) {
|
||||
|
||||
// If this sign is not enabled and it has been requested to not protect it's name (when disabled), then do not protect the name.
|
||||
// By lower-casing it and stripping colours.
|
||||
if (!ess.getSettings().enabledSigns().contains(sign)
|
||||
&& ess.getSettings().getUnprotectedSignNames().contains(sign)) {
|
||||
continue;
|
||||
}
|
||||
event.setLine(0, lColorlessTopLine);
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,9 @@ import java.util.*;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
|
||||
|
||||
public class LocationUtil {
|
||||
// The player can stand inside these materials
|
||||
@ -261,12 +264,26 @@ public class LocationUtil {
|
||||
return new Location(world, x + 0.5, y, z + 0.5, loc.getYaw(), loc.getPitch());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getSafeDestination(IEssentials, IUser, Location)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Location getSafeDestination(final IUser user, final Location loc) throws Exception {
|
||||
return getSafeDestination(null, user, loc);
|
||||
}
|
||||
|
||||
public static Location getSafeDestination(final IEssentials ess, final IUser user, final Location loc) throws Exception {
|
||||
if (user.getBase().isOnline() && loc.getWorld().equals(user.getBase().getWorld()) && (user.getBase().getGameMode() == GameMode.CREATIVE || user.isGodModeEnabled()) && user.getBase().getAllowFlight()) {
|
||||
if (shouldFly(loc)) {
|
||||
user.getBase().setFlying(true);
|
||||
}
|
||||
return getRoundedDestination(loc);
|
||||
// ess can be null if old deprecated method is calling it.
|
||||
System.out.println((ess == null) + " " + ess.getSettings().isTeleportToCenterLocation());
|
||||
if (ess == null || ess.getSettings().isTeleportToCenterLocation()) {
|
||||
return getRoundedDestination(loc);
|
||||
} else {
|
||||
return loc;
|
||||
}
|
||||
}
|
||||
return getSafeDestination(loc);
|
||||
}
|
||||
|
@ -15,6 +15,9 @@ import static com.earth2me.essentials.I18n.tl;
|
||||
public class NumberUtil {
|
||||
static DecimalFormat twoDPlaces = new DecimalFormat("#,###.##");
|
||||
static DecimalFormat currencyFormat = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
|
||||
|
||||
// This field is likely to be modified in com.earth2me.essentials.Settings when loading currency format.
|
||||
// This ensures that we can supply a constant formatting.
|
||||
static final NumberFormat PRETTY_FORMAT = NumberFormat.getInstance(Locale.US);
|
||||
|
||||
static {
|
||||
|
@ -64,6 +64,9 @@ teleport-delay: 0
|
||||
# This will also prevent the player attacking other players.
|
||||
teleport-invulnerability: 4
|
||||
|
||||
# Whether to make all teleportations go to the center of the block; where the x and z coordinates decimal become .5
|
||||
teleport-to-center: true
|
||||
|
||||
# The delay, in seconds, required between /heal or /feed attempts.
|
||||
heal-cooldown: 60
|
||||
|
||||
@ -322,6 +325,15 @@ enabledSigns:
|
||||
# Lower numbers will reduce the possibility of lag, but may annoy players.
|
||||
sign-use-per-second: 4
|
||||
|
||||
# List of sign names Essentials should not protect. This feature is especially useful when
|
||||
# another plugin provides a sign that EssentialsX provides, but Essentials overrides.
|
||||
# For example, if a plugin provides a [kit] sign, and you wish to use theirs instead of
|
||||
# Essentials's, then simply add kit below and Essentials will not protect it.
|
||||
#
|
||||
# See https://github.com/drtshock/Essentials/pull/699 for more information.
|
||||
unprotected-sign-names:
|
||||
#- kit
|
||||
|
||||
# Backup runs a batch/bash command while saving is disabled.
|
||||
backup:
|
||||
# Interval in minutes.
|
||||
@ -481,6 +493,28 @@ send-fly-enable-on-join: true
|
||||
# Give someone permission to teleport to a world with essentials.time.world.<worldname>.
|
||||
world-time-permissions: false
|
||||
|
||||
# Specify cooldown for both Essentials commands and external commands as well.
|
||||
# All commands do not start with a Forward Slash (/). Instead of /msg, write msg
|
||||
#
|
||||
# Wildcards are supported. E.g.
|
||||
# - '*i*': 50
|
||||
# adds a 50 second cooldown to all commands that include the letter i
|
||||
#
|
||||
# EssentialsX supports regex by starting the command with a caret ^
|
||||
# For example, to target commands starting with ban and not banip the following would be used:
|
||||
# '^ban([^ip])( .*)?': 60 # 60 seconds /ban cooldown.
|
||||
# Note: If you have a command that starts with ^, then you can escape it using backslash (\). e.g. \^command: 123
|
||||
command-cooldowns:
|
||||
# feed: 100 # 100 second cooldown on /feed command
|
||||
# '*': 5 # 5 Second cooldown on all commands
|
||||
|
||||
# Whether command cooldowns should be persistent past server shutdowns
|
||||
command-cooldown-persistence: true
|
||||
|
||||
# Whether NPC balances should be listed in balance ranking features such as /balancetop.
|
||||
# NPC balances can include features like factions from FactionsUUID plugin.
|
||||
npcs-in-balance-ranking: false
|
||||
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
# | EssentialsHome | #
|
||||
@ -560,6 +594,19 @@ use-bukkit-permissions: false
|
||||
# Minimum acceptable amount to be used in /pay.
|
||||
minimum-pay-amount: 0.001
|
||||
|
||||
# The format of currency, excluding symbols. See currency-sumbol-format-locale for symbol configuration.
|
||||
#
|
||||
# "#,##0.00" is how the majority of countries display currency.
|
||||
#currency-format: "#,##0.00"
|
||||
|
||||
# Format currency symbols. Some locales use , and . interchangeably.
|
||||
# Some formats do not display properly in-game due to faulty Minecraft font rendering.
|
||||
#
|
||||
# For 1.234,50 use de-DE
|
||||
# For 1,234.50 use en-US
|
||||
# For 1'234,50 use fr-ch
|
||||
#currency-symbol-format-locale: en-US
|
||||
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
# | EssentialsHelp | #
|
||||
@ -801,4 +848,7 @@ respawn-listener-priority: high
|
||||
# When users die, should they respawn at their first home or bed, instead of the spawnpoint?
|
||||
respawn-at-home: false
|
||||
|
||||
# Teleport all joining players to the spawnpoint
|
||||
spawn-on-join: false
|
||||
|
||||
# End of file <-- No seriously, you're done with configuration.
|
||||
|
@ -575,3 +575,4 @@ msgEnabled=\u00a76Receiving messages \u00a7cenabled\u00a76.
|
||||
msgEnabledFor=\u00a76Receiving messages \u00a7cenabled \u00a76for \u00a7c{0}\u00a76.
|
||||
msgIgnore=\u00a7c{0} \u00a74has messages disabled.
|
||||
minimumPayAmount=\u00a7cThe minimum amount you can pay is {0}.
|
||||
commandCooldown=\u00a7cYou cannot type that command for {0}.
|
||||
|
@ -564,3 +564,4 @@ spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
||||
commandCooldown=\u00a7cYou cannot type that command for {0}.
|
||||
|
@ -564,3 +564,4 @@ spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
||||
commandCooldown=\u00a7cYou cannot type that command for {0}.
|
||||
|
@ -568,3 +568,4 @@ spectator=Zuschauer
|
||||
kitContains=\u00a76Ausr\u00fcstung \u00a7c{0} \u00a76enth\u00e4lt:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Ung\u00fcltige Banner-Syntax.
|
||||
commandCooldown=\u00a7cYou cannot type that command for {0}.
|
||||
|
@ -568,3 +568,4 @@ msgDisabled=\u00a76Receiving messages \u00a7cdisabled\u00a76.
|
||||
msgDisabledFor=\u00a76Receiving messages \u00a7cdisabled \u00a76for \u00a7c{0}\u00a76.
|
||||
msgEnabled=\u00a76Receiving messages \u00a7cenabled\u00a76.
|
||||
msgEnabledFor=\u00a76Receiving messages \u00a7cenabled \u00a76for \u00a7c{0}\u00a76.
|
||||
commandCooldown=\u00a7cYou cannot type that command for {0}.
|
||||
|
@ -564,3 +564,4 @@ spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
||||
commandCooldown=\u00a7cYou cannot type that command for {0}.
|
||||
|
@ -564,3 +564,4 @@ spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
||||
commandCooldown=\u00a7cYou cannot type that command for {0}.
|
||||
|
@ -564,3 +564,4 @@ spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
||||
commandCooldown=\u00a7cYou cannot type that command for {0}.
|
||||
|
@ -112,7 +112,7 @@ extinguishOthers=\u00a77Vous avez \u00e9teint le feu sur {0}.
|
||||
failedToCloseConfig=\u00c9chec de la fermeture de la configuration {0}.
|
||||
failedToCreateConfig=\u00c9chec de la cr\u00e9ation de la configuration {0}.
|
||||
failedToWriteConfig=\u00c9chec de l''\u00e9criture de la configuration {0}.
|
||||
false=\u00a74faux\u00a7f
|
||||
false=\u00a74non\u00a7f
|
||||
feed=\u00a77Vous avez \u00e9t\u00e9 rassasi\u00e9.
|
||||
feedOther=\u00a76Vous avez rassasi\u00e9 \u00a7c{0}\u00a76.
|
||||
fileRenameError=\u00c9chec du changement de nom de {0}.
|
||||
@ -120,7 +120,7 @@ fireworkColor=\u00a74Vous devez ajouter une couleur au feu d''artifice pour pouv
|
||||
fireworkEffectsCleared=\u00a76Les effets ont \u00e9t\u00e9 retir\u00e9s.
|
||||
fireworkSyntax=\u00a76Param\u00e8tres du feu d''artifice \:\u00a7c color\:<color> [fade\:<color>] [shape\:<shape>] [effect\:<effect>]\n\u00a76Pour utiliser plusieurs couleurs/effets, s\u00e9parez les valeurs avec des virgules \: \u00a7cred,blue,pink\n\u00a76Shapes \:\u00a7c star, ball, large, creeper, burst \u00a76Effects \:\u00a7c trail, twinkle
|
||||
flyMode=\u00a77Fly mode {0} pour {1} d\u00e9fini.
|
||||
flying=volant
|
||||
flying=vole
|
||||
foreverAlone=\u00a7cVous n''avez personne \u00e0 qui r\u00e9pondre.
|
||||
fullStack=\u00a74Vous avez d\u00e9j\u00e0 un stack complet.
|
||||
gameMode=\u00a76Mode de jeu\u00a7c {0} \u00a76pour \u00a7c{1}\u00a76.
|
||||
@ -293,7 +293,7 @@ notAllowedToQuestion=\u00a7cVous n''\u00eates pas autoris\u00e9 \u00e0 poser des
|
||||
notAllowedToShout=\u00a7cVous n''\u00eates pas autoris\u00e9 \u00e0 crier.
|
||||
notEnoughExperience=Vous n''avez pas assez d''exp\u00e9rience.
|
||||
notEnoughMoney=Vous n''avez pas les fonds n\u00e9cessaires.
|
||||
notFlying=ne volant pas
|
||||
notFlying=ne vole pas
|
||||
notRecommendedBukkit=* \! * Cette version de Bukkit n''est pas recommand\u00e9 pour cette version de Essentials.
|
||||
notSupportedYet=Pas encore pris en charge.
|
||||
nothingInHand=\u00a7cVous n''avez rien en main.
|
||||
@ -444,7 +444,7 @@ tradeSignEmpty=Le panneau de vente n''a pas encore assez de stock.
|
||||
tradeSignEmptyOwner=Il n''y a rien \u00e0 collecter de cette pancarte d''\u00e9change commercial.
|
||||
treeFailure=\u00a7c\u00c9chec de la g\u00e9n\u00e9ration de l''arbre. Essayez de nouveau sur de l''herbe ou de la terre.
|
||||
treeSpawned=\u00a77Arbre cr\u00e9\u00e9.
|
||||
true=\u00a72vrai\u00a7f
|
||||
true=\u00a72oui\u00a7f
|
||||
typeTpaccept=\u00a77Pour le t\u00e9l\u00e9porter, utilisez \u00a7c/tpaccept\u00a77 \u00a77ou \u00a7c/tpyes\u00a77.
|
||||
typeTpdeny=\u00a77Pour d\u00e9cliner cette demande, utilisez \u00a7c/tpdeny\u00a77 \u00a77ou \u00a7c/tpno\u00a77.
|
||||
typeWorldName=\u00a77Vous pouvez aussi taper le nom d''un monde sp\u00e9cifique.
|
||||
@ -553,7 +553,7 @@ seenAccounts=\u00a76Le joueur est aussi connu sous le(s) pseudo(s) \:\u00a7c {0}
|
||||
unableToSpawnItem=\u00a74Impossible de cr\u00e9er \u00a7c{0}\u00a74, ce n''est pas un objet cr\u00e9able.
|
||||
itemsConverted=\u00a76Tous les items ont \u00e9t\u00e9 convertis en blocs.
|
||||
itemsNotConverted=\u00a74Vous n''avez pas d''items pouvant \u00eatre convertis en blocs.
|
||||
mailSentTo=\u00a7c{0}\u00a76 a envoy\u00e9 le mail suivant \:
|
||||
mailSentTo=\u00a76Mail suivant envoy\u00e9 a \u00a7c{0}\u00a76\:
|
||||
mailMessage={0}
|
||||
|
||||
whoisTempBanned=\u00a76 - Expiration du ban:\u00a7r {0}
|
||||
@ -569,3 +569,4 @@ msgDisabled=\u00a76R\u00e9ception des messages \u00a7cd\u00e9sactiv\u00e9e\u00a7
|
||||
msgDisabledFor=\u00a76R\u00e9ception des messages \u00a7cd\u00e9sactiv\u00e9e \u00a76pour \u00a7c{0}\u00a76.
|
||||
msgEnabled=\u00a76R\u00e9ception des messages \u00a7cactiv\u00e9e\u00a76.
|
||||
msgEnabledFor=\u00a76R\u00e9ception des messages \u00a7cactiv\u00e9e \u00a76pour \u00a7c{0}\u00a76.
|
||||
commandCooldown=\u00a7cYou cannot type that command for {0}.
|
||||
|
@ -564,3 +564,4 @@ spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
||||
commandCooldown=\u00a7cYou cannot type that command for {0}.
|
||||
|
@ -564,3 +564,4 @@ spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
||||
commandCooldown=\u00a7cYou cannot type that command for {0}.
|
||||
|
@ -564,3 +564,4 @@ spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
||||
commandCooldown=\u00a7cYou cannot type that command for {0}.
|
||||
|
@ -564,3 +564,4 @@ spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
||||
commandCooldown=\u00a7cYou cannot type that command for {0}.
|
||||
|
@ -564,3 +564,4 @@ spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
||||
commandCooldown=\u00a7cYou cannot type that command for {0}.
|
||||
|
@ -564,3 +564,4 @@ spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
||||
commandCooldown=\u00a7cYou cannot type that command for {0}.
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -564,3 +564,4 @@ spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
||||
commandCooldown=\u00a7cYou cannot type that command for {0}.
|
||||
|
@ -104,7 +104,7 @@ errorWithMessage=\u00a7c\u041e\u0448\u0438\u0431\u043a\u0430\:\u00a74 {0}
|
||||
essentialsHelp1=\u0424\u0430\u0439\u043b \u0438\u0441\u043f\u043e\u0440\u0447\u0435\u043d, Essentials \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0435\u0433\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c. Essentials \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d. \u0422\u044b \u043c\u043e\u0436\u0435\u0448\u044c \u0441\u0430\u043c \u0443\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u044c \u044d\u0442\u043e, \u043f\u0435\u0440\u0435\u0439\u0434\u044f \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 http\://tiny.cc/EssentialsChat
|
||||
essentialsHelp2=\u0424\u0430\u0439\u043b \u0438\u0441\u043f\u043e\u0440\u0447\u0435\u043d, Essentials \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0435\u0433\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c. Essentials \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d. \u0422\u044b \u043c\u043e\u0436\u0435\u0448\u044c \u0441\u0430\u043c \u0443\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u044c \u044d\u0442\u043e, \u0432\u0432\u0435\u0434\u044f /essentialshelp \u0432 \u0438\u0433\u0440\u0435, \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0439\u0434\u044f \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 http\://tiny.cc/EssentialsChat
|
||||
essentialsReload=\u00a76Essentials \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u00a7c {0}.
|
||||
exp=c{0} \u00a76\u0438\u043c\u0435\u0435\u0442\u00a7c {1} \u00a76\u043e\u043f\u044b\u0442\u0430 (\u0443\u0440\u043e\u0432\u0435\u043d\u044c\u00a7c {2}\u00a76) \u043d\u0443\u0436\u043d\u043e\u00a7c {3} \u00a76\u043e\u043f\u044b\u0442\u0430 \u0434\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f.
|
||||
exp={0} \u00a76\u0438\u043c\u0435\u0435\u0442\u00a7c {1} \u00a76\u043e\u043f\u044b\u0442\u0430 (\u0443\u0440\u043e\u0432\u0435\u043d\u044c\u00a7c {2}\u00a76) \u043d\u0443\u0436\u043d\u043e\u00a7c {3} \u00a76\u043e\u043f\u044b\u0442\u0430 \u0434\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f.
|
||||
expSet=\u00a7c{0} \u00a76\u0442\u0435\u043f\u0435\u0440\u044c \u0438\u043c\u0435\u0435\u0442\u00a7c {1} \u00a76\u043e\u043f\u044b\u0442\u0430.
|
||||
extinguish=\u00a76\u0412\u044b \u043f\u043e\u0442\u0443\u0448\u0438\u043b\u0438 \u0441\u0435\u0431\u044f.
|
||||
extinguishOthers=\u00a76\u0412\u044b \u043f\u043e\u0442\u0443\u0448\u0438\u043b\u0438 {0}\u00a76.
|
||||
@ -564,3 +564,4 @@ spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
||||
commandCooldown=\u00a7cYou cannot type that command for {0}.
|
||||
|
@ -564,3 +564,4 @@ spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
||||
commandCooldown=\u00a7cYou cannot type that command for {0}.
|
||||
|
@ -564,3 +564,4 @@ spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
||||
commandCooldown=\u00a7cYou cannot type that command for {0}.
|
||||
|
@ -564,3 +564,4 @@ spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
||||
commandCooldown=\u00a7cYou cannot type that command for {0}.
|
||||
|
@ -564,3 +564,4 @@ spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
||||
commandCooldown=\u00a7cYou cannot type that command for {0}.
|
||||
|
@ -564,3 +564,4 @@ spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
||||
commandCooldown=\u00a7cYou cannot type that command for {0}.
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.ess3.api.events;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@ -11,7 +13,7 @@ public class UserBalanceUpdateEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final Player player;
|
||||
private final BigDecimal originalBalance;
|
||||
private final BigDecimal balance;
|
||||
private BigDecimal balance;
|
||||
|
||||
public UserBalanceUpdateEvent(Player player, BigDecimal originalBalance, BigDecimal balance) {
|
||||
this.player = player;
|
||||
@ -35,6 +37,11 @@ public class UserBalanceUpdateEvent extends Event {
|
||||
public BigDecimal getNewBalance() {
|
||||
return balance;
|
||||
}
|
||||
|
||||
public void setNewBalance(BigDecimal newBalance) {
|
||||
Preconditions.checkNotNull(newBalance, "newBalance cannot be null.");
|
||||
this.balance = newBalance;
|
||||
}
|
||||
|
||||
public BigDecimal getOldBalance() {
|
||||
return originalBalance;
|
||||
|
@ -0,0 +1,12 @@
|
||||
package net.ess3.api.events;
|
||||
|
||||
import net.ess3.api.IUser;
|
||||
|
||||
/**
|
||||
* Called only in Commandvanish. For other events please use classes such as PlayerJoinEvent and eventually {@link IUser#isVanished()}.
|
||||
*/
|
||||
public class VanishStatusChangeEvent extends StatusChangeEvent {
|
||||
public VanishStatusChangeEvent(IUser affected, IUser controller, boolean value) {
|
||||
super(affected, controller, value);
|
||||
}
|
||||
}
|
@ -68,9 +68,27 @@ public class EssentialsSpawnPlayerListener implements Listener {
|
||||
});
|
||||
}
|
||||
|
||||
public void delayedJoin(Player player) {
|
||||
public void delayedJoin(final Player player) {
|
||||
if (player.hasPlayedBefore()) {
|
||||
LOGGER.log(Level.FINE, "Old player join");
|
||||
|
||||
if (ess.getSettings().isSpawnOnJoin()) {
|
||||
final User user = ess.getUser(player);
|
||||
if (!user.isAuthorized("essentials.spawn-on-join.exempt")) {
|
||||
ess.scheduleSyncDelayedTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Location spawn = spawns.getSpawn(user.getGroup());
|
||||
try {
|
||||
user.getTeleport().now(spawn, false, TeleportCause.PLUGIN);
|
||||
} catch (Exception e) {
|
||||
ess.showError(user.getSource(), e, "spawn-on-join");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -15,4 +15,8 @@ commands:
|
||||
spawn:
|
||||
description: Teleport to the spawnpoint.
|
||||
usage: /<command> [player]
|
||||
aliases: [espawn]
|
||||
aliases: [espawn]
|
||||
permissions:
|
||||
essentials.spawn-on-join.exempt:
|
||||
default: false
|
||||
description: "Bypass spawn teleportation on join when spawn-on-join is true."
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.ess3.nms.refl;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.HashBasedTable;
|
||||
import com.google.common.collect.Table;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -10,8 +12,16 @@ import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ReflUtil {
|
||||
public static final NMSVersion V1_8_R1 = NMSVersion.fromString("v1_8_R1");
|
||||
public static final NMSVersion V1_8_R2 = NMSVersion.fromString("v1_8_R2");
|
||||
public static final NMSVersion V1_8_R3 = NMSVersion.fromString("v1_8_R3");
|
||||
public static final NMSVersion V1_9_R1 = NMSVersion.fromString("v1_9_R1");
|
||||
public static final NMSVersion V1_10_R1 = NMSVersion.fromString("v1_10_R1");
|
||||
private static NMSVersion nmsVersionObject;
|
||||
private static String nmsVersion;
|
||||
|
||||
public static String getNMSVersion() {
|
||||
@ -22,6 +32,13 @@ public class ReflUtil {
|
||||
}
|
||||
return nmsVersion;
|
||||
}
|
||||
|
||||
public static NMSVersion getNmsVersionObject() {
|
||||
if (nmsVersionObject == null) {
|
||||
nmsVersionObject = NMSVersion.fromString(getNMSVersion());
|
||||
}
|
||||
return nmsVersionObject;
|
||||
}
|
||||
|
||||
public static Class<?> getNMSClass(String className) {
|
||||
return getClassCached("net.minecraft.server." + getNMSVersion() + "." + className);
|
||||
@ -200,4 +217,104 @@ public class ReflUtil {
|
||||
return Arrays.deepHashCode(params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* https://gist.github.com/SupaHam/dad1db6406596c5f8e4b221ff473831c
|
||||
*
|
||||
* @author SupaHam (<a href="https://github.com/SupaHam">https://github.com/SupaHam</a>)
|
||||
*/
|
||||
public static class NMSVersion implements Comparable<NMSVersion> {
|
||||
private static final Pattern VERSION_PATTERN = Pattern.compile("^v(\\d+)_(\\d+)_R(\\d+)");
|
||||
private final int major;
|
||||
private final int minor;
|
||||
private final int release;
|
||||
|
||||
public static NMSVersion fromString(String string) {
|
||||
Preconditions.checkNotNull(string, "string cannot be null.");
|
||||
Matcher matcher = VERSION_PATTERN.matcher(string);
|
||||
Preconditions.checkArgument(matcher.matches(), string + " is not in valid version format. e.g. v1_10_R1");
|
||||
return new NMSVersion(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2)), Integer.parseInt(matcher.group(3)));
|
||||
}
|
||||
|
||||
private NMSVersion(int major, int minor, int release) {
|
||||
this.major = major;
|
||||
this.minor = minor;
|
||||
this.release = release;
|
||||
}
|
||||
|
||||
public boolean isHigherThan(NMSVersion o) {
|
||||
return compareTo(o) > 0;
|
||||
}
|
||||
|
||||
public boolean isHigherThanOrEqualTo(NMSVersion o) {
|
||||
return compareTo(o) >= 0;
|
||||
}
|
||||
|
||||
public boolean isLowerThan(NMSVersion o) {
|
||||
return compareTo(o) < 0;
|
||||
}
|
||||
|
||||
public boolean isLowerThanOrEqualTo(NMSVersion o) {
|
||||
return compareTo(o) <= 0;
|
||||
}
|
||||
|
||||
public int getMajor() {
|
||||
return major;
|
||||
}
|
||||
|
||||
public int getMinor() {
|
||||
return minor;
|
||||
}
|
||||
|
||||
public int getRelease() {
|
||||
return release;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
NMSVersion that = (NMSVersion) o;
|
||||
return major == that.major &&
|
||||
minor == that.minor &&
|
||||
release == that.release;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(major, minor, release);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "v" + major + "_" + minor + "_R" + release;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(NMSVersion o) {
|
||||
if (major < o.major) {
|
||||
return -1;
|
||||
} else if (major > o.major) {
|
||||
return 1;
|
||||
} else { // equal major
|
||||
if (minor < o.minor) {
|
||||
return -1;
|
||||
} else if (minor > o.minor) {
|
||||
return 1;
|
||||
} else { // equal minor
|
||||
if (release < o.release) {
|
||||
return -1;
|
||||
} else if (release > o.release) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0; // o is the same version as this.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,51 @@
|
||||
package net.ess3.nms.refl;
|
||||
|
||||
import net.ess3.nms.refl.ReflUtil.NMSVersion;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class NMSVersionTest {
|
||||
|
||||
@Test
|
||||
public void testMajor() throws Exception {
|
||||
NMSVersion v2_9_R1 = NMSVersion.fromString("v2_9_R1");
|
||||
|
||||
Assert.assertEquals(2, v2_9_R1.getMajor());
|
||||
Assert.assertEquals(9, v2_9_R1.getMinor());
|
||||
Assert.assertEquals(1, v2_9_R1.getRelease());
|
||||
|
||||
Assert.assertEquals(v2_9_R1.toString(), "v2_9_R1");
|
||||
|
||||
Assert.assertTrue(v2_9_R1.isHigherThan(NMSVersion.fromString("v1_10_R1")));
|
||||
Assert.assertTrue(v2_9_R1.isHigherThanOrEqualTo(NMSVersion.fromString("v1_9_R1")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinor() throws Exception {
|
||||
NMSVersion v1_10_R1 = NMSVersion.fromString("v1_10_R1");
|
||||
|
||||
Assert.assertEquals(1, v1_10_R1.getMajor());
|
||||
Assert.assertEquals(10, v1_10_R1.getMinor());
|
||||
Assert.assertEquals(1, v1_10_R1.getRelease());
|
||||
|
||||
Assert.assertEquals(v1_10_R1.toString(), "v1_10_R1");
|
||||
|
||||
Assert.assertTrue(NMSVersion.fromString("v1_9_R1").isLowerThan(v1_10_R1));
|
||||
Assert.assertTrue(NMSVersion.fromString("v1_9_R1").isLowerThanOrEqualTo(v1_10_R1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRelease() throws Exception {
|
||||
NMSVersion v1_9_R2 = NMSVersion.fromString("v1_9_R2");
|
||||
|
||||
Assert.assertEquals(1, v1_9_R2.getMajor());
|
||||
Assert.assertEquals(9, v1_9_R2.getMinor());
|
||||
Assert.assertEquals(2, v1_9_R2.getRelease());
|
||||
|
||||
Assert.assertEquals(v1_9_R2.toString(), "v1_9_R2");
|
||||
Assert.assertEquals(v1_9_R2, NMSVersion.fromString("v1_9_R2"));
|
||||
|
||||
Assert.assertTrue(v1_9_R2.isHigherThan(NMSVersion.fromString("v1_9_R1")));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user