Add additional checkstyle checks

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot
2020-01-24 17:37:30 +11:00
parent 78e6909f8c
commit 0c53c95293
35 changed files with 227 additions and 202 deletions

View File

@@ -218,9 +218,9 @@ public enum ChatColor {
char[] b = textToTranslate.toCharArray();
for (int i = 0; i < b.length - 1; i++) {
if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i+1]) > -1) {
if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i + 1]) > -1) {
b[i] = ChatColor.COLOR_CHAR;
b[i+1] = Character.toLowerCase(b[i+1]);
b[i + 1] = Character.toLowerCase(b[i + 1]);
}
}
return new String(b);

View File

@@ -263,5 +263,5 @@ public enum Effect {
/**
* Represents the type of an effect.
*/
public enum Type {SOUND, VISUAL}
public enum Type { SOUND, VISUAL }
}

View File

@@ -38,7 +38,7 @@ public @interface Warning {
*/
DEFAULT;
private static final Map<String, WarningState> values = ImmutableMap.<String,WarningState>builder()
private static final Map<String, WarningState> values = ImmutableMap.<String, WarningState>builder()
.put("off", OFF)
.put("false", OFF)
.put("f", OFF)

View File

@@ -29,7 +29,7 @@ public class HelpCommand extends BukkitCommand {
super("help");
this.description = "Shows the help menu";
this.usageMessage = "/help <pageNumber>\n/help <topic>\n/help <topic> <pageNumber>";
this.setAliases(Arrays.asList(new String[] { "?" }));
this.setAliases(Arrays.asList(new String[]{"?"}));
this.setPermission("bukkit.command.help");
}

View File

@@ -31,7 +31,7 @@ public class TimingsCommand extends BukkitCommand {
@Override
public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) {
if (!testPermission(sender)) return true;
if (args.length != 1) {
if (args.length != 1) {
sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
return false;
}
@@ -73,8 +73,9 @@ public class TimingsCommand extends BukkitCommand {
if (separate) {
fileNames.println(pluginIdx + " " + plugin.getDescription().getFullName());
fileTimings.println("Plugin " + pluginIdx);
} else {
fileTimings.println(plugin.getDescription().getFullName());
}
else fileTimings.println(plugin.getDescription().getFullName());
for (RegisteredListener listener : HandlerList.getRegisteredListeners(plugin)) {
if (listener instanceof TimedRegisteredListener) {
TimedRegisteredListener trl = (TimedRegisteredListener) listener;

View File

@@ -826,10 +826,10 @@ public class MemorySection implements ConfigurationSection {
}
protected boolean isPrimitiveWrapper(@Nullable Object input) {
return input instanceof Integer || input instanceof Boolean ||
input instanceof Character || input instanceof Byte ||
input instanceof Short || input instanceof Double ||
input instanceof Long || input instanceof Float;
return input instanceof Integer || input instanceof Boolean
|| input instanceof Character || input instanceof Byte
|| input instanceof Short || input instanceof Double
|| input instanceof Long || input instanceof Float;
}
@Nullable

View File

@@ -17,7 +17,7 @@ public abstract class BooleanPrompt extends ValidatingPrompt {
@Override
protected boolean isInputValid(@NotNull ConversationContext context, @NotNull String input) {
String[] accepted = {/* Apache values: */"true", "false", "on", "off", "yes", "no",/* Additional values: */ "y", "n", "1", "0", "right", "wrong", "correct", "incorrect", "valid", "invalid"};
String[] accepted = {/* Apache values: */ "true", "false", "on", "off", "yes", "no", /* Additional values: */ "y", "n", "1", "0", "right", "wrong", "correct", "incorrect", "valid", "invalid"};
return ArrayUtils.contains(accepted, input.toLowerCase());
}

View File

@@ -3,4 +3,4 @@ package org.bukkit.entity;
/**
* Represents a trader Llama.
*/
public interface TraderLlama extends Llama { }
public interface TraderLlama extends Llama { }

View File

@@ -23,7 +23,7 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable {
private final ItemStack item;
private int level;
private boolean cancelled;
private final Map<Enchantment,Integer> enchants;
private final Map<Enchantment, Integer> enchants;
private final Player enchanter;
private final int button;

View File

@@ -9,7 +9,7 @@ import org.jetbrains.annotations.Nullable;
* Called when an Entity targets a {@link LivingEntity} and can only target
* LivingEntity's.
*/
public class EntityTargetLivingEntityEvent extends EntityTargetEvent{
public class EntityTargetLivingEntityEvent extends EntityTargetEvent {
public EntityTargetLivingEntityEvent(@NotNull final Entity entity, @Nullable final LivingEntity target, @Nullable final TargetReason reason) {
super(entity, target, reason);
}

View File

@@ -71,6 +71,6 @@ public class PlayerLeashEntityEvent extends Event implements Cancellable {
@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
this.cancelled = cancel;
}
}

View File

@@ -25,11 +25,11 @@ public enum InventoryType {
* A chest inventory, with 0, 9, 18, 27, 36, 45, or 54 slots of type
* CONTAINER.
*/
CHEST(27,"Chest"),
CHEST(27, "Chest"),
/**
* A dispenser inventory, with 9 slots of type CONTAINER.
*/
DISPENSER(9,"Dispenser"),
DISPENSER(9, "Dispenser"),
/**
* A dropper inventory, with 9 slots of type CONTAINER.
*/
@@ -38,45 +38,45 @@ public enum InventoryType {
* A furnace inventory, with a RESULT slot, a CRAFTING slot, and a FUEL
* slot.
*/
FURNACE(3,"Furnace"),
FURNACE(3, "Furnace"),
/**
* A workbench inventory, with 9 CRAFTING slots and a RESULT slot.
*/
WORKBENCH(10,"Crafting"),
WORKBENCH(10, "Crafting"),
/**
* A player's crafting inventory, with 4 CRAFTING slots and a RESULT slot.
* Also implies that the 4 ARMOR slots are accessible.
*/
CRAFTING(5,"Crafting", false),
CRAFTING(5, "Crafting", false),
/**
* An enchantment table inventory, with two CRAFTING slots and three
* enchanting buttons.
*/
ENCHANTING(2,"Enchanting"),
ENCHANTING(2, "Enchanting"),
/**
* A brewing stand inventory, with one FUEL slot and four CRAFTING slots.
*/
BREWING(5,"Brewing"),
BREWING(5, "Brewing"),
/**
* A player's inventory, with 9 QUICKBAR slots, 27 CONTAINER slots, 4 ARMOR
* slots and 1 offhand slot. The ARMOR and offhand slots may not be visible
* to the player, though.
*/
PLAYER(41,"Player"),
PLAYER(41, "Player"),
/**
* The creative mode inventory, with only 9 QUICKBAR slots and nothing
* else. (The actual creative interface with the items is client-side and
* cannot be altered by the server.)
*/
CREATIVE(9,"Creative", false),
CREATIVE(9, "Creative", false),
/**
* The merchant inventory, with 2 CRAFTING slots, and 1 RESULT slot.
*/
MERCHANT(3,"Villager", false),
MERCHANT(3, "Villager", false),
/**
* The ender chest inventory, with 27 slots.
*/
ENDER_CHEST(27,"Ender Chest"),
ENDER_CHEST(27, "Ender Chest"),
/**
* An anvil inventory, with 2 CRAFTING slots and 1 RESULT slot
*/

View File

@@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
* alternative for thread safe implementations.
*/
@Deprecated
@Warning(reason="Listening to this event forces chat to wait for the main thread, delaying chat messages.")
@Warning(reason = "Listening to this event forces chat to wait for the main thread, delaying chat messages.")
public class PlayerChatEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel = false;

View File

@@ -70,7 +70,7 @@ public class PlayerEggThrowEvent extends PlayerEvent {
* @param hatchType The type of the mob being hatched by the egg
*/
public void setHatchingType(@NotNull EntityType hatchType) {
if(!hatchType.isSpawnable()) throw new IllegalArgumentException("Can't spawn that entity type from an egg!");
if (!hatchType.isSpawnable()) throw new IllegalArgumentException("Can't spawn that entity type from an egg!");
this.hatchType = hatchType;
}

View File

@@ -15,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
* asynchronous.
*/
@Deprecated
@Warning(reason="This event causes a login thread to synchronize with the main thread")
@Warning(reason = "This event causes a login thread to synchronize with the main thread")
public class PlayerPreLoginEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private Result result;

View File

@@ -329,13 +329,13 @@ public abstract class InventoryView {
public final InventoryType.SlotType getSlotType(int slot) {
InventoryType.SlotType type = InventoryType.SlotType.CONTAINER;
if (slot >= 0 && slot < this.getTopInventory().getSize()) {
switch(this.getType()) {
switch (this.getType()) {
case BLAST_FURNACE:
case FURNACE:
case SMOKER:
if (slot == 2) {
type = InventoryType.SlotType.RESULT;
} else if(slot == 1) {
} else if (slot == 1) {
type = InventoryType.SlotType.FUEL;
} else {
type = InventoryType.SlotType.CRAFTING;

View File

@@ -9,6 +9,7 @@ public class MinecraftFont extends MapFont {
private static final int spaceSize = 2;
// CHECKSTYLE:OFF
private static final String fontChars =
" !\"#$%&'()*+,-./0123456789:;<=>?" +
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" +
@@ -278,6 +279,7 @@ public class MinecraftFont extends MapFont {
/* 254 */ {0,0,60,60,60,60,0,0},
/* 255 */ {0,0,0,0,0,0,0,0},
};
// CHECKSTYLE:ON
/**
* A static non-malleable MinecraftFont.

View File

@@ -49,7 +49,7 @@ import org.yaml.snakeyaml.error.YAMLException;
*/
public final class JavaPluginLoader implements PluginLoader {
final Server server;
private final Pattern[] fileFilters = new Pattern[] { Pattern.compile("\\.jar$"), };
private final Pattern[] fileFilters = new Pattern[]{Pattern.compile("\\.jar$")};
private final Map<String, Class<?>> classes = new ConcurrentHashMap<String, Class<?>>();
private final List<PluginClassLoader> loaders = new CopyOnWriteArrayList<PluginClassLoader>();
@@ -288,8 +288,7 @@ public final class JavaPluginLoader implements PluginLoader {
plugin.getLogger().log(
Level.WARNING,
String.format(
"\"%s\" has registered a listener for %s on method \"%s\", but the event is Deprecated." +
" \"%s\"; please notify the authors %s.",
"\"%s\" has registered a listener for %s on method \"%s\", but the event is Deprecated. \"%s\"; please notify the authors %s.",
plugin.getDescription().getFullName(),
clazz.getName(),
method.toGenericString(),

View File

@@ -58,7 +58,7 @@ public abstract class BukkitRunnable implements Runnable {
* @see BukkitScheduler#runTaskAsynchronously(Plugin, Runnable)
*/
@NotNull
public synchronized BukkitTask runTaskAsynchronously(@NotNull Plugin plugin) throws IllegalArgumentException, IllegalStateException {
public synchronized BukkitTask runTaskAsynchronously(@NotNull Plugin plugin) throws IllegalArgumentException, IllegalStateException {
checkNotYetScheduled();
return setupTask(Bukkit.getScheduler().runTaskAsynchronously(plugin, (Runnable) this));
}
@@ -74,7 +74,7 @@ public abstract class BukkitRunnable implements Runnable {
* @see BukkitScheduler#runTaskLater(Plugin, Runnable, long)
*/
@NotNull
public synchronized BukkitTask runTaskLater(@NotNull Plugin plugin, long delay) throws IllegalArgumentException, IllegalStateException {
public synchronized BukkitTask runTaskLater(@NotNull Plugin plugin, long delay) throws IllegalArgumentException, IllegalStateException {
checkNotYetScheduled();
return setupTask(Bukkit.getScheduler().runTaskLater(plugin, (Runnable) this, delay));
}
@@ -94,7 +94,7 @@ public abstract class BukkitRunnable implements Runnable {
* @see BukkitScheduler#runTaskLaterAsynchronously(Plugin, Runnable, long)
*/
@NotNull
public synchronized BukkitTask runTaskLaterAsynchronously(@NotNull Plugin plugin, long delay) throws IllegalArgumentException, IllegalStateException {
public synchronized BukkitTask runTaskLaterAsynchronously(@NotNull Plugin plugin, long delay) throws IllegalArgumentException, IllegalStateException {
checkNotYetScheduled();
return setupTask(Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, (Runnable) this, delay));
}
@@ -112,7 +112,7 @@ public abstract class BukkitRunnable implements Runnable {
* @see BukkitScheduler#runTaskTimer(Plugin, Runnable, long, long)
*/
@NotNull
public synchronized BukkitTask runTaskTimer(@NotNull Plugin plugin, long delay, long period) throws IllegalArgumentException, IllegalStateException {
public synchronized BukkitTask runTaskTimer(@NotNull Plugin plugin, long delay, long period) throws IllegalArgumentException, IllegalStateException {
checkNotYetScheduled();
return setupTask(Bukkit.getScheduler().runTaskTimer(plugin, (Runnable) this, delay, period));
}
@@ -135,7 +135,7 @@ public abstract class BukkitRunnable implements Runnable {
* long)
*/
@NotNull
public synchronized BukkitTask runTaskTimerAsynchronously(@NotNull Plugin plugin, long delay, long period) throws IllegalArgumentException, IllegalStateException {
public synchronized BukkitTask runTaskTimerAsynchronously(@NotNull Plugin plugin, long delay, long period) throws IllegalArgumentException, IllegalStateException {
checkNotYetScheduled();
return setupTask(Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, (Runnable) this, delay, period));
}

View File

@@ -4,7 +4,7 @@ package org.bukkit.util.noise;
* Base class for all noise generators
*/
public abstract class NoiseGenerator {
protected final int[] perm= new int[512];
protected final int[] perm = new int[512];
protected double offsetX;
protected double offsetY;
protected double offsetZ;

View File

@@ -1,3 +1,4 @@
// CHECKSTYLE:OFF
package org.bukkit.util.noise;
import java.util.Random;