mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-23 09:37:50 +01:00
Cleanup code (#3067)
Co-Authored-By: md678685 <1917406+md678685@users.noreply.github.com> Basically cleans up a bunch of warnings that are easily suppressed.
This commit is contained in:
parent
6bbdbc89a6
commit
23f0f98af3
@ -46,15 +46,12 @@ public class AlternativeCommandsHandler {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (String label : labels) {
|
for (String label : labels) {
|
||||||
List<PluginCommand> plugincommands = altcommands.get(label.toLowerCase(Locale.ENGLISH));
|
List<PluginCommand> plugincommands = altcommands.computeIfAbsent(label.toLowerCase(Locale.ENGLISH), k -> new ArrayList<>());
|
||||||
if (plugincommands == null) {
|
|
||||||
plugincommands = new ArrayList<>();
|
|
||||||
altcommands.put(label.toLowerCase(Locale.ENGLISH), plugincommands);
|
|
||||||
}
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (PluginCommand pc2 : plugincommands) {
|
for (PluginCommand pc2 : plugincommands) {
|
||||||
if (pc2.getPlugin().equals(plugin)) {
|
if (pc2.getPlugin().equals(plugin)) {
|
||||||
found = true;
|
found = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
@ -68,13 +65,7 @@ public class AlternativeCommandsHandler {
|
|||||||
final Iterator<Map.Entry<String, List<PluginCommand>>> iterator = altcommands.entrySet().iterator();
|
final Iterator<Map.Entry<String, List<PluginCommand>>> iterator = altcommands.entrySet().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
final Map.Entry<String, List<PluginCommand>> entry = iterator.next();
|
final Map.Entry<String, List<PluginCommand>> entry = iterator.next();
|
||||||
final Iterator<PluginCommand> pcIterator = entry.getValue().iterator();
|
entry.getValue().removeIf(pc -> pc.getPlugin() == null || pc.getPlugin().equals(plugin));
|
||||||
while (pcIterator.hasNext()) {
|
|
||||||
final PluginCommand pc = pcIterator.next();
|
|
||||||
if (pc.getPlugin() == null || pc.getPlugin().equals(plugin)) {
|
|
||||||
pcIterator.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (entry.getValue().isEmpty()) {
|
if (entry.getValue().isEmpty()) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
|
@ -73,54 +73,43 @@ public class Backup implements Runnable {
|
|||||||
server.dispatchCommand(cs, "save-all");
|
server.dispatchCommand(cs, "save-all");
|
||||||
server.dispatchCommand(cs, "save-off");
|
server.dispatchCommand(cs, "save-off");
|
||||||
|
|
||||||
ess.runTaskAsynchronously(new Runnable() {
|
ess.runTaskAsynchronously(() -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
final ProcessBuilder childBuilder = new ProcessBuilder(command);
|
||||||
try {
|
childBuilder.redirectErrorStream(true);
|
||||||
final ProcessBuilder childBuilder = new ProcessBuilder(command);
|
childBuilder.directory(ess.getDataFolder().getParentFile().getParentFile());
|
||||||
childBuilder.redirectErrorStream(true);
|
final Process child = childBuilder.start();
|
||||||
childBuilder.directory(ess.getDataFolder().getParentFile().getParentFile());
|
ess.runTaskAsynchronously(() -> {
|
||||||
final Process child = childBuilder.start();
|
try {
|
||||||
ess.runTaskAsynchronously(new Runnable() {
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(child.getInputStream()))) {
|
||||||
@Override
|
String line;
|
||||||
public void run() {
|
do {
|
||||||
try {
|
line = reader.readLine();
|
||||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(child.getInputStream()));
|
if (line != null) {
|
||||||
try {
|
LOGGER.log(Level.INFO, line);
|
||||||
String line;
|
|
||||||
do {
|
|
||||||
line = reader.readLine();
|
|
||||||
if (line != null) {
|
|
||||||
LOGGER.log(Level.INFO, line);
|
|
||||||
}
|
|
||||||
} while (line != null);
|
|
||||||
} finally {
|
|
||||||
reader.close();
|
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} while (line != null);
|
||||||
LOGGER.log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
child.waitFor();
|
|
||||||
} catch (InterruptedException ex) {
|
|
||||||
LOGGER.log(Level.SEVERE, null, ex);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
LOGGER.log(Level.SEVERE, null, ex);
|
|
||||||
} finally {
|
|
||||||
class BackupEnableSaveTask implements Runnable {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
server.dispatchCommand(cs, "save-on");
|
|
||||||
if (ess.getOnlinePlayers().isEmpty()) {
|
|
||||||
stopTask();
|
|
||||||
}
|
|
||||||
active = false;
|
|
||||||
LOGGER.log(Level.INFO, tl("backupFinished"));
|
|
||||||
}
|
}
|
||||||
|
} catch (IOException ex) {
|
||||||
|
LOGGER.log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
child.waitFor();
|
||||||
|
} catch (InterruptedException | IOException ex) {
|
||||||
|
LOGGER.log(Level.SEVERE, null, ex);
|
||||||
|
} finally {
|
||||||
|
class BackupEnableSaveTask implements Runnable {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
server.dispatchCommand(cs, "save-on");
|
||||||
|
if (ess.getOnlinePlayers().isEmpty()) {
|
||||||
|
stopTask();
|
||||||
|
}
|
||||||
|
active = false;
|
||||||
|
LOGGER.log(Level.INFO, tl("backupFinished"));
|
||||||
}
|
}
|
||||||
ess.scheduleSyncDelayedTask(new BackupEnableSaveTask());
|
|
||||||
}
|
}
|
||||||
|
ess.scheduleSyncDelayedTask(new BackupEnableSaveTask());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@ import java.util.Set;
|
|||||||
|
|
||||||
|
|
||||||
public class Enchantments {
|
public class Enchantments {
|
||||||
private static final Map<String, Enchantment> ENCHANTMENTS = new HashMap<String, Enchantment>();
|
private static final Map<String, Enchantment> ENCHANTMENTS = new HashMap<>();
|
||||||
private static final Map<String, Enchantment> ALIASENCHANTMENTS = new HashMap<String, Enchantment>();
|
private static final Map<String, Enchantment> ALIASENCHANTMENTS = new HashMap<>();
|
||||||
private static boolean isFlat;
|
private static boolean isFlat;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -570,9 +570,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
|||||||
cmd.run(getServer(), user, commandLabel, command, args);
|
cmd.run(getServer(), user, commandLabel, command, args);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (NoChargeException ex) {
|
} catch (NoChargeException | QuietAbortException ex) {
|
||||||
return true;
|
|
||||||
} catch (QuietAbortException ex) {
|
|
||||||
return true;
|
return true;
|
||||||
} catch (NotEnoughArgumentsException ex) {
|
} catch (NotEnoughArgumentsException ex) {
|
||||||
sender.sendMessage(command.getDescription());
|
sender.sendMessage(command.getDescription());
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
import com.earth2me.essentials.utils.EnumUtil;
|
|
||||||
import com.earth2me.essentials.utils.LocationUtil;
|
import com.earth2me.essentials.utils.LocationUtil;
|
||||||
import com.earth2me.essentials.utils.MaterialUtil;
|
import com.earth2me.essentials.utils.MaterialUtil;
|
||||||
import net.ess3.api.IEssentials;
|
import net.ess3.api.IEssentials;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.CreatureSpawner;
|
import org.bukkit.block.CreatureSpawner;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n.tl;
|
|
||||||
|
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
import java.io.File;
|
import net.ess3.api.InvalidWorldException;
|
||||||
import java.io.FileInputStream;
|
import org.bukkit.OfflinePlayer;
|
||||||
import java.io.FileNotFoundException;
|
import org.bukkit.*;
|
||||||
import java.io.FileOutputStream;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import java.io.IOException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import java.io.InputStream;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import java.io.OutputStream;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import java.io.OutputStreamWriter;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.MathContext;
|
import java.math.MathContext;
|
||||||
import java.nio.Buffer;
|
import java.nio.Buffer;
|
||||||
@ -19,13 +20,8 @@ import java.nio.CharBuffer;
|
|||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.CharsetDecoder;
|
import java.nio.charset.CharsetDecoder;
|
||||||
import java.nio.charset.CoderResult;
|
import java.nio.charset.CoderResult;
|
||||||
import java.util.ArrayList;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
@ -34,25 +30,15 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import net.ess3.api.InvalidWorldException;
|
|
||||||
import org.bukkit.Location;
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.Server;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
|
|
||||||
public class EssentialsConf extends YamlConfiguration {
|
public class EssentialsConf extends YamlConfiguration {
|
||||||
protected static final Logger LOGGER = Logger.getLogger("Essentials");
|
protected static final Logger LOGGER = Logger.getLogger("Essentials");
|
||||||
protected final File configFile;
|
protected final File configFile;
|
||||||
protected String templateName = null;
|
protected String templateName = null;
|
||||||
protected static final Charset UTF8 = Charset.forName("UTF-8");
|
protected static final Charset UTF8 = StandardCharsets.UTF_8;
|
||||||
private Class<?> resourceClass = EssentialsConf.class;
|
private Class<?> resourceClass = EssentialsConf.class;
|
||||||
private static final ExecutorService EXECUTOR_SERVICE = Executors.newSingleThreadExecutor();
|
private static final ExecutorService EXECUTOR_SERVICE = Executors.newSingleThreadExecutor();
|
||||||
private final AtomicInteger pendingDiskWrites = new AtomicInteger(0);
|
private final AtomicInteger pendingDiskWrites = new AtomicInteger(0);
|
||||||
@ -454,9 +440,7 @@ public class EssentialsConf extends YamlConfiguration {
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
return new BigDecimal(input, MathContext.DECIMAL128);
|
return new BigDecimal(input, MathContext.DECIMAL128);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException | ArithmeticException e) {
|
||||||
return def;
|
|
||||||
} catch (ArithmeticException e) {
|
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -356,7 +356,7 @@ public class EssentialsPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class DelayMotdTask implements Runnable {
|
class DelayMotdTask implements Runnable {
|
||||||
private User user;
|
private final User user;
|
||||||
|
|
||||||
public DelayMotdTask(User user) {
|
public DelayMotdTask(User user) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
@ -709,7 +709,6 @@ public class EssentialsPlayerListener implements Listener {
|
|||||||
// We need to loop through each command and execute
|
// We need to loop through each command and execute
|
||||||
for (final String command : commandList) {
|
for (final String command : commandList) {
|
||||||
if (command.contains("{player}")) {
|
if (command.contains("{player}")) {
|
||||||
continue;
|
|
||||||
} else if (command.startsWith("c:")) {
|
} else if (command.startsWith("c:")) {
|
||||||
used = true;
|
used = true;
|
||||||
user.getBase().chat(command.substring(2));
|
user.getBase().chat(command.substring(2));
|
||||||
@ -746,7 +745,7 @@ public class EssentialsPlayerListener implements Listener {
|
|||||||
if (type == InventoryType.PLAYER) {
|
if (type == InventoryType.PLAYER) {
|
||||||
final User user = ess.getUser((Player) event.getWhoClicked());
|
final User user = ess.getUser((Player) event.getWhoClicked());
|
||||||
final InventoryHolder invHolder = top.getHolder();
|
final InventoryHolder invHolder = top.getHolder();
|
||||||
if (invHolder != null && invHolder instanceof HumanEntity) {
|
if (invHolder instanceof HumanEntity) {
|
||||||
final User invOwner = ess.getUser((Player) invHolder);
|
final User invOwner = ess.getUser((Player) invHolder);
|
||||||
if (user.isInvSee() && (!user.isAuthorized("essentials.invsee.modify") || invOwner.isAuthorized("essentials.invsee.preventmodify") || !invOwner.getBase().isOnline())) {
|
if (user.isInvSee() && (!user.isAuthorized("essentials.invsee.modify") || invOwner.isAuthorized("essentials.invsee.preventmodify") || !invOwner.getBase().isOnline())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -768,7 +767,7 @@ public class EssentialsPlayerListener implements Listener {
|
|||||||
} else if (type == InventoryType.CHEST && top.getSize() == 9) {
|
} else if (type == InventoryType.CHEST && top.getSize() == 9) {
|
||||||
final User user = ess.getUser((Player) event.getWhoClicked());
|
final User user = ess.getUser((Player) event.getWhoClicked());
|
||||||
final InventoryHolder invHolder = top.getHolder();
|
final InventoryHolder invHolder = top.getHolder();
|
||||||
if (invHolder != null && invHolder instanceof HumanEntity && user.isInvSee()) {
|
if (invHolder instanceof HumanEntity && user.isInvSee()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
refreshPlayer = user.getBase();
|
refreshPlayer = user.getBase();
|
||||||
}
|
}
|
||||||
@ -786,8 +785,7 @@ public class EssentialsPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (refreshPlayer != null) {
|
if (refreshPlayer != null) {
|
||||||
final Player player = refreshPlayer;
|
ess.scheduleSyncDelayedTask(refreshPlayer::updateInventory, 1);
|
||||||
ess.scheduleSyncDelayedTask(player::updateInventory, 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -813,7 +811,7 @@ public class EssentialsPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
} else if (type == InventoryType.CHEST && top.getSize() == 9) {
|
} else if (type == InventoryType.CHEST && top.getSize() == 9) {
|
||||||
final InventoryHolder invHolder = top.getHolder();
|
final InventoryHolder invHolder = top.getHolder();
|
||||||
if (invHolder != null && invHolder instanceof HumanEntity) {
|
if (invHolder instanceof HumanEntity) {
|
||||||
final User user = ess.getUser((Player) event.getPlayer());
|
final User user = ess.getUser((Player) event.getPlayer());
|
||||||
user.setInvSee(false);
|
user.setInvSee(false);
|
||||||
refreshPlayer = user.getBase();
|
refreshPlayer = user.getBase();
|
||||||
@ -821,8 +819,7 @@ public class EssentialsPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (refreshPlayer != null) {
|
if (refreshPlayer != null) {
|
||||||
final Player player = refreshPlayer;
|
ess.scheduleSyncDelayedTask(refreshPlayer::updateInventory, 1);
|
||||||
ess.scheduleSyncDelayedTask(player::updateInventory, 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
|
|
||||||
public class EssentialsServerListener implements Listener {
|
public class EssentialsServerListener implements Listener {
|
||||||
private static List<String> ignoredSLPECallers = Arrays.asList(
|
private static final List<String> ignoredSLPECallers = Arrays.asList(
|
||||||
".LegacyPingHandler.channelRead(", // CB responding to pings from pre-Netty clients
|
".LegacyPingHandler.channelRead(", // CB responding to pings from pre-Netty clients
|
||||||
"de.dytanic.cloudnet.bridge.BukkitBootstrap" // CloudNet v2 doing... something
|
"de.dytanic.cloudnet.bridge.BukkitBootstrap" // CloudNet v2 doing... something
|
||||||
);
|
);
|
||||||
@ -25,7 +25,7 @@ public class EssentialsServerListener implements Listener {
|
|||||||
private final transient IEssentials ess;
|
private final transient IEssentials ess;
|
||||||
private boolean unsupportedLogged = false;
|
private boolean unsupportedLogged = false;
|
||||||
private boolean npeWarned = false;
|
private boolean npeWarned = false;
|
||||||
private boolean isPaperSample;
|
private final boolean isPaperSample;
|
||||||
private Method setSampleText;
|
private Method setSampleText;
|
||||||
private Method getSampleText;
|
private Method getSampleText;
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ public class EssentialsUpgrade {
|
|||||||
try {
|
try {
|
||||||
config.load();
|
config.load();
|
||||||
if (config.hasProperty("powertools")) {
|
if (config.hasProperty("powertools")) {
|
||||||
@SuppressWarnings("unchecked") final Map<String, Object> powertools = config.getConfigurationSection("powertools").getValues(false);
|
final Map<String, Object> powertools = config.getConfigurationSection("powertools").getValues(false);
|
||||||
if (powertools == null) {
|
if (powertools == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -204,7 +204,7 @@ public class EssentialsUpgrade {
|
|||||||
|
|
||||||
config.load();
|
config.load();
|
||||||
if (config.hasProperty("home") && config.hasProperty("home.default")) {
|
if (config.hasProperty("home") && config.hasProperty("home.default")) {
|
||||||
@SuppressWarnings("unchecked") final String defworld = (String) config.getProperty("home.default");
|
final String defworld = (String) config.getProperty("home.default");
|
||||||
final Location defloc = getFakeLocation(config, "home.worlds." + defworld);
|
final Location defloc = getFakeLocation(config, "home.worlds." + defworld);
|
||||||
if (defloc != null) {
|
if (defloc != null) {
|
||||||
config.setProperty("homes.home", defloc);
|
config.setProperty("homes.home", defloc);
|
||||||
@ -575,7 +575,7 @@ public class EssentialsUpgrade {
|
|||||||
conf.load();
|
conf.load();
|
||||||
|
|
||||||
String banReason;
|
String banReason;
|
||||||
Long banTimeout;
|
long banTimeout;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
banReason = conf.getConfigurationSection("ban").getString("reason");
|
banReason = conf.getConfigurationSection("ban").getString("reason");
|
||||||
@ -616,12 +616,7 @@ public class EssentialsUpgrade {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final FileFilter YML_FILTER = new FileFilter() {
|
private static final FileFilter YML_FILTER = pathname -> pathname.isFile() && pathname.getName().endsWith(".yml");
|
||||||
@Override
|
|
||||||
public boolean accept(File pathname) {
|
|
||||||
return pathname.isFile() && pathname.getName().endsWith(".yml");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private static final String PATTERN_CONFIG_UUID_REGEX = "(?mi)^uuid:\\s*([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\\s*$";
|
private static final String PATTERN_CONFIG_UUID_REGEX = "(?mi)^uuid:\\s*([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\\s*$";
|
||||||
private static final Pattern PATTERN_CONFIG_UUID = Pattern.compile(PATTERN_CONFIG_UUID_REGEX);
|
private static final Pattern PATTERN_CONFIG_UUID = Pattern.compile(PATTERN_CONFIG_UUID_REGEX);
|
||||||
|
@ -13,7 +13,7 @@ public class ExecuteTimer {
|
|||||||
|
|
||||||
|
|
||||||
public ExecuteTimer() {
|
public ExecuteTimer() {
|
||||||
times = new ArrayList<ExecuteRecord>();
|
times = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
|
@ -23,7 +23,7 @@ public class I18n implements net.ess3.api.II18n {
|
|||||||
private transient ResourceBundle customBundle;
|
private transient ResourceBundle customBundle;
|
||||||
private transient ResourceBundle localeBundle;
|
private transient ResourceBundle localeBundle;
|
||||||
private final transient ResourceBundle defaultBundle;
|
private final transient ResourceBundle defaultBundle;
|
||||||
private transient Map<String, MessageFormat> messageFormatCache = new HashMap<String, MessageFormat>();
|
private transient Map<String, MessageFormat> messageFormatCache = new HashMap<>();
|
||||||
private final transient IEssentials ess;
|
private final transient IEssentials ess;
|
||||||
private static final Pattern NODOUBLEMARK = Pattern.compile("''");
|
private static final Pattern NODOUBLEMARK = Pattern.compile("''");
|
||||||
private static final ResourceBundle NULL_BUNDLE = new ResourceBundle() {
|
private static final ResourceBundle NULL_BUNDLE = new ResourceBundle() {
|
||||||
@ -110,7 +110,7 @@ public class I18n implements net.ess3.api.II18n {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ResourceBundle.clearCache();
|
ResourceBundle.clearCache();
|
||||||
messageFormatCache = new HashMap<String, MessageFormat>();
|
messageFormatCache = new HashMap<>();
|
||||||
Logger.getLogger("Essentials").log(Level.INFO, String.format("Using locale %s", currentLocale.toString()));
|
Logger.getLogger("Essentials").log(Level.INFO, String.format("Using locale %s", currentLocale.toString()));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -145,7 +145,7 @@ public class I18n implements net.ess3.api.II18n {
|
|||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
try {
|
try {
|
||||||
return file.toURI().toURL();
|
return file.toURI().toURL();
|
||||||
} catch (MalformedURLException ex) {
|
} catch (MalformedURLException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -157,7 +157,7 @@ public class I18n implements net.ess3.api.II18n {
|
|||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
try {
|
try {
|
||||||
return new FileInputStream(file);
|
return new FileInputStream(file);
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (FileNotFoundException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -71,7 +71,7 @@ public interface IUser {
|
|||||||
*
|
*
|
||||||
* @return If the user is hidden or not
|
* @return If the user is hidden or not
|
||||||
*
|
*
|
||||||
* @see isVanished
|
* @see IUser#isVanished()
|
||||||
*/
|
*/
|
||||||
boolean isHidden();
|
boolean isHidden();
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ public interface IUser {
|
|||||||
*
|
*
|
||||||
* @return If the user is vanished or not
|
* @return If the user is vanished or not
|
||||||
*
|
*
|
||||||
* @see isHidden
|
* @see IUser#isHidden()
|
||||||
*/
|
*/
|
||||||
boolean isVanished();
|
boolean isVanished();
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkRegister() {
|
private void checkRegister() {
|
||||||
if (enabled == false && getCount() > 0) {
|
if (!enabled && getCount() > 0) {
|
||||||
registerListeners();
|
registerListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
|||||||
if (getData().getJails() == null) {
|
if (getData().getJails() == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
return new ArrayList<String>(getData().getJails().keySet());
|
return new ArrayList<>(getData().getJails().keySet());
|
||||||
} finally {
|
} finally {
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
|||||||
acquireWriteLock();
|
acquireWriteLock();
|
||||||
try {
|
try {
|
||||||
if (getData().getJails() == null) {
|
if (getData().getJails() == null) {
|
||||||
getData().setJails(new HashMap<String, Location>());
|
getData().setJails(new HashMap<>());
|
||||||
}
|
}
|
||||||
getData().getJails().put(jailName.toLowerCase(Locale.ENGLISH), loc);
|
getData().getJails().put(jailName.toLowerCase(Locale.ENGLISH), loc);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -50,7 +50,6 @@ public class Kit {
|
|||||||
long nextUse = getNextUse(user);
|
long nextUse = getNextUse(user);
|
||||||
|
|
||||||
if (nextUse == 0L) {
|
if (nextUse == 0L) {
|
||||||
return;
|
|
||||||
} else if (nextUse < 0L) {
|
} else if (nextUse < 0L) {
|
||||||
user.sendMessage(tl("kitOnce"));
|
user.sendMessage(tl("kitOnce"));
|
||||||
throw new NoChargeException();
|
throw new NoChargeException();
|
||||||
@ -122,7 +121,7 @@ public class Kit {
|
|||||||
throw new Exception(tl("kitNotFound"));
|
throw new Exception(tl("kitNotFound"));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final List<String> itemList = new ArrayList<String>();
|
final List<String> itemList = new ArrayList<>();
|
||||||
final Object kitItems = kit.get("items");
|
final Object kitItems = kit.get("items");
|
||||||
if (kitItems instanceof List) {
|
if (kitItems instanceof List) {
|
||||||
for (Object item : (List) kitItems) {
|
for (Object item : (List) kitItems) {
|
||||||
@ -192,14 +191,14 @@ public class Kit {
|
|||||||
final boolean isDropItemsIfFull = ess.getSettings().isDropItemsIfFull();
|
final boolean isDropItemsIfFull = ess.getSettings().isDropItemsIfFull();
|
||||||
if (isDropItemsIfFull) {
|
if (isDropItemsIfFull) {
|
||||||
if (allowOversizedStacks) {
|
if (allowOversizedStacks) {
|
||||||
overfilled = InventoryWorkaround.addOversizedItems(user.getBase().getInventory(), ess.getSettings().getOversizedStackSize(), itemList.toArray(new ItemStack[itemList.size()]));
|
overfilled = InventoryWorkaround.addOversizedItems(user.getBase().getInventory(), ess.getSettings().getOversizedStackSize(), itemList.toArray(new ItemStack[0]));
|
||||||
} else {
|
} else {
|
||||||
overfilled = InventoryWorkaround.addItems(user.getBase().getInventory(), itemList.toArray(new ItemStack[itemList.size()]));
|
overfilled = InventoryWorkaround.addItems(user.getBase().getInventory(), itemList.toArray(new ItemStack[0]));
|
||||||
}
|
}
|
||||||
for (ItemStack itemStack : overfilled.values()) {
|
for (ItemStack itemStack : overfilled.values()) {
|
||||||
int spillAmount = itemStack.getAmount();
|
int spillAmount = itemStack.getAmount();
|
||||||
if (!allowOversizedStacks) {
|
if (!allowOversizedStacks) {
|
||||||
itemStack.setAmount(spillAmount < itemStack.getMaxStackSize() ? spillAmount : itemStack.getMaxStackSize());
|
itemStack.setAmount(Math.min(spillAmount, itemStack.getMaxStackSize()));
|
||||||
}
|
}
|
||||||
while (spillAmount > 0) {
|
while (spillAmount > 0) {
|
||||||
user.getWorld().dropItemNaturally(user.getLocation(), itemStack);
|
user.getWorld().dropItemNaturally(user.getLocation(), itemStack);
|
||||||
@ -209,9 +208,9 @@ public class Kit {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (allowOversizedStacks) {
|
if (allowOversizedStacks) {
|
||||||
overfilled = InventoryWorkaround.addAllOversizedItems(user.getBase().getInventory(), ess.getSettings().getOversizedStackSize(), itemList.toArray(new ItemStack[itemList.size()]));
|
overfilled = InventoryWorkaround.addAllOversizedItems(user.getBase().getInventory(), ess.getSettings().getOversizedStackSize(), itemList.toArray(new ItemStack[0]));
|
||||||
} else {
|
} else {
|
||||||
overfilled = InventoryWorkaround.addAllItems(user.getBase().getInventory(), itemList.toArray(new ItemStack[itemList.size()]));
|
overfilled = InventoryWorkaround.addAllItems(user.getBase().getInventory(), itemList.toArray(new ItemStack[0]));
|
||||||
}
|
}
|
||||||
if (overfilled != null) {
|
if (overfilled != null) {
|
||||||
user.sendMessage(tl("kitInvFullNoDrop"));
|
user.sendMessage(tl("kitInvFullNoDrop"));
|
||||||
|
@ -64,7 +64,6 @@ public class Kits implements IConf {
|
|||||||
// you just found if you don't toLowercase it.
|
// you just found if you don't toLowercase it.
|
||||||
if (kits.isConfigurationSection(name.toLowerCase())) {
|
if (kits.isConfigurationSection(name.toLowerCase())) {
|
||||||
return kits.getConfigurationSection(name.toLowerCase()).getValues(true);
|
return kits.getConfigurationSection(name.toLowerCase()).getValues(true);
|
||||||
} else {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
|
import net.ess3.api.IEssentials;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.security.DigestInputStream;
|
import java.security.DigestInputStream;
|
||||||
@ -10,9 +13,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import net.ess3.api.IEssentials;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n.tl;
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
|
|
||||||
@ -44,13 +44,10 @@ public class ManagedFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void copyResourceAscii(final String resourceName, final File file) throws IOException {
|
public static void copyResourceAscii(final String resourceName, final File file) throws IOException {
|
||||||
final InputStreamReader reader = new InputStreamReader(ManagedFile.class.getResourceAsStream(resourceName));
|
try (InputStreamReader reader = new InputStreamReader(ManagedFile.class.getResourceAsStream(resourceName))) {
|
||||||
try {
|
|
||||||
final MessageDigest digest = getDigest();
|
final MessageDigest digest = getDigest();
|
||||||
final DigestOutputStream digestStream = new DigestOutputStream(new FileOutputStream(file), digest);
|
try (DigestOutputStream digestStream = new DigestOutputStream(new FileOutputStream(file), digest)) {
|
||||||
try {
|
try (OutputStreamWriter writer = new OutputStreamWriter(digestStream)) {
|
||||||
final OutputStreamWriter writer = new OutputStreamWriter(digestStream);
|
|
||||||
try {
|
|
||||||
final char[] buffer = new char[BUFFERSIZE];
|
final char[] buffer = new char[BUFFERSIZE];
|
||||||
do {
|
do {
|
||||||
final int length = reader.read(buffer);
|
final int length = reader.read(buffer);
|
||||||
@ -66,14 +63,8 @@ public class ManagedFile {
|
|||||||
digestStream.on(false);
|
digestStream.on(false);
|
||||||
digestStream.write('#');
|
digestStream.write('#');
|
||||||
digestStream.write(hashInt.toString(16).getBytes());
|
digestStream.write(hashInt.toString(16).getBytes());
|
||||||
} finally {
|
|
||||||
writer.close();
|
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
digestStream.close();
|
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
reader.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,8 +72,7 @@ public class ManagedFile {
|
|||||||
if (file.length() < 33) {
|
if (file.length() < 33) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
|
try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file))) {
|
||||||
try {
|
|
||||||
final byte[] buffer = new byte[(int) file.length()];
|
final byte[] buffer = new byte[(int) file.length()];
|
||||||
int position = 0;
|
int position = 0;
|
||||||
do {
|
do {
|
||||||
@ -96,8 +86,7 @@ public class ManagedFile {
|
|||||||
if (bais.skip(file.length() - 33) != file.length() - 33) {
|
if (bais.skip(file.length() - 33) != file.length() - 33) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(bais));
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(bais))) {
|
||||||
try {
|
|
||||||
String hash = reader.readLine();
|
String hash = reader.readLine();
|
||||||
if (hash != null && hash.matches("#[a-f0-9]{32}")) {
|
if (hash != null && hash.matches("#[a-f0-9]{32}")) {
|
||||||
hash = hash.substring(1);
|
hash = hash.substring(1);
|
||||||
@ -108,8 +97,7 @@ public class ManagedFile {
|
|||||||
if (!versioncheck.equalsIgnoreCase(version)) {
|
if (!versioncheck.equalsIgnoreCase(version)) {
|
||||||
bais.reset();
|
bais.reset();
|
||||||
final MessageDigest digest = getDigest();
|
final MessageDigest digest = getDigest();
|
||||||
final DigestInputStream digestStream = new DigestInputStream(bais, digest);
|
try (DigestInputStream digestStream = new DigestInputStream(bais, digest)) {
|
||||||
try {
|
|
||||||
final byte[] bytes = new byte[(int) file.length() - 33];
|
final byte[] bytes = new byte[(int) file.length() - 33];
|
||||||
digestStream.read(bytes);
|
digestStream.read(bytes);
|
||||||
final BigInteger correct = new BigInteger(hash, 16);
|
final BigInteger correct = new BigInteger(hash, 16);
|
||||||
@ -119,17 +107,11 @@ public class ManagedFile {
|
|||||||
} else {
|
} else {
|
||||||
Bukkit.getLogger().warning("File " + file.toString() + " has been modified by user and file version differs, please update the file manually.");
|
Bukkit.getLogger().warning("File " + file.toString() + " has been modified by user and file version differs, please update the file manually.");
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
digestStream.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
reader.close();
|
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
bis.close();
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -144,9 +126,8 @@ public class ManagedFile {
|
|||||||
|
|
||||||
public List<String> getLines() {
|
public List<String> getLines() {
|
||||||
try {
|
try {
|
||||||
final BufferedReader reader = new BufferedReader(new FileReader(file));
|
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||||
try {
|
final List<String> lines = new ArrayList<>();
|
||||||
final List<String> lines = new ArrayList<String>();
|
|
||||||
do {
|
do {
|
||||||
final String line = reader.readLine();
|
final String line = reader.readLine();
|
||||||
if (line == null) {
|
if (line == null) {
|
||||||
@ -156,8 +137,6 @@ public class ManagedFile {
|
|||||||
}
|
}
|
||||||
} while (true);
|
} while (true);
|
||||||
return lines;
|
return lines;
|
||||||
} finally {
|
|
||||||
reader.close();
|
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||||
|
@ -8,10 +8,6 @@ import com.earth2me.essentials.utils.FormatUtil;
|
|||||||
import com.earth2me.essentials.utils.MaterialUtil;
|
import com.earth2me.essentials.utils.MaterialUtil;
|
||||||
import com.earth2me.essentials.utils.NumberUtil;
|
import com.earth2me.essentials.utils.NumberUtil;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import net.ess3.api.IEssentials;
|
import net.ess3.api.IEssentials;
|
||||||
import net.ess3.nms.refl.ReflUtil;
|
import net.ess3.nms.refl.ReflUtil;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
@ -28,6 +24,11 @@ import org.bukkit.potion.Potion;
|
|||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n.tl;
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
|
|
||||||
|
|
||||||
@ -100,16 +101,11 @@ public class MetaItemStack {
|
|||||||
try {
|
try {
|
||||||
ess.getServer().getUnsafe().modifyItemStack(stack.clone(), "{}");
|
ess.getServer().getUnsafe().modifyItemStack(stack.clone(), "{}");
|
||||||
return true;
|
return true;
|
||||||
} catch (NullPointerException npe) {
|
|
||||||
if (ess.getSettings().isDebug()) {
|
|
||||||
ess.getLogger().log(Level.INFO, "Itemstack is invalid", npe);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
} catch (NoSuchMethodError nsme) {
|
} catch (NoSuchMethodError nsme) {
|
||||||
return true;
|
return true;
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable npe) {
|
||||||
if (ess.getSettings().isDebug()) {
|
if (ess.getSettings().isDebug()) {
|
||||||
ess.getLogger().log(Level.INFO, "Itemstack is invalid", throwable);
|
ess.getLogger().log(Level.INFO, "Itemstack is invalid", npe);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -161,7 +157,7 @@ public class MetaItemStack {
|
|||||||
meta.setDisplayName(displayName);
|
meta.setDisplayName(displayName);
|
||||||
stack.setItemMeta(meta);
|
stack.setItemMeta(meta);
|
||||||
} else if (split.length > 1 && (split[0].equalsIgnoreCase("lore") || split[0].equalsIgnoreCase("desc")) && hasMetaPermission(sender, "lore", false, true, ess)) {
|
} else if (split.length > 1 && (split[0].equalsIgnoreCase("lore") || split[0].equalsIgnoreCase("desc")) && hasMetaPermission(sender, "lore", false, true, ess)) {
|
||||||
final List<String> lore = new ArrayList<String>();
|
final List<String> lore = new ArrayList<>();
|
||||||
for (String line : split[1].split("(?<!\\\\)\\|")) {
|
for (String line : split[1].split("(?<!\\\\)\\|")) {
|
||||||
lore.add(FormatUtil.replaceFormat(line.replace('_', ' ').replace("\\|", "|")));
|
lore.add(FormatUtil.replaceFormat(line.replace('_', ' ').replace("\\|", "|")));
|
||||||
}
|
}
|
||||||
@ -169,7 +165,7 @@ public class MetaItemStack {
|
|||||||
meta.setLore(lore);
|
meta.setLore(lore);
|
||||||
stack.setItemMeta(meta);
|
stack.setItemMeta(meta);
|
||||||
} else if (split[0].equalsIgnoreCase("unbreakable") && hasMetaPermission(sender, "unbreakable", false, true, ess)) {
|
} else if (split[0].equalsIgnoreCase("unbreakable") && hasMetaPermission(sender, "unbreakable", false, true, ess)) {
|
||||||
boolean value = split.length > 1 ? Boolean.valueOf(split[1]) : true;
|
boolean value = split.length <= 1 || Boolean.parseBoolean(split[1]);
|
||||||
setUnbreakable(stack, value);
|
setUnbreakable(stack, value);
|
||||||
} else if (split.length > 1 && (split[0].equalsIgnoreCase("player") || split[0].equalsIgnoreCase("owner")) && hasMetaPermission(sender, "head", false, true, ess)) {
|
} else if (split.length > 1 && (split[0].equalsIgnoreCase("player") || split[0].equalsIgnoreCase("owner")) && hasMetaPermission(sender, "head", false, true, ess)) {
|
||||||
if (MaterialUtil.isPlayerHead(stack.getType(), stack.getDurability())) {
|
if (MaterialUtil.isPlayerHead(stack.getType(), stack.getDurability())) {
|
||||||
@ -292,7 +288,7 @@ public class MetaItemStack {
|
|||||||
builder = FireworkEffect.builder();
|
builder = FireworkEffect.builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Color> primaryColors = new ArrayList<Color>();
|
List<Color> primaryColors = new ArrayList<>();
|
||||||
String[] colors = split[1].split(",");
|
String[] colors = split[1].split(",");
|
||||||
for (String color : colors) {
|
for (String color : colors) {
|
||||||
if (colorMap.containsKey(color.toUpperCase())) {
|
if (colorMap.containsKey(color.toUpperCase())) {
|
||||||
@ -315,7 +311,7 @@ public class MetaItemStack {
|
|||||||
builder.with(finalEffect);
|
builder.with(finalEffect);
|
||||||
}
|
}
|
||||||
} else if (split[0].equalsIgnoreCase("fade") || (allowShortName && split[0].equalsIgnoreCase("f"))) {
|
} else if (split[0].equalsIgnoreCase("fade") || (allowShortName && split[0].equalsIgnoreCase("f"))) {
|
||||||
List<Color> fadeColors = new ArrayList<Color>();
|
List<Color> fadeColors = new ArrayList<>();
|
||||||
String[] colors = split[1].split(",");
|
String[] colors = split[1].split(",");
|
||||||
for (String color : colors) {
|
for (String color : colors) {
|
||||||
if (colorMap.containsKey(color.toUpperCase())) {
|
if (colorMap.containsKey(color.toUpperCase())) {
|
||||||
@ -379,7 +375,7 @@ public class MetaItemStack {
|
|||||||
throw new Exception(tl("invalidPotionMeta", split[1]));
|
throw new Exception(tl("invalidPotionMeta", split[1]));
|
||||||
}
|
}
|
||||||
} else if (split[0].equalsIgnoreCase("splash") || (allowShortName && split[0].equalsIgnoreCase("s"))) {
|
} else if (split[0].equalsIgnoreCase("splash") || (allowShortName && split[0].equalsIgnoreCase("s"))) {
|
||||||
isSplashPotion = Boolean.valueOf(split[1]);
|
isSplashPotion = Boolean.parseBoolean(split[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isValidPotion()) {
|
if (isValidPotion()) {
|
||||||
@ -486,11 +482,11 @@ public class MetaItemStack {
|
|||||||
|
|
||||||
final BannerMeta meta = (BannerMeta) stack.getItemMeta();
|
final BannerMeta meta = (BannerMeta) stack.getItemMeta();
|
||||||
if (split[0].equalsIgnoreCase("basecolor")) {
|
if (split[0].equalsIgnoreCase("basecolor")) {
|
||||||
Color color = Color.fromRGB(Integer.valueOf(split[1]));
|
Color color = Color.fromRGB(Integer.parseInt(split[1]));
|
||||||
meta.setBaseColor(DyeColor.getByColor(color));
|
meta.setBaseColor(DyeColor.getByColor(color));
|
||||||
} else if (patternType != null) {
|
} else if (patternType != null) {
|
||||||
PatternType type = PatternType.valueOf(split[0]);
|
PatternType type = PatternType.valueOf(split[0]);
|
||||||
DyeColor color = DyeColor.getByColor(Color.fromRGB(Integer.valueOf(split[1])));
|
DyeColor color = DyeColor.getByColor(Color.fromRGB(Integer.parseInt(split[1])));
|
||||||
org.bukkit.block.banner.Pattern pattern = new org.bukkit.block.banner.Pattern(color, type);
|
org.bukkit.block.banner.Pattern pattern = new org.bukkit.block.banner.Pattern(color, type);
|
||||||
meta.addPattern(pattern);
|
meta.addPattern(pattern);
|
||||||
}
|
}
|
||||||
@ -512,11 +508,11 @@ public class MetaItemStack {
|
|||||||
BlockStateMeta meta = (BlockStateMeta) stack.getItemMeta();
|
BlockStateMeta meta = (BlockStateMeta) stack.getItemMeta();
|
||||||
Banner banner = (Banner) meta.getBlockState();
|
Banner banner = (Banner) meta.getBlockState();
|
||||||
if (split[0].equalsIgnoreCase("basecolor")) {
|
if (split[0].equalsIgnoreCase("basecolor")) {
|
||||||
Color color = Color.fromRGB(Integer.valueOf(split[1]));
|
Color color = Color.fromRGB(Integer.parseInt(split[1]));
|
||||||
banner.setBaseColor(DyeColor.getByColor(color));
|
banner.setBaseColor(DyeColor.getByColor(color));
|
||||||
} else if (patternType != null) {
|
} else if (patternType != null) {
|
||||||
PatternType type = PatternType.valueOf(split[0]);
|
PatternType type = PatternType.valueOf(split[0]);
|
||||||
DyeColor color = DyeColor.getByColor(Color.fromRGB(Integer.valueOf(split[1])));
|
DyeColor color = DyeColor.getByColor(Color.fromRGB(Integer.parseInt(split[1])));
|
||||||
org.bukkit.block.banner.Pattern pattern = new org.bukkit.block.banner.Pattern(color, type);
|
org.bukkit.block.banner.Pattern pattern = new org.bukkit.block.banner.Pattern(color, type);
|
||||||
banner.addPattern(pattern);
|
banner.addPattern(pattern);
|
||||||
}
|
}
|
||||||
|
@ -67,9 +67,9 @@ public class MobCompat {
|
|||||||
WEAPONSMITH("BLACKSMITH", "WEAPON_SMITH", "WEAPONSMITH")
|
WEAPONSMITH("BLACKSMITH", "WEAPON_SMITH", "WEAPONSMITH")
|
||||||
;
|
;
|
||||||
|
|
||||||
private String oldProfession;
|
private final String oldProfession;
|
||||||
private String oldCareer;
|
private final String oldCareer;
|
||||||
private String newProfession;
|
private final String newProfession;
|
||||||
|
|
||||||
VillagerProfession(final String oldProfession, final String career) {
|
VillagerProfession(final String oldProfession, final String career) {
|
||||||
this.oldProfession = oldProfession;
|
this.oldProfession = oldProfession;
|
||||||
@ -89,9 +89,9 @@ public class MobCompat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Older cats are Ocelots, whereas 1.14+ cats are Cats
|
// Older cats are Ocelots, whereas 1.14+ cats are Cats
|
||||||
private static Class catClass = ReflUtil.getClassCached("org.bukkit.entity.Cat");
|
private static final Class catClass = ReflUtil.getClassCached("org.bukkit.entity.Cat");
|
||||||
private static Class catTypeClass = ReflUtil.getClassCached("org.bukkit.entity.Cat.Type");
|
private static final Class catTypeClass = ReflUtil.getClassCached("org.bukkit.entity.Cat.Type");
|
||||||
private static Method catSetTypeMethod = (catClass == null || catTypeClass == null) ? null : ReflUtil.getMethodCached(catClass, "setCatType", catTypeClass);
|
private static final Method catSetTypeMethod = (catClass == null || catTypeClass == null) ? null : ReflUtil.getMethodCached(catClass, "setCatType", catTypeClass);
|
||||||
|
|
||||||
private static boolean isNewCat() {
|
private static boolean isNewCat() {
|
||||||
return (catClass != null && catTypeClass != null && catSetTypeMethod != null);
|
return (catClass != null && catTypeClass != null && catSetTypeMethod != null);
|
||||||
@ -110,8 +110,8 @@ public class MobCompat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Older villagers have professions and careers, 1.14+ villagers only have professions
|
// Older villagers have professions and careers, 1.14+ villagers only have professions
|
||||||
private static Class villagerCareerClass = ReflUtil.getClassCached("org.bukkit.entity.Villager.Career");
|
private static final Class villagerCareerClass = ReflUtil.getClassCached("org.bukkit.entity.Villager.Career");
|
||||||
private static Method villagerSetCareerMethod = (villagerCareerClass == null) ? null : ReflUtil.getMethodCached(Villager.class, "setCareer", villagerCareerClass);
|
private static final Method villagerSetCareerMethod = (villagerCareerClass == null) ? null : ReflUtil.getMethodCached(Villager.class, "setCareer", villagerCareerClass);
|
||||||
|
|
||||||
private static boolean isCareerVillager() {
|
private static boolean isCareerVillager() {
|
||||||
return (villagerCareerClass != null && villagerSetCareerMethod != null);
|
return (villagerCareerClass != null && villagerSetCareerMethod != null);
|
||||||
|
@ -203,7 +203,7 @@ public enum MobData {
|
|||||||
private String matched;
|
private String matched;
|
||||||
|
|
||||||
public static LinkedHashMap<String, MobData> getPossibleData(final Entity spawned, boolean publicOnly) {
|
public static LinkedHashMap<String, MobData> getPossibleData(final Entity spawned, boolean publicOnly) {
|
||||||
LinkedHashMap<String, MobData> mobList = new LinkedHashMap<String, MobData>();
|
LinkedHashMap<String, MobData> mobList = new LinkedHashMap<>();
|
||||||
for (MobData data : MobData.values()) {
|
for (MobData data : MobData.values()) {
|
||||||
if (data.type == null || (publicOnly && !data.isPublic)) continue;
|
if (data.type == null || (publicOnly && !data.isPublic)) continue;
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ public enum MobData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> getValidHelp(final Entity spawned) {
|
public static List<String> getValidHelp(final Entity spawned) {
|
||||||
List<String> output = new ArrayList<String>();
|
List<String> output = new ArrayList<>();
|
||||||
LinkedHashMap<String, MobData> posData = getPossibleData(spawned, true);
|
LinkedHashMap<String, MobData> posData = getPossibleData(spawned, true);
|
||||||
|
|
||||||
for (MobData data : posData.values()) {
|
for (MobData data : posData.values()) {
|
||||||
|
@ -42,7 +42,7 @@ public class OfflinePlayer implements Player {
|
|||||||
private final transient Server server;
|
private final transient Server server;
|
||||||
private transient Location location = new Location(null, 0, 0, 0, 0, 0);
|
private transient Location location = new Location(null, 0, 0, 0, 0, 0);
|
||||||
private transient World world;
|
private transient World world;
|
||||||
private transient org.bukkit.OfflinePlayer base;
|
private final transient org.bukkit.OfflinePlayer base;
|
||||||
private boolean allowFlight = false;
|
private boolean allowFlight = false;
|
||||||
private boolean isFlying = false;
|
private boolean isFlying = false;
|
||||||
private String name = null;
|
private String name = null;
|
||||||
|
@ -66,11 +66,7 @@ public class PlayerList {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final String group = FormatUtil.stripFormat(FormatUtil.stripEssentialsFormat(onlineUser.getGroup().toLowerCase()));
|
final String group = FormatUtil.stripFormat(FormatUtil.stripEssentialsFormat(onlineUser.getGroup().toLowerCase()));
|
||||||
List<User> list = playerList.get(group);
|
List<User> list = playerList.computeIfAbsent(group, k -> new ArrayList<>());
|
||||||
if (list == null) {
|
|
||||||
list = new ArrayList<User>();
|
|
||||||
playerList.put(group, list);
|
|
||||||
}
|
|
||||||
list.add(onlineUser);
|
list.add(onlineUser);
|
||||||
}
|
}
|
||||||
return playerList;
|
return playerList;
|
||||||
@ -85,7 +81,7 @@ public class PlayerList {
|
|||||||
String[] groupValues = ess.getSettings().getListGroupConfig().get(configGroup).toString().trim().split(" ");
|
String[] groupValues = ess.getSettings().getListGroupConfig().get(configGroup).toString().trim().split(" ");
|
||||||
for (String groupValue : groupValues) {
|
for (String groupValue : groupValues) {
|
||||||
groupValue = groupValue.toLowerCase(Locale.ENGLISH);
|
groupValue = groupValue.toLowerCase(Locale.ENGLISH);
|
||||||
if (groupValue == null || groupValue.isEmpty()) {
|
if (groupValue.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
List<User> u = playerList.get(groupValue.trim());
|
List<User> u = playerList.get(groupValue.trim());
|
||||||
@ -107,20 +103,17 @@ public class PlayerList {
|
|||||||
if (groupUsers != null && !groupUsers.isEmpty()) {
|
if (groupUsers != null && !groupUsers.isEmpty()) {
|
||||||
users.addAll(groupUsers);
|
users.addAll(groupUsers);
|
||||||
}
|
}
|
||||||
if (users == null || users.isEmpty()) {
|
if (users.isEmpty()) {
|
||||||
throw new Exception(tl("groupDoesNotExist"));
|
throw new Exception(tl("groupDoesNotExist"));
|
||||||
}
|
}
|
||||||
final StringBuilder displayGroupName = new StringBuilder();
|
String displayGroupName = Character.toTitleCase(groupName.charAt(0)) +
|
||||||
displayGroupName.append(Character.toTitleCase(groupName.charAt(0)));
|
groupName.substring(1);
|
||||||
displayGroupName.append(groupName.substring(1));
|
return outputFormat(displayGroupName, listUsers(ess, users, ", "));
|
||||||
return outputFormat(displayGroupName.toString(), listUsers(ess, users, ", "));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the output string
|
// Build the output string
|
||||||
public static String outputFormat(final String group, final String message) {
|
public static String outputFormat(final String group, final String message) {
|
||||||
final StringBuilder outputString = new StringBuilder();
|
return tl("listGroupTag", FormatUtil.replaceFormat(group)) +
|
||||||
outputString.append(tl("listGroupTag", FormatUtil.replaceFormat(group)));
|
message;
|
||||||
outputString.append(message);
|
|
||||||
return outputString.toString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
return isCommandDisabled(cmd.getName());
|
return isCommandDisabled(cmd.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> disabledCommands = new HashSet<String>();
|
private Set<String> disabledCommands = new HashSet<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCommandDisabled(String label) {
|
public boolean isCommandDisabled(String label) {
|
||||||
@ -195,7 +195,7 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> getDisabledCommands() {
|
private Set<String> getDisabledCommands() {
|
||||||
Set<String> disCommands = new HashSet<String>();
|
Set<String> disCommands = new HashSet<>();
|
||||||
for (String c : config.getStringList("disabled-commands")) {
|
for (String c : config.getStringList("disabled-commands")) {
|
||||||
disCommands.add(c.toLowerCase(Locale.ENGLISH));
|
disCommands.add(c.toLowerCase(Locale.ENGLISH));
|
||||||
}
|
}
|
||||||
@ -275,10 +275,10 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
return BigDecimal.ZERO;
|
return BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> socialSpyCommands = new HashSet<String>();
|
private Set<String> socialSpyCommands = new HashSet<>();
|
||||||
|
|
||||||
private Set<String> _getSocialSpyCommands() {
|
private Set<String> _getSocialSpyCommands() {
|
||||||
Set<String> socialspyCommands = new HashSet<String>();
|
Set<String> socialspyCommands = new HashSet<>();
|
||||||
|
|
||||||
if (config.isList("socialspy-commands")) {
|
if (config.isList("socialspy-commands")) {
|
||||||
for (String c : config.getStringList("socialspy-commands")) {
|
for (String c : config.getStringList("socialspy-commands")) {
|
||||||
@ -301,10 +301,10 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
return config.getBoolean("socialspy-listen-muted-players", true);
|
return config.getBoolean("socialspy-listen-muted-players", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> muteCommands = new HashSet<String>();
|
private Set<String> muteCommands = new HashSet<>();
|
||||||
|
|
||||||
private Set<String> _getMuteCommands() {
|
private Set<String> _getMuteCommands() {
|
||||||
Set<String> muteCommands = new HashSet<String>();
|
Set<String> muteCommands = new HashSet<>();
|
||||||
if (config.isList("mute-commands")) {
|
if (config.isList("mute-commands")) {
|
||||||
for (String s : config.getStringList("mute-commands")) {
|
for (String s : config.getStringList("mute-commands")) {
|
||||||
muteCommands.add(s.toLowerCase(Locale.ENGLISH));
|
muteCommands.add(s.toLowerCase(Locale.ENGLISH));
|
||||||
@ -384,7 +384,7 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return ChatColor.valueOf(colorName.toUpperCase(Locale.ENGLISH));
|
return ChatColor.valueOf(colorName.toUpperCase(Locale.ENGLISH));
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return ChatColor.getByChar(colorName);
|
return ChatColor.getByChar(colorName);
|
||||||
@ -425,7 +425,7 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
return config.getString("backup.command", null);
|
return config.getString("backup.command", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Map<String, String> chatFormats = Collections.synchronizedMap(new HashMap<String, String>());
|
private final Map<String, String> chatFormats = Collections.synchronizedMap(new HashMap<>());
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getChatFormat(String group) {
|
public String getChatFormat(String group) {
|
||||||
@ -487,7 +487,7 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Map<String, Object> defaultMap = new HashMap<String, Object>();
|
Map<String, Object> defaultMap = new HashMap<>();
|
||||||
if (config.getBoolean("sort-list-by-groups", false)) {
|
if (config.getBoolean("sort-list-by-groups", false)) {
|
||||||
defaultMap.put("ListByGroup", "ListByGroup");
|
defaultMap.put("ListByGroup", "ListByGroup");
|
||||||
} else {
|
} else {
|
||||||
@ -499,7 +499,7 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
@Override
|
@Override
|
||||||
public void reloadConfig() {
|
public void reloadConfig() {
|
||||||
config.load();
|
config.load();
|
||||||
noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds"));
|
noGodWorlds = new HashSet<>(config.getStringList("no-god-in-worlds"));
|
||||||
enabledSigns = _getEnabledSigns();
|
enabledSigns = _getEnabledSigns();
|
||||||
teleportSafety = _isTeleportSafetyEnabled();
|
teleportSafety = _isTeleportSafetyEnabled();
|
||||||
forceDisableTeleportSafety = _isForceDisableTeleportSafety();
|
forceDisableTeleportSafety = _isForceDisableTeleportSafety();
|
||||||
@ -600,7 +600,7 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
return epItemSpwn;
|
return epItemSpwn;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EssentialsSign> enabledSigns = new ArrayList<EssentialsSign>();
|
private List<EssentialsSign> enabledSigns = new ArrayList<>();
|
||||||
private boolean signsEnabled = false;
|
private boolean signsEnabled = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -611,7 +611,7 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
private List<EssentialsSign> _getEnabledSigns() {
|
private List<EssentialsSign> _getEnabledSigns() {
|
||||||
this.signsEnabled = false; // Ensure boolean resets on reload.
|
this.signsEnabled = false; // Ensure boolean resets on reload.
|
||||||
|
|
||||||
List<EssentialsSign> newSigns = new ArrayList<EssentialsSign>();
|
List<EssentialsSign> newSigns = new ArrayList<>();
|
||||||
|
|
||||||
for (String signName : config.getStringList("enabledSigns")) {
|
for (String signName : config.getStringList("enabledSigns")) {
|
||||||
signName = signName.trim().toUpperCase(Locale.ENGLISH);
|
signName = signName.trim().toUpperCase(Locale.ENGLISH);
|
||||||
@ -966,7 +966,7 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
return config.getBoolean("death-messages", true);
|
return config.getBoolean("death-messages", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> noGodWorlds = new HashSet<String>();
|
private Set<String> noGodWorlds = new HashSet<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getNoGodWorlds() {
|
public Set<String> getNoGodWorlds() {
|
||||||
@ -1132,8 +1132,7 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
|
|
||||||
private long _getEconomyLagWarning() {
|
private long _getEconomyLagWarning() {
|
||||||
// Default to 25ms
|
// Default to 25ms
|
||||||
final long value = (long) (config.getDouble("economy-lag-warning", 25.0) * 1000000);
|
return (long) (config.getDouble("economy-lag-warning", 25.0) * 1000000);
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1146,8 +1145,7 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
|
|
||||||
private long _getPermissionsLagWarning() {
|
private long _getPermissionsLagWarning() {
|
||||||
// Default to 25ms
|
// Default to 25ms
|
||||||
final long value = (long) (config.getDouble("permissions-lag-warning", 25.0) * 1000000);
|
return (long) (config.getDouble("permissions-lag-warning", 25.0) * 1000000);
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1345,7 +1343,7 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
* >> Process cooldown value
|
* >> Process cooldown value
|
||||||
* ================================ */
|
* ================================ */
|
||||||
Object value = section.get(cmdEntry);
|
Object value = section.get(cmdEntry);
|
||||||
if (!(value instanceof Number) && value instanceof String) {
|
if (value instanceof String) {
|
||||||
try {
|
try {
|
||||||
value = Double.parseDouble(value.toString());
|
value = Double.parseDouble(value.toString());
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
@ -1457,7 +1455,6 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
newSigns.add(Signs.valueOf(signName).getSign());
|
newSigns.add(Signs.valueOf(signName).getSign());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.log(Level.SEVERE, tl("unknownItemInList", signName, "unprotected-sign-names"));
|
logger.log(Level.SEVERE, tl("unknownItemInList", signName, "unprotected-sign-names"));
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newSigns;
|
return newSigns;
|
||||||
|
@ -29,7 +29,7 @@ public class SpawnMob {
|
|||||||
|
|
||||||
public static String mobList(final User user) {
|
public static String mobList(final User user) {
|
||||||
final Set<String> mobList = Mob.getMobList();
|
final Set<String> mobList = Mob.getMobList();
|
||||||
final Set<String> availableList = new HashSet<String>();
|
final Set<String> availableList = new HashSet<>();
|
||||||
for (String mob : mobList) {
|
for (String mob : mobList) {
|
||||||
if (user.isAuthorized("essentials.spawnmob." + mob.toLowerCase(Locale.ENGLISH))) {
|
if (user.isAuthorized("essentials.spawnmob." + mob.toLowerCase(Locale.ENGLISH))) {
|
||||||
availableList.add(mob);
|
availableList.add(mob);
|
||||||
@ -44,7 +44,7 @@ public class SpawnMob {
|
|||||||
public static List<String> mobParts(final String mobString) {
|
public static List<String> mobParts(final String mobString) {
|
||||||
String[] mobParts = mobString.split(",");
|
String[] mobParts = mobString.split(",");
|
||||||
|
|
||||||
List<String> mobs = new ArrayList<String>();
|
List<String> mobs = new ArrayList<>();
|
||||||
|
|
||||||
for (String mobPart : mobParts) {
|
for (String mobPart : mobParts) {
|
||||||
String[] mobDatas = mobPart.split(":");
|
String[] mobDatas = mobPart.split(":");
|
||||||
@ -56,7 +56,7 @@ public class SpawnMob {
|
|||||||
public static List<String> mobData(final String mobString) {
|
public static List<String> mobData(final String mobString) {
|
||||||
String[] mobParts = mobString.split(",");
|
String[] mobParts = mobString.split(",");
|
||||||
|
|
||||||
List<String> mobData = new ArrayList<String>();
|
List<String> mobData = new ArrayList<>();
|
||||||
|
|
||||||
for (String mobPart : mobParts) {
|
for (String mobPart : mobParts) {
|
||||||
String[] mobDatas = mobPart.split(":");
|
String[] mobDatas = mobPart.split(":");
|
||||||
@ -92,8 +92,8 @@ public class SpawnMob {
|
|||||||
public static void spawnmob(final IEssentials ess, final Server server, final CommandSource sender, final User target, final Location loc, final List<String> parts, final List<String> data, int mobCount) throws Exception {
|
public static void spawnmob(final IEssentials ess, final Server server, final CommandSource sender, final User target, final Location loc, final List<String> parts, final List<String> data, int mobCount) throws Exception {
|
||||||
final Location sloc = LocationUtil.getSafeDestination(loc);
|
final Location sloc = LocationUtil.getSafeDestination(loc);
|
||||||
|
|
||||||
for (int i = 0; i < parts.size(); i++) {
|
for (String part : parts) {
|
||||||
Mob mob = Mob.fromName(parts.get(i));
|
Mob mob = Mob.fromName(part);
|
||||||
checkSpawnable(ess, sender, mob);
|
checkSpawnable(ess, sender, mob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
public class UUIDMap {
|
public class UUIDMap {
|
||||||
private final transient net.ess3.api.IEssentials ess;
|
private final transient net.ess3.api.IEssentials ess;
|
||||||
private File userList;
|
private final File userList;
|
||||||
private final transient Pattern splitPattern = Pattern.compile(",");
|
private final transient Pattern splitPattern = Pattern.compile(",");
|
||||||
|
|
||||||
private static boolean pendingWrite;
|
private static boolean pendingWrite;
|
||||||
@ -28,15 +28,12 @@ public class UUIDMap {
|
|||||||
this.ess = ess;
|
this.ess = ess;
|
||||||
userList = new File(ess.getDataFolder(), "usermap.csv");
|
userList = new File(ess.getDataFolder(), "usermap.csv");
|
||||||
pendingWrite = false;
|
pendingWrite = false;
|
||||||
writeTaskRunnable = new Runnable() {
|
writeTaskRunnable = () -> {
|
||||||
@Override
|
if (pendingWrite) {
|
||||||
public void run() {
|
try {
|
||||||
if (pendingWrite) {
|
new WriteRunner(ess.getDataFolder(), userList, ess.getUserMap().getNames()).run();
|
||||||
try {
|
} catch (Throwable t) { // bad code to prevent task from being suppressed
|
||||||
new WriteRunner(ess.getDataFolder(), userList, ess.getUserMap().getNames()).run();
|
t.printStackTrace();
|
||||||
} catch (Throwable t) { // bad code to prevent task from being suppressed
|
|
||||||
t.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -37,7 +37,7 @@ import static com.earth2me.essentials.I18n.tl;
|
|||||||
|
|
||||||
public class User extends UserData implements Comparable<User>, IMessageRecipient, net.ess3.api.IUser {
|
public class User extends UserData implements Comparable<User>, IMessageRecipient, net.ess3.api.IUser {
|
||||||
private static final Logger logger = Logger.getLogger("Essentials");
|
private static final Logger logger = Logger.getLogger("Essentials");
|
||||||
private IMessageRecipient messageRecipient;
|
private final IMessageRecipient messageRecipient;
|
||||||
private transient UUID teleportRequester;
|
private transient UUID teleportRequester;
|
||||||
private transient boolean teleportRequestHere;
|
private transient boolean teleportRequestHere;
|
||||||
private transient Location teleportLocation;
|
private transient Location teleportLocation;
|
||||||
@ -57,7 +57,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
|||||||
private boolean ignoreMsg = false;
|
private boolean ignoreMsg = false;
|
||||||
private String afkMessage;
|
private String afkMessage;
|
||||||
private long afkSince;
|
private long afkSince;
|
||||||
private Map<User, BigDecimal> confirmingPayments = new WeakHashMap<>();
|
private final Map<User, BigDecimal> confirmingPayments = new WeakHashMap<>();
|
||||||
private String confirmingClearCommand;
|
private String confirmingClearCommand;
|
||||||
private long lastNotifiedAboutMailsMs;
|
private long lastNotifiedAboutMailsMs;
|
||||||
|
|
||||||
@ -238,12 +238,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
ess.runTaskAsynchronously(new Runnable() {
|
ess.runTaskAsynchronously(this::_dispose);
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
_dispose();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _dispose() {
|
private void _dispose() {
|
||||||
@ -346,7 +341,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
|||||||
prefix.insert(0, opPrefix.toString());
|
prefix.insert(0, opPrefix.toString());
|
||||||
suffix = "§r";
|
suffix = "§r";
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,7 +439,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
|||||||
}
|
}
|
||||||
final Method.MethodAccount account = Methods.getMethod().getAccount(this.getName());
|
final Method.MethodAccount account = Methods.getMethod().getAccount(this.getName());
|
||||||
return BigDecimal.valueOf(account.balance());
|
return BigDecimal.valueOf(account.balance());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.getMoney();
|
return super.getMoney();
|
||||||
@ -476,7 +471,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
|||||||
}
|
}
|
||||||
final Method.MethodAccount account = Methods.getMethod().getAccount(this.getName());
|
final Method.MethodAccount account = Methods.getMethod().getAccount(this.getName());
|
||||||
account.set(newBalance.doubleValue());
|
account.set(newBalance.doubleValue());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.setMoney(newBalance, true);
|
super.setMoney(newBalance, true);
|
||||||
@ -487,7 +482,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
|||||||
if (ess.getSettings().isEcoDisabled()) {
|
if (ess.getSettings().isEcoDisabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Methods.hasMethod() && super.getMoney() != value) {
|
if (Methods.hasMethod() && !super.getMoney().equals(value)) {
|
||||||
try {
|
try {
|
||||||
super.setMoney(value, false);
|
super.setMoney(value, false);
|
||||||
} catch (MaxMoneyException ex) {
|
} catch (MaxMoneyException ex) {
|
||||||
@ -555,7 +550,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
|||||||
@Override
|
@Override
|
||||||
public void setHidden(final boolean hidden) {
|
public void setHidden(final boolean hidden) {
|
||||||
this.hidden = hidden;
|
this.hidden = hidden;
|
||||||
if (hidden == true) {
|
if (hidden) {
|
||||||
setLastLogout(getLastOnlineActivity());
|
setLastLogout(getLastOnlineActivity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -577,7 +572,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
try {
|
try {
|
||||||
getTeleport().respawn(null, TeleportCause.PLUGIN);
|
getTeleport().respawn(null, TeleportCause.PLUGIN);
|
||||||
} catch (Exception ex1) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -696,9 +691,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
|||||||
}
|
}
|
||||||
if (isAfk()) {
|
if (isAfk()) {
|
||||||
// Protect AFK players by representing them in a god mode state to render them invulnerable to damage.
|
// Protect AFK players by representing them in a god mode state to render them invulnerable to damage.
|
||||||
if (ess.getSettings().getFreezeAfkPlayers()) {
|
return ess.getSettings().getFreezeAfkPlayers();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -25,12 +25,11 @@ import static com.earth2me.essentials.I18n.tl;
|
|||||||
public abstract class UserData extends PlayerExtension implements IConf {
|
public abstract class UserData extends PlayerExtension implements IConf {
|
||||||
protected final transient IEssentials ess;
|
protected final transient IEssentials ess;
|
||||||
private final EssentialsUserConf config;
|
private final EssentialsUserConf config;
|
||||||
private final File folder;
|
|
||||||
|
|
||||||
protected UserData(Player base, IEssentials ess) {
|
protected UserData(Player base, IEssentials ess) {
|
||||||
super(base);
|
super(base);
|
||||||
this.ess = ess;
|
this.ess = ess;
|
||||||
folder = new File(ess.getDataFolder(), "userdata");
|
File folder = new File(ess.getDataFolder(), "userdata");
|
||||||
if (!folder.exists()) {
|
if (!folder.exists()) {
|
||||||
folder.mkdirs();
|
folder.mkdirs();
|
||||||
}
|
}
|
||||||
@ -150,15 +149,14 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
|||||||
if (config.isConfigurationSection("homes")) {
|
if (config.isConfigurationSection("homes")) {
|
||||||
return config.getConfigurationSection("homes").getValues(false);
|
return config.getConfigurationSection("homes").getValues(false);
|
||||||
}
|
}
|
||||||
return new HashMap<String, Object>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getHomeName(String search) {
|
private String getHomeName(String search) {
|
||||||
if (NumberUtil.isInt(search)) {
|
if (NumberUtil.isInt(search)) {
|
||||||
try {
|
try {
|
||||||
search = getHomes().get(Integer.parseInt(search) - 1);
|
search = getHomes().get(Integer.parseInt(search) - 1);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException | IndexOutOfBoundsException ignored) {
|
||||||
} catch (IndexOutOfBoundsException e) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return search;
|
return search;
|
||||||
@ -190,7 +188,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getHomes() {
|
public List<String> getHomes() {
|
||||||
return new ArrayList<String>(homes.keySet());
|
return new ArrayList<>(homes.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHome(String name, Location loc) {
|
public void setHome(String name, Location loc) {
|
||||||
@ -480,7 +478,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
|||||||
|
|
||||||
public void setIgnoredPlayers(List<String> players) {
|
public void setIgnoredPlayers(List<String> players) {
|
||||||
if (players == null || players.isEmpty()) {
|
if (players == null || players.isEmpty()) {
|
||||||
ignoredPlayers = Collections.synchronizedList(new ArrayList<String>());
|
ignoredPlayers = Collections.synchronizedList(new ArrayList<>());
|
||||||
config.removeProperty("ignore");
|
config.removeProperty("ignore");
|
||||||
} else {
|
} else {
|
||||||
ignoredPlayers = players;
|
ignoredPlayers = players;
|
||||||
@ -795,7 +793,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
|||||||
|
|
||||||
if (config.isConfigurationSection("timestamps.kits")) {
|
if (config.isConfigurationSection("timestamps.kits")) {
|
||||||
final ConfigurationSection section = config.getConfigurationSection("timestamps.kits");
|
final ConfigurationSection section = config.getConfigurationSection("timestamps.kits");
|
||||||
final Map<String, Long> timestamps = new HashMap<String, Long>();
|
final Map<String, Long> timestamps = new HashMap<>();
|
||||||
for (String command : section.getKeys(false)) {
|
for (String command : section.getKeys(false)) {
|
||||||
if (section.isLong(command)) {
|
if (section.isLong(command)) {
|
||||||
timestamps.put(command.toLowerCase(Locale.ENGLISH), section.getLong(command));
|
timestamps.put(command.toLowerCase(Locale.ENGLISH), section.getLong(command));
|
||||||
@ -805,7 +803,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
|||||||
}
|
}
|
||||||
return timestamps;
|
return timestamps;
|
||||||
}
|
}
|
||||||
return new HashMap<String, Long>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getKitTimestamp(String name) {
|
public long getKitTimestamp(String name) {
|
||||||
@ -844,21 +842,21 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
|||||||
if (config.isConfigurationSection("info")) {
|
if (config.isConfigurationSection("info")) {
|
||||||
return config.getConfigurationSection("info").getKeys(true);
|
return config.getConfigurationSection("info").getKeys(true);
|
||||||
}
|
}
|
||||||
return new HashSet<String>();
|
return new HashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> getConfigMap() {
|
public Map<String, Object> getConfigMap() {
|
||||||
if (config.isConfigurationSection("info")) {
|
if (config.isConfigurationSection("info")) {
|
||||||
return config.getConfigurationSection("info").getValues(true);
|
return config.getConfigurationSection("info").getValues(true);
|
||||||
}
|
}
|
||||||
return new HashMap<String, Object>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> getConfigMap(String node) {
|
public Map<String, Object> getConfigMap(String node) {
|
||||||
if (config.isConfigurationSection("info." + node)) {
|
if (config.isConfigurationSection("info." + node)) {
|
||||||
return config.getConfigurationSection("info." + node).getValues(true);
|
return config.getConfigurationSection("info." + node).getValues(true);
|
||||||
}
|
}
|
||||||
return new HashMap<String, Object>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pattern, Date. Pattern for less pattern creations
|
// Pattern, Date. Pattern for less pattern creations
|
||||||
|
@ -25,7 +25,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf {
|
|||||||
private final transient ConcurrentSkipListSet<UUID> keys = new ConcurrentSkipListSet<>();
|
private final transient ConcurrentSkipListSet<UUID> keys = new ConcurrentSkipListSet<>();
|
||||||
private final transient ConcurrentSkipListMap<String, UUID> names = new ConcurrentSkipListMap<>();
|
private final transient ConcurrentSkipListMap<String, UUID> names = new ConcurrentSkipListMap<>();
|
||||||
private final transient ConcurrentSkipListMap<UUID, ArrayList<String>> history = new ConcurrentSkipListMap<>();
|
private final transient ConcurrentSkipListMap<UUID, ArrayList<String>> history = new ConcurrentSkipListMap<>();
|
||||||
private UUIDMap uuidMap;
|
private final UUIDMap uuidMap;
|
||||||
|
|
||||||
private final transient Cache<String, User> users;
|
private final transient Cache<String, User> users;
|
||||||
private static boolean legacy = false;
|
private static boolean legacy = false;
|
||||||
@ -53,29 +53,26 @@ public class UserMap extends CacheLoader<String, User> implements IConf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadAllUsersAsync(final IEssentials ess) {
|
private void loadAllUsersAsync(final IEssentials ess) {
|
||||||
ess.runTaskAsynchronously(new Runnable() {
|
ess.runTaskAsynchronously(() -> {
|
||||||
@Override
|
synchronized (users) {
|
||||||
public void run() {
|
final File userdir = new File(ess.getDataFolder(), "userdata");
|
||||||
synchronized (users) {
|
if (!userdir.exists()) {
|
||||||
final File userdir = new File(ess.getDataFolder(), "userdata");
|
return;
|
||||||
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);
|
|
||||||
try {
|
|
||||||
keys.add(UUID.fromString(name));
|
|
||||||
} catch (IllegalArgumentException ex) {
|
|
||||||
//Ignore these users till they rejoin.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
uuidMap.loadAllUsers(names, history);
|
|
||||||
}
|
}
|
||||||
|
keys.clear();
|
||||||
|
users.invalidateAll();
|
||||||
|
for (String string : userdir.list()) {
|
||||||
|
if (!string.endsWith(".yml")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final String name = string.substring(0, string.length() - 4);
|
||||||
|
try {
|
||||||
|
keys.add(UUID.fromString(name));
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
//Ignore these users till they rejoin.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uuidMap.loadAllUsers(names, history);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -112,9 +109,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf {
|
|||||||
} else {
|
} else {
|
||||||
return legacyCacheGet(uuid);
|
return legacyCacheGet(uuid);
|
||||||
}
|
}
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException | UncheckedExecutionException ex) {
|
||||||
return null;
|
|
||||||
} catch (UncheckedExecutionException ex) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ import static com.earth2me.essentials.I18n.tl;
|
|||||||
|
|
||||||
public class Warps implements IConf, net.ess3.api.IWarps {
|
public class Warps implements IConf, net.ess3.api.IWarps {
|
||||||
private static final Logger logger = Logger.getLogger("Essentials");
|
private static final Logger logger = Logger.getLogger("Essentials");
|
||||||
private final Map<StringIgnoreCase, EssentialsConf> warpPoints = new HashMap<StringIgnoreCase, EssentialsConf>();
|
private final Map<StringIgnoreCase, EssentialsConf> warpPoints = new HashMap<>();
|
||||||
private final File warpsFolder;
|
private final File warpsFolder;
|
||||||
private final Server server;
|
private final Server server;
|
||||||
|
|
||||||
@ -36,11 +36,11 @@ public class Warps implements IConf, net.ess3.api.IWarps {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> getList() {
|
public Collection<String> getList() {
|
||||||
final List<String> keys = new ArrayList<String>();
|
final List<String> keys = new ArrayList<>();
|
||||||
for (StringIgnoreCase stringIgnoreCase : warpPoints.keySet()) {
|
for (StringIgnoreCase stringIgnoreCase : warpPoints.keySet()) {
|
||||||
keys.add(stringIgnoreCase.getString());
|
keys.add(stringIgnoreCase.getString());
|
||||||
}
|
}
|
||||||
Collections.sort(keys, String.CASE_INSENSITIVE_ORDER);
|
keys.sort(String.CASE_INSENSITIVE_ORDER);
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ public class Warps implements IConf, net.ess3.api.IWarps {
|
|||||||
try {
|
try {
|
||||||
uuid = UUID.fromString(conf.getString("lastowner"));
|
uuid = UUID.fromString(conf.getString("lastowner"));
|
||||||
}
|
}
|
||||||
catch (Exception ex) {}
|
catch (Exception ignored) {}
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,11 +111,11 @@ public class Warps implements IConf, net.ess3.api.IWarps {
|
|||||||
warpPoints.clear();
|
warpPoints.clear();
|
||||||
File[] listOfFiles = warpsFolder.listFiles();
|
File[] listOfFiles = warpsFolder.listFiles();
|
||||||
if (listOfFiles.length >= 1) {
|
if (listOfFiles.length >= 1) {
|
||||||
for (int i = 0; i < listOfFiles.length; i++) {
|
for (File listOfFile : listOfFiles) {
|
||||||
String filename = listOfFiles[i].getName();
|
String filename = listOfFile.getName();
|
||||||
if (listOfFiles[i].isFile() && filename.endsWith(".yml")) {
|
if (listOfFile.isFile() && filename.endsWith(".yml")) {
|
||||||
try {
|
try {
|
||||||
EssentialsConf conf = new EssentialsConf(listOfFiles[i]);
|
EssentialsConf conf = new EssentialsConf(listOfFile);
|
||||||
conf.load();
|
conf.load();
|
||||||
String name = conf.getString("name");
|
String name = conf.getString("name");
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
|
@ -55,7 +55,7 @@ public interface IItemDb {
|
|||||||
nameList = nameList.subList(0, 14);
|
nameList = nameList.subList(0, 14);
|
||||||
}
|
}
|
||||||
return StringUtil.joinList(", ", nameList);
|
return StringUtil.joinList(", ", nameList);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a List of all aliases for the given item stack.
|
* Get a List of all aliases for the given item stack.
|
||||||
|
@ -70,7 +70,7 @@ public interface IWarps extends IConf {
|
|||||||
/**
|
/**
|
||||||
* Gets Lastowner UUID
|
* Gets Lastowner UUID
|
||||||
*
|
*
|
||||||
* @param name - Name of warp
|
* @param warp - Name of warp
|
||||||
*
|
*
|
||||||
* @throws WarpNotFoundException
|
* @throws WarpNotFoundException
|
||||||
*/
|
*/
|
||||||
|
@ -11,7 +11,6 @@ import org.bukkit.Server;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n.tl;
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
@ -88,7 +87,7 @@ public class Commandbalancetop extends EssentialsCommand {
|
|||||||
try {
|
try {
|
||||||
if (force || cacheage <= System.currentTimeMillis() - CACHETIME) {
|
if (force || cacheage <= System.currentTimeMillis() - CACHETIME) {
|
||||||
cache.getLines().clear();
|
cache.getLines().clear();
|
||||||
final Map<String, BigDecimal> balances = new HashMap<String, BigDecimal>();
|
final Map<String, BigDecimal> balances = new HashMap<>();
|
||||||
BigDecimal totalMoney = BigDecimal.ZERO;
|
BigDecimal totalMoney = BigDecimal.ZERO;
|
||||||
if (ess.getSettings().isEcoDisabled()) {
|
if (ess.getSettings().isEcoDisabled()) {
|
||||||
if (ess.getSettings().isDebug()) {
|
if (ess.getSettings().isDebug()) {
|
||||||
@ -113,13 +112,8 @@ public class Commandbalancetop extends EssentialsCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Map.Entry<String, BigDecimal>> sortedEntries = new ArrayList<Map.Entry<String, BigDecimal>>(balances.entrySet());
|
final List<Map.Entry<String, BigDecimal>> sortedEntries = new ArrayList<>(balances.entrySet());
|
||||||
Collections.sort(sortedEntries, new Comparator<Map.Entry<String, BigDecimal>>() {
|
sortedEntries.sort((entry1, entry2) -> entry2.getValue().compareTo(entry1.getValue()));
|
||||||
@Override
|
|
||||||
public int compare(final Entry<String, BigDecimal> entry1, final Entry<String, BigDecimal> entry2) {
|
|
||||||
return entry2.getValue().compareTo(entry1.getValue());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
cache.getLines().add(tl("serverTotal", NumberUtil.displayCurrency(totalMoney, ess)));
|
cache.getLines().add(tl("serverTotal", NumberUtil.displayCurrency(totalMoney, ess)));
|
||||||
int pos = 1;
|
int pos = 1;
|
||||||
|
@ -6,8 +6,6 @@ import org.bukkit.Server;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n.tl;
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
|
|
||||||
|
|
||||||
@ -19,7 +17,7 @@ public class Commandbreak extends EssentialsCommand {
|
|||||||
//TODO: Switch to use util class
|
//TODO: Switch to use util class
|
||||||
@Override
|
@Override
|
||||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||||
final Block block = user.getBase().getTargetBlock((Set<Material>) null, 20);
|
final Block block = user.getBase().getTargetBlock(null, 20);
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
throw new NoChargeException();
|
throw new NoChargeException();
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n.tl;
|
|
||||||
|
|
||||||
import com.earth2me.essentials.CommandSource;
|
import com.earth2me.essentials.CommandSource;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||||
import com.earth2me.essentials.utils.NumberUtil;
|
import com.earth2me.essentials.utils.NumberUtil;
|
||||||
import com.earth2me.essentials.utils.StringUtil;
|
import com.earth2me.essentials.utils.StringUtil;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -15,6 +12,8 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
|
|
||||||
|
|
||||||
public class Commandclearinventory extends EssentialsCommand {
|
public class Commandclearinventory extends EssentialsCommand {
|
||||||
|
|
||||||
@ -38,7 +37,7 @@ public class Commandclearinventory extends EssentialsCommand {
|
|||||||
|
|
||||||
private void parseCommand(Server server, CommandSource sender, String commandLabel, String[] args, boolean allowOthers, boolean allowAll)
|
private void parseCommand(Server server, CommandSource sender, String commandLabel, String[] args, boolean allowOthers, boolean allowAll)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Collection<Player> players = new ArrayList<Player>();
|
Collection<Player> players = new ArrayList<>();
|
||||||
User senderUser = ess.getUser(sender.getPlayer());
|
User senderUser = ess.getUser(sender.getPlayer());
|
||||||
String previousClearCommand = "";
|
String previousClearCommand = "";
|
||||||
|
|
||||||
@ -195,6 +194,6 @@ public class Commandclearinventory extends EssentialsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String formatCommand(String commandLabel, String[] args) {
|
private String formatCommand(String commandLabel, String[] args) {
|
||||||
return "/" + commandLabel + " " + StringUtil.joinList(" ", (Object[]) args);
|
return "/" + commandLabel + " " + StringUtil.joinList(" ", args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ public class Commandcondense extends EssentialsCommand {
|
|||||||
super("condense");
|
super("condense");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<ItemStack, SimpleRecipe> condenseList = new HashMap<>();
|
private final Map<ItemStack, SimpleRecipe> condenseList = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||||
@ -120,7 +120,7 @@ public class Commandcondense extends EssentialsCommand {
|
|||||||
}
|
}
|
||||||
if (!bestRecipes.isEmpty()) {
|
if (!bestRecipes.isEmpty()) {
|
||||||
if (bestRecipes.size() > 1) {
|
if (bestRecipes.size() > 1) {
|
||||||
Collections.sort(bestRecipes, SimpleRecipeComparator.INSTANCE);
|
bestRecipes.sort(SimpleRecipeComparator.INSTANCE);
|
||||||
}
|
}
|
||||||
SimpleRecipe recipe = bestRecipes.get(0);
|
SimpleRecipe recipe = bestRecipes.get(0);
|
||||||
condenseList.put(stack, recipe);
|
condenseList.put(stack, recipe);
|
||||||
@ -171,9 +171,9 @@ public class Commandcondense extends EssentialsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class SimpleRecipe implements Recipe {
|
private static class SimpleRecipe implements Recipe {
|
||||||
private ItemStack result;
|
private final ItemStack result;
|
||||||
private ItemStack input;
|
private final ItemStack input;
|
||||||
|
|
||||||
private SimpleRecipe(ItemStack result, ItemStack input) {
|
private SimpleRecipe(ItemStack result, ItemStack input) {
|
||||||
this.result = result;
|
this.result = result;
|
||||||
|
@ -57,7 +57,7 @@ public class Commandcreatekit extends EssentialsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Command handler will auto fail if this fails.
|
// Command handler will auto fail if this fails.
|
||||||
long delay = Long.valueOf(args[1]);
|
long delay = Long.parseLong(args[1]);
|
||||||
String kitname = args[0];
|
String kitname = args[0];
|
||||||
ItemStack[] items = user.getBase().getInventory().getContents();
|
ItemStack[] items = user.getBase().getInventory().getContents();
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
@ -85,46 +85,43 @@ public class Commandcreatekit extends EssentialsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void uploadPaste(final CommandSource sender, final String kitName, final long delay, final String contents) {
|
private void uploadPaste(final CommandSource sender, final String kitName, final long delay, final String contents) {
|
||||||
executorService.submit(new Runnable() {
|
executorService.submit(() -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
HttpURLConnection connection = (HttpURLConnection) new URL(PASTE_UPLOAD_URL).openConnection();
|
||||||
try {
|
connection.setRequestMethod("POST");
|
||||||
HttpURLConnection connection = (HttpURLConnection) new URL(PASTE_UPLOAD_URL).openConnection();
|
connection.setDoInput(true);
|
||||||
connection.setRequestMethod("POST");
|
connection.setDoOutput(true);
|
||||||
connection.setDoInput(true);
|
connection.setRequestProperty("User-Agent", "EssentialsX plugin");
|
||||||
connection.setDoOutput(true);
|
try (OutputStream os = connection.getOutputStream()) {
|
||||||
connection.setRequestProperty("User-Agent", "EssentialsX plugin");
|
os.write(contents.getBytes(Charsets.UTF_8));
|
||||||
try (OutputStream os = connection.getOutputStream()) {
|
|
||||||
os.write(contents.getBytes(Charsets.UTF_8));
|
|
||||||
}
|
|
||||||
// Error
|
|
||||||
if (connection.getResponseCode() >= 400) {
|
|
||||||
sender.sendMessage(tl("createKitFailed", kitName));
|
|
||||||
String message = CharStreams.toString(new InputStreamReader(connection.getErrorStream(), Charsets.UTF_8));
|
|
||||||
ess.getLogger().severe("Error creating kit: " + message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read URL
|
|
||||||
JsonObject object = GSON.fromJson(new InputStreamReader(connection.getInputStream(), Charsets.UTF_8), JsonObject.class);
|
|
||||||
String pasteUrl = PASTE_URL + object.get("key").getAsString();
|
|
||||||
connection.disconnect();
|
|
||||||
|
|
||||||
String separator = tl("createKitSeparator");
|
|
||||||
String delayFormat = "0";
|
|
||||||
if (delay > 0) {
|
|
||||||
delayFormat = DateUtil.formatDateDiff(System.currentTimeMillis() + (delay * 1000));
|
|
||||||
}
|
|
||||||
sender.sendMessage(separator);
|
|
||||||
sender.sendMessage(tl("createKitSuccess", kitName, delayFormat, pasteUrl));
|
|
||||||
sender.sendMessage(separator);
|
|
||||||
if (ess.getSettings().isDebug()) {
|
|
||||||
ess.getLogger().info(sender.getSender().getName() + " created a kit: " + pasteUrl);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
sender.sendMessage(tl("createKitFailed", kitName));
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
// Error
|
||||||
|
if (connection.getResponseCode() >= 400) {
|
||||||
|
sender.sendMessage(tl("createKitFailed", kitName));
|
||||||
|
String message = CharStreams.toString(new InputStreamReader(connection.getErrorStream(), Charsets.UTF_8));
|
||||||
|
ess.getLogger().severe("Error creating kit: " + message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read URL
|
||||||
|
JsonObject object = GSON.fromJson(new InputStreamReader(connection.getInputStream(), Charsets.UTF_8), JsonObject.class);
|
||||||
|
String pasteUrl = PASTE_URL + object.get("key").getAsString();
|
||||||
|
connection.disconnect();
|
||||||
|
|
||||||
|
String separator = tl("createKitSeparator");
|
||||||
|
String delayFormat = "0";
|
||||||
|
if (delay > 0) {
|
||||||
|
delayFormat = DateUtil.formatDateDiff(System.currentTimeMillis() + (delay * 1000));
|
||||||
|
}
|
||||||
|
sender.sendMessage(separator);
|
||||||
|
sender.sendMessage(tl("createKitSuccess", kitName, delayFormat, pasteUrl));
|
||||||
|
sender.sendMessage(separator);
|
||||||
|
if (ess.getSettings().isDebug()) {
|
||||||
|
ess.getLogger().info(sender.getSender().getName() + " created a kit: " + pasteUrl);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
sender.sendMessage(tl("createKitFailed", kitName));
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import com.earth2me.essentials.CommandSource;
|
|||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -175,7 +175,7 @@ public class Commandessentials extends EssentialsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cow farts.
|
// Cow farts.
|
||||||
private void runMoo(final Server server, final CommandSource sender, final String command, final String args[]) {
|
private void runMoo(final Server server, final CommandSource sender, final String command, final String[] args) {
|
||||||
if (args.length == 2 && args[1].equals("moo")) {
|
if (args.length == 2 && args[1].equals("moo")) {
|
||||||
for (String s : CONSOLE_MOO) {
|
for (String s : CONSOLE_MOO) {
|
||||||
logger.info(s);
|
logger.info(s);
|
||||||
@ -197,7 +197,7 @@ public class Commandessentials extends EssentialsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cleans up inactive users.
|
// Cleans up inactive users.
|
||||||
private void runCleanup(final Server server, final CommandSource sender, final String command, final String args[]) throws Exception {
|
private void runCleanup(final Server server, final CommandSource sender, final String command, final String[] args) throws Exception {
|
||||||
if (args.length < 2 || !NumberUtil.isInt(args[1])) {
|
if (args.length < 2 || !NumberUtil.isInt(args[1])) {
|
||||||
sender.sendMessage("This sub-command will delete users who haven't logged in in the last <days> days.");
|
sender.sendMessage("This sub-command will delete users who haven't logged in in the last <days> days.");
|
||||||
sender.sendMessage("Optional parameters define the minimum amount required to prevent deletion.");
|
sender.sendMessage("Optional parameters define the minimum amount required to prevent deletion.");
|
||||||
@ -213,7 +213,7 @@ public class Commandessentials extends EssentialsCommand {
|
|||||||
final UserMap userMap = ess.getUserMap();
|
final UserMap userMap = ess.getUserMap();
|
||||||
|
|
||||||
ess.runTaskAsynchronously(() -> {
|
ess.runTaskAsynchronously(() -> {
|
||||||
Long currTime = System.currentTimeMillis();
|
long currTime = System.currentTimeMillis();
|
||||||
for (UUID u : userMap.getAllUniqueUsers()) {
|
for (UUID u : userMap.getAllUniqueUsers()) {
|
||||||
final User user = ess.getUserMap().getUser(u);
|
final User user = ess.getUserMap().getUser(u);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
@ -1,222 +1,222 @@
|
|||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import com.earth2me.essentials.CommandSource;
|
import com.earth2me.essentials.CommandSource;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import com.earth2me.essentials.craftbukkit.SetExpFix;
|
import com.earth2me.essentials.craftbukkit.SetExpFix;
|
||||||
import com.earth2me.essentials.utils.NumberUtil;
|
import com.earth2me.essentials.utils.NumberUtil;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n.tl;
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
|
|
||||||
|
|
||||||
public class Commandexp extends EssentialsCommand {
|
public class Commandexp extends EssentialsCommand {
|
||||||
public Commandexp() {
|
public Commandexp() {
|
||||||
super("exp");
|
super("exp");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
showExp(user.getSource(), user);
|
showExp(user.getSource(), user);
|
||||||
} else if (args.length > 1 && args[0].equalsIgnoreCase("set") && user.isAuthorized("essentials.exp.set")) {
|
} else if (args.length > 1 && args[0].equalsIgnoreCase("set") && user.isAuthorized("essentials.exp.set")) {
|
||||||
if (args.length == 3 && user.isAuthorized("essentials.exp.set.others")) {
|
if (args.length == 3 && user.isAuthorized("essentials.exp.set.others")) {
|
||||||
expMatch(server, user.getSource(), args[1], args[2], false);
|
expMatch(server, user.getSource(), args[1], args[2], false);
|
||||||
} else {
|
} else {
|
||||||
setExp(user.getSource(), user, args[1], false);
|
setExp(user.getSource(), user, args[1], false);
|
||||||
}
|
}
|
||||||
} else if (args.length > 1 && args[0].equalsIgnoreCase("give") && user.isAuthorized("essentials.exp.give")) {
|
} else if (args.length > 1 && args[0].equalsIgnoreCase("give") && user.isAuthorized("essentials.exp.give")) {
|
||||||
if (args.length == 3 && user.isAuthorized("essentials.exp.give.others")) {
|
if (args.length == 3 && user.isAuthorized("essentials.exp.give.others")) {
|
||||||
expMatch(server, user.getSource(), args[1], args[2], true);
|
expMatch(server, user.getSource(), args[1], args[2], true);
|
||||||
} else {
|
} else {
|
||||||
setExp(user.getSource(), user, args[1], true);
|
setExp(user.getSource(), user, args[1], true);
|
||||||
}
|
}
|
||||||
} else if (args.length > 1 && args[0].equalsIgnoreCase("take") && user.isAuthorized("essentials.exp.take")) {
|
} else if (args.length > 1 && args[0].equalsIgnoreCase("take") && user.isAuthorized("essentials.exp.take")) {
|
||||||
if (args.length == 3 && user.isAuthorized("essentials.exp.take.others")) {
|
if (args.length == 3 && user.isAuthorized("essentials.exp.take.others")) {
|
||||||
expMatch(server, user.getSource(), args[1], "-" + args[2], true);
|
expMatch(server, user.getSource(), args[1], "-" + args[2], true);
|
||||||
} else {
|
} else {
|
||||||
setExp(user.getSource(), user, "-" + args[1], true);
|
setExp(user.getSource(), user, "-" + args[1], true);
|
||||||
}
|
}
|
||||||
} else if (args.length < 3 && args[0].equalsIgnoreCase("reset") && user.isAuthorized("essentials.exp.reset")) {
|
} else if (args.length < 3 && args[0].equalsIgnoreCase("reset") && user.isAuthorized("essentials.exp.reset")) {
|
||||||
if (args.length == 2 && user.isAuthorized("essentials.exp.reset.others")) {
|
if (args.length == 2 && user.isAuthorized("essentials.exp.reset.others")) {
|
||||||
expMatch(server, user.getSource(), args[1], "0", false);
|
expMatch(server, user.getSource(), args[1], "0", false);
|
||||||
} else {
|
} else {
|
||||||
setExp(user.getSource(), user, "0", false);
|
setExp(user.getSource(), user, "0", false);
|
||||||
}
|
}
|
||||||
} else if (args[0].equalsIgnoreCase("show")) {
|
} else if (args[0].equalsIgnoreCase("show")) {
|
||||||
if (args.length >= 2 && user.isAuthorized("essentials.exp.others")) {
|
if (args.length >= 2 && user.isAuthorized("essentials.exp.others")) {
|
||||||
String match = args[1].trim();
|
String match = args[1].trim();
|
||||||
showMatch(server, user.getSource(), match);
|
showMatch(server, user.getSource(), match);
|
||||||
} else {
|
} else {
|
||||||
showExp(user.getSource(), user);
|
showExp(user.getSource(), user);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (args.length >= 1 && NumberUtil.isInt(args[0].toLowerCase(Locale.ENGLISH).replace("l", "")) && user.isAuthorized("essentials.exp.give")) {
|
if (args.length >= 1 && NumberUtil.isInt(args[0].toLowerCase(Locale.ENGLISH).replace("l", "")) && user.isAuthorized("essentials.exp.give")) {
|
||||||
if (args.length >= 2 && user.isAuthorized("essentials.exp.give.others")) {
|
if (args.length >= 2 && user.isAuthorized("essentials.exp.give.others")) {
|
||||||
expMatch(server, user.getSource(), args[1], args[0], true);
|
expMatch(server, user.getSource(), args[1], args[0], true);
|
||||||
} else {
|
} else {
|
||||||
setExp(user.getSource(), user, args[0], true);
|
setExp(user.getSource(), user, args[0], true);
|
||||||
}
|
}
|
||||||
} else if (args.length >= 1 && user.isAuthorized("essentials.exp.others")) {
|
} else if (args.length >= 1 && user.isAuthorized("essentials.exp.others")) {
|
||||||
String match = args[0].trim();
|
String match = args[0].trim();
|
||||||
showMatch(server, user.getSource(), match);
|
showMatch(server, user.getSource(), match);
|
||||||
} else {
|
} else {
|
||||||
showExp(user.getSource(), user);
|
showExp(user.getSource(), user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
} else if (args.length > 2 && args[0].equalsIgnoreCase("set")) {
|
} else if (args.length > 2 && args[0].equalsIgnoreCase("set")) {
|
||||||
expMatch(server, sender, args[1], args[2], false);
|
expMatch(server, sender, args[1], args[2], false);
|
||||||
} else if (args.length > 2 && args[0].equalsIgnoreCase("give")) {
|
} else if (args.length > 2 && args[0].equalsIgnoreCase("give")) {
|
||||||
expMatch(server, sender, args[1], args[2], true);
|
expMatch(server, sender, args[1], args[2], true);
|
||||||
} else {
|
} else {
|
||||||
String match = args[0].trim();
|
String match = args[0].trim();
|
||||||
if (args.length >= 2 && NumberUtil.isInt(args[0].toLowerCase(Locale.ENGLISH).replace("l", ""))) {
|
if (args.length >= 2 && NumberUtil.isInt(args[0].toLowerCase(Locale.ENGLISH).replace("l", ""))) {
|
||||||
match = args[1].trim();
|
match = args[1].trim();
|
||||||
expMatch(server, sender, match, args[0], true);
|
expMatch(server, sender, match, args[0], true);
|
||||||
} else if (args.length == 1) {
|
} else if (args.length == 1) {
|
||||||
match = args[0].trim();
|
match = args[0].trim();
|
||||||
}
|
}
|
||||||
showMatch(server, sender, match);
|
showMatch(server, sender, match);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showMatch(final Server server, final CommandSource sender, final String match) throws PlayerNotFoundException {
|
private void showMatch(final Server server, final CommandSource sender, final String match) throws PlayerNotFoundException {
|
||||||
boolean skipHidden = sender.isPlayer() && !ess.getUser(sender.getPlayer()).canInteractVanished();
|
boolean skipHidden = sender.isPlayer() && !ess.getUser(sender.getPlayer()).canInteractVanished();
|
||||||
boolean foundUser = false;
|
boolean foundUser = false;
|
||||||
final List<Player> matchedPlayers = server.matchPlayer(match);
|
final List<Player> matchedPlayers = server.matchPlayer(match);
|
||||||
for (Player matchPlayer : matchedPlayers) {
|
for (Player matchPlayer : matchedPlayers) {
|
||||||
final User player = ess.getUser(matchPlayer);
|
final User player = ess.getUser(matchPlayer);
|
||||||
if (skipHidden && player.isHidden(sender.getPlayer()) && !sender.getPlayer().canSee(matchPlayer)) {
|
if (skipHidden && player.isHidden(sender.getPlayer()) && !sender.getPlayer().canSee(matchPlayer)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
foundUser = true;
|
foundUser = true;
|
||||||
showExp(sender, player);
|
showExp(sender, player);
|
||||||
}
|
}
|
||||||
if (!foundUser) {
|
if (!foundUser) {
|
||||||
throw new PlayerNotFoundException();
|
throw new PlayerNotFoundException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void expMatch(final Server server, final CommandSource sender, final String match, String amount, final boolean give) throws NotEnoughArgumentsException, PlayerNotFoundException {
|
private void expMatch(final Server server, final CommandSource sender, final String match, String amount, final boolean give) throws NotEnoughArgumentsException, PlayerNotFoundException {
|
||||||
boolean skipHidden = sender.isPlayer() && !ess.getUser(sender.getPlayer()).canInteractVanished();
|
boolean skipHidden = sender.isPlayer() && !ess.getUser(sender.getPlayer()).canInteractVanished();
|
||||||
boolean foundUser = false;
|
boolean foundUser = false;
|
||||||
final List<Player> matchedPlayers = server.matchPlayer(match);
|
final List<Player> matchedPlayers = server.matchPlayer(match);
|
||||||
for (Player matchPlayer : matchedPlayers) {
|
for (Player matchPlayer : matchedPlayers) {
|
||||||
final User player = ess.getUser(matchPlayer);
|
final User player = ess.getUser(matchPlayer);
|
||||||
if (skipHidden && player.isHidden(sender.getPlayer()) && !sender.getPlayer().canSee(matchPlayer)) {
|
if (skipHidden && player.isHidden(sender.getPlayer()) && !sender.getPlayer().canSee(matchPlayer)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
foundUser = true;
|
foundUser = true;
|
||||||
setExp(sender, player, amount, give);
|
setExp(sender, player, amount, give);
|
||||||
}
|
}
|
||||||
if (!foundUser) {
|
if (!foundUser) {
|
||||||
throw new PlayerNotFoundException();
|
throw new PlayerNotFoundException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showExp(final CommandSource sender, final User target) {
|
private void showExp(final CommandSource sender, final User target) {
|
||||||
sender.sendMessage(tl("exp", target.getDisplayName(), SetExpFix.getTotalExperience(target.getBase()), target.getBase().getLevel(), SetExpFix.getExpUntilNextLevel(target.getBase())));
|
sender.sendMessage(tl("exp", target.getDisplayName(), SetExpFix.getTotalExperience(target.getBase()), target.getBase().getLevel(), SetExpFix.getExpUntilNextLevel(target.getBase())));
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Limit who can give negative exp?
|
//TODO: Limit who can give negative exp?
|
||||||
private void setExp(final CommandSource sender, final User target, String strAmount, final boolean give) throws NotEnoughArgumentsException {
|
private void setExp(final CommandSource sender, final User target, String strAmount, final boolean give) throws NotEnoughArgumentsException {
|
||||||
long amount;
|
long amount;
|
||||||
strAmount = strAmount.toLowerCase(Locale.ENGLISH);
|
strAmount = strAmount.toLowerCase(Locale.ENGLISH);
|
||||||
if (strAmount.contains("l")) {
|
if (strAmount.contains("l")) {
|
||||||
strAmount = strAmount.replaceAll("l", "");
|
strAmount = strAmount.replaceAll("l", "");
|
||||||
int neededLevel = Integer.parseInt(strAmount);
|
int neededLevel = Integer.parseInt(strAmount);
|
||||||
if (give) {
|
if (give) {
|
||||||
neededLevel += target.getBase().getLevel();
|
neededLevel += target.getBase().getLevel();
|
||||||
}
|
}
|
||||||
amount = (long) SetExpFix.getExpToLevel(neededLevel);
|
amount = SetExpFix.getExpToLevel(neededLevel);
|
||||||
SetExpFix.setTotalExperience(target.getBase(), 0);
|
SetExpFix.setTotalExperience(target.getBase(), 0);
|
||||||
} else {
|
} else {
|
||||||
amount = Long.parseLong(strAmount);
|
amount = Long.parseLong(strAmount);
|
||||||
if (amount > Integer.MAX_VALUE || amount < Integer.MIN_VALUE) {
|
if (amount > Integer.MAX_VALUE || amount < Integer.MIN_VALUE) {
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (give) {
|
if (give) {
|
||||||
amount += SetExpFix.getTotalExperience(target.getBase());
|
amount += SetExpFix.getTotalExperience(target.getBase());
|
||||||
}
|
}
|
||||||
if (amount > Integer.MAX_VALUE) {
|
if (amount > Integer.MAX_VALUE) {
|
||||||
amount = (long) Integer.MAX_VALUE;
|
amount = Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
if (amount < 0l) {
|
if (amount < 0L) {
|
||||||
amount = 0l;
|
amount = 0L;
|
||||||
}
|
}
|
||||||
SetExpFix.setTotalExperience(target.getBase(), (int) amount);
|
SetExpFix.setTotalExperience(target.getBase(), (int) amount);
|
||||||
sender.sendMessage(tl("expSet", target.getDisplayName(), amount));
|
sender.sendMessage(tl("expSet", target.getDisplayName(), amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getTabCompleteOptions(final Server server, final User user, final String commandLabel, final String[] args) {
|
protected List<String> getTabCompleteOptions(final Server server, final User user, final String commandLabel, final String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
List<String> options = Lists.newArrayList("show");
|
List<String> options = Lists.newArrayList("show");
|
||||||
if (user.isAuthorized("essentials.exp.set")) {
|
if (user.isAuthorized("essentials.exp.set")) {
|
||||||
options.add("set");
|
options.add("set");
|
||||||
}
|
}
|
||||||
if (user.isAuthorized("essentials.exp.give")) {
|
if (user.isAuthorized("essentials.exp.give")) {
|
||||||
options.add("give");
|
options.add("give");
|
||||||
}
|
}
|
||||||
if (user.isAuthorized("essentials.exp.take")) {
|
if (user.isAuthorized("essentials.exp.take")) {
|
||||||
options.add("take");
|
options.add("take");
|
||||||
}
|
}
|
||||||
if (user.isAuthorized("essentials.exp.reset")) {
|
if (user.isAuthorized("essentials.exp.reset")) {
|
||||||
options.add("reset");
|
options.add("reset");
|
||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
} else if (args.length == 2) {
|
} else if (args.length == 2) {
|
||||||
if ((args[0].equalsIgnoreCase("set") && user.isAuthorized("essentials.exp.set")) || (args[0].equalsIgnoreCase("give") && user.isAuthorized("essentials.exp.give")) || (args[0].equalsIgnoreCase("take") && user.isAuthorized("essentials.exp.take"))) {
|
if ((args[0].equalsIgnoreCase("set") && user.isAuthorized("essentials.exp.set")) || (args[0].equalsIgnoreCase("give") && user.isAuthorized("essentials.exp.give")) || (args[0].equalsIgnoreCase("take") && user.isAuthorized("essentials.exp.take"))) {
|
||||||
String levellessArg = args[1].toLowerCase(Locale.ENGLISH).replaceAll("l", "");
|
String levellessArg = args[1].toLowerCase(Locale.ENGLISH).replaceAll("l", "");
|
||||||
if (NumberUtil.isInt(levellessArg)) {
|
if (NumberUtil.isInt(levellessArg)) {
|
||||||
return Lists.newArrayList(levellessArg + "l");
|
return Lists.newArrayList(levellessArg + "l");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (user.isAuthorized("essentials.exp.others")) {
|
if (user.isAuthorized("essentials.exp.others")) {
|
||||||
return getPlayers(server, user);
|
return getPlayers(server, user);
|
||||||
}
|
}
|
||||||
} else if (args.length == 3 && !(args[0].equalsIgnoreCase("show") || args[0].equalsIgnoreCase("reset"))) {
|
} else if (args.length == 3 && !(args[0].equalsIgnoreCase("show") || args[0].equalsIgnoreCase("reset"))) {
|
||||||
String levellessArg = args[2].toLowerCase(Locale.ENGLISH).replaceAll("l", "");
|
String levellessArg = args[2].toLowerCase(Locale.ENGLISH).replaceAll("l", "");
|
||||||
if (NumberUtil.isInt(levellessArg)) {
|
if (NumberUtil.isInt(levellessArg)) {
|
||||||
return Lists.newArrayList(levellessArg + "l");
|
return Lists.newArrayList(levellessArg + "l");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
// TODO: This seems somewhat buggy, both setting and showing - right now, ignoring that
|
// TODO: This seems somewhat buggy, both setting and showing - right now, ignoring that
|
||||||
return Lists.newArrayList("set", "give", "show", "take", "reset");
|
return Lists.newArrayList("set", "give", "show", "take", "reset");
|
||||||
} else if (args.length == 2) {
|
} else if (args.length == 2) {
|
||||||
if (args[0].equalsIgnoreCase("set") || args[0].equalsIgnoreCase("give")) {
|
if (args[0].equalsIgnoreCase("set") || args[0].equalsIgnoreCase("give")) {
|
||||||
String levellessArg = args[1].toLowerCase(Locale.ENGLISH).replace("l", "");
|
String levellessArg = args[1].toLowerCase(Locale.ENGLISH).replace("l", "");
|
||||||
if (NumberUtil.isInt(levellessArg)) {
|
if (NumberUtil.isInt(levellessArg)) {
|
||||||
return Lists.newArrayList(levellessArg, args[1] + "l");
|
return Lists.newArrayList(levellessArg, args[1] + "l");
|
||||||
} else {
|
} else {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
} else { // even without 'show'
|
} else { // even without 'show'
|
||||||
return getPlayers(server, sender);
|
return getPlayers(server, sender);
|
||||||
}
|
}
|
||||||
} else if (args.length == 3 && (args[0].equalsIgnoreCase("set") || args[0].equalsIgnoreCase("give"))) {
|
} else if (args.length == 3 && (args[0].equalsIgnoreCase("set") || args[0].equalsIgnoreCase("give"))) {
|
||||||
return getPlayers(server, sender);
|
return getPlayers(server, sender);
|
||||||
} else {
|
} else {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ public class Commandfeed extends EssentialsLoopCommand {
|
|||||||
throw new QuietAbortException();
|
throw new QuietAbortException();
|
||||||
}
|
}
|
||||||
|
|
||||||
player.setFoodLevel(flce.getFoodLevel() > 20 ? 20 : flce.getFoodLevel());
|
player.setFoodLevel(Math.min(flce.getFoodLevel(), 20));
|
||||||
player.setSaturation(10);
|
player.setSaturation(10);
|
||||||
player.setExhaustion(0F);
|
player.setExhaustion(0F);
|
||||||
}
|
}
|
||||||
|
@ -1,178 +1,177 @@
|
|||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import com.earth2me.essentials.MetaItemStack;
|
import com.earth2me.essentials.MetaItemStack;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import com.earth2me.essentials.utils.MaterialUtil;
|
import com.earth2me.essentials.utils.MaterialUtil;
|
||||||
import com.earth2me.essentials.utils.NumberUtil;
|
import com.earth2me.essentials.utils.NumberUtil;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.FireworkEffect;
|
import org.bukkit.FireworkEffect;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.Firework;
|
||||||
import org.bukkit.entity.Firework;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.meta.FireworkMeta;
|
||||||
import org.bukkit.inventory.meta.FireworkMeta;
|
import org.bukkit.util.Vector;
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Collections;
|
import java.util.List;
|
||||||
import java.util.List;
|
|
||||||
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
import static com.earth2me.essentials.I18n.tl;
|
|
||||||
|
//This command has quite a complicated syntax, in theory it has 4 seperate syntaxes which are all variable:
|
||||||
//This command has quite a complicated syntax, in theory it has 4 seperate syntaxes which are all variable:
|
//
|
||||||
//
|
//1: /firework clear - This clears all of the effects on a firework stack
|
||||||
//1: /firework clear - This clears all of the effects on a firework stack
|
//
|
||||||
//
|
//2: /firework power <int> - This changes the base power of a firework
|
||||||
//2: /firework power <int> - This changes the base power of a firework
|
//
|
||||||
//
|
//3: /firework fire - This 'fires' a copy of the firework held.
|
||||||
//3: /firework fire - This 'fires' a copy of the firework held.
|
//3: /firework fire <int> - This 'fires' a number of copies of the firework held.
|
||||||
//3: /firework fire <int> - This 'fires' a number of copies of the firework held.
|
//3: /firework fire <other> - This 'fires' a copy of the firework held, in the direction you are looking, #easteregg
|
||||||
//3: /firework fire <other> - This 'fires' a copy of the firework held, in the direction you are looking, #easteregg
|
//
|
||||||
//
|
//4: /firework [meta] - This will add an effect to the firework stack held
|
||||||
//4: /firework [meta] - This will add an effect to the firework stack held
|
//4: /firework color:<color> - The minimum you need to set an effect is 'color'
|
||||||
//4: /firework color:<color> - The minimum you need to set an effect is 'color'
|
//4: Full Syntax: color:<color[,color,..]> [fade:<color[,color,..]>] [shape:<shape>] [effect:<effect[,effect]>]
|
||||||
//4: Full Syntax: color:<color[,color,..]> [fade:<color[,color,..]>] [shape:<shape>] [effect:<effect[,effect]>]
|
//4: Possible Shapes: star, ball, large, creeper, burst
|
||||||
//4: Possible Shapes: star, ball, large, creeper, burst
|
//4: Possible Effects trail, twinkle
|
||||||
//4: Possible Effects trail, twinkle
|
|
||||||
|
public class Commandfirework extends EssentialsCommand {
|
||||||
public class Commandfirework extends EssentialsCommand {
|
|
||||||
|
public Commandfirework() {
|
||||||
public Commandfirework() {
|
super("firework");
|
||||||
super("firework");
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
final ItemStack stack = user.getItemInHand();
|
||||||
final ItemStack stack = user.getItemInHand();
|
if (MaterialUtil.isFirework(stack.getType())) {
|
||||||
if (MaterialUtil.isFirework(stack.getType())) {
|
if (args.length > 0) {
|
||||||
if (args.length > 0) {
|
if (args[0].equalsIgnoreCase("clear")) {
|
||||||
if (args[0].equalsIgnoreCase("clear")) {
|
FireworkMeta fmeta = (FireworkMeta) stack.getItemMeta();
|
||||||
FireworkMeta fmeta = (FireworkMeta) stack.getItemMeta();
|
fmeta.clearEffects();
|
||||||
fmeta.clearEffects();
|
stack.setItemMeta(fmeta);
|
||||||
stack.setItemMeta(fmeta);
|
user.sendMessage(tl("fireworkEffectsCleared"));
|
||||||
user.sendMessage(tl("fireworkEffectsCleared"));
|
} else if (args.length > 1 && (args[0].equalsIgnoreCase("power") || (args[0].equalsIgnoreCase("p")))) {
|
||||||
} else if (args.length > 1 && (args[0].equalsIgnoreCase("power") || (args[0].equalsIgnoreCase("p")))) {
|
FireworkMeta fmeta = (FireworkMeta) stack.getItemMeta();
|
||||||
FireworkMeta fmeta = (FireworkMeta) stack.getItemMeta();
|
try {
|
||||||
try {
|
int power = Integer.parseInt(args[1]);
|
||||||
int power = Integer.parseInt(args[1]);
|
fmeta.setPower(power > 3 ? 4 : power);
|
||||||
fmeta.setPower(power > 3 ? 4 : power);
|
} catch (NumberFormatException e) {
|
||||||
} catch (NumberFormatException e) {
|
throw new Exception(tl("invalidFireworkFormat", args[1], args[0]));
|
||||||
throw new Exception(tl("invalidFireworkFormat", args[1], args[0]));
|
}
|
||||||
}
|
stack.setItemMeta(fmeta);
|
||||||
stack.setItemMeta(fmeta);
|
} else if ((args[0].equalsIgnoreCase("fire") || (args[0].equalsIgnoreCase("f"))) && user.isAuthorized("essentials.firework.fire")) {
|
||||||
} else if ((args[0].equalsIgnoreCase("fire") || (args[0].equalsIgnoreCase("f"))) && user.isAuthorized("essentials.firework.fire")) {
|
int amount = 1;
|
||||||
int amount = 1;
|
boolean direction = false;
|
||||||
boolean direction = false;
|
if (args.length > 1) {
|
||||||
if (args.length > 1) {
|
if (NumberUtil.isInt(args[1])) {
|
||||||
if (NumberUtil.isInt(args[1])) {
|
final int serverLimit = ess.getSettings().getSpawnMobLimit();
|
||||||
final int serverLimit = ess.getSettings().getSpawnMobLimit();
|
amount = Integer.parseInt(args[1]);
|
||||||
amount = Integer.parseInt(args[1]);
|
if (amount > serverLimit) {
|
||||||
if (amount > serverLimit) {
|
amount = serverLimit;
|
||||||
amount = serverLimit;
|
user.sendMessage(tl("mobSpawnLimit"));
|
||||||
user.sendMessage(tl("mobSpawnLimit"));
|
}
|
||||||
}
|
} else {
|
||||||
} else {
|
direction = true;
|
||||||
direction = true;
|
}
|
||||||
}
|
}
|
||||||
}
|
for (int i = 0; i < amount; i++) {
|
||||||
for (int i = 0; i < amount; i++) {
|
Firework firework = (Firework) user.getWorld().spawnEntity(user.getLocation(), EntityType.FIREWORK);
|
||||||
Firework firework = (Firework) user.getWorld().spawnEntity(user.getLocation(), EntityType.FIREWORK);
|
FireworkMeta fmeta = (FireworkMeta) stack.getItemMeta();
|
||||||
FireworkMeta fmeta = (FireworkMeta) stack.getItemMeta();
|
if (direction) {
|
||||||
if (direction) {
|
final Vector vector = user.getBase().getEyeLocation().getDirection().multiply(0.070);
|
||||||
final Vector vector = user.getBase().getEyeLocation().getDirection().multiply(0.070);
|
if (fmeta.getPower() > 1) {
|
||||||
if (fmeta.getPower() > 1) {
|
fmeta.setPower(1);
|
||||||
fmeta.setPower(1);
|
}
|
||||||
}
|
firework.setVelocity(vector);
|
||||||
firework.setVelocity(vector);
|
}
|
||||||
}
|
firework.setFireworkMeta(fmeta);
|
||||||
firework.setFireworkMeta(fmeta);
|
}
|
||||||
}
|
} else {
|
||||||
} else {
|
final MetaItemStack mStack = new MetaItemStack(stack);
|
||||||
final MetaItemStack mStack = new MetaItemStack(stack);
|
for (String arg : args) {
|
||||||
for (String arg : args) {
|
try {
|
||||||
try {
|
mStack.addFireworkMeta(user.getSource(), true, arg, ess);
|
||||||
mStack.addFireworkMeta(user.getSource(), true, arg, ess);
|
} catch (Exception e) {
|
||||||
} catch (Exception e) {
|
user.sendMessage(tl("fireworkSyntax"));
|
||||||
user.sendMessage(tl("fireworkSyntax"));
|
throw e;
|
||||||
throw e;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if (mStack.isValidFirework()) {
|
||||||
if (mStack.isValidFirework()) {
|
FireworkMeta fmeta = (FireworkMeta) mStack.getItemStack().getItemMeta();
|
||||||
FireworkMeta fmeta = (FireworkMeta) mStack.getItemStack().getItemMeta();
|
FireworkEffect effect = mStack.getFireworkBuilder().build();
|
||||||
FireworkEffect effect = mStack.getFireworkBuilder().build();
|
if (fmeta.getEffects().size() > 0 && !user.isAuthorized("essentials.firework.multiple")) {
|
||||||
if (fmeta.getEffects().size() > 0 && !user.isAuthorized("essentials.firework.multiple")) {
|
throw new Exception(tl("multipleCharges"));
|
||||||
throw new Exception(tl("multipleCharges"));
|
}
|
||||||
}
|
fmeta.addEffect(effect);
|
||||||
fmeta.addEffect(effect);
|
stack.setItemMeta(fmeta);
|
||||||
stack.setItemMeta(fmeta);
|
} else {
|
||||||
} else {
|
user.sendMessage(tl("fireworkSyntax"));
|
||||||
user.sendMessage(tl("fireworkSyntax"));
|
throw new Exception(tl("fireworkColor"));
|
||||||
throw new Exception(tl("fireworkColor"));
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
} else {
|
throw new NotEnoughArgumentsException();
|
||||||
throw new NotEnoughArgumentsException();
|
}
|
||||||
}
|
} else {
|
||||||
} else {
|
throw new Exception(tl("holdFirework"));
|
||||||
throw new Exception(tl("holdFirework"));
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
protected List<String> getTabCompleteOptions(Server server, User user, String commandLabel, String[] args) {
|
||||||
protected List<String> getTabCompleteOptions(Server server, User user, String commandLabel, String[] args) {
|
// Note: this enforces an order of color fade shape effect, which the actual command doesn't have. But that's fine.
|
||||||
// Note: this enforces an order of color fade shape effect, which the actual command doesn't have. But that's fine.
|
if (args.length == 1) {
|
||||||
if (args.length == 1) {
|
List<String> options = Lists.newArrayList();
|
||||||
List<String> options = Lists.newArrayList();
|
if (args[0].startsWith("color:")) {
|
||||||
if (args[0].startsWith("color:")) {
|
String prefix;
|
||||||
String prefix;
|
if (args[0].contains(",")) {
|
||||||
if (args[0].contains(",")) {
|
prefix = args[0].substring(0, args[0].lastIndexOf(',') + 1);
|
||||||
prefix = args[0].substring(0, args[0].lastIndexOf(',') + 1);
|
} else {
|
||||||
} else {
|
prefix = "color:";
|
||||||
prefix = "color:";
|
}
|
||||||
}
|
for (DyeColor color : DyeColor.values()) {
|
||||||
for (DyeColor color : DyeColor.values()) {
|
options.add(prefix + color.name().toLowerCase() + ",");
|
||||||
options.add(prefix + color.name().toLowerCase() + ",");
|
}
|
||||||
}
|
return options;
|
||||||
return options;
|
}
|
||||||
}
|
options.add("clear");
|
||||||
options.add("clear");
|
options.add("power");
|
||||||
options.add("power");
|
options.add("color:");
|
||||||
options.add("color:");
|
if (user.isAuthorized("essentials.firework.fire")) {
|
||||||
if (user.isAuthorized("essentials.firework.fire")) {
|
options.add("fire");
|
||||||
options.add("fire");
|
}
|
||||||
}
|
return options;
|
||||||
return options;
|
} else if (args.length == 2) {
|
||||||
} else if (args.length == 2) {
|
if (args[0].equals("power")) {
|
||||||
if (args[0].equals("power")) {
|
return Lists.newArrayList("1", "2", "3", "4");
|
||||||
return Lists.newArrayList("1", "2", "3", "4");
|
} else if (args[0].equals("fire")) {
|
||||||
} else if (args[0].equals("fire")) {
|
return Lists.newArrayList("1");
|
||||||
return Lists.newArrayList("1");
|
} else if (args[0].startsWith("color:")) {
|
||||||
} else if (args[0].startsWith("color:")) {
|
List<String> options = Lists.newArrayList();
|
||||||
List<String> options = Lists.newArrayList();
|
if (!args[1].startsWith("fade:")) {
|
||||||
if (!args[1].startsWith("fade:")) {
|
args[1] = "fade:";
|
||||||
args[1] = "fade:";
|
}
|
||||||
}
|
String prefix;
|
||||||
String prefix;
|
if (args[1].contains(",")) {
|
||||||
if (args[1].contains(",")) {
|
prefix = args[1].substring(0, args[1].lastIndexOf(',') + 1);
|
||||||
prefix = args[1].substring(0, args[1].lastIndexOf(',') + 1);
|
} else {
|
||||||
} else {
|
prefix = "fade:";
|
||||||
prefix = "fade:";
|
}
|
||||||
}
|
for (DyeColor color : DyeColor.values()) {
|
||||||
for (DyeColor color : DyeColor.values()) {
|
options.add(prefix + color.name().toLowerCase() + ",");
|
||||||
options.add(prefix + color.name().toLowerCase() + ",");
|
}
|
||||||
}
|
return options;
|
||||||
return options;
|
} else {
|
||||||
} else {
|
return Collections.emptyList();
|
||||||
return Collections.emptyList();
|
}
|
||||||
}
|
} else if (args.length == 3 && args[0].startsWith("color:")) {
|
||||||
} else if (args.length == 3 && args[0].startsWith("color:")) {
|
return Lists.newArrayList("shape:star", "shape:ball", "shape:large", "shape:creeper", "shape:burst");
|
||||||
return Lists.newArrayList("shape:star", "shape:ball", "shape:large", "shape:creeper", "shape:burst");
|
} else if (args.length == 4 && args[0].startsWith("color:")) {
|
||||||
} else if (args.length == 4 && args[0].startsWith("color:")) {
|
return Lists.newArrayList("effect:trail", "effect:twinkle", "effect:trail,twinkle", "effect:twinkle,trail");
|
||||||
return Lists.newArrayList("effect:trail", "effect:twinkle", "effect:trail,twinkle", "effect:twinkle,trail");
|
} else {
|
||||||
} else {
|
return Collections.emptyList();
|
||||||
return Collections.emptyList();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -119,7 +119,7 @@ public class Commandgamemode extends EssentialsCommand {
|
|||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> STANDARD_OPTIONS = ImmutableList.of("creative", "survival", "adventure", "spectator", "toggle");
|
private final List<String> STANDARD_OPTIONS = ImmutableList.of("creative", "survival", "adventure", "spectator", "toggle");
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
|
@ -7,7 +7,6 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -1,20 +1,15 @@
|
|||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n.tl;
|
|
||||||
|
|
||||||
import com.earth2me.essentials.CommandSource;
|
|
||||||
import com.earth2me.essentials.I18n;
|
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import com.earth2me.essentials.utils.FormatUtil;
|
import com.earth2me.essentials.utils.FormatUtil;
|
||||||
|
|
||||||
import com.earth2me.essentials.utils.MaterialUtil;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
|
|
||||||
public class Commanditemname extends EssentialsCommand {
|
public class Commanditemname extends EssentialsCommand {
|
||||||
|
|
||||||
public Commanditemname() {
|
public Commanditemname() {
|
||||||
|
@ -4,8 +4,6 @@ import com.earth2me.essentials.CommandSource;
|
|||||||
import com.earth2me.essentials.utils.StringUtil;
|
import com.earth2me.essentials.utils.StringUtil;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n.tl;
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class Commandkit extends EssentialsCommand {
|
|||||||
}
|
}
|
||||||
String[] kitList = kitNames.split(",");
|
String[] kitList = kitNames.split(",");
|
||||||
|
|
||||||
List<Kit> kits = new ArrayList<Kit>();
|
List<Kit> kits = new ArrayList<>();
|
||||||
|
|
||||||
for (final String kitName : kitList) {
|
for (final String kitName : kitList) {
|
||||||
if (kitName.isEmpty()) {
|
if (kitName.isEmpty()) {
|
||||||
|
@ -27,7 +27,7 @@ public class Commandlightning extends EssentialsLoopCommand {
|
|||||||
if (sender.isPlayer()) {
|
if (sender.isPlayer()) {
|
||||||
User user = ess.getUser(sender.getPlayer());
|
User user = ess.getUser(sender.getPlayer());
|
||||||
if ((args.length < 1 || !user.isAuthorized("essentials.lightning.others"))) {
|
if ((args.length < 1 || !user.isAuthorized("essentials.lightning.others"))) {
|
||||||
user.getWorld().strikeLightning(user.getBase().getTargetBlock((Set<Material>) null, 600).getLocation());
|
user.getWorld().strikeLightning(user.getBase().getTargetBlock(null, 600).getLocation());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ public class Commandlightning extends EssentialsLoopCommand {
|
|||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
try {
|
try {
|
||||||
power = Integer.parseInt(args[1]);
|
power = Integer.parseInt(args[1]);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loopOnlinePlayers(server, sender, true, true, args[0], null);
|
loopOnlinePlayers(server, sender, true, true, args[0], null);
|
||||||
|
@ -57,14 +57,14 @@ public class Commandlist extends EssentialsCommand {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<User> outputUserList = new ArrayList<>();
|
List<User> outputUserList;
|
||||||
final List<User> matchedList = playerList.get(configGroup);
|
final List<User> matchedList = playerList.get(configGroup);
|
||||||
|
|
||||||
// If the group value is an int, then we might need to truncate it
|
// If the group value is an int, then we might need to truncate it
|
||||||
if (NumberUtil.isInt(groupValue)) {
|
if (NumberUtil.isInt(groupValue)) {
|
||||||
if (matchedList != null && !matchedList.isEmpty()) {
|
if (matchedList != null && !matchedList.isEmpty()) {
|
||||||
playerList.remove(configGroup);
|
playerList.remove(configGroup);
|
||||||
outputUserList.addAll(matchedList);
|
outputUserList = new ArrayList<>(matchedList);
|
||||||
int limit = Integer.parseInt(groupValue);
|
int limit = Integer.parseInt(groupValue);
|
||||||
if (matchedList.size() > limit) {
|
if (matchedList.size() > limit) {
|
||||||
sender.sendMessage(PlayerList.outputFormat(oConfigGroup, tl("groupNumber", matchedList.size(), commandLabel, FormatUtil.stripFormat(configGroup))));
|
sender.sendMessage(PlayerList.outputFormat(oConfigGroup, tl("groupNumber", matchedList.size(), commandLabel, FormatUtil.stripFormat(configGroup))));
|
||||||
@ -86,7 +86,7 @@ public class Commandlist extends EssentialsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Set<String> var = playerList.keySet();
|
Set<String> var = playerList.keySet();
|
||||||
String[] onlineGroups = var.toArray(new String[var.size()]);
|
String[] onlineGroups = var.toArray(new String[0]);
|
||||||
Arrays.sort(onlineGroups, String.CASE_INSENSITIVE_ORDER);
|
Arrays.sort(onlineGroups, String.CASE_INSENSITIVE_ORDER);
|
||||||
|
|
||||||
// If we have an asterisk group, then merge all remaining groups
|
// If we have an asterisk group, then merge all remaining groups
|
||||||
@ -98,7 +98,7 @@ public class Commandlist extends EssentialsCommand {
|
|||||||
for (String key : asterisk) {
|
for (String key : asterisk) {
|
||||||
playerList.put(key, asteriskUsers);
|
playerList.put(key, asteriskUsers);
|
||||||
}
|
}
|
||||||
onlineGroups = asterisk.toArray(new String[asterisk.size()]);
|
onlineGroups = asterisk.toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have any groups remaining after the custom groups loop through and display them
|
// If we have any groups remaining after the custom groups loop through and display them
|
||||||
|
@ -38,13 +38,13 @@ public class Commandnear extends EssentialsCommand {
|
|||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
try {
|
try {
|
||||||
otherUser = getPlayer(server, user, args, 0);
|
otherUser = getPlayer(server, user, args, 0);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.length > 1 && otherUser != null) {
|
if (args.length > 1 && otherUser != null) {
|
||||||
try {
|
try {
|
||||||
radius = Long.parseLong(args[1]);
|
radius = Long.parseLong(args[1]);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ public class Commandnear extends EssentialsCommand {
|
|||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
try {
|
try {
|
||||||
radius = Long.parseLong(args[1]);
|
radius = Long.parseLong(args[1]);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sender.sendMessage(tl("nearbyPlayers", getLocal(server, otherUser, radius)));
|
sender.sendMessage(tl("nearbyPlayers", getLocal(server, otherUser, radius)));
|
||||||
|
@ -50,7 +50,7 @@ public class Commandpay extends EssentialsLoopCommand {
|
|||||||
}
|
}
|
||||||
loopOnlinePlayers(server, user.getSource(), false, user.isAuthorized("essentials.pay.multiple"), args[0], args);
|
loopOnlinePlayers(server, user.getSource(), false, user.isAuthorized("essentials.pay.multiple"), args[0], args);
|
||||||
if (informToConfirm) {
|
if (informToConfirm) {
|
||||||
String cmd = "/" + commandLabel + " " + StringUtil.joinList(" ", (Object[]) args);
|
String cmd = "/" + commandLabel + " " + StringUtil.joinList(" ", args);
|
||||||
user.sendMessage(tl("confirmPayment", NumberUtil.displayCurrency(amount, ess), cmd));
|
user.sendMessage(tl("confirmPayment", NumberUtil.displayCurrency(amount, ess), cmd));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n.tl;
|
|
||||||
|
|
||||||
import com.earth2me.essentials.I18n;
|
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
|
||||||
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
|
|
||||||
public class Commandpaytoggle extends EssentialsCommand {
|
public class Commandpaytoggle extends EssentialsCommand {
|
||||||
|
|
||||||
public Commandpaytoggle() {
|
public Commandpaytoggle() {
|
||||||
|
@ -1,31 +1,22 @@
|
|||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.earth2me.essentials.MetaItemStack;
|
import com.earth2me.essentials.MetaItemStack;
|
||||||
import com.earth2me.essentials.Potions;
|
import com.earth2me.essentials.Potions;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import com.earth2me.essentials.utils.StringUtil;
|
import com.earth2me.essentials.utils.StringUtil;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import net.ess3.nms.refl.ReflUtil;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
import org.bukkit.potion.PotionData;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n.tl;
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
|
|
||||||
import net.ess3.nms.refl.ReflUtil;
|
|
||||||
|
|
||||||
|
|
||||||
public class Commandpotion extends EssentialsCommand {
|
public class Commandpotion extends EssentialsCommand {
|
||||||
public Commandpotion() {
|
public Commandpotion() {
|
||||||
|
@ -85,7 +85,7 @@ public class Commandpowertool extends EssentialsCommand {
|
|||||||
// Replace all commands with this one
|
// Replace all commands with this one
|
||||||
powertools.clear();
|
powertools.clear();
|
||||||
} else {
|
} else {
|
||||||
powertools = new ArrayList<String>();
|
powertools = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
powertools.add(command);
|
powertools.add(command);
|
||||||
@ -122,7 +122,7 @@ public class Commandpowertool extends EssentialsCommand {
|
|||||||
for (String tool : powertools) {
|
for (String tool : powertools) {
|
||||||
options.add("r:" + tool);
|
options.add("r:" + tool);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {}
|
} catch (Exception ignored) {}
|
||||||
return options;
|
return options;
|
||||||
} else if (args[0].startsWith("a:")) {
|
} else if (args[0].startsWith("a:")) {
|
||||||
return tabCompleteCommand(user.getSource(), server, args[0].substring(2), args, 1);
|
return tabCompleteCommand(user.getSource(), server, args[0].substring(2), args, 1);
|
||||||
@ -151,7 +151,7 @@ public class Commandpowertool extends EssentialsCommand {
|
|||||||
for (String tool : powertools) {
|
for (String tool : powertools) {
|
||||||
options.add("r:" + tool);
|
options.add("r:" + tool);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {}
|
} catch (Exception ignored) {}
|
||||||
return options;
|
return options;
|
||||||
} else if (args[2].startsWith("a:")) {
|
} else if (args[2].startsWith("a:")) {
|
||||||
return tabCompleteCommand(sender, server, args[2].substring(2), args, 3);
|
return tabCompleteCommand(sender, server, args[2].substring(2), args, 3);
|
||||||
|
@ -1,195 +1,192 @@
|
|||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import com.earth2me.essentials.CommandSource;
|
import com.earth2me.essentials.CommandSource;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import com.earth2me.essentials.utils.EnumUtil;
|
import com.earth2me.essentials.utils.EnumUtil;
|
||||||
import com.earth2me.essentials.utils.NumberUtil;
|
import com.earth2me.essentials.utils.NumberUtil;
|
||||||
import com.earth2me.essentials.utils.VersionUtil;
|
import com.earth2me.essentials.utils.VersionUtil;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.inventory.*;
|
import org.bukkit.inventory.*;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n.tl;
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
|
|
||||||
import net.ess3.nms.refl.ReflUtil;
|
public class Commandrecipe extends EssentialsCommand {
|
||||||
|
|
||||||
|
private static final Material FIREWORK_ROCKET = EnumUtil.getMaterial("FIREWORK_ROCKET", "FIREWORK");
|
||||||
public class Commandrecipe extends EssentialsCommand {
|
private static final Material FIREWORK_STAR = EnumUtil.getMaterial("FIREWORK_STAR", "FIREWORK_CHARGE");
|
||||||
|
private static final Material GUNPOWDER = EnumUtil.getMaterial("GUNPOWDER", "SULPHUR");
|
||||||
private static final Material FIREWORK_ROCKET = EnumUtil.getMaterial("FIREWORK_ROCKET", "FIREWORK");
|
|
||||||
private static final Material FIREWORK_STAR = EnumUtil.getMaterial("FIREWORK_STAR", "FIREWORK_CHARGE");
|
public Commandrecipe() {
|
||||||
private static final Material GUNPOWDER = EnumUtil.getMaterial("GUNPOWDER", "SULPHUR");
|
super("recipe");
|
||||||
|
}
|
||||||
public Commandrecipe() {
|
|
||||||
super("recipe");
|
private void disableCommandForVersion1_12() throws Exception {
|
||||||
}
|
VersionUtil.BukkitVersion version = VersionUtil.getServerBukkitVersion();
|
||||||
|
if (version.isHigherThanOrEqualTo(VersionUtil.v1_12_0_R01)
|
||||||
private void disableCommandForVersion1_12() throws Exception {
|
&& !ess.getSettings().isForceEnableRecipe()) {
|
||||||
VersionUtil.BukkitVersion version = VersionUtil.getServerBukkitVersion();
|
throw new Exception("Please use the recipe book in your inventory.");
|
||||||
if (version.isHigherThanOrEqualTo(VersionUtil.v1_12_0_R01)
|
}
|
||||||
&& !ess.getSettings().isForceEnableRecipe()) {
|
}
|
||||||
throw new Exception("Please use the recipe book in your inventory.");
|
|
||||||
}
|
@Override
|
||||||
}
|
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||||
|
disableCommandForVersion1_12();
|
||||||
@Override
|
if (args.length < 1) {
|
||||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
throw new NotEnoughArgumentsException();
|
||||||
disableCommandForVersion1_12();
|
}
|
||||||
if (args.length < 1) {
|
|
||||||
throw new NotEnoughArgumentsException();
|
final ItemStack itemType = ess.getItemDb().get(args[0]);
|
||||||
}
|
int recipeNo = 0;
|
||||||
|
|
||||||
final ItemStack itemType = ess.getItemDb().get(args[0]);
|
if (args.length > 1) {
|
||||||
int recipeNo = 0;
|
if (NumberUtil.isInt(args[1])) {
|
||||||
|
recipeNo = Integer.parseInt(args[1]) - 1;
|
||||||
if (args.length > 1) {
|
} else {
|
||||||
if (NumberUtil.isInt(args[1])) {
|
throw new Exception(tl("invalidNumber"));
|
||||||
recipeNo = Integer.parseInt(args[1]) - 1;
|
}
|
||||||
} else {
|
}
|
||||||
throw new Exception(tl("invalidNumber"));
|
|
||||||
}
|
final List<Recipe> recipesOfType = ess.getServer().getRecipesFor(itemType);
|
||||||
}
|
if (recipesOfType.size() < 1) {
|
||||||
|
throw new Exception(tl("recipeNone", getMaterialName(itemType)));
|
||||||
final List<Recipe> recipesOfType = ess.getServer().getRecipesFor(itemType);
|
}
|
||||||
if (recipesOfType.size() < 1) {
|
|
||||||
throw new Exception(tl("recipeNone", getMaterialName(itemType)));
|
if (recipeNo < 0 || recipeNo >= recipesOfType.size()) {
|
||||||
}
|
throw new Exception(tl("recipeBadIndex"));
|
||||||
|
}
|
||||||
if (recipeNo < 0 || recipeNo >= recipesOfType.size()) {
|
|
||||||
throw new Exception(tl("recipeBadIndex"));
|
final Recipe selectedRecipe = recipesOfType.get(recipeNo);
|
||||||
}
|
sender.sendMessage(tl("recipe", getMaterialName(itemType), recipeNo + 1, recipesOfType.size()));
|
||||||
|
|
||||||
final Recipe selectedRecipe = recipesOfType.get(recipeNo);
|
if (selectedRecipe instanceof FurnaceRecipe) {
|
||||||
sender.sendMessage(tl("recipe", getMaterialName(itemType), recipeNo + 1, recipesOfType.size()));
|
furnaceRecipe(sender, (FurnaceRecipe) selectedRecipe);
|
||||||
|
} else if (selectedRecipe instanceof ShapedRecipe) {
|
||||||
if (selectedRecipe instanceof FurnaceRecipe) {
|
shapedRecipe(sender, (ShapedRecipe) selectedRecipe, sender.isPlayer());
|
||||||
furnaceRecipe(sender, (FurnaceRecipe) selectedRecipe);
|
} else if (selectedRecipe instanceof ShapelessRecipe) {
|
||||||
} else if (selectedRecipe instanceof ShapedRecipe) {
|
if (recipesOfType.size() == 1 && (itemType.getType() == FIREWORK_ROCKET)) {
|
||||||
shapedRecipe(sender, (ShapedRecipe) selectedRecipe, sender.isPlayer());
|
ShapelessRecipe shapelessRecipe = new ShapelessRecipe(itemType);
|
||||||
} else if (selectedRecipe instanceof ShapelessRecipe) {
|
shapelessRecipe.addIngredient(GUNPOWDER);
|
||||||
if (recipesOfType.size() == 1 && (itemType.getType() == FIREWORK_ROCKET)) {
|
shapelessRecipe.addIngredient(Material.PAPER);
|
||||||
ShapelessRecipe shapelessRecipe = new ShapelessRecipe(itemType);
|
shapelessRecipe.addIngredient(FIREWORK_STAR);
|
||||||
shapelessRecipe.addIngredient(GUNPOWDER);
|
shapelessRecipe(sender, shapelessRecipe, sender.isPlayer());
|
||||||
shapelessRecipe.addIngredient(Material.PAPER);
|
} else {
|
||||||
shapelessRecipe.addIngredient(FIREWORK_STAR);
|
shapelessRecipe(sender, (ShapelessRecipe) selectedRecipe, sender.isPlayer());
|
||||||
shapelessRecipe(sender, shapelessRecipe, sender.isPlayer());
|
}
|
||||||
} else {
|
}
|
||||||
shapelessRecipe(sender, (ShapelessRecipe) selectedRecipe, sender.isPlayer());
|
|
||||||
}
|
if (recipesOfType.size() > 1 && args.length == 1) {
|
||||||
}
|
sender.sendMessage(tl("recipeMore", commandLabel, args[0], getMaterialName(itemType)));
|
||||||
|
}
|
||||||
if (recipesOfType.size() > 1 && args.length == 1) {
|
}
|
||||||
sender.sendMessage(tl("recipeMore", commandLabel, args[0], getMaterialName(itemType)));
|
|
||||||
}
|
public void furnaceRecipe(final CommandSource sender, final FurnaceRecipe recipe) {
|
||||||
}
|
sender.sendMessage(tl("recipeFurnace", getMaterialName(recipe.getInput())));
|
||||||
|
}
|
||||||
public void furnaceRecipe(final CommandSource sender, final FurnaceRecipe recipe) {
|
|
||||||
sender.sendMessage(tl("recipeFurnace", getMaterialName(recipe.getInput())));
|
public void shapedRecipe(final CommandSource sender, final ShapedRecipe recipe, final boolean showWindow) {
|
||||||
}
|
final Map<Character, ItemStack> recipeMap = recipe.getIngredientMap();
|
||||||
|
|
||||||
public void shapedRecipe(final CommandSource sender, final ShapedRecipe recipe, final boolean showWindow) {
|
if (showWindow) {
|
||||||
final Map<Character, ItemStack> recipeMap = recipe.getIngredientMap();
|
final User user = ess.getUser(sender.getPlayer());
|
||||||
|
user.getBase().closeInventory();
|
||||||
if (showWindow) {
|
user.setRecipeSee(true);
|
||||||
final User user = ess.getUser(sender.getPlayer());
|
final InventoryView view = user.getBase().openWorkbench(null, true);
|
||||||
user.getBase().closeInventory();
|
final String[] recipeShape = recipe.getShape();
|
||||||
user.setRecipeSee(true);
|
final Map<Character, ItemStack> ingredientMap = recipe.getIngredientMap();
|
||||||
final InventoryView view = user.getBase().openWorkbench(null, true);
|
for (int j = 0; j < recipeShape.length; j++) {
|
||||||
final String[] recipeShape = recipe.getShape();
|
for (int k = 0; k < recipeShape[j].length(); k++) {
|
||||||
final Map<Character, ItemStack> ingredientMap = recipe.getIngredientMap();
|
final ItemStack item = ingredientMap.get(recipeShape[j].toCharArray()[k]);
|
||||||
for (int j = 0; j < recipeShape.length; j++) {
|
if (item == null) {
|
||||||
for (int k = 0; k < recipeShape[j].length(); k++) {
|
continue;
|
||||||
final ItemStack item = ingredientMap.get(recipeShape[j].toCharArray()[k]);
|
}
|
||||||
if (item == null) {
|
if (item.getDurability() == Short.MAX_VALUE) {
|
||||||
continue;
|
item.setDurability((short) 0);
|
||||||
}
|
}
|
||||||
if (item.getDurability() == Short.MAX_VALUE) {
|
view.getTopInventory().setItem(j * 3 + k + 1, item);
|
||||||
item.setDurability((short) 0);
|
}
|
||||||
}
|
}
|
||||||
view.getTopInventory().setItem(j * 3 + k + 1, item);
|
} else {
|
||||||
}
|
final HashMap<Material, String> colorMap = new HashMap<>();
|
||||||
}
|
int i = 1;
|
||||||
} else {
|
for (Character c : "abcdefghi".toCharArray()) {
|
||||||
final HashMap<Material, String> colorMap = new HashMap<>();
|
ItemStack item = recipeMap.get(c);
|
||||||
int i = 1;
|
if (!colorMap.containsKey(item == null ? null : item.getType())) {
|
||||||
for (Character c : "abcdefghi".toCharArray()) {
|
colorMap.put(item == null ? null : item.getType(), String.valueOf(i++));
|
||||||
ItemStack item = recipeMap.get(c);
|
}
|
||||||
if (!colorMap.containsKey(item == null ? null : item.getType())) {
|
}
|
||||||
colorMap.put(item == null ? null : item.getType(), String.valueOf(i++));
|
final Material[][] materials = new Material[3][3];
|
||||||
}
|
for (int j = 0; j < recipe.getShape().length; j++) {
|
||||||
}
|
for (int k = 0; k < recipe.getShape()[j].length(); k++) {
|
||||||
final Material[][] materials = new Material[3][3];
|
ItemStack item = recipe.getIngredientMap().get(recipe.getShape()[j].toCharArray()[k]);
|
||||||
for (int j = 0; j < recipe.getShape().length; j++) {
|
materials[j][k] = item == null ? null : item.getType();
|
||||||
for (int k = 0; k < recipe.getShape()[j].length(); k++) {
|
}
|
||||||
ItemStack item = recipe.getIngredientMap().get(recipe.getShape()[j].toCharArray()[k]);
|
}
|
||||||
materials[j][k] = item == null ? null : item.getType();
|
sender.sendMessage(tl("recipeGrid", colorMap.get(materials[0][0]), colorMap.get(materials[0][1]), colorMap.get(materials[0][2])));
|
||||||
}
|
sender.sendMessage(tl("recipeGrid", colorMap.get(materials[1][0]), colorMap.get(materials[1][1]), colorMap.get(materials[1][2])));
|
||||||
}
|
sender.sendMessage(tl("recipeGrid", colorMap.get(materials[2][0]), colorMap.get(materials[2][1]), colorMap.get(materials[2][2])));
|
||||||
sender.sendMessage(tl("recipeGrid", colorMap.get(materials[0][0]), colorMap.get(materials[0][1]), colorMap.get(materials[0][2])));
|
|
||||||
sender.sendMessage(tl("recipeGrid", colorMap.get(materials[1][0]), colorMap.get(materials[1][1]), colorMap.get(materials[1][2])));
|
StringBuilder s = new StringBuilder();
|
||||||
sender.sendMessage(tl("recipeGrid", colorMap.get(materials[2][0]), colorMap.get(materials[2][1]), colorMap.get(materials[2][2])));
|
for (Material items : colorMap.keySet().toArray(new Material[0])) {
|
||||||
|
s.append(tl("recipeGridItem", colorMap.get(items), getMaterialName(items)));
|
||||||
StringBuilder s = new StringBuilder();
|
}
|
||||||
for (Material items : colorMap.keySet().toArray(new Material[colorMap.size()])) {
|
sender.sendMessage(tl("recipeWhere", s.toString()));
|
||||||
s.append(tl("recipeGridItem", colorMap.get(items), getMaterialName(items)));
|
}
|
||||||
}
|
}
|
||||||
sender.sendMessage(tl("recipeWhere", s.toString()));
|
|
||||||
}
|
public void shapelessRecipe(final CommandSource sender, final ShapelessRecipe recipe, final boolean showWindow) {
|
||||||
}
|
final List<ItemStack> ingredients = recipe.getIngredientList();
|
||||||
|
if (showWindow) {
|
||||||
public void shapelessRecipe(final CommandSource sender, final ShapelessRecipe recipe, final boolean showWindow) {
|
final User user = ess.getUser(sender.getPlayer());
|
||||||
final List<ItemStack> ingredients = recipe.getIngredientList();
|
user.setRecipeSee(true);
|
||||||
if (showWindow) {
|
final InventoryView view = user.getBase().openWorkbench(null, true);
|
||||||
final User user = ess.getUser(sender.getPlayer());
|
for (int i = 0; i < ingredients.size(); i++) {
|
||||||
user.setRecipeSee(true);
|
final ItemStack item = ingredients.get(i);
|
||||||
final InventoryView view = user.getBase().openWorkbench(null, true);
|
if (item.getDurability() == Short.MAX_VALUE) {
|
||||||
for (int i = 0; i < ingredients.size(); i++) {
|
item.setDurability((short) 0);
|
||||||
final ItemStack item = ingredients.get(i);
|
}
|
||||||
if (item.getDurability() == Short.MAX_VALUE) {
|
view.setItem(i + 1, item);
|
||||||
item.setDurability((short) 0);
|
}
|
||||||
}
|
|
||||||
view.setItem(i + 1, item);
|
} else {
|
||||||
}
|
StringBuilder s = new StringBuilder();
|
||||||
|
for (int i = 0; i < ingredients.size(); i++) {
|
||||||
} else {
|
s.append(getMaterialName(ingredients.get(i)));
|
||||||
StringBuilder s = new StringBuilder();
|
if (i != ingredients.size() - 1) {
|
||||||
for (int i = 0; i < ingredients.size(); i++) {
|
s.append(",");
|
||||||
s.append(getMaterialName(ingredients.get(i)));
|
}
|
||||||
if (i != ingredients.size() - 1) {
|
s.append(" ");
|
||||||
s.append(",");
|
}
|
||||||
}
|
sender.sendMessage(tl("recipeShapeless", s.toString()));
|
||||||
s.append(" ");
|
}
|
||||||
}
|
}
|
||||||
sender.sendMessage(tl("recipeShapeless", s.toString()));
|
|
||||||
}
|
public String getMaterialName(final ItemStack stack) {
|
||||||
}
|
if (stack == null) {
|
||||||
|
return tl("recipeNothing");
|
||||||
public String getMaterialName(final ItemStack stack) {
|
}
|
||||||
if (stack == null) {
|
return getMaterialName(stack.getType());
|
||||||
return tl("recipeNothing");
|
}
|
||||||
}
|
|
||||||
return getMaterialName(stack.getType());
|
public String getMaterialName(final Material type) {
|
||||||
}
|
if (type == null) {
|
||||||
|
return tl("recipeNothing");
|
||||||
public String getMaterialName(final Material type) {
|
}
|
||||||
if (type == null) {
|
return type.toString().replace("_", " ").toLowerCase(Locale.ENGLISH);
|
||||||
return tl("recipeNothing");
|
}
|
||||||
}
|
|
||||||
return type.toString().replace("_", " ").toLowerCase(Locale.ENGLISH);
|
@Override
|
||||||
}
|
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||||
|
if (args.length == 1) {
|
||||||
@Override
|
return getItems();
|
||||||
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
} else {
|
||||||
if (args.length == 1) {
|
return Collections.emptyList();
|
||||||
return getItems();
|
}
|
||||||
} else {
|
}
|
||||||
return Collections.emptyList();
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -199,31 +199,28 @@ public class Commandseen extends EssentialsCommand {
|
|||||||
|
|
||||||
sender.sendMessage(tl("runningPlayerMatch", ipAddress));
|
sender.sendMessage(tl("runningPlayerMatch", ipAddress));
|
||||||
|
|
||||||
ess.runTaskAsynchronously(new Runnable() {
|
ess.runTaskAsynchronously(() -> {
|
||||||
@Override
|
final List<String> matches = new ArrayList<>();
|
||||||
public void run() {
|
for (final UUID u : userMap.getAllUniqueUsers()) {
|
||||||
final List<String> matches = new ArrayList<>();
|
final User user = ess.getUserMap().getUser(u);
|
||||||
for (final UUID u : userMap.getAllUniqueUsers()) {
|
if (user == null) {
|
||||||
final User user = ess.getUserMap().getUser(u);
|
continue;
|
||||||
if (user == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String uIPAddress = user.getLastLoginAddress();
|
|
||||||
|
|
||||||
if (!uIPAddress.isEmpty() && uIPAddress.equalsIgnoreCase(ipAddress)) {
|
|
||||||
matches.add(user.getName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matches.size() > 0) {
|
final String uIPAddress = user.getLastLoginAddress();
|
||||||
sender.sendMessage(tl("matchingIPAddress"));
|
|
||||||
sender.sendMessage(StringUtil.joinList(matches));
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(tl("noMatchingPlayers"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!uIPAddress.isEmpty() && uIPAddress.equalsIgnoreCase(ipAddress)) {
|
||||||
|
matches.add(user.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (matches.size() > 0) {
|
||||||
|
sender.sendMessage(tl("matchingIPAddress"));
|
||||||
|
sender.sendMessage(StringUtil.joinList(matches));
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(tl("noMatchingPlayers"));
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -66,9 +66,7 @@ public class Commandsethome extends EssentialsCommand {
|
|||||||
if (usersHome.getHomes().size() >= limit) {
|
if (usersHome.getHomes().size() >= limit) {
|
||||||
throw new Exception(tl("maxHomes", ess.getSettings().getHomeLimit(user)));
|
throw new Exception(tl("maxHomes", ess.getSettings().getHomeLimit(user)));
|
||||||
}
|
}
|
||||||
if (limit == 1) {
|
return limit == 1;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public class Commandsetwarp extends EssentialsCommand {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
warpLoc = warps.getWarp(args[0]);
|
warpLoc = warps.getWarp(args[0]);
|
||||||
} catch (WarpNotFoundException | InvalidWorldException ex) {
|
} catch (WarpNotFoundException | InvalidWorldException ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (warpLoc == null || user.isAuthorized("essentials.warp.overwrite." + StringUtil.safeString(args[0]))) {
|
if (warpLoc == null || user.isAuthorized("essentials.warp.overwrite." + StringUtil.safeString(args[0]))) {
|
||||||
|
@ -88,10 +88,7 @@ public class Commandspeed extends EssentialsCommand {
|
|||||||
boolean canWalk = user.isAuthorized("essentials.speed.walk");
|
boolean canWalk = user.isAuthorized("essentials.speed.walk");
|
||||||
if (input && canFly || !input && canWalk || !canFly && !canWalk) {
|
if (input && canFly || !input && canWalk || !canFly && !canWalk) {
|
||||||
return input;
|
return input;
|
||||||
} else if (canWalk) {
|
} else return !canWalk;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isFlyMode(final String modeString) throws NotEnoughArgumentsException {
|
private boolean isFlyMode(final String modeString) throws NotEnoughArgumentsException {
|
||||||
|
@ -28,7 +28,7 @@ public class Commandsudo extends EssentialsLoopCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final String command = getFinalArg(arguments, 0);
|
final String command = getFinalArg(arguments, 0);
|
||||||
boolean multiple = !sender.isPlayer() ? true : ess.getUser(sender.getPlayer()).isAuthorized("essentials.sudo.multiple");
|
boolean multiple = !sender.isPlayer() || ess.getUser(sender.getPlayer()).isAuthorized("essentials.sudo.multiple");
|
||||||
|
|
||||||
sender.sendMessage(tl("sudoRun", args[0], command, ""));
|
sender.sendMessage(tl("sudoRun", args[0], command, ""));
|
||||||
loopOnlinePlayers(server, sender, multiple, multiple, args[0], new String[]{command});
|
loopOnlinePlayers(server, sender, multiple, multiple, args[0], new String[]{command});
|
||||||
|
@ -7,7 +7,6 @@ import com.earth2me.essentials.utils.DateUtil;
|
|||||||
import org.bukkit.BanList;
|
import org.bukkit.BanList;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -29,7 +29,7 @@ public class Commandtime extends EssentialsCommand {
|
|||||||
add = true;
|
add = true;
|
||||||
argList.set(0, argList.get(0) + "t");
|
argList.set(0, argList.get(0) + "t");
|
||||||
}
|
}
|
||||||
final String[] validArgs = argList.toArray(new String[argList.size()]);
|
final String[] validArgs = argList.toArray(new String[0]);
|
||||||
|
|
||||||
// Which World(s) are we interested in?
|
// Which World(s) are we interested in?
|
||||||
String worldSelector = null;
|
String worldSelector = null;
|
||||||
|
@ -4,10 +4,8 @@ import com.earth2me.essentials.CommandSource;
|
|||||||
import com.earth2me.essentials.Console;
|
import com.earth2me.essentials.Console;
|
||||||
import com.earth2me.essentials.Trade;
|
import com.earth2me.essentials.Trade;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -39,7 +39,7 @@ public class Commandtpaall extends EssentialsCommand {
|
|||||||
if (!player.isTeleportEnabled()) {
|
if (!player.isTeleportEnabled()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (sender.equals(target.getBase()) && target.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !target.isAuthorized("essentials.worlds." + target.getWorld().getName())) {
|
if (sender.getSender().equals(target.getBase()) && target.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !target.isAuthorized("essentials.worlds." + target.getWorld().getName())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n.tl;
|
|
||||||
|
|
||||||
import com.earth2me.essentials.I18n;
|
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
|
|
||||||
import net.ess3.api.IEssentials;
|
import net.ess3.api.IEssentials;
|
||||||
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
|
||||||
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
|
|
||||||
|
|
||||||
public class Commandtpacancel extends EssentialsCommand {
|
public class Commandtpacancel extends EssentialsCommand {
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public class Commandtpall extends EssentialsCommand {
|
|||||||
if (target == player) {
|
if (target == player) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (sender.equals(target.getBase()) && target.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !target.isAuthorized("essentials.worlds." + target.getWorld().getName())) {
|
if (sender.getSender().equals(target.getBase()) && target.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !target.isAuthorized("essentials.worlds." + target.getWorld().getName())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -6,7 +6,6 @@ import org.bukkit.Server;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand {
|
|||||||
if (options == null) {
|
if (options == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return StringUtil.copyPartialMatches(args[args.length - 1], options, Lists.<String>newArrayList());
|
return StringUtil.copyPartialMatches(args[args.length - 1], options, Lists.newArrayList());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Doesn't need to do any starts-with checks
|
// Doesn't need to do any starts-with checks
|
||||||
@ -203,7 +203,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand {
|
|||||||
if (options == null) {
|
if (options == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return StringUtil.copyPartialMatches(args[args.length - 1], options, Lists.<String>newArrayList());
|
return StringUtil.copyPartialMatches(args[args.length - 1], options, Lists.newArrayList());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Doesn't need to do any starts-with checks
|
// Doesn't need to do any starts-with checks
|
||||||
@ -333,9 +333,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand {
|
|||||||
int numArgs = args.length - index - 1;
|
int numArgs = args.length - index - 1;
|
||||||
ess.getLogger().info(numArgs + " " + index + " " + Arrays.toString(args));
|
ess.getLogger().info(numArgs + " " + index + " " + Arrays.toString(args));
|
||||||
String[] effectiveArgs = new String[numArgs];
|
String[] effectiveArgs = new String[numArgs];
|
||||||
for (int i = 0; i < numArgs; i++) {
|
System.arraycopy(args, index, effectiveArgs, 0, numArgs);
|
||||||
effectiveArgs[i] = args[i + index];
|
|
||||||
}
|
|
||||||
if (effectiveArgs.length == 0) {
|
if (effectiveArgs.length == 0) {
|
||||||
effectiveArgs = new String[] { "" };
|
effectiveArgs = new String[] { "" };
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ public abstract class EssentialsToggleCommand extends EssentialsCommand {
|
|||||||
foundUser = true;
|
foundUser = true;
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
Boolean toggle = matchToggleArgument(args[1]);
|
Boolean toggle = matchToggleArgument(args[1]);
|
||||||
if (toggle == true) {
|
if (toggle) {
|
||||||
togglePlayer(sender, player, true);
|
togglePlayer(sender, player, true);
|
||||||
} else {
|
} else {
|
||||||
togglePlayer(sender, player, false);
|
togglePlayer(sender, player, false);
|
||||||
|
@ -152,7 +152,7 @@ public final class InventoryWorkaround {
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// Do we already have a stack of it?
|
// Do we already have a stack of it?
|
||||||
final int maxAmount = oversizedStacks > item.getType().getMaxStackSize() ? oversizedStacks : item.getType().getMaxStackSize();
|
final int maxAmount = Math.max(oversizedStacks, item.getType().getMaxStackSize());
|
||||||
final int firstPartial = firstPartial(inventory, item, maxAmount);
|
final int firstPartial = firstPartial(inventory, item, maxAmount);
|
||||||
|
|
||||||
// Drat! no partial stack
|
// Drat! no partial stack
|
||||||
@ -259,7 +259,6 @@ public final class InventoryWorkaround {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public static void setItemInOffHand(Player p, ItemStack item) {
|
public static void setItemInOffHand(Player p, ItemStack item) {
|
||||||
// This assumes that all builds that support a main hand also support an off hand.
|
// This assumes that all builds that support a main hand also support an off hand.
|
||||||
if (hasMainHandSupport == null || hasMainHandSupport) {
|
if (hasMainHandSupport == null || hasMainHandSupport) {
|
||||||
|
@ -65,7 +65,7 @@ public class SetExpFix {
|
|||||||
//This method is required because the bukkit player.getTotalExperience() method, shows exp that has been 'spent'.
|
//This method is required because the bukkit player.getTotalExperience() method, shows exp that has been 'spent'.
|
||||||
//Without this people would be able to use exp and then still sell it.
|
//Without this people would be able to use exp and then still sell it.
|
||||||
public static int getTotalExperience(final Player player) {
|
public static int getTotalExperience(final Player player) {
|
||||||
int exp = (int) Math.round(getExpAtLevel(player) * player.getExp());
|
int exp = Math.round(getExpAtLevel(player) * player.getExp());
|
||||||
int currentLevel = player.getLevel();
|
int currentLevel = player.getLevel();
|
||||||
|
|
||||||
while (currentLevel > 0) {
|
while (currentLevel > 0) {
|
||||||
@ -79,7 +79,7 @@ public class SetExpFix {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int getExpUntilNextLevel(final Player player) {
|
public static int getExpUntilNextLevel(final Player player) {
|
||||||
int exp = (int) Math.round(getExpAtLevel(player) * player.getExp());
|
int exp = Math.round(getExpAtLevel(player) * player.getExp());
|
||||||
int nextLevel = player.getLevel();
|
int nextLevel = player.getLevel();
|
||||||
return getExpAtLevel(nextLevel) - exp;
|
return getExpAtLevel(nextLevel) - exp;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public abstract class AbstractItemDb implements IConf, net.ess3.api.IItemDb {
|
|||||||
protected final IEssentials ess;
|
protected final IEssentials ess;
|
||||||
protected boolean ready = false;
|
protected boolean ready = false;
|
||||||
|
|
||||||
private Map<PluginKey, ItemResolver> resolverMap = new HashMap<>();
|
private final Map<PluginKey, ItemResolver> resolverMap = new HashMap<>();
|
||||||
|
|
||||||
AbstractItemDb(IEssentials ess) {
|
AbstractItemDb(IEssentials ess) {
|
||||||
this.ess = ess;
|
this.ess = ess;
|
||||||
|
@ -25,7 +25,7 @@ import static com.earth2me.essentials.I18n.tl;
|
|||||||
|
|
||||||
public class FlatItemDb extends AbstractItemDb {
|
public class FlatItemDb extends AbstractItemDb {
|
||||||
protected static final Logger LOGGER = Logger.getLogger("Essentials");
|
protected static final Logger LOGGER = Logger.getLogger("Essentials");
|
||||||
private static Gson gson = new Gson();
|
private static final Gson gson = new Gson();
|
||||||
|
|
||||||
// Maps primary name to ItemData
|
// Maps primary name to ItemData
|
||||||
private final transient Map<String, ItemData> items = new HashMap<>();
|
private final transient Map<String, ItemData> items = new HashMap<>();
|
||||||
|
@ -111,7 +111,7 @@ public class LegacyItemDb extends AbstractItemDb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (List<String> nameList : names.values()) {
|
for (List<String> nameList : names.values()) {
|
||||||
Collections.sort(nameList, LengthCompare.INSTANCE);
|
nameList.sort(LengthCompare.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.info(String.format("Loaded %s items from items.csv.", listNames().size()));
|
LOGGER.info(String.format("Loaded %s items from items.csv.", listNames().size()));
|
||||||
@ -229,9 +229,6 @@ public class LegacyItemDb extends AbstractItemDb {
|
|||||||
if (name == null) {
|
if (name == null) {
|
||||||
itemData = new ItemData(item.getType().getId(), (short) 0);
|
itemData = new ItemData(item.getType().getId(), (short) 0);
|
||||||
name = primaryName.get(itemData);
|
name = primaryName.get(itemData);
|
||||||
if (name == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@ -255,7 +252,7 @@ public class LegacyItemDb extends AbstractItemDb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static class ItemData {
|
static class ItemData {
|
||||||
private int itemNo;
|
private final int itemNo;
|
||||||
final private short itemData;
|
final private short itemData;
|
||||||
|
|
||||||
ItemData(final int itemNo, final short itemData) {
|
ItemData(final int itemNo, final short itemData) {
|
||||||
|
@ -11,7 +11,7 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
public class PermissionsHandler implements IPermissionsHandler {
|
public class PermissionsHandler implements IPermissionsHandler {
|
||||||
private transient IPermissionsHandler handler = null;
|
private transient IPermissionsHandler handler = null;
|
||||||
private transient String defaultGroup = "default";
|
private final transient String defaultGroup = "default";
|
||||||
private final transient Essentials ess;
|
private final transient Essentials ess;
|
||||||
private transient boolean useSuperperms;
|
private transient boolean useSuperperms;
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ public class VaultEco implements Method {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class VaultAccount implements MethodAccount {
|
public static class VaultAccount implements MethodAccount {
|
||||||
private final String name;
|
private final String name;
|
||||||
private final Economy economy;
|
private final Economy economy;
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ public class VaultEco implements Method {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class VaultBankAccount implements MethodBankAccount {
|
public static class VaultBankAccount implements MethodBankAccount {
|
||||||
private final String bank;
|
private final String bank;
|
||||||
private final Economy economy;
|
private final Economy economy;
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ import static com.earth2me.essentials.I18n.tl;
|
|||||||
|
|
||||||
|
|
||||||
public class EssentialsSign {
|
public class EssentialsSign {
|
||||||
private static final Set<Material> EMPTY_SET = new HashSet<Material>();
|
private static final Set<Material> EMPTY_SET = new HashSet<>();
|
||||||
protected static final BigDecimal MINTRANSACTION = new BigDecimal("0.01");
|
protected static final BigDecimal MINTRANSACTION = new BigDecimal("0.01");
|
||||||
protected transient final String signName;
|
protected transient final String signName;
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ public class EssentialsSign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getUsername(final User user) {
|
public String getUsername(final User user) {
|
||||||
return user.getName().substring(0, user.getName().length() > 13 ? 13 : user.getName().length());
|
return user.getName().substring(0, Math.min(user.getName().length(), 13));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final boolean onSignInteract(final Block block, final Player player, final IEssentials ess) {
|
protected final boolean onSignInteract(final Block block, final Player player, final IEssentials ess) {
|
||||||
@ -333,9 +333,7 @@ public class EssentialsSign {
|
|||||||
|
|
||||||
protected final int getInteger(final String line) throws SignException {
|
protected final int getInteger(final String line) throws SignException {
|
||||||
try {
|
try {
|
||||||
final int quantity = Integer.parseInt(line);
|
return Integer.parseInt(line);
|
||||||
|
|
||||||
return quantity;
|
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
throw new SignException("Invalid sign", ex);
|
throw new SignException("Invalid sign", ex);
|
||||||
}
|
}
|
||||||
@ -393,9 +391,7 @@ public class EssentialsSign {
|
|||||||
protected final BigDecimal getBigDecimal(final String line) throws SignException {
|
protected final BigDecimal getBigDecimal(final String line) throws SignException {
|
||||||
try {
|
try {
|
||||||
return new BigDecimal(line);
|
return new BigDecimal(line);
|
||||||
} catch (ArithmeticException ex) {
|
} catch (ArithmeticException | NumberFormatException ex) {
|
||||||
throw new SignException(ex.getMessage(), ex);
|
|
||||||
} catch (NumberFormatException ex) {
|
|
||||||
throw new SignException(ex.getMessage(), ex);
|
throw new SignException(ex.getMessage(), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package com.earth2me.essentials.signs;
|
|||||||
|
|
||||||
import com.earth2me.essentials.I18n;
|
import com.earth2me.essentials.I18n;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import com.earth2me.essentials.utils.EnumUtil;
|
|
||||||
import com.earth2me.essentials.utils.FormatUtil;
|
import com.earth2me.essentials.utils.FormatUtil;
|
||||||
import com.earth2me.essentials.utils.MaterialUtil;
|
import com.earth2me.essentials.utils.MaterialUtil;
|
||||||
import net.ess3.api.IEssentials;
|
import net.ess3.api.IEssentials;
|
||||||
|
@ -5,7 +5,6 @@ import com.earth2me.essentials.Trade;
|
|||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import net.ess3.api.IEssentials;
|
import net.ess3.api.IEssentials;
|
||||||
import net.ess3.api.MaxMoneyException;
|
import net.ess3.api.MaxMoneyException;
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@ -39,6 +38,7 @@ public class SignBuy extends EssentialsSign {
|
|||||||
items = new Trade(item, ess);
|
items = new Trade(item, ess);
|
||||||
|
|
||||||
BigDecimal chargeAmount = charge.getMoney();
|
BigDecimal chargeAmount = charge.getMoney();
|
||||||
|
//noinspection BigDecimalMethodWithoutRoundingCalled
|
||||||
BigDecimal pricePerSingleItem = chargeAmount.divide(new BigDecimal(initialItemAmount));
|
BigDecimal pricePerSingleItem = chargeAmount.divide(new BigDecimal(initialItemAmount));
|
||||||
pricePerSingleItem = pricePerSingleItem.multiply(new BigDecimal(newItemAmount));
|
pricePerSingleItem = pricePerSingleItem.multiply(new BigDecimal(newItemAmount));
|
||||||
charge = new Trade(pricePerSingleItem, ess);
|
charge = new Trade(pricePerSingleItem, ess);
|
||||||
|
@ -92,15 +92,14 @@ public class SignEnchant extends EssentialsSign {
|
|||||||
throw new SignException(tl("missingItems", 1, search.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ')));
|
throw new SignException(tl("missingItems", 1, search.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ')));
|
||||||
}
|
}
|
||||||
|
|
||||||
final ItemStack toEnchant = playerHand;
|
|
||||||
try {
|
try {
|
||||||
if (level == 0) {
|
if (level == 0) {
|
||||||
toEnchant.removeEnchantment(enchantment);
|
playerHand.removeEnchantment(enchantment);
|
||||||
} else {
|
} else {
|
||||||
if (ess.getSettings().allowUnsafeEnchantments() && player.isAuthorized("essentials.signs.enchant.allowunsafe")) {
|
if (ess.getSettings().allowUnsafeEnchantments() && player.isAuthorized("essentials.signs.enchant.allowunsafe")) {
|
||||||
toEnchant.addUnsafeEnchantment(enchantment, level);
|
playerHand.addUnsafeEnchantment(enchantment, level);
|
||||||
} else {
|
} else {
|
||||||
toEnchant.addEnchantment(enchantment, level);
|
playerHand.addEnchantment(enchantment, level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package com.earth2me.essentials.signs;
|
package com.earth2me.essentials.signs;
|
||||||
|
|
||||||
import com.earth2me.essentials.utils.EnumUtil;
|
|
||||||
import com.earth2me.essentials.utils.MaterialUtil;
|
import com.earth2me.essentials.utils.MaterialUtil;
|
||||||
import net.ess3.api.IEssentials;
|
import net.ess3.api.IEssentials;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
@ -11,7 +11,6 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@ -40,7 +39,7 @@ public class SignPlayerListener implements Listener {
|
|||||||
if (event.isCancelled() && event.getAction() == Action.RIGHT_CLICK_AIR) {
|
if (event.isCancelled() && event.getAction() == Action.RIGHT_CLICK_AIR) {
|
||||||
Block targetBlock = null;
|
Block targetBlock = null;
|
||||||
try {
|
try {
|
||||||
targetBlock = event.getPlayer().getTargetBlock((Set<Material>) null, 5);
|
targetBlock = event.getPlayer().getTargetBlock(null, 5);
|
||||||
} catch (IllegalStateException ex) {
|
} catch (IllegalStateException ex) {
|
||||||
if (ess.getSettings().isDebug()) {
|
if (ess.getSettings().isDebug()) {
|
||||||
ess.getLogger().log(Level.WARNING, ex.getMessage(), ex);
|
ess.getLogger().log(Level.WARNING, ex.getMessage(), ex);
|
||||||
|
@ -83,7 +83,7 @@ public class SignProtection extends EssentialsSign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Map<Location, SignProtectionState> getConnectedSigns(final Block block, final User user, final String username, boolean secure) {
|
private Map<Location, SignProtectionState> getConnectedSigns(final Block block, final User user, final String username, boolean secure) {
|
||||||
final Map<Location, SignProtectionState> signs = new HashMap<Location, SignProtectionState>();
|
final Map<Location, SignProtectionState> signs = new HashMap<>();
|
||||||
getConnectedSigns(block, signs, user, username, secure ? 4 : 2);
|
getConnectedSigns(block, signs, user, username, secure ? 4 : 2);
|
||||||
return signs;
|
return signs;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import com.earth2me.essentials.Trade.OverflowType;
|
|||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import net.ess3.api.IEssentials;
|
import net.ess3.api.IEssentials;
|
||||||
import net.ess3.api.MaxMoneyException;
|
import net.ess3.api.MaxMoneyException;
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@ -40,6 +39,7 @@ public class SignSell extends EssentialsSign {
|
|||||||
charge = new Trade(item, ess);
|
charge = new Trade(item, ess);
|
||||||
|
|
||||||
BigDecimal chargeAmount = money.getMoney();
|
BigDecimal chargeAmount = money.getMoney();
|
||||||
|
//noinspection BigDecimalMethodWithoutRoundingCalled
|
||||||
BigDecimal pricePerSingleItem = chargeAmount.divide(new BigDecimal(initialItemAmount));
|
BigDecimal pricePerSingleItem = chargeAmount.divide(new BigDecimal(initialItemAmount));
|
||||||
pricePerSingleItem = pricePerSingleItem.multiply(new BigDecimal(newItemAmount));
|
pricePerSingleItem = pricePerSingleItem.multiply(new BigDecimal(newItemAmount));
|
||||||
money = new Trade(pricePerSingleItem, ess);
|
money = new Trade(pricePerSingleItem, ess);
|
||||||
|
@ -101,8 +101,8 @@ public class SignTrade extends EssentialsSign {
|
|||||||
final String signOwner = sign.getLine(3);
|
final String signOwner = sign.getLine(3);
|
||||||
|
|
||||||
final boolean isOwner = (signOwner.length() > 3 && signOwner.substring(2).equalsIgnoreCase(username));
|
final boolean isOwner = (signOwner.length() > 3 && signOwner.substring(2).equalsIgnoreCase(username));
|
||||||
final boolean canBreak = isOwner ? true : player.isAuthorized("essentials.signs.trade.override");
|
final boolean canBreak = isOwner || player.isAuthorized("essentials.signs.trade.override");
|
||||||
final boolean canCollect = isOwner ? true : player.isAuthorized("essentials.signs.trade.override.collect");
|
final boolean canCollect = isOwner || player.isAuthorized("essentials.signs.trade.override.collect");
|
||||||
|
|
||||||
if (canBreak) {
|
if (canBreak) {
|
||||||
try {
|
try {
|
||||||
@ -267,7 +267,7 @@ public class SignTrade extends EssentialsSign {
|
|||||||
}
|
}
|
||||||
final Integer exp = trade.getExperience();
|
final Integer exp = trade.getExperience();
|
||||||
if (exp != null) {
|
if (exp != null) {
|
||||||
changeAmount(sign, index, BigDecimal.valueOf(-exp.intValue()), ess);
|
changeAmount(sign, index, BigDecimal.valueOf(-exp), ess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,7 +282,7 @@ public class SignTrade extends EssentialsSign {
|
|||||||
}
|
}
|
||||||
final Integer exp = trade.getExperience();
|
final Integer exp = trade.getExperience();
|
||||||
if (exp != null) {
|
if (exp != null) {
|
||||||
changeAmount(sign, index, BigDecimal.valueOf(exp.intValue()), ess);
|
changeAmount(sign, index, BigDecimal.valueOf(exp), ess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,9 +21,7 @@ public abstract class AsyncStorageObjectHolder<T extends StorageObject> implemen
|
|||||||
this.clazz = clazz;
|
this.clazz = clazz;
|
||||||
try {
|
try {
|
||||||
this.data = clazz.newInstance();
|
this.data = clazz.newInstance();
|
||||||
} catch (IllegalAccessException ex) {
|
} catch (IllegalAccessException | InstantiationException ex) {
|
||||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
|
||||||
} catch (InstantiationException ex) {
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,9 +121,7 @@ public abstract class AsyncStorageObjectHolder<T extends StorageObject> implemen
|
|||||||
if (data == null) {
|
if (data == null) {
|
||||||
try {
|
try {
|
||||||
data = clazz.newInstance();
|
data = clazz.newInstance();
|
||||||
} catch (IllegalAccessException ex) {
|
} catch (IllegalAccessException | InstantiationException ex) {
|
||||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
|
||||||
} catch (InstantiationException ex) {
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import com.earth2me.essentials.utils.NumberUtil;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -18,15 +17,11 @@ import org.yaml.snakeyaml.nodes.*;
|
|||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
|
|
||||||
public class BukkitConstructor extends CustomClassLoaderConstructor {
|
public class BukkitConstructor extends CustomClassLoaderConstructor {
|
||||||
private final transient Plugin plugin;
|
public BukkitConstructor(final Class<?> clazz, final Plugin plugin) {
|
||||||
|
|
||||||
public BukkitConstructor(final Class clazz, final Plugin plugin) {
|
|
||||||
super(clazz, plugin.getClass().getClassLoader());
|
super(clazz, plugin.getClass().getClassLoader());
|
||||||
this.plugin = plugin;
|
|
||||||
yamlClassConstructors.put(NodeId.scalar, new ConstructBukkitScalar());
|
yamlClassConstructors.put(NodeId.scalar, new ConstructBukkitScalar());
|
||||||
yamlClassConstructors.put(NodeId.mapping, new ConstructBukkitMapping());
|
yamlClassConstructors.put(NodeId.mapping, new ConstructBukkitMapping());
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public class EnchantmentLevel implements Entry<Enchantment, Integer> {
|
|||||||
if (entry.getKey() instanceof Enchantment && entry.getValue() instanceof Integer) {
|
if (entry.getKey() instanceof Enchantment && entry.getValue() instanceof Integer) {
|
||||||
final Enchantment enchant = (Enchantment) entry.getKey();
|
final Enchantment enchant = (Enchantment) entry.getKey();
|
||||||
final Integer lvl = (Integer) entry.getValue();
|
final Integer lvl = (Integer) entry.getValue();
|
||||||
return this.enchantment.equals(enchant) && this.level == lvl.intValue();
|
return this.enchantment.equals(enchant) && this.level == lvl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -12,8 +12,8 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
|
|
||||||
|
|
||||||
public class YamlStorageReader implements IStorageReader {
|
public class YamlStorageReader implements IStorageReader {
|
||||||
private transient static final Map<Class, Yaml> PREPARED_YAMLS = Collections.synchronizedMap(new HashMap<Class, Yaml>());
|
private transient static final Map<Class, Yaml> PREPARED_YAMLS = Collections.synchronizedMap(new HashMap<>());
|
||||||
private transient static final Map<Class, ReentrantLock> LOCKS = new HashMap<Class, ReentrantLock>();
|
private transient static final Map<Class, ReentrantLock> LOCKS = new HashMap<>();
|
||||||
private transient final Reader reader;
|
private transient final Reader reader;
|
||||||
private transient final Plugin plugin;
|
private transient final Plugin plugin;
|
||||||
|
|
||||||
@ -38,14 +38,12 @@ public class YamlStorageReader implements IStorageReader {
|
|||||||
}
|
}
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
T object = (T) yaml.load(reader);
|
T object = yaml.load(reader);
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
object = clazz.newInstance();
|
object = clazz.newInstance();
|
||||||
}
|
}
|
||||||
return object;
|
return object;
|
||||||
} catch (IllegalAccessException ex) {
|
} catch (IllegalAccessException | InstantiationException ex) {
|
||||||
throw new ObjectLoadException(ex);
|
|
||||||
} catch (InstantiationException ex) {
|
|
||||||
throw new ObjectLoadException(ex);
|
throw new ObjectLoadException(ex);
|
||||||
} finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
@ -54,7 +52,7 @@ public class YamlStorageReader implements IStorageReader {
|
|||||||
|
|
||||||
private Constructor prepareConstructor(final Class<?> clazz) {
|
private Constructor prepareConstructor(final Class<?> clazz) {
|
||||||
final Constructor constructor = new BukkitConstructor(clazz, plugin);
|
final Constructor constructor = new BukkitConstructor(clazz, plugin);
|
||||||
final Set<Class> classes = new HashSet<Class>();
|
final Set<Class> classes = new HashSet<>();
|
||||||
|
|
||||||
prepareConstructor(constructor, classes, clazz);
|
prepareConstructor(constructor, classes, clazz);
|
||||||
return constructor;
|
return constructor;
|
||||||
|
@ -33,9 +33,7 @@ public class YamlStorageWriter implements IStorageWriter {
|
|||||||
public void save(final StorageObject object) {
|
public void save(final StorageObject object) {
|
||||||
try {
|
try {
|
||||||
writeToFile(object, 0, object.getClass());
|
writeToFile(object, 0, object.getClass());
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException | IllegalAccessException ex) {
|
||||||
Logger.getLogger(YamlStorageWriter.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
Logger.getLogger(YamlStorageWriter.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(YamlStorageWriter.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,12 @@ import net.ess3.api.IEssentials;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.ref.SoftReference;
|
import java.lang.ref.SoftReference;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
public class BookInput implements IText {
|
public class BookInput implements IText {
|
||||||
private final static HashMap<String, SoftReference<BookInput>> cache = new HashMap<String, SoftReference<BookInput>>();
|
private final static HashMap<String, SoftReference<BookInput>> cache = new HashMap<>();
|
||||||
private final transient List<String> lines;
|
private final transient List<String> lines;
|
||||||
private final transient List<String> chapters;
|
private final transient List<String> chapters;
|
||||||
private final transient Map<String, Integer> bookmarks;
|
private final transient Map<String, Integer> bookmarks;
|
||||||
@ -22,18 +23,13 @@ public class BookInput implements IText {
|
|||||||
}
|
}
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
if (createFile) {
|
if (createFile) {
|
||||||
final InputStream input = ess.getResource(filename + ".txt");
|
try (InputStream input = ess.getResource(filename + ".txt"); OutputStream output = new FileOutputStream(file)) {
|
||||||
final OutputStream output = new FileOutputStream(file);
|
|
||||||
try {
|
|
||||||
final byte[] buffer = new byte[1024];
|
final byte[] buffer = new byte[1024];
|
||||||
int length = input.read(buffer);
|
int length = input.read(buffer);
|
||||||
while (length > 0) {
|
while (length > 0) {
|
||||||
output.write(buffer, 0, length);
|
output.write(buffer, 0, length);
|
||||||
length = input.read(buffer);
|
length = input.read(buffer);
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
output.close();
|
|
||||||
input.close();
|
|
||||||
}
|
}
|
||||||
ess.getLogger().info("File " + filename + ".txt does not exist. Creating one for you.");
|
ess.getLogger().info("File " + filename + ".txt does not exist. Creating one for you.");
|
||||||
}
|
}
|
||||||
@ -51,10 +47,10 @@ public class BookInput implements IText {
|
|||||||
final SoftReference<BookInput> inputRef = cache.get(file.getName());
|
final SoftReference<BookInput> inputRef = cache.get(file.getName());
|
||||||
BookInput input;
|
BookInput input;
|
||||||
if (inputRef == null || (input = inputRef.get()) == null || input.lastChange < lastChange) {
|
if (inputRef == null || (input = inputRef.get()) == null || input.lastChange < lastChange) {
|
||||||
lines = new ArrayList<String>();
|
lines = new ArrayList<>();
|
||||||
chapters = new ArrayList<String>();
|
chapters = new ArrayList<>();
|
||||||
bookmarks = new HashMap<String, Integer>();
|
bookmarks = new HashMap<>();
|
||||||
cache.put(file.getName(), new SoftReference<BookInput>(this));
|
cache.put(file.getName(), new SoftReference<>(this));
|
||||||
readFromfile = true;
|
readFromfile = true;
|
||||||
} else {
|
} else {
|
||||||
lines = Collections.unmodifiableList(input.getLines());
|
lines = Collections.unmodifiableList(input.getLines());
|
||||||
@ -64,7 +60,7 @@ public class BookInput implements IText {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (readFromfile) {
|
if (readFromfile) {
|
||||||
final Reader reader = new InputStreamReader(new FileInputStream(file), "utf-8");
|
final Reader reader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
|
||||||
final BufferedReader bufferedReader = new BufferedReader(reader);
|
final BufferedReader bufferedReader = new BufferedReader(reader);
|
||||||
try {
|
try {
|
||||||
int lineNumber = 0;
|
int lineNumber = 0;
|
||||||
|
@ -20,8 +20,7 @@ public class BookPager {
|
|||||||
|
|
||||||
public List<String> getPages(final String pageStr) throws Exception {
|
public List<String> getPages(final String pageStr) throws Exception {
|
||||||
List<String> lines = text.getLines();
|
List<String> lines = text.getLines();
|
||||||
List<String> chapters = text.getChapters();
|
List<String> pageLines = new ArrayList<>();
|
||||||
List<String> pageLines = new ArrayList<String>();
|
|
||||||
Map<String, Integer> bookmarks = text.getBookmarks();
|
Map<String, Integer> bookmarks = text.getBookmarks();
|
||||||
|
|
||||||
//This checks to see if we have the chapter in the index
|
//This checks to see if we have the chapter in the index
|
||||||
@ -39,7 +38,7 @@ public class BookPager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> pages = new ArrayList<String>();
|
List<String> pages = new ArrayList<>();
|
||||||
double pageLength = 0;
|
double pageLength = 0;
|
||||||
|
|
||||||
for (int lineNo = chapterstart; lineNo < chapterend; lineNo += 1) {
|
for (int lineNo = chapterstart; lineNo < chapterend; lineNo += 1) {
|
||||||
@ -54,7 +53,7 @@ public class BookPager {
|
|||||||
boolean forcePageEnd = false;
|
boolean forcePageEnd = false;
|
||||||
|
|
||||||
while (pointer < lineLength) {
|
while (pointer < lineLength) {
|
||||||
Character letter = pageLine.charAt(pointer);
|
char letter = pageLine.charAt(pointer);
|
||||||
|
|
||||||
if (pageLine.charAt(start) == ' ') {
|
if (pageLine.charAt(start) == ' ') {
|
||||||
start++;
|
start++;
|
||||||
@ -95,7 +94,7 @@ public class BookPager {
|
|||||||
pageLength++;
|
pageLength++;
|
||||||
|
|
||||||
if (letter == '\u00a7' && pointer + 1 < lineLength) {
|
if (letter == '\u00a7' && pointer + 1 < lineLength) {
|
||||||
Character nextLetter = pageLine.charAt(pointer + 1);
|
char nextLetter = pageLine.charAt(pointer + 1);
|
||||||
if (nextLetter == 'l' || nextLetter == 'L') {
|
if (nextLetter == 'l' || nextLetter == 'L') {
|
||||||
weight = 1.25;
|
weight = 1.25;
|
||||||
} else {
|
} else {
|
||||||
|
@ -18,13 +18,13 @@ public class HelpInput implements IText {
|
|||||||
private static final String PERMISSION = "permission";
|
private static final String PERMISSION = "permission";
|
||||||
private static final String PERMISSIONS = "permissions";
|
private static final String PERMISSIONS = "permissions";
|
||||||
private static final Logger logger = Logger.getLogger("Essentials");
|
private static final Logger logger = Logger.getLogger("Essentials");
|
||||||
private final transient List<String> lines = new ArrayList<String>();
|
private final transient List<String> lines = new ArrayList<>();
|
||||||
private final transient List<String> chapters = new ArrayList<String>();
|
private final transient List<String> chapters = new ArrayList<>();
|
||||||
private final transient Map<String, Integer> bookmarks = new HashMap<String, Integer>();
|
private final transient Map<String, Integer> bookmarks = new HashMap<>();
|
||||||
|
|
||||||
public HelpInput(final User user, final String match, final IEssentials ess) throws IOException {
|
public HelpInput(final User user, final String match, final IEssentials ess) throws IOException {
|
||||||
boolean reported = false;
|
boolean reported = false;
|
||||||
final List<String> newLines = new ArrayList<String>();
|
final List<String> newLines = new ArrayList<>();
|
||||||
String pluginName = "";
|
String pluginName = "";
|
||||||
String pluginNameLow = "";
|
String pluginNameLow = "";
|
||||||
if (!match.equalsIgnoreCase("")) {
|
if (!match.equalsIgnoreCase("")) {
|
||||||
@ -33,7 +33,7 @@ public class HelpInput implements IText {
|
|||||||
|
|
||||||
for (Plugin p : ess.getServer().getPluginManager().getPlugins()) {
|
for (Plugin p : ess.getServer().getPluginManager().getPlugins()) {
|
||||||
try {
|
try {
|
||||||
final List<String> pluginLines = new ArrayList<String>();
|
final List<String> pluginLines = new ArrayList<>();
|
||||||
final PluginDescriptionFile desc = p.getDescription();
|
final PluginDescriptionFile desc = p.getDescription();
|
||||||
final Map<String, Map<String, Object>> cmds = desc.getCommands();
|
final Map<String, Map<String, Object>> cmds = desc.getCommands();
|
||||||
pluginName = p.getDescription().getName();
|
pluginName = p.getDescription().getName();
|
||||||
@ -89,7 +89,7 @@ public class HelpInput implements IText {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (NullPointerException ex) {
|
} catch (NullPointerException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!pluginLines.isEmpty()) {
|
if (!pluginLines.isEmpty()) {
|
||||||
@ -101,7 +101,7 @@ public class HelpInput implements IText {
|
|||||||
lines.add(tl("helpPlugin", pluginName, pluginNameLow));
|
lines.add(tl("helpPlugin", pluginName, pluginNameLow));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (NullPointerException ex) {
|
} catch (NullPointerException ignored) {
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (!reported) {
|
if (!reported) {
|
||||||
logger.log(Level.WARNING, tl("commandHelpFailedForPlugin", pluginNameLow), ex);
|
logger.log(Level.WARNING, tl("commandHelpFailedForPlugin", pluginNameLow), ex);
|
||||||
|
@ -33,11 +33,11 @@ public class KeywordReplacer implements IText {
|
|||||||
private final transient boolean includePrivate;
|
private final transient boolean includePrivate;
|
||||||
private transient ExecuteTimer execTimer;
|
private transient ExecuteTimer execTimer;
|
||||||
private final transient boolean replaceSpacesWithUnderscores;
|
private final transient boolean replaceSpacesWithUnderscores;
|
||||||
private final EnumMap<KeywordType, Object> keywordCache = new EnumMap<KeywordType, Object>(KeywordType.class);
|
private final EnumMap<KeywordType, Object> keywordCache = new EnumMap<>(KeywordType.class);
|
||||||
|
|
||||||
public KeywordReplacer(final IText input, final CommandSource sender, final IEssentials ess) {
|
public KeywordReplacer(final IText input, final CommandSource sender, final IEssentials ess) {
|
||||||
this.input = input;
|
this.input = input;
|
||||||
this.replaced = new ArrayList<String>(this.input.getLines().size());
|
this.replaced = new ArrayList<>(this.input.getLines().size());
|
||||||
this.ess = ess;
|
this.ess = ess;
|
||||||
this.includePrivate = true;
|
this.includePrivate = true;
|
||||||
this.replaceSpacesWithUnderscores = false;
|
this.replaceSpacesWithUnderscores = false;
|
||||||
@ -46,7 +46,7 @@ public class KeywordReplacer implements IText {
|
|||||||
|
|
||||||
public KeywordReplacer(final IText input, final CommandSource sender, final IEssentials ess, final boolean showPrivate) {
|
public KeywordReplacer(final IText input, final CommandSource sender, final IEssentials ess, final boolean showPrivate) {
|
||||||
this.input = input;
|
this.input = input;
|
||||||
this.replaced = new ArrayList<String>(this.input.getLines().size());
|
this.replaced = new ArrayList<>(this.input.getLines().size());
|
||||||
this.ess = ess;
|
this.ess = ess;
|
||||||
this.includePrivate = showPrivate;
|
this.includePrivate = showPrivate;
|
||||||
this.replaceSpacesWithUnderscores = false;
|
this.replaceSpacesWithUnderscores = false;
|
||||||
@ -56,7 +56,7 @@ public class KeywordReplacer implements IText {
|
|||||||
public KeywordReplacer(final IText input, final CommandSource sender, final IEssentials ess, final boolean showPrivate,
|
public KeywordReplacer(final IText input, final CommandSource sender, final IEssentials ess, final boolean showPrivate,
|
||||||
boolean replaceSpacesWithUnderscores) {
|
boolean replaceSpacesWithUnderscores) {
|
||||||
this.input = input;
|
this.input = input;
|
||||||
this.replaced = new ArrayList<String>(this.input.getLines().size());
|
this.replaced = new ArrayList<>(this.input.getLines().size());
|
||||||
this.ess = ess;
|
this.ess = ess;
|
||||||
this.includePrivate = showPrivate;
|
this.includePrivate = showPrivate;
|
||||||
this.replaceSpacesWithUnderscores = replaceSpacesWithUnderscores;
|
this.replaceSpacesWithUnderscores = replaceSpacesWithUnderscores;
|
||||||
@ -184,7 +184,7 @@ public class KeywordReplacer implements IText {
|
|||||||
|
|
||||||
//First lets build the per group playerlist
|
//First lets build the per group playerlist
|
||||||
final Map<String, List<User>> playerList = PlayerList.getPlayerLists(ess, user, showHidden);
|
final Map<String, List<User>> playerList = PlayerList.getPlayerLists(ess, user, showHidden);
|
||||||
outputList = new HashMap<String, String>();
|
outputList = new HashMap<>();
|
||||||
for (String groupName : playerList.keySet()) {
|
for (String groupName : playerList.keySet()) {
|
||||||
final List<User> groupUsers = playerList.get(groupName);
|
final List<User> groupUsers = playerList.get(groupName);
|
||||||
if (groupUsers != null && !groupUsers.isEmpty()) {
|
if (groupUsers != null && !groupUsers.isEmpty()) {
|
||||||
@ -290,7 +290,7 @@ public class KeywordReplacer implements IText {
|
|||||||
}
|
}
|
||||||
|
|
||||||
line = line.replace(fullMatch, replacer);
|
line = line.replace(fullMatch, replacer);
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return line;
|
return line;
|
||||||
|
@ -4,7 +4,7 @@ import java.util.*;
|
|||||||
|
|
||||||
|
|
||||||
public class SimpleTextInput implements IText {
|
public class SimpleTextInput implements IText {
|
||||||
private final transient List<String> lines = new ArrayList<String>();
|
private final transient List<String> lines = new ArrayList<>();
|
||||||
|
|
||||||
public SimpleTextInput(final String input) {
|
public SimpleTextInput(final String input) {
|
||||||
lines.addAll(Arrays.asList(input.split("\\n")));
|
lines.addAll(Arrays.asList(input.split("\\n")));
|
||||||
|
@ -8,11 +8,12 @@ import net.ess3.api.IEssentials;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.ref.SoftReference;
|
import java.lang.ref.SoftReference;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
public class TextInput implements IText {
|
public class TextInput implements IText {
|
||||||
private static final HashMap<String, SoftReference<TextInput>> cache = new HashMap<String, SoftReference<TextInput>>();
|
private static final HashMap<String, SoftReference<TextInput>> cache = new HashMap<>();
|
||||||
private final transient List<String> lines;
|
private final transient List<String> lines;
|
||||||
private final transient List<String> chapters;
|
private final transient List<String> chapters;
|
||||||
private final transient Map<String, Integer> bookmarks;
|
private final transient Map<String, Integer> bookmarks;
|
||||||
@ -38,10 +39,10 @@ public class TextInput implements IText {
|
|||||||
final SoftReference<TextInput> inputRef = cache.get(file.getName());
|
final SoftReference<TextInput> inputRef = cache.get(file.getName());
|
||||||
TextInput input;
|
TextInput input;
|
||||||
if (inputRef == null || (input = inputRef.get()) == null || input.lastChange < lastChange) {
|
if (inputRef == null || (input = inputRef.get()) == null || input.lastChange < lastChange) {
|
||||||
lines = new ArrayList<String>();
|
lines = new ArrayList<>();
|
||||||
chapters = new ArrayList<String>();
|
chapters = new ArrayList<>();
|
||||||
bookmarks = new HashMap<String, Integer>();
|
bookmarks = new HashMap<>();
|
||||||
cache.put(file.getName(), new SoftReference<TextInput>(this));
|
cache.put(file.getName(), new SoftReference<>(this));
|
||||||
readFromfile = true;
|
readFromfile = true;
|
||||||
} else {
|
} else {
|
||||||
lines = Collections.unmodifiableList(input.getLines());
|
lines = Collections.unmodifiableList(input.getLines());
|
||||||
@ -51,7 +52,7 @@ public class TextInput implements IText {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (readFromfile) {
|
if (readFromfile) {
|
||||||
final Reader reader = new InputStreamReader(new FileInputStream(file), "utf-8");
|
final Reader reader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
|
||||||
final BufferedReader bufferedReader = new BufferedReader(reader);
|
final BufferedReader bufferedReader = new BufferedReader(reader);
|
||||||
try {
|
try {
|
||||||
int lineNumber = 0;
|
int lineNumber = 0;
|
||||||
@ -81,18 +82,13 @@ public class TextInput implements IText {
|
|||||||
chapters = Collections.emptyList();
|
chapters = Collections.emptyList();
|
||||||
bookmarks = Collections.emptyMap();
|
bookmarks = Collections.emptyMap();
|
||||||
if (createFile) {
|
if (createFile) {
|
||||||
final InputStream input = ess.getResource(filename + ".txt");
|
try (InputStream input = ess.getResource(filename + ".txt"); OutputStream output = new FileOutputStream(file)) {
|
||||||
final OutputStream output = new FileOutputStream(file);
|
|
||||||
try {
|
|
||||||
final byte[] buffer = new byte[1024];
|
final byte[] buffer = new byte[1024];
|
||||||
int length = input.read(buffer);
|
int length = input.read(buffer);
|
||||||
while (length > 0) {
|
while (length > 0) {
|
||||||
output.write(buffer, 0, length);
|
output.write(buffer, 0, length);
|
||||||
length = input.read(buffer);
|
length = input.read(buffer);
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
output.close();
|
|
||||||
input.close();
|
|
||||||
}
|
}
|
||||||
throw new FileNotFoundException("File " + filename + ".txt does not exist. Creating one for you.");
|
throw new FileNotFoundException("File " + filename + ".txt does not exist. Creating one for you.");
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import static com.earth2me.essentials.I18n.tl;
|
|||||||
|
|
||||||
|
|
||||||
public class DateUtil {
|
public class DateUtil {
|
||||||
private static Pattern timePattern = Pattern.compile("(?:([0-9]+)\\s*y[a-z]*[,\\s]*)?" + "(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?" + "(?:([0-9]+)\\s*w[a-z]*[,\\s]*)?" + "(?:([0-9]+)\\s*d[a-z]*[,\\s]*)?" + "(?:([0-9]+)\\s*h[a-z]*[,\\s]*)?" + "(?:([0-9]+)\\s*m[a-z]*[,\\s]*)?" + "(?:([0-9]+)\\s*(?:s[a-z]*)?)?", Pattern.CASE_INSENSITIVE);
|
private static final Pattern timePattern = Pattern.compile("(?:([0-9]+)\\s*y[a-z]*[,\\s]*)?" + "(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?" + "(?:([0-9]+)\\s*w[a-z]*[,\\s]*)?" + "(?:([0-9]+)\\s*d[a-z]*[,\\s]*)?" + "(?:([0-9]+)\\s*h[a-z]*[,\\s]*)?" + "(?:([0-9]+)\\s*m[a-z]*[,\\s]*)?" + "(?:([0-9]+)\\s*(?:s[a-z]*)?)?", Pattern.CASE_INSENSITIVE);
|
||||||
private static final int maxYears = 100000;
|
private static final int maxYears = 100000;
|
||||||
|
|
||||||
public static String removeTimePattern(String input) {
|
public static String removeTimePattern(String input) {
|
||||||
|
@ -18,8 +18,8 @@ public final class DescParseTickFormat {
|
|||||||
// ============================================
|
// ============================================
|
||||||
// First some information vars. TODO: Should this be in a config file?
|
// First some information vars. TODO: Should this be in a config file?
|
||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
public static final Map<String, Integer> nameToTicks = new LinkedHashMap<String, Integer>();
|
public static final Map<String, Integer> nameToTicks = new LinkedHashMap<>();
|
||||||
public static final Set<String> resetAliases = new HashSet<String>();
|
public static final Set<String> resetAliases = new HashSet<>();
|
||||||
public static final int ticksAtMidnight = 18000;
|
public static final int ticksAtMidnight = 18000;
|
||||||
public static final int ticksPerDay = 24000;
|
public static final int ticksPerDay = 24000;
|
||||||
public static final int ticksPerHour = 1000;
|
public static final int ticksPerHour = 1000;
|
||||||
@ -68,25 +68,25 @@ public final class DescParseTickFormat {
|
|||||||
// Detect ticks format
|
// Detect ticks format
|
||||||
try {
|
try {
|
||||||
return parseTicks(desc);
|
return parseTicks(desc);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect 24-hour format
|
// Detect 24-hour format
|
||||||
try {
|
try {
|
||||||
return parse24(desc);
|
return parse24(desc);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect 12-hour format
|
// Detect 12-hour format
|
||||||
try {
|
try {
|
||||||
return parse12(desc);
|
return parse12(desc);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect aliases
|
// Detect aliases
|
||||||
try {
|
try {
|
||||||
return parseAlias(desc);
|
return parseAlias(desc);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Well we failed to understand...
|
// Well we failed to understand...
|
||||||
|
@ -3,14 +3,11 @@ package com.earth2me.essentials.utils;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.material.MaterialData;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class MaterialUtil {
|
public class MaterialUtil {
|
||||||
@ -91,7 +88,7 @@ public class MaterialUtil {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return LEGACY_SKULLS.contains(material) && (durability < 0 || durability != 3);
|
return LEGACY_SKULLS.contains(material) && (durability != 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPlayerHead(Material material, int durability) {
|
public static boolean isPlayerHead(Material material, int durability) {
|
||||||
|
@ -13,8 +13,8 @@ import static com.earth2me.essentials.I18n.tl;
|
|||||||
|
|
||||||
public class NumberUtil {
|
public class NumberUtil {
|
||||||
|
|
||||||
private static DecimalFormat twoDPlaces = new DecimalFormat("#,###.##");
|
private static final DecimalFormat twoDPlaces = new DecimalFormat("#,###.##");
|
||||||
private static DecimalFormat currencyFormat = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
|
private static final 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 field is likely to be modified in com.earth2me.essentials.Settings when loading currency format.
|
||||||
// This ensures that we can supply a constant formatting.
|
// This ensures that we can supply a constant formatting.
|
||||||
|
Loading…
Reference in New Issue
Block a user