forked from LogBlock/LogBlock
Code style
This commit is contained in:
@ -122,13 +122,14 @@ public class Actor {
|
||||
* or {@link #actorFromEntity(org.bukkit.entity.EntityType) } methods
|
||||
* <p>
|
||||
* If you know something is a server effect (like gravity) use {@link #Actor(java.lang.String)}
|
||||
*
|
||||
*
|
||||
* @deprecated Only use this if you have a String of unknown origin
|
||||
*
|
||||
*
|
||||
* @param actorName
|
||||
* String of unknown origin
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public static Actor actorFromString(String actorName) {
|
||||
Collection<? extends Player> players = Bukkit.getServer().getOnlinePlayers();
|
||||
for (Player p : players) {
|
||||
|
@ -124,7 +124,7 @@ public class CommandsHandler implements CommandExecutor {
|
||||
final WorldConfig wcfg = getWorldConfig(world.getName());
|
||||
if (wcfg != null) {
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + "Currently logging in " + world.getName() + ":");
|
||||
final List<String> logging = new ArrayList<String>();
|
||||
final List<String> logging = new ArrayList<>();
|
||||
for (final Logging l : Logging.values()) {
|
||||
if (wcfg.isLogging(l)) {
|
||||
logging.add(l.toString());
|
||||
@ -343,7 +343,7 @@ public class CommandsHandler implements CommandExecutor {
|
||||
}
|
||||
} else if (command.equals("lookup") || QueryParams.isKeyWord(args[0])) {
|
||||
if (logblock.hasPermission(sender, "logblock.lookup")) {
|
||||
final List<String> argsList = new ArrayList<String>(Arrays.asList(args));
|
||||
final List<String> argsList = new ArrayList<>(Arrays.asList(args));
|
||||
if (command.equals("lookup")) {
|
||||
argsList.remove(0);
|
||||
}
|
||||
@ -486,7 +486,7 @@ public class CommandsHandler implements CommandExecutor {
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + params.getTitle() + ":");
|
||||
if (rs.next()) {
|
||||
rs.beforeFirst();
|
||||
final List<LookupCacheElement> blockchanges = new ArrayList<LookupCacheElement>();
|
||||
final List<LookupCacheElement> blockchanges = new ArrayList<>();
|
||||
final LookupCacheElementFactory factory = new LookupCacheElementFactory(params, sender instanceof Player ? 2 / 3f : 1);
|
||||
while (rs.next()) {
|
||||
blockchanges.add(factory.getLookupCacheElement(rs));
|
||||
@ -989,7 +989,7 @@ public class CommandsHandler implements CommandExecutor {
|
||||
}
|
||||
|
||||
private static List<String> argsToList(String[] arr, int offset) {
|
||||
final List<String> list = new ArrayList<String>(Arrays.asList(arr));
|
||||
final List<String> list = new ArrayList<>(Arrays.asList(arr));
|
||||
for (int i = 0; i < offset; i++) {
|
||||
list.remove(0);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class Consumer extends Thread {
|
||||
private static final int RETURN_IDLE_CONNECTION_TIME_MILLIS = 120000;
|
||||
private static final int RETRIES_ON_UNKNOWN_CONNECTION_ERROR = 2;
|
||||
|
||||
private final Deque<Row> queue = new ArrayDeque<Row>();
|
||||
private final Deque<Row> queue = new ArrayDeque<>();
|
||||
private final LogBlock logblock;
|
||||
private final Map<Actor, Integer> playerIds = new HashMap<>();
|
||||
private final Map<Actor, Integer> uncommitedPlayerIds = new HashMap<>();
|
||||
@ -534,7 +534,7 @@ public class Consumer extends Thread {
|
||||
|
||||
public void writeToFile() throws FileNotFoundException {
|
||||
final long time = System.currentTimeMillis();
|
||||
final Set<Actor> insertedPlayers = new HashSet<Actor>();
|
||||
final Set<Actor> insertedPlayers = new HashSet<>();
|
||||
int counter = 0;
|
||||
new File("plugins/LogBlock/import/").mkdirs();
|
||||
PrintWriter writer = new PrintWriter(new File("plugins/LogBlock/import/queue-" + time + "-0.sql"));
|
||||
@ -734,7 +734,7 @@ public class Consumer extends Thread {
|
||||
/**
|
||||
* Change the UUID that is stored for an entity in the database. This is needed when an entity is respawned
|
||||
* and now has a different UUID.
|
||||
*
|
||||
*
|
||||
* @param world the world that contains the entity
|
||||
* @param entityId the database id of the entity
|
||||
* @param entityUUID the new UUID of the entity
|
||||
@ -1128,10 +1128,12 @@ public class Consumer extends Thread {
|
||||
|
||||
private int safeY(Location loc) {
|
||||
int safeY = loc.getBlockY();
|
||||
if (safeY < 0)
|
||||
if (safeY < 0) {
|
||||
safeY = 0;
|
||||
if (safeY > 65535)
|
||||
}
|
||||
if (safeY > 65535) {
|
||||
safeY = 65535;
|
||||
}
|
||||
return safeY;
|
||||
}
|
||||
|
||||
|
@ -287,7 +287,7 @@ public class LogBlock extends JavaPlugin {
|
||||
try {
|
||||
state = conn.createStatement();
|
||||
final ResultSet rs = state.executeQuery(params.getQuery());
|
||||
final List<BlockChange> blockchanges = new ArrayList<BlockChange>();
|
||||
final List<BlockChange> blockchanges = new ArrayList<>();
|
||||
while (rs.next()) {
|
||||
blockchanges.add(new BlockChange(rs, params));
|
||||
}
|
||||
|
@ -62,17 +62,17 @@ public final class QueryParams implements Cloneable {
|
||||
public int limit = -1, before = 0, since = 0, radius = -1;
|
||||
public Location loc = null;
|
||||
public Order order = Order.DESC;
|
||||
public List<String> players = new ArrayList<String>();
|
||||
public List<String> killers = new ArrayList<String>();
|
||||
public List<String> victims = new ArrayList<String>();
|
||||
public List<String> players = new ArrayList<>();
|
||||
public List<String> killers = new ArrayList<>();
|
||||
public List<String> victims = new ArrayList<>();
|
||||
public boolean excludePlayersMode = false, excludeKillersMode = false, excludeVictimsMode = false, excludeBlocksEntitiesMode = false, prepareToolQuery = false, silent = false, noForcedLimit = false;
|
||||
public boolean forceReplace = false, noCache = false;
|
||||
public CuboidRegion sel = null;
|
||||
public SummarizationMode sum = SummarizationMode.NONE;
|
||||
public List<Material> types = new ArrayList<Material>();
|
||||
public List<Integer> typeIds = new ArrayList<Integer>();
|
||||
public List<EntityType> entityTypes = new ArrayList<EntityType>();
|
||||
public List<Integer> entityTypeIds = new ArrayList<Integer>();
|
||||
public List<Material> types = new ArrayList<>();
|
||||
public List<Integer> typeIds = new ArrayList<>();
|
||||
public List<EntityType> entityTypes = new ArrayList<>();
|
||||
public List<Integer> entityTypeIds = new ArrayList<>();
|
||||
public World world = null;
|
||||
public String match = null;
|
||||
public boolean needCount = false, needId = false, needDate = false, needType = false, needData = false, needPlayerId = false, needPlayer = false, needCoords = false, needChestAccess = false, needMessage = false, needKiller = false, needVictim = false, needWeapon = false;
|
||||
@ -961,13 +961,13 @@ public final class QueryParams implements Cloneable {
|
||||
public QueryParams clone() {
|
||||
try {
|
||||
final QueryParams params = (QueryParams) super.clone();
|
||||
params.players = new ArrayList<String>(players);
|
||||
params.killers = new ArrayList<String>(killers);
|
||||
params.victims = new ArrayList<String>(victims);
|
||||
params.typeIds = new ArrayList<Integer>(typeIds);
|
||||
params.types = new ArrayList<Material>(types);
|
||||
params.entityTypeIds = new ArrayList<Integer>(entityTypeIds);
|
||||
params.entityTypes = new ArrayList<EntityType>(entityTypes);
|
||||
params.players = new ArrayList<>(players);
|
||||
params.killers = new ArrayList<>(killers);
|
||||
params.victims = new ArrayList<>(victims);
|
||||
params.typeIds = new ArrayList<>(typeIds);
|
||||
params.types = new ArrayList<>(types);
|
||||
params.entityTypeIds = new ArrayList<>(entityTypeIds);
|
||||
params.entityTypes = new ArrayList<>(entityTypes);
|
||||
params.loc = loc == null ? null : loc.clone();
|
||||
params.sel = sel == null ? null : sel.clone();
|
||||
return params;
|
||||
|
@ -10,14 +10,14 @@ import static de.diddiz.LogBlock.config.Config.toolsByType;
|
||||
import static org.bukkit.Bukkit.getServer;
|
||||
|
||||
public class Session {
|
||||
private static final Map<String, Session> sessions = new HashMap<String, Session>();
|
||||
private static final Map<String, Session> sessions = new HashMap<>();
|
||||
public QueryParams lastQuery = null;
|
||||
public LookupCacheElement[] lookupCache = null;
|
||||
public int page = 1;
|
||||
public Map<Tool, ToolData> toolData;
|
||||
|
||||
private Session(Player player) {
|
||||
toolData = new HashMap<Tool, ToolData>();
|
||||
toolData = new HashMap<>();
|
||||
final LogBlock logblock = LogBlock.getInstance();
|
||||
if (player != null) {
|
||||
for (final Tool tool : toolsByType.values()) {
|
||||
|
@ -290,8 +290,8 @@ class Updater {
|
||||
int done = 0;
|
||||
|
||||
conn.setAutoCommit(false);
|
||||
Map<String, Integer> players = new HashMap<String, Integer>();
|
||||
List<String> names = new ArrayList<String>(UUID_CONVERT_BATCH_SIZE);
|
||||
Map<String, Integer> players = new HashMap<>();
|
||||
List<String> names = new ArrayList<>(UUID_CONVERT_BATCH_SIZE);
|
||||
Map<String, UUID> response;
|
||||
rs = st.executeQuery("SELECT playerid,playername FROM `lb-players` WHERE LENGTH(UUID)=0 LIMIT " + Integer.toString(UUID_CONVERT_BATCH_SIZE));
|
||||
while (rs.next()) {
|
||||
|
@ -147,7 +147,7 @@ public class WorldEditor implements Runnable {
|
||||
|
||||
@Override
|
||||
public synchronized void run() {
|
||||
final List<WorldEditorException> errorList = new ArrayList<WorldEditorException>();
|
||||
final List<WorldEditorException> errorList = new ArrayList<>();
|
||||
int counter = 0;
|
||||
float size = edits.size();
|
||||
while (!edits.isEmpty() && counter < 100) {
|
||||
@ -337,6 +337,7 @@ public class WorldEditor implements Runnable {
|
||||
return date;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PerformResult perform() throws WorldEditorException {
|
||||
BlockData replacedBlock = getBlockReplaced();
|
||||
BlockData setBlock = getBlockSet();
|
||||
|
@ -85,8 +85,9 @@ public class BlockStateCodecSign implements BlockStateCodec {
|
||||
if (conf != null) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String line : conf.getStringList("lines")) {
|
||||
if (sb.length() > 0)
|
||||
if (sb.length() > 0) {
|
||||
sb.append(" ");
|
||||
}
|
||||
sb.append("[").append(line).append("]");
|
||||
}
|
||||
return sb.toString();
|
||||
|
@ -65,9 +65,9 @@ public class Config {
|
||||
|
||||
public static void load(LogBlock logblock) throws DataFormatException, IOException {
|
||||
final ConfigurationSection config = logblock.getConfig();
|
||||
final Map<String, Object> def = new HashMap<String, Object>();
|
||||
final Map<String, Object> def = new HashMap<>();
|
||||
def.put("version", logblock.getDescription().getVersion());
|
||||
final List<String> worldNames = new ArrayList<String>();
|
||||
final List<String> worldNames = new ArrayList<>();
|
||||
for (final World world : getWorlds()) {
|
||||
worldNames.add(world.getName());
|
||||
}
|
||||
@ -91,7 +91,7 @@ public class Config {
|
||||
def.put("consumer.queueWarningSize", 1000);
|
||||
def.put("clearlog.dumpDeletedLog", false);
|
||||
def.put("clearlog.enableAutoClearLog", false);
|
||||
final List<String> autoClearlog = new ArrayList<String>();
|
||||
final List<String> autoClearlog = new ArrayList<>();
|
||||
for (final String world : worldNames) {
|
||||
autoClearlog.add("world \"" + world + "\" before 365 days all");
|
||||
autoClearlog.add("world \"" + world + "\" player lavaflow waterflow leavesdecay before 7 days all");
|
||||
@ -189,11 +189,11 @@ public class Config {
|
||||
throw new DataFormatException("logging.logKillsLevel doesn't appear to be a valid log level. Allowed are 'PLAYERS', 'MONSTERS' and 'ANIMALS'");
|
||||
}
|
||||
logEnvironmentalKills = config.getBoolean("logging.logEnvironmentalKills", false);
|
||||
hiddenPlayers = new HashSet<String>();
|
||||
hiddenPlayers = new HashSet<>();
|
||||
for (final String playerName : config.getStringList("logging.hiddenPlayers")) {
|
||||
hiddenPlayers.add(playerName.toLowerCase().trim());
|
||||
}
|
||||
hiddenBlocks = new HashSet<Material>();
|
||||
hiddenBlocks = new HashSet<>();
|
||||
for (final String blocktype : config.getStringList("logging.hiddenBlocks")) {
|
||||
final Material mat = Material.matchMaterial(blocktype);
|
||||
if (mat != null) {
|
||||
@ -202,11 +202,11 @@ public class Config {
|
||||
throw new DataFormatException("Not a valid material in hiddenBlocks: '" + blocktype + "'");
|
||||
}
|
||||
}
|
||||
ignoredChat = new ArrayList<String>();
|
||||
ignoredChat = new ArrayList<>();
|
||||
for (String chatCommand : config.getStringList("logging.ignoredChat")) {
|
||||
ignoredChat.add(chatCommand.toLowerCase());
|
||||
}
|
||||
dontRollback = new HashSet<Material>();
|
||||
dontRollback = new HashSet<>();
|
||||
for (String e : config.getStringList("rollback.dontRollback")) {
|
||||
Material mat = Material.matchMaterial(e);
|
||||
if (mat != null) {
|
||||
@ -215,7 +215,7 @@ public class Config {
|
||||
throw new DataFormatException("Not a valid material in dontRollback: '" + e + "'");
|
||||
}
|
||||
}
|
||||
replaceAnyway = new HashSet<Material>();
|
||||
replaceAnyway = new HashSet<>();
|
||||
for (String e : config.getStringList("rollback.replaceAnyway")) {
|
||||
Material mat = Material.matchMaterial(e);
|
||||
if (mat != null) {
|
||||
@ -239,7 +239,7 @@ public class Config {
|
||||
safetyIdCheck = config.getBoolean("safety.id.check", true);
|
||||
debug = config.getBoolean("debug", false);
|
||||
banPermission = config.getString("questioner.banPermission");
|
||||
final List<Tool> tools = new ArrayList<Tool>();
|
||||
final List<Tool> tools = new ArrayList<>();
|
||||
final ConfigurationSection toolsSec = config.getConfigurationSection("tools");
|
||||
for (final String toolName : toolsSec.getKeys(false)) {
|
||||
try {
|
||||
@ -262,8 +262,8 @@ public class Config {
|
||||
getLogger().log(Level.WARNING, "Error at parsing tool '" + toolName + "': ", ex);
|
||||
}
|
||||
}
|
||||
toolsByName = new HashMap<String, Tool>();
|
||||
toolsByType = new HashMap<Material, Tool>();
|
||||
toolsByName = new HashMap<>();
|
||||
toolsByType = new HashMap<>();
|
||||
for (final Tool tool : tools) {
|
||||
toolsByType.put(tool.item, tool);
|
||||
toolsByName.put(tool.name.toLowerCase(), tool);
|
||||
@ -272,7 +272,7 @@ public class Config {
|
||||
}
|
||||
}
|
||||
final List<String> loggedWorlds = config.getStringList("loggedWorlds");
|
||||
worldConfigs = new HashMap<String, WorldConfig>();
|
||||
worldConfigs = new HashMap<>();
|
||||
if (loggedWorlds.isEmpty()) {
|
||||
throw new DataFormatException("No worlds configured");
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class WorldConfig extends LoggingEnabledMapping {
|
||||
|
||||
public WorldConfig(String world, File file) throws IOException {
|
||||
this.world = world;
|
||||
final Map<String, Object> def = new HashMap<String, Object>();
|
||||
final Map<String, Object> def = new HashMap<>();
|
||||
// "Before MySQL 5.1.6, database and table names cannot contain "/", "\", ".", or characters that are not permitted in file names" - MySQL manual
|
||||
// They _can_ contain spaces, but replace them as well
|
||||
def.put("table", "lb-" + file.getName().substring(0, file.getName().length() - 4).replaceAll("[ ./\\\\]", "_"));
|
||||
|
@ -19,9 +19,7 @@ public class BlockChangePreLogEvent extends PreLogEvent {
|
||||
private YamlConfiguration stateBefore;
|
||||
private YamlConfiguration stateAfter;
|
||||
|
||||
public BlockChangePreLogEvent(Actor owner, Location location, BlockData typeBefore, BlockData typeAfter,
|
||||
YamlConfiguration stateBefore, YamlConfiguration stateAfter, ChestAccess chestAccess) {
|
||||
|
||||
public BlockChangePreLogEvent(Actor owner, Location location, BlockData typeBefore, BlockData typeAfter, YamlConfiguration stateBefore, YamlConfiguration stateAfter, ChestAccess chestAccess) {
|
||||
super(owner);
|
||||
this.location = location;
|
||||
this.typeBefore = typeBefore;
|
||||
@ -32,17 +30,14 @@ public class BlockChangePreLogEvent extends PreLogEvent {
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(Location location) {
|
||||
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public BlockData getTypeBefore() {
|
||||
|
||||
return typeBefore;
|
||||
}
|
||||
|
||||
@ -54,7 +49,6 @@ public class BlockChangePreLogEvent extends PreLogEvent {
|
||||
}
|
||||
|
||||
public BlockData getTypeAfter() {
|
||||
|
||||
return typeAfter;
|
||||
}
|
||||
|
||||
@ -82,22 +76,19 @@ public class BlockChangePreLogEvent extends PreLogEvent {
|
||||
}
|
||||
|
||||
public ChestAccess getChestAccess() {
|
||||
|
||||
return chestAccess;
|
||||
}
|
||||
|
||||
public void setChestAccess(ChestAccess chestAccess) {
|
||||
|
||||
this.chestAccess = chestAccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ public abstract class PreLogEvent extends Event implements Cancellable {
|
||||
protected Actor owner;
|
||||
|
||||
public PreLogEvent(Actor owner) {
|
||||
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@ -21,8 +20,8 @@ public abstract class PreLogEvent extends Event implements Cancellable {
|
||||
* @deprecated {@link #getOwnerActor() } returns an object encapsulating
|
||||
* name and uuid. Names are not guaranteed to be unique.
|
||||
*/
|
||||
@Deprecated
|
||||
public String getOwner() {
|
||||
|
||||
return owner.getName();
|
||||
}
|
||||
|
||||
@ -41,17 +40,16 @@ public abstract class PreLogEvent extends Event implements Cancellable {
|
||||
* @param owner The player/monster/cause who is involved in this event
|
||||
*/
|
||||
public void setOwner(Actor owner) {
|
||||
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class BlockBurnLogging extends LoggingListener {
|
||||
Actor actor = new Actor("Fire", Config.logFireSpreadAsPlayerWhoCreatedIt ? event.getIgnitingBlock() : null);
|
||||
if (event.getCause() == IgniteCause.FLINT_AND_STEEL) {
|
||||
if (event.getIgnitingEntity() != null) {
|
||||
return; // handled in block place
|
||||
return; // handled in block place
|
||||
} else {
|
||||
actor = new Actor("Dispenser");
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ import static de.diddiz.LogBlock.config.Config.isLogging;
|
||||
import static de.diddiz.util.BukkitUtils.*;
|
||||
|
||||
public class ChestAccessLogging extends LoggingListener {
|
||||
private final Map<HumanEntity, ItemStack[]> containers = new HashMap<HumanEntity, ItemStack[]>();
|
||||
private final Map<HumanEntity, ItemStack[]> containers = new HashMap<>();
|
||||
|
||||
public ChestAccessLogging(LogBlock lb) {
|
||||
super(lb);
|
||||
|
@ -15,7 +15,7 @@ import de.diddiz.LogBlock.LogBlock;
|
||||
|
||||
public class Questioner {
|
||||
private final LogBlock logBlock;
|
||||
private final ConcurrentHashMap<UUID, Question> questions = new ConcurrentHashMap<UUID, Question>();
|
||||
private final ConcurrentHashMap<UUID, Question> questions = new ConcurrentHashMap<>();
|
||||
|
||||
public Questioner(LogBlock logBlock) {
|
||||
this.logBlock = logBlock;
|
||||
@ -42,6 +42,7 @@ public class Questioner {
|
||||
}
|
||||
|
||||
private class QuestionsReaper implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
if (questions.isEmpty()) {
|
||||
return;
|
||||
|
@ -158,14 +158,14 @@ public class BukkitUtils {
|
||||
doublePlants.add(Material.SUNFLOWER);
|
||||
doublePlants.add(Material.PEONY);
|
||||
|
||||
blockEquivalents = new HashSet<Set<Integer>>(7);
|
||||
blockEquivalents.add(new HashSet<Integer>(Arrays.asList(2, 3, 60)));
|
||||
blockEquivalents.add(new HashSet<Integer>(Arrays.asList(8, 9, 79)));
|
||||
blockEquivalents.add(new HashSet<Integer>(Arrays.asList(10, 11)));
|
||||
blockEquivalents.add(new HashSet<Integer>(Arrays.asList(61, 62)));
|
||||
blockEquivalents.add(new HashSet<Integer>(Arrays.asList(73, 74)));
|
||||
blockEquivalents.add(new HashSet<Integer>(Arrays.asList(75, 76)));
|
||||
blockEquivalents.add(new HashSet<Integer>(Arrays.asList(93, 94)));
|
||||
blockEquivalents = new HashSet<>(7);
|
||||
blockEquivalents.add(new HashSet<>(Arrays.asList(2, 3, 60)));
|
||||
blockEquivalents.add(new HashSet<>(Arrays.asList(8, 9, 79)));
|
||||
blockEquivalents.add(new HashSet<>(Arrays.asList(10, 11)));
|
||||
blockEquivalents.add(new HashSet<>(Arrays.asList(61, 62)));
|
||||
blockEquivalents.add(new HashSet<>(Arrays.asList(73, 74)));
|
||||
blockEquivalents.add(new HashSet<>(Arrays.asList(75, 76)));
|
||||
blockEquivalents.add(new HashSet<>(Arrays.asList(93, 94)));
|
||||
|
||||
// Blocks that break when they are attached to a block
|
||||
relativeBreakable = EnumSet.noneOf(Material.class);
|
||||
@ -332,7 +332,7 @@ public class BukkitUtils {
|
||||
// containerBlocks.add(Material.ENDER_CHEST);
|
||||
|
||||
// It doesn't seem like you could injure people with some of these, but they exist, so....
|
||||
projectileItems = new EnumMap<EntityType, Material>(EntityType.class);
|
||||
projectileItems = new EnumMap<>(EntityType.class);
|
||||
projectileItems.put(EntityType.ARROW, Material.ARROW);
|
||||
projectileItems.put(EntityType.EGG, Material.EGG);
|
||||
projectileItems.put(EntityType.ENDER_PEARL, Material.ENDER_PEARL);
|
||||
@ -441,7 +441,7 @@ public class BukkitUtils {
|
||||
* @return List of block locations around the block that are of the type specified by the integer list parameter
|
||||
*/
|
||||
public static List<Location> getBlocksNearby(org.bukkit.block.Block block, Set<Material> type) {
|
||||
ArrayList<Location> blocks = new ArrayList<Location>();
|
||||
ArrayList<Location> blocks = new ArrayList<>();
|
||||
for (BlockFace blockFace : relativeBlockFaces) {
|
||||
if (type.contains(block.getRelative(blockFace).getType())) {
|
||||
blocks.add(block.getRelative(blockFace).getLocation());
|
||||
@ -478,7 +478,7 @@ public class BukkitUtils {
|
||||
}
|
||||
|
||||
public static ItemStack[] compareInventories(ItemStack[] items1, ItemStack[] items2) {
|
||||
final ArrayList<ItemStack> diff = new ArrayList<ItemStack>();
|
||||
final ArrayList<ItemStack> diff = new ArrayList<>();
|
||||
for (ItemStack current : items2) {
|
||||
diff.add(new ItemStack(current));
|
||||
}
|
||||
@ -506,7 +506,7 @@ public class BukkitUtils {
|
||||
}
|
||||
|
||||
public static ItemStack[] compressInventory(ItemStack[] items) {
|
||||
final ArrayList<ItemStack> compressed = new ArrayList<ItemStack>();
|
||||
final ArrayList<ItemStack> compressed = new ArrayList<>();
|
||||
for (final ItemStack item : items) {
|
||||
if (item != null) {
|
||||
boolean found = false;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package de.diddiz.util;
|
||||
|
||||
// Taken from maven-artifact at
|
||||
// Taken from maven-artifact at
|
||||
// http://grepcode.com/file_/repo1.maven.org/maven2/org.apache.maven/maven-artifact/3.2.3/org/apache/maven/artifact/versioning/ComparableVersion.java/?v=source
|
||||
|
||||
/*
|
||||
@ -34,7 +34,7 @@ import java.util.Stack;
|
||||
|
||||
/**
|
||||
* Generic implementation of version comparison.
|
||||
*
|
||||
*
|
||||
* <p>Features:
|
||||
* <ul>
|
||||
* <li>mixing of '<code>-</code>' (dash) and '<code>.</code>' (dot) separators,</li>
|
||||
@ -98,14 +98,17 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
|
||||
this.value = new BigInteger(str);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return INTEGER_ITEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNull() {
|
||||
return BIG_INTEGER_ZERO.equals(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Item item) {
|
||||
if (item == null) {
|
||||
return BIG_INTEGER_ZERO.equals(value) ? 0 : 1; // 1.0 == 1, 1.1 > 1
|
||||
@ -126,6 +129,7 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value.toString();
|
||||
}
|
||||
@ -172,10 +176,12 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
|
||||
this.value = ALIASES.getProperty(value, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return STRING_ITEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNull() {
|
||||
return (comparableQualifier(value).compareTo(RELEASE_VERSION_INDEX) == 0);
|
||||
}
|
||||
@ -198,6 +204,7 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
|
||||
return i == -1 ? (_QUALIFIERS.size() + "-" + qualifier) : String.valueOf(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Item item) {
|
||||
if (item == null) {
|
||||
// 1-rc < 1, 1-ga > 1
|
||||
@ -218,6 +225,7 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
@ -230,10 +238,12 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
|
||||
private static class ListItem extends ArrayList<Item> implements Item {
|
||||
private static final long serialVersionUID = 5914575811857700009L;
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return LIST_ITEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNull() {
|
||||
return (size() == 0);
|
||||
}
|
||||
@ -249,6 +259,7 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Item item) {
|
||||
if (item == null) {
|
||||
if (size() == 0) {
|
||||
@ -287,6 +298,7 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buffer = new StringBuilder("(");
|
||||
for (Iterator<Item> iter = iterator(); iter.hasNext();) {
|
||||
@ -313,7 +325,7 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
|
||||
|
||||
ListItem list = items;
|
||||
|
||||
Stack<Item> stack = new Stack<Item>();
|
||||
Stack<Item> stack = new Stack<>();
|
||||
stack.push(list);
|
||||
|
||||
boolean isDigit = false;
|
||||
@ -382,6 +394,7 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
|
||||
return isDigit ? new IntegerItem(buf) : new StringItem(buf, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ComparableVersion o) {
|
||||
return items.compareTo(o.items);
|
||||
}
|
||||
@ -390,6 +403,7 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
|
||||
return compareTo(new ComparableVersion(version));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
@ -398,10 +412,12 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
|
||||
return canonical;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return (o instanceof ComparableVersion) && canonical.equals(((ComparableVersion) o).canonical);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return canonical.hashCode();
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public class UUIDFetcher {
|
||||
private static final JSONParser jsonParser = new JSONParser();
|
||||
|
||||
public static Map<String, UUID> getUUIDs(List<String> names) throws Exception {
|
||||
Map<String, UUID> uuidMap = new HashMap<String, UUID>();
|
||||
Map<String, UUID> uuidMap = new HashMap<>();
|
||||
HttpURLConnection connection = createConnection();
|
||||
String body = JSONArray.toJSONString(names);
|
||||
writeBody(connection, body);
|
||||
|
@ -181,7 +181,7 @@ public class Utils {
|
||||
* @return A new list with the quoted arguments parsed to single values
|
||||
*/
|
||||
public static List<String> parseQuotes(List<String> args) {
|
||||
List<String> newArguments = new ArrayList<String>();
|
||||
List<String> newArguments = new ArrayList<>();
|
||||
String subjectString = join(args.toArray(new String[args.size()]), " ");
|
||||
|
||||
Pattern regex = Pattern.compile("[^\\s\"']+|\"[^\"]*\"|'[^']*'");
|
||||
|
Reference in New Issue
Block a user