Code style

This commit is contained in:
Brokkonaut
2019-06-23 17:14:17 +02:00
parent 1525d7682f
commit e8aaadf37b
20 changed files with 92 additions and 81 deletions

View File

@ -122,13 +122,14 @@ public class Actor {
* or {@link #actorFromEntity(org.bukkit.entity.EntityType) } methods * or {@link #actorFromEntity(org.bukkit.entity.EntityType) } methods
* <p> * <p>
* If you know something is a server effect (like gravity) use {@link #Actor(java.lang.String)} * 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 * @deprecated Only use this if you have a String of unknown origin
* *
* @param actorName * @param actorName
* String of unknown origin * String of unknown origin
* @return * @return
*/ */
@Deprecated
public static Actor actorFromString(String actorName) { public static Actor actorFromString(String actorName) {
Collection<? extends Player> players = Bukkit.getServer().getOnlinePlayers(); Collection<? extends Player> players = Bukkit.getServer().getOnlinePlayers();
for (Player p : players) { for (Player p : players) {

View File

@ -124,7 +124,7 @@ public class CommandsHandler implements CommandExecutor {
final WorldConfig wcfg = getWorldConfig(world.getName()); final WorldConfig wcfg = getWorldConfig(world.getName());
if (wcfg != null) { if (wcfg != null) {
sender.sendMessage(ChatColor.DARK_AQUA + "Currently logging in " + world.getName() + ":"); 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()) { for (final Logging l : Logging.values()) {
if (wcfg.isLogging(l)) { if (wcfg.isLogging(l)) {
logging.add(l.toString()); logging.add(l.toString());
@ -343,7 +343,7 @@ public class CommandsHandler implements CommandExecutor {
} }
} else if (command.equals("lookup") || QueryParams.isKeyWord(args[0])) { } else if (command.equals("lookup") || QueryParams.isKeyWord(args[0])) {
if (logblock.hasPermission(sender, "logblock.lookup")) { 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")) { if (command.equals("lookup")) {
argsList.remove(0); argsList.remove(0);
} }
@ -486,7 +486,7 @@ public class CommandsHandler implements CommandExecutor {
sender.sendMessage(ChatColor.DARK_AQUA + params.getTitle() + ":"); sender.sendMessage(ChatColor.DARK_AQUA + params.getTitle() + ":");
if (rs.next()) { if (rs.next()) {
rs.beforeFirst(); 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); final LookupCacheElementFactory factory = new LookupCacheElementFactory(params, sender instanceof Player ? 2 / 3f : 1);
while (rs.next()) { while (rs.next()) {
blockchanges.add(factory.getLookupCacheElement(rs)); blockchanges.add(factory.getLookupCacheElement(rs));
@ -989,7 +989,7 @@ public class CommandsHandler implements CommandExecutor {
} }
private static List<String> argsToList(String[] arr, int offset) { 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++) { for (int i = 0; i < offset; i++) {
list.remove(0); list.remove(0);
} }

View File

@ -60,7 +60,7 @@ public class Consumer extends Thread {
private static final int RETURN_IDLE_CONNECTION_TIME_MILLIS = 120000; private static final int RETURN_IDLE_CONNECTION_TIME_MILLIS = 120000;
private static final int RETRIES_ON_UNKNOWN_CONNECTION_ERROR = 2; 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 LogBlock logblock;
private final Map<Actor, Integer> playerIds = new HashMap<>(); private final Map<Actor, Integer> playerIds = new HashMap<>();
private final Map<Actor, Integer> uncommitedPlayerIds = new HashMap<>(); private final Map<Actor, Integer> uncommitedPlayerIds = new HashMap<>();
@ -534,7 +534,7 @@ public class Consumer extends Thread {
public void writeToFile() throws FileNotFoundException { public void writeToFile() throws FileNotFoundException {
final long time = System.currentTimeMillis(); final long time = System.currentTimeMillis();
final Set<Actor> insertedPlayers = new HashSet<Actor>(); final Set<Actor> insertedPlayers = new HashSet<>();
int counter = 0; int counter = 0;
new File("plugins/LogBlock/import/").mkdirs(); new File("plugins/LogBlock/import/").mkdirs();
PrintWriter writer = new PrintWriter(new File("plugins/LogBlock/import/queue-" + time + "-0.sql")); 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 * 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. * and now has a different UUID.
* *
* @param world the world that contains the entity * @param world the world that contains the entity
* @param entityId the database id of the entity * @param entityId the database id of the entity
* @param entityUUID the new UUID 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) { private int safeY(Location loc) {
int safeY = loc.getBlockY(); int safeY = loc.getBlockY();
if (safeY < 0) if (safeY < 0) {
safeY = 0; safeY = 0;
if (safeY > 65535) }
if (safeY > 65535) {
safeY = 65535; safeY = 65535;
}
return safeY; return safeY;
} }

View File

@ -287,7 +287,7 @@ public class LogBlock extends JavaPlugin {
try { try {
state = conn.createStatement(); state = conn.createStatement();
final ResultSet rs = state.executeQuery(params.getQuery()); final ResultSet rs = state.executeQuery(params.getQuery());
final List<BlockChange> blockchanges = new ArrayList<BlockChange>(); final List<BlockChange> blockchanges = new ArrayList<>();
while (rs.next()) { while (rs.next()) {
blockchanges.add(new BlockChange(rs, params)); blockchanges.add(new BlockChange(rs, params));
} }

View File

@ -62,17 +62,17 @@ public final class QueryParams implements Cloneable {
public int limit = -1, before = 0, since = 0, radius = -1; public int limit = -1, before = 0, since = 0, radius = -1;
public Location loc = null; public Location loc = null;
public Order order = Order.DESC; public Order order = Order.DESC;
public List<String> players = new ArrayList<String>(); public List<String> players = new ArrayList<>();
public List<String> killers = new ArrayList<String>(); public List<String> killers = new ArrayList<>();
public List<String> victims = new ArrayList<String>(); public List<String> victims = new ArrayList<>();
public boolean excludePlayersMode = false, excludeKillersMode = false, excludeVictimsMode = false, excludeBlocksEntitiesMode = false, prepareToolQuery = false, silent = false, noForcedLimit = false; public boolean excludePlayersMode = false, excludeKillersMode = false, excludeVictimsMode = false, excludeBlocksEntitiesMode = false, prepareToolQuery = false, silent = false, noForcedLimit = false;
public boolean forceReplace = false, noCache = false; public boolean forceReplace = false, noCache = false;
public CuboidRegion sel = null; public CuboidRegion sel = null;
public SummarizationMode sum = SummarizationMode.NONE; public SummarizationMode sum = SummarizationMode.NONE;
public List<Material> types = new ArrayList<Material>(); public List<Material> types = new ArrayList<>();
public List<Integer> typeIds = new ArrayList<Integer>(); public List<Integer> typeIds = new ArrayList<>();
public List<EntityType> entityTypes = new ArrayList<EntityType>(); public List<EntityType> entityTypes = new ArrayList<>();
public List<Integer> entityTypeIds = new ArrayList<Integer>(); public List<Integer> entityTypeIds = new ArrayList<>();
public World world = null; public World world = null;
public String match = 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; 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() { public QueryParams clone() {
try { try {
final QueryParams params = (QueryParams) super.clone(); final QueryParams params = (QueryParams) super.clone();
params.players = new ArrayList<String>(players); params.players = new ArrayList<>(players);
params.killers = new ArrayList<String>(killers); params.killers = new ArrayList<>(killers);
params.victims = new ArrayList<String>(victims); params.victims = new ArrayList<>(victims);
params.typeIds = new ArrayList<Integer>(typeIds); params.typeIds = new ArrayList<>(typeIds);
params.types = new ArrayList<Material>(types); params.types = new ArrayList<>(types);
params.entityTypeIds = new ArrayList<Integer>(entityTypeIds); params.entityTypeIds = new ArrayList<>(entityTypeIds);
params.entityTypes = new ArrayList<EntityType>(entityTypes); params.entityTypes = new ArrayList<>(entityTypes);
params.loc = loc == null ? null : loc.clone(); params.loc = loc == null ? null : loc.clone();
params.sel = sel == null ? null : sel.clone(); params.sel = sel == null ? null : sel.clone();
return params; return params;

View File

@ -10,14 +10,14 @@ import static de.diddiz.LogBlock.config.Config.toolsByType;
import static org.bukkit.Bukkit.getServer; import static org.bukkit.Bukkit.getServer;
public class Session { 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 QueryParams lastQuery = null;
public LookupCacheElement[] lookupCache = null; public LookupCacheElement[] lookupCache = null;
public int page = 1; public int page = 1;
public Map<Tool, ToolData> toolData; public Map<Tool, ToolData> toolData;
private Session(Player player) { private Session(Player player) {
toolData = new HashMap<Tool, ToolData>(); toolData = new HashMap<>();
final LogBlock logblock = LogBlock.getInstance(); final LogBlock logblock = LogBlock.getInstance();
if (player != null) { if (player != null) {
for (final Tool tool : toolsByType.values()) { for (final Tool tool : toolsByType.values()) {

View File

@ -290,8 +290,8 @@ class Updater {
int done = 0; int done = 0;
conn.setAutoCommit(false); conn.setAutoCommit(false);
Map<String, Integer> players = new HashMap<String, Integer>(); Map<String, Integer> players = new HashMap<>();
List<String> names = new ArrayList<String>(UUID_CONVERT_BATCH_SIZE); List<String> names = new ArrayList<>(UUID_CONVERT_BATCH_SIZE);
Map<String, UUID> response; Map<String, UUID> response;
rs = st.executeQuery("SELECT playerid,playername FROM `lb-players` WHERE LENGTH(UUID)=0 LIMIT " + Integer.toString(UUID_CONVERT_BATCH_SIZE)); rs = st.executeQuery("SELECT playerid,playername FROM `lb-players` WHERE LENGTH(UUID)=0 LIMIT " + Integer.toString(UUID_CONVERT_BATCH_SIZE));
while (rs.next()) { while (rs.next()) {

View File

@ -147,7 +147,7 @@ public class WorldEditor implements Runnable {
@Override @Override
public synchronized void run() { public synchronized void run() {
final List<WorldEditorException> errorList = new ArrayList<WorldEditorException>(); final List<WorldEditorException> errorList = new ArrayList<>();
int counter = 0; int counter = 0;
float size = edits.size(); float size = edits.size();
while (!edits.isEmpty() && counter < 100) { while (!edits.isEmpty() && counter < 100) {
@ -337,6 +337,7 @@ public class WorldEditor implements Runnable {
return date; return date;
} }
@Override
public PerformResult perform() throws WorldEditorException { public PerformResult perform() throws WorldEditorException {
BlockData replacedBlock = getBlockReplaced(); BlockData replacedBlock = getBlockReplaced();
BlockData setBlock = getBlockSet(); BlockData setBlock = getBlockSet();

View File

@ -85,8 +85,9 @@ public class BlockStateCodecSign implements BlockStateCodec {
if (conf != null) { if (conf != null) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (String line : conf.getStringList("lines")) { for (String line : conf.getStringList("lines")) {
if (sb.length() > 0) if (sb.length() > 0) {
sb.append(" "); sb.append(" ");
}
sb.append("[").append(line).append("]"); sb.append("[").append(line).append("]");
} }
return sb.toString(); return sb.toString();

View File

@ -65,9 +65,9 @@ public class Config {
public static void load(LogBlock logblock) throws DataFormatException, IOException { public static void load(LogBlock logblock) throws DataFormatException, IOException {
final ConfigurationSection config = logblock.getConfig(); 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()); def.put("version", logblock.getDescription().getVersion());
final List<String> worldNames = new ArrayList<String>(); final List<String> worldNames = new ArrayList<>();
for (final World world : getWorlds()) { for (final World world : getWorlds()) {
worldNames.add(world.getName()); worldNames.add(world.getName());
} }
@ -91,7 +91,7 @@ public class Config {
def.put("consumer.queueWarningSize", 1000); def.put("consumer.queueWarningSize", 1000);
def.put("clearlog.dumpDeletedLog", false); def.put("clearlog.dumpDeletedLog", false);
def.put("clearlog.enableAutoClearLog", false); def.put("clearlog.enableAutoClearLog", false);
final List<String> autoClearlog = new ArrayList<String>(); final List<String> autoClearlog = new ArrayList<>();
for (final String world : worldNames) { for (final String world : worldNames) {
autoClearlog.add("world \"" + world + "\" before 365 days all"); autoClearlog.add("world \"" + world + "\" before 365 days all");
autoClearlog.add("world \"" + world + "\" player lavaflow waterflow leavesdecay before 7 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'"); 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); logEnvironmentalKills = config.getBoolean("logging.logEnvironmentalKills", false);
hiddenPlayers = new HashSet<String>(); hiddenPlayers = new HashSet<>();
for (final String playerName : config.getStringList("logging.hiddenPlayers")) { for (final String playerName : config.getStringList("logging.hiddenPlayers")) {
hiddenPlayers.add(playerName.toLowerCase().trim()); hiddenPlayers.add(playerName.toLowerCase().trim());
} }
hiddenBlocks = new HashSet<Material>(); hiddenBlocks = new HashSet<>();
for (final String blocktype : config.getStringList("logging.hiddenBlocks")) { for (final String blocktype : config.getStringList("logging.hiddenBlocks")) {
final Material mat = Material.matchMaterial(blocktype); final Material mat = Material.matchMaterial(blocktype);
if (mat != null) { if (mat != null) {
@ -202,11 +202,11 @@ public class Config {
throw new DataFormatException("Not a valid material in hiddenBlocks: '" + blocktype + "'"); throw new DataFormatException("Not a valid material in hiddenBlocks: '" + blocktype + "'");
} }
} }
ignoredChat = new ArrayList<String>(); ignoredChat = new ArrayList<>();
for (String chatCommand : config.getStringList("logging.ignoredChat")) { for (String chatCommand : config.getStringList("logging.ignoredChat")) {
ignoredChat.add(chatCommand.toLowerCase()); ignoredChat.add(chatCommand.toLowerCase());
} }
dontRollback = new HashSet<Material>(); dontRollback = new HashSet<>();
for (String e : config.getStringList("rollback.dontRollback")) { for (String e : config.getStringList("rollback.dontRollback")) {
Material mat = Material.matchMaterial(e); Material mat = Material.matchMaterial(e);
if (mat != null) { if (mat != null) {
@ -215,7 +215,7 @@ public class Config {
throw new DataFormatException("Not a valid material in dontRollback: '" + e + "'"); throw new DataFormatException("Not a valid material in dontRollback: '" + e + "'");
} }
} }
replaceAnyway = new HashSet<Material>(); replaceAnyway = new HashSet<>();
for (String e : config.getStringList("rollback.replaceAnyway")) { for (String e : config.getStringList("rollback.replaceAnyway")) {
Material mat = Material.matchMaterial(e); Material mat = Material.matchMaterial(e);
if (mat != null) { if (mat != null) {
@ -239,7 +239,7 @@ public class Config {
safetyIdCheck = config.getBoolean("safety.id.check", true); safetyIdCheck = config.getBoolean("safety.id.check", true);
debug = config.getBoolean("debug", false); debug = config.getBoolean("debug", false);
banPermission = config.getString("questioner.banPermission"); banPermission = config.getString("questioner.banPermission");
final List<Tool> tools = new ArrayList<Tool>(); final List<Tool> tools = new ArrayList<>();
final ConfigurationSection toolsSec = config.getConfigurationSection("tools"); final ConfigurationSection toolsSec = config.getConfigurationSection("tools");
for (final String toolName : toolsSec.getKeys(false)) { for (final String toolName : toolsSec.getKeys(false)) {
try { try {
@ -262,8 +262,8 @@ public class Config {
getLogger().log(Level.WARNING, "Error at parsing tool '" + toolName + "': ", ex); getLogger().log(Level.WARNING, "Error at parsing tool '" + toolName + "': ", ex);
} }
} }
toolsByName = new HashMap<String, Tool>(); toolsByName = new HashMap<>();
toolsByType = new HashMap<Material, Tool>(); toolsByType = new HashMap<>();
for (final Tool tool : tools) { for (final Tool tool : tools) {
toolsByType.put(tool.item, tool); toolsByType.put(tool.item, tool);
toolsByName.put(tool.name.toLowerCase(), tool); toolsByName.put(tool.name.toLowerCase(), tool);
@ -272,7 +272,7 @@ public class Config {
} }
} }
final List<String> loggedWorlds = config.getStringList("loggedWorlds"); final List<String> loggedWorlds = config.getStringList("loggedWorlds");
worldConfigs = new HashMap<String, WorldConfig>(); worldConfigs = new HashMap<>();
if (loggedWorlds.isEmpty()) { if (loggedWorlds.isEmpty()) {
throw new DataFormatException("No worlds configured"); throw new DataFormatException("No worlds configured");
} }

View File

@ -38,7 +38,7 @@ public class WorldConfig extends LoggingEnabledMapping {
public WorldConfig(String world, File file) throws IOException { public WorldConfig(String world, File file) throws IOException {
this.world = world; 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 // "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 // They _can_ contain spaces, but replace them as well
def.put("table", "lb-" + file.getName().substring(0, file.getName().length() - 4).replaceAll("[ ./\\\\]", "_")); def.put("table", "lb-" + file.getName().substring(0, file.getName().length() - 4).replaceAll("[ ./\\\\]", "_"));

View File

@ -19,9 +19,7 @@ public class BlockChangePreLogEvent extends PreLogEvent {
private YamlConfiguration stateBefore; private YamlConfiguration stateBefore;
private YamlConfiguration stateAfter; private YamlConfiguration stateAfter;
public BlockChangePreLogEvent(Actor owner, Location location, BlockData typeBefore, BlockData typeAfter, public BlockChangePreLogEvent(Actor owner, Location location, BlockData typeBefore, BlockData typeAfter, YamlConfiguration stateBefore, YamlConfiguration stateAfter, ChestAccess chestAccess) {
YamlConfiguration stateBefore, YamlConfiguration stateAfter, ChestAccess chestAccess) {
super(owner); super(owner);
this.location = location; this.location = location;
this.typeBefore = typeBefore; this.typeBefore = typeBefore;
@ -32,17 +30,14 @@ public class BlockChangePreLogEvent extends PreLogEvent {
} }
public Location getLocation() { public Location getLocation() {
return location; return location;
} }
public void setLocation(Location location) { public void setLocation(Location location) {
this.location = location; this.location = location;
} }
public BlockData getTypeBefore() { public BlockData getTypeBefore() {
return typeBefore; return typeBefore;
} }
@ -54,7 +49,6 @@ public class BlockChangePreLogEvent extends PreLogEvent {
} }
public BlockData getTypeAfter() { public BlockData getTypeAfter() {
return typeAfter; return typeAfter;
} }
@ -82,22 +76,19 @@ public class BlockChangePreLogEvent extends PreLogEvent {
} }
public ChestAccess getChestAccess() { public ChestAccess getChestAccess() {
return chestAccess; return chestAccess;
} }
public void setChestAccess(ChestAccess chestAccess) { public void setChestAccess(ChestAccess chestAccess) {
this.chestAccess = chestAccess; this.chestAccess = chestAccess;
} }
@Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
return handlers; return handlers;
} }
} }

View File

@ -10,7 +10,6 @@ public abstract class PreLogEvent extends Event implements Cancellable {
protected Actor owner; protected Actor owner;
public PreLogEvent(Actor owner) { public PreLogEvent(Actor owner) {
this.owner = owner; this.owner = owner;
} }
@ -21,8 +20,8 @@ public abstract class PreLogEvent extends Event implements Cancellable {
* @deprecated {@link #getOwnerActor() } returns an object encapsulating * @deprecated {@link #getOwnerActor() } returns an object encapsulating
* name and uuid. Names are not guaranteed to be unique. * name and uuid. Names are not guaranteed to be unique.
*/ */
@Deprecated
public String getOwner() { public String getOwner() {
return owner.getName(); 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 * @param owner The player/monster/cause who is involved in this event
*/ */
public void setOwner(Actor owner) { public void setOwner(Actor owner) {
this.owner = owner; this.owner = owner;
} }
@Override
public boolean isCancelled() { public boolean isCancelled() {
return cancelled; return cancelled;
} }
@Override
public void setCancelled(boolean cancelled) { public void setCancelled(boolean cancelled) {
this.cancelled = cancelled; this.cancelled = cancelled;
} }
} }

View File

@ -39,7 +39,7 @@ public class BlockBurnLogging extends LoggingListener {
Actor actor = new Actor("Fire", Config.logFireSpreadAsPlayerWhoCreatedIt ? event.getIgnitingBlock() : null); Actor actor = new Actor("Fire", Config.logFireSpreadAsPlayerWhoCreatedIt ? event.getIgnitingBlock() : null);
if (event.getCause() == IgniteCause.FLINT_AND_STEEL) { if (event.getCause() == IgniteCause.FLINT_AND_STEEL) {
if (event.getIgnitingEntity() != null) { if (event.getIgnitingEntity() != null) {
return; // handled in block place return; // handled in block place
} else { } else {
actor = new Actor("Dispenser"); actor = new Actor("Dispenser");
} }

View File

@ -22,7 +22,7 @@ import static de.diddiz.LogBlock.config.Config.isLogging;
import static de.diddiz.util.BukkitUtils.*; import static de.diddiz.util.BukkitUtils.*;
public class ChestAccessLogging extends LoggingListener { 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) { public ChestAccessLogging(LogBlock lb) {
super(lb); super(lb);

View File

@ -15,7 +15,7 @@ import de.diddiz.LogBlock.LogBlock;
public class Questioner { public class Questioner {
private final LogBlock logBlock; 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) { public Questioner(LogBlock logBlock) {
this.logBlock = logBlock; this.logBlock = logBlock;
@ -42,6 +42,7 @@ public class Questioner {
} }
private class QuestionsReaper implements Runnable { private class QuestionsReaper implements Runnable {
@Override
public void run() { public void run() {
if (questions.isEmpty()) { if (questions.isEmpty()) {
return; return;

View File

@ -158,14 +158,14 @@ public class BukkitUtils {
doublePlants.add(Material.SUNFLOWER); doublePlants.add(Material.SUNFLOWER);
doublePlants.add(Material.PEONY); doublePlants.add(Material.PEONY);
blockEquivalents = new HashSet<Set<Integer>>(7); blockEquivalents = new HashSet<>(7);
blockEquivalents.add(new HashSet<Integer>(Arrays.asList(2, 3, 60))); blockEquivalents.add(new HashSet<>(Arrays.asList(2, 3, 60)));
blockEquivalents.add(new HashSet<Integer>(Arrays.asList(8, 9, 79))); blockEquivalents.add(new HashSet<>(Arrays.asList(8, 9, 79)));
blockEquivalents.add(new HashSet<Integer>(Arrays.asList(10, 11))); blockEquivalents.add(new HashSet<>(Arrays.asList(10, 11)));
blockEquivalents.add(new HashSet<Integer>(Arrays.asList(61, 62))); blockEquivalents.add(new HashSet<>(Arrays.asList(61, 62)));
blockEquivalents.add(new HashSet<Integer>(Arrays.asList(73, 74))); blockEquivalents.add(new HashSet<>(Arrays.asList(73, 74)));
blockEquivalents.add(new HashSet<Integer>(Arrays.asList(75, 76))); blockEquivalents.add(new HashSet<>(Arrays.asList(75, 76)));
blockEquivalents.add(new HashSet<Integer>(Arrays.asList(93, 94))); blockEquivalents.add(new HashSet<>(Arrays.asList(93, 94)));
// Blocks that break when they are attached to a block // Blocks that break when they are attached to a block
relativeBreakable = EnumSet.noneOf(Material.class); relativeBreakable = EnumSet.noneOf(Material.class);
@ -332,7 +332,7 @@ public class BukkitUtils {
// containerBlocks.add(Material.ENDER_CHEST); // containerBlocks.add(Material.ENDER_CHEST);
// It doesn't seem like you could injure people with some of these, but they exist, so.... // 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.ARROW, Material.ARROW);
projectileItems.put(EntityType.EGG, Material.EGG); projectileItems.put(EntityType.EGG, Material.EGG);
projectileItems.put(EntityType.ENDER_PEARL, Material.ENDER_PEARL); 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 * @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) { 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) { for (BlockFace blockFace : relativeBlockFaces) {
if (type.contains(block.getRelative(blockFace).getType())) { if (type.contains(block.getRelative(blockFace).getType())) {
blocks.add(block.getRelative(blockFace).getLocation()); blocks.add(block.getRelative(blockFace).getLocation());
@ -478,7 +478,7 @@ public class BukkitUtils {
} }
public static ItemStack[] compareInventories(ItemStack[] items1, ItemStack[] items2) { 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) { for (ItemStack current : items2) {
diff.add(new ItemStack(current)); diff.add(new ItemStack(current));
} }
@ -506,7 +506,7 @@ public class BukkitUtils {
} }
public static ItemStack[] compressInventory(ItemStack[] items) { public static ItemStack[] compressInventory(ItemStack[] items) {
final ArrayList<ItemStack> compressed = new ArrayList<ItemStack>(); final ArrayList<ItemStack> compressed = new ArrayList<>();
for (final ItemStack item : items) { for (final ItemStack item : items) {
if (item != null) { if (item != null) {
boolean found = false; boolean found = false;

View File

@ -1,6 +1,6 @@
package de.diddiz.util; 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 // 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. * Generic implementation of version comparison.
* *
* <p>Features: * <p>Features:
* <ul> * <ul>
* <li>mixing of '<code>-</code>' (dash) and '<code>.</code>' (dot) separators,</li> * <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); this.value = new BigInteger(str);
} }
@Override
public int getType() { public int getType() {
return INTEGER_ITEM; return INTEGER_ITEM;
} }
@Override
public boolean isNull() { public boolean isNull() {
return BIG_INTEGER_ZERO.equals(value); return BIG_INTEGER_ZERO.equals(value);
} }
@Override
public int compareTo(Item item) { public int compareTo(Item item) {
if (item == null) { if (item == null) {
return BIG_INTEGER_ZERO.equals(value) ? 0 : 1; // 1.0 == 1, 1.1 > 1 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() { public String toString() {
return value.toString(); return value.toString();
} }
@ -172,10 +176,12 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
this.value = ALIASES.getProperty(value, value); this.value = ALIASES.getProperty(value, value);
} }
@Override
public int getType() { public int getType() {
return STRING_ITEM; return STRING_ITEM;
} }
@Override
public boolean isNull() { public boolean isNull() {
return (comparableQualifier(value).compareTo(RELEASE_VERSION_INDEX) == 0); 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); return i == -1 ? (_QUALIFIERS.size() + "-" + qualifier) : String.valueOf(i);
} }
@Override
public int compareTo(Item item) { public int compareTo(Item item) {
if (item == null) { if (item == null) {
// 1-rc < 1, 1-ga > 1 // 1-rc < 1, 1-ga > 1
@ -218,6 +225,7 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
} }
} }
@Override
public String toString() { public String toString() {
return value; return value;
} }
@ -230,10 +238,12 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
private static class ListItem extends ArrayList<Item> implements Item { private static class ListItem extends ArrayList<Item> implements Item {
private static final long serialVersionUID = 5914575811857700009L; private static final long serialVersionUID = 5914575811857700009L;
@Override
public int getType() { public int getType() {
return LIST_ITEM; return LIST_ITEM;
} }
@Override
public boolean isNull() { public boolean isNull() {
return (size() == 0); return (size() == 0);
} }
@ -249,6 +259,7 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
} }
} }
@Override
public int compareTo(Item item) { public int compareTo(Item item) {
if (item == null) { if (item == null) {
if (size() == 0) { if (size() == 0) {
@ -287,6 +298,7 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
} }
} }
@Override
public String toString() { public String toString() {
StringBuilder buffer = new StringBuilder("("); StringBuilder buffer = new StringBuilder("(");
for (Iterator<Item> iter = iterator(); iter.hasNext();) { for (Iterator<Item> iter = iterator(); iter.hasNext();) {
@ -313,7 +325,7 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
ListItem list = items; ListItem list = items;
Stack<Item> stack = new Stack<Item>(); Stack<Item> stack = new Stack<>();
stack.push(list); stack.push(list);
boolean isDigit = false; boolean isDigit = false;
@ -382,6 +394,7 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
return isDigit ? new IntegerItem(buf) : new StringItem(buf, false); return isDigit ? new IntegerItem(buf) : new StringItem(buf, false);
} }
@Override
public int compareTo(ComparableVersion o) { public int compareTo(ComparableVersion o) {
return items.compareTo(o.items); return items.compareTo(o.items);
} }
@ -390,6 +403,7 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
return compareTo(new ComparableVersion(version)); return compareTo(new ComparableVersion(version));
} }
@Override
public String toString() { public String toString() {
return value; return value;
} }
@ -398,10 +412,12 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
return canonical; return canonical;
} }
@Override
public boolean equals(Object o) { public boolean equals(Object o) {
return (o instanceof ComparableVersion) && canonical.equals(((ComparableVersion) o).canonical); return (o instanceof ComparableVersion) && canonical.equals(((ComparableVersion) o).canonical);
} }
@Override
public int hashCode() { public int hashCode() {
return canonical.hashCode(); return canonical.hashCode();
} }

View File

@ -22,7 +22,7 @@ public class UUIDFetcher {
private static final JSONParser jsonParser = new JSONParser(); private static final JSONParser jsonParser = new JSONParser();
public static Map<String, UUID> getUUIDs(List<String> names) throws Exception { 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(); HttpURLConnection connection = createConnection();
String body = JSONArray.toJSONString(names); String body = JSONArray.toJSONString(names);
writeBody(connection, body); writeBody(connection, body);

View File

@ -181,7 +181,7 @@ public class Utils {
* @return A new list with the quoted arguments parsed to single values * @return A new list with the quoted arguments parsed to single values
*/ */
public static List<String> parseQuotes(List<String> args) { 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()]), " "); String subjectString = join(args.toArray(new String[args.size()]), " ");
Pattern regex = Pattern.compile("[^\\s\"']+|\"[^\"]*\"|'[^']*'"); Pattern regex = Pattern.compile("[^\\s\"']+|\"[^\"]*\"|'[^']*'");