From a0eb7ce59ecd873035600518485bbebca2790a10 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Tue, 28 May 2019 23:23:51 -0400 Subject: [PATCH] Typo Fixes and Added Annotations --- build.gradle | 5 ++ .../fawe/bukkit/util/BukkitTaskMan.java | 34 ++++----- .../java/com/boydti/fawe/config/Config.java | 2 +- .../fawe/example/DefaultFaweQueueMap.java | 2 +- .../boydti/fawe/example/IFaweQueueMap.java | 2 +- .../boydti/fawe/example/MappedFaweQueue.java | 2 +- .../boydti/fawe/example/WeakFaweQueueMap.java | 2 +- .../boydti/fawe/jnbt/anvil/MCAQueueMap.java | 4 +- .../boydti/fawe/object/brush/TargetMode.java | 2 +- .../fawe/object/collection/SparseBitSet.java | 4 +- .../com/boydti/fawe/util/ReflectionUtils.java | 16 ++--- .../com/boydti/fawe/util/TaskManager.java | 69 +++++++++---------- .../worldedit/command/tool/BrushTool.java | 2 +- 13 files changed, 71 insertions(+), 75 deletions(-) diff --git a/build.gradle b/build.gradle index 2d42f2d6a..a86e153a6 100644 --- a/build.gradle +++ b/build.gradle @@ -108,6 +108,10 @@ subprojects { build.dependsOn(sourcesJar) } + dependencies { + compileOnly 'org.jetbrains:annotations:17.0.0' + } + shadowJar { classifier 'dist' dependencies { @@ -116,6 +120,7 @@ subprojects { include(dependency('com.sk89q.lib:jlibnoise:1.0.0')) include(dependency('com.github.luben:zstd-jni:1.1.1')) include(dependency('co.aikar:fastutil-lite:1.0')) + include(dependency('org.jetbrains:annotations:17.0.0')) } exclude 'GradleStart**' exclude '.cache' diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitTaskMan.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitTaskMan.java index 12de1f9ec..37d8722ba 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitTaskMan.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitTaskMan.java @@ -4,6 +4,7 @@ import com.boydti.fawe.util.TaskManager; import org.apache.commons.lang.mutable.MutableInt; import org.bukkit.Bukkit; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; public class BukkitTaskMan extends TaskManager { @@ -14,44 +15,35 @@ public class BukkitTaskMan extends TaskManager { } @Override - public int repeat(final Runnable r, final int interval) { - return this.plugin.getServer().getScheduler().scheduleSyncRepeatingTask(this.plugin, r, interval, interval); + public int repeat(@NotNull final Runnable runnable, final int interval) { + return this.plugin.getServer().getScheduler().scheduleSyncRepeatingTask(this.plugin, runnable, interval, interval); } @Override - public int repeatAsync(final Runnable r, final int interval) { - return this.plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(this.plugin, r, interval, interval); + public int repeatAsync(@NotNull final Runnable runnable, final int interval) { + return this.plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(this.plugin, runnable, interval, interval); } public MutableInt index = new MutableInt(0); @Override - public void async(final Runnable r) { - if (r == null) { - return; - } - this.plugin.getServer().getScheduler().runTaskAsynchronously(this.plugin, r).getTaskId(); + public void async(@NotNull final Runnable runnable) { + this.plugin.getServer().getScheduler().runTaskAsynchronously(this.plugin, runnable).getTaskId(); } @Override - public void task(final Runnable r) { - if (r == null) { - return; - } - this.plugin.getServer().getScheduler().runTask(this.plugin, r).getTaskId(); + public void task(@NotNull final Runnable runnable) { + this.plugin.getServer().getScheduler().runTask(this.plugin, runnable).getTaskId(); } @Override - public void later(final Runnable r, final int delay) { - if (r == null) { - return; - } - this.plugin.getServer().getScheduler().runTaskLater(this.plugin, r, delay).getTaskId(); + public void later(@NotNull final Runnable runnable, final int delay) { + this.plugin.getServer().getScheduler().runTaskLater(this.plugin, runnable, delay).getTaskId(); } @Override - public void laterAsync(final Runnable r, final int delay) { - this.plugin.getServer().getScheduler().runTaskLaterAsynchronously(this.plugin, r, delay); + public void laterAsync(@NotNull final Runnable runnable, final int delay) { + this.plugin.getServer().getScheduler().runTaskLaterAsynchronously(this.plugin, runnable, delay); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/config/Config.java b/worldedit-core/src/main/java/com/boydti/fawe/config/Config.java index c16ebc848..49b68709b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/config/Config.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/config/Config.java @@ -441,7 +441,7 @@ public class Config { } /** - * Set some field to be accesible + * Set some field to be accessible * * @param field * @throws NoSuchFieldException diff --git a/worldedit-core/src/main/java/com/boydti/fawe/example/DefaultFaweQueueMap.java b/worldedit-core/src/main/java/com/boydti/fawe/example/DefaultFaweQueueMap.java index 5e1536ec7..08cb86e52 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/example/DefaultFaweQueueMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/example/DefaultFaweQueueMap.java @@ -45,7 +45,7 @@ public class DefaultFaweQueueMap implements IFaweQueueMap { }; @Override - public Collection getFaweCunks() { + public Collection getFaweChunks() { synchronized (blocks) { return new HashSet<>(blocks.values()); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/example/IFaweQueueMap.java b/worldedit-core/src/main/java/com/boydti/fawe/example/IFaweQueueMap.java index 6633b075c..2f2bbaa38 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/example/IFaweQueueMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/example/IFaweQueueMap.java @@ -6,7 +6,7 @@ import java.util.Collection; public interface IFaweQueueMap { - Collection getFaweCunks(); + Collection getFaweChunks(); void forEachChunk(RunnableVal onEach); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/example/MappedFaweQueue.java b/worldedit-core/src/main/java/com/boydti/fawe/example/MappedFaweQueue.java index 2c88f5900..85d2ba46b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/example/MappedFaweQueue.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/example/MappedFaweQueue.java @@ -102,7 +102,7 @@ public abstract class MappedFaweQueue impl @Override public Collection getFaweChunks() { - return map.getFaweCunks(); + return map.getFaweChunks(); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/example/WeakFaweQueueMap.java b/worldedit-core/src/main/java/com/boydti/fawe/example/WeakFaweQueueMap.java index 681745ec4..0f2b4f808 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/example/WeakFaweQueueMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/example/WeakFaweQueueMap.java @@ -48,7 +48,7 @@ public class WeakFaweQueueMap implements IFaweQueueMap { }; @Override - public Collection getFaweCunks() { + public Collection getFaweChunks() { HashSet set = new HashSet<>(); synchronized (blocks) { Iterator>> iter = blocks.entrySet().iterator(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAQueueMap.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAQueueMap.java index e2dab560e..15449f8be 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAQueueMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAQueueMap.java @@ -80,7 +80,7 @@ public class MCAQueueMap implements IFaweQueueMap { } @Override - public Collection getFaweCunks() { + public Collection getFaweChunks() { final List chunks = new ArrayList<>(); for (Map.Entry entry : mcaFileMap.entrySet()) { MCAFile file = entry.getValue(); @@ -93,7 +93,7 @@ public class MCAQueueMap implements IFaweQueueMap { @Override public void forEachChunk(RunnableVal onEach) { - for (FaweChunk chunk : getFaweCunks()) { + for (FaweChunk chunk : getFaweChunks()) { onEach.run(chunk); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/TargetMode.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/TargetMode.java index 84a3547e2..98b04a3c8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/TargetMode.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/TargetMode.java @@ -2,7 +2,7 @@ package com.boydti.fawe.object.brush; public enum TargetMode { TARGET_BLOCK_RANGE, - FOWARD_POINT_PITCH, + FORWARD_POINT_PITCH, TARGET_POINT_HEIGHT, TARGET_FACE_RANGE, } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SparseBitSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SparseBitSet.java index a2ccec249..91935f821 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SparseBitSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SparseBitSet.java @@ -94,7 +94,7 @@ public final class SparseBitSet implements Cloneable, Serializable { bits (setting, flipping, clearing, etc.) do not attempt to normalize the set, in the interests of speed. However, when a set is scanned as the resultant set of some operation, then, in most cases, the set will be - normalized--the exception being level2 areas that are not completly scanned + normalized--the exception being level2 areas that are not completely scanned in a particular pass. The sizes of the blocks and areas has been the result of some investigation @@ -2797,4 +2797,4 @@ public final class SparseBitSet implements Cloneable, Serializable { * Word and block xor strategy. */ protected transient XorStrategy xorStrategy; -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/ReflectionUtils.java b/worldedit-core/src/main/java/com/boydti/fawe/util/ReflectionUtils.java index 32f09ba84..05f51b8fc 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/ReflectionUtils.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/ReflectionUtils.java @@ -63,8 +63,8 @@ public class ReflectionUtils { T newValue = (T) makeEnum(enumType, // The target enum class enumName, // THE NEW ENUM INSTANCE TO BE DYNAMICALLY ADDED values.size(), - additionalTypes, // can be used to pass values to the enum constuctor - additionalValues); // can be used to pass values to the enum constuctor + additionalTypes, // can be used to pass values to the enum constructor + additionalValues); // can be used to pass values to the enum constructor // 4. add new value values.add(newValue); @@ -219,9 +219,9 @@ public class ReflectionUtils { } //Utils - public static Method makeMethod(final Class clazz, final String methodName, final Class... paramaters) { + public static Method makeMethod(final Class clazz, final String methodName, final Class... parameters) { try { - return clazz.getDeclaredMethod(methodName, paramaters); + return clazz.getDeclaredMethod(methodName, parameters); } catch (final NoSuchMethodException ex) { return null; } catch (final Exception ex) { @@ -230,13 +230,13 @@ public class ReflectionUtils { } @SuppressWarnings("unchecked") - public static T callMethod(final Method method, final Object instance, final Object... paramaters) { + public static T callMethod(final Method method, final Object instance, final Object... parameters) { if (method == null) { throw new RuntimeException("No such method"); } method.setAccessible(true); try { - return (T) method.invoke(instance, paramaters); + return (T) method.invoke(instance, parameters); } catch (final InvocationTargetException ex) { throw new RuntimeException(ex.getCause()); } catch (final Exception ex) { @@ -245,9 +245,9 @@ public class ReflectionUtils { } @SuppressWarnings("unchecked") - public static Constructor makeConstructor(final Class clazz, final Class... paramaterTypes) { + public static Constructor makeConstructor(final Class clazz, final Class... parameterTypes) { try { - return (Constructor) clazz.getConstructor(paramaterTypes); + return (Constructor) clazz.getConstructor(parameterTypes); } catch (final NoSuchMethodException ex) { return null; } catch (final Exception ex) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java b/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java index 793f18b51..368853e91 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java @@ -4,6 +4,8 @@ import com.boydti.fawe.Fawe; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.object.RunnableVal; +import org.jetbrains.annotations.NotNull; + import java.util.Collection; import java.util.Iterator; import java.util.concurrent.ForkJoinPool; @@ -21,34 +23,34 @@ public abstract class TaskManager { /** * Run a repeating task on the main thread * - * @param r + * @param runnable * @param interval in ticks * @return */ - public abstract int repeat(final Runnable r, final int interval); + public abstract int repeat(@NotNull final Runnable runnable, final int interval); /** * Run a repeating task asynchronously * - * @param r + * @param runnable * @param interval in ticks * @return */ - public abstract int repeatAsync(final Runnable r, final int interval); + public abstract int repeatAsync(@NotNull final Runnable runnable, final int interval); /** * Run a task asynchronously * - * @param r + * @param runnable */ - public abstract void async(final Runnable r); + public abstract void async(@NotNull final Runnable runnable); /** * Run a task on the main thread * - * @param r + * @param runnable */ - public abstract void task(final Runnable r); + public abstract void task(@NotNull final Runnable runnable); /** * Get the public ForkJoinPool
@@ -149,14 +151,14 @@ public abstract class TaskManager { * Run a task on the current thread or asynchronously * - If it's already the main thread, it will jst call run() * - * @param r + * @param runnable * @param async */ - public void taskNow(final Runnable r, boolean async) { + public void taskNow(@NotNull final Runnable runnable, boolean async) { if (async) { - async(r); - } else if (r != null) { - r.run(); + async(runnable); + } else { + runnable.run(); } } @@ -164,40 +166,37 @@ public abstract class TaskManager { * Run a task as soon as possible on the main thread * - Non blocking if not calling from the main thread * - * @param r + * @param runnable */ - public void taskNowMain(final Runnable r) { - if (r == null) { - return; - } + public void taskNowMain(@NotNull final Runnable runnable) { if (Fawe.isMainThread()) { - r.run(); + runnable.run(); } else { - task(r); + task(runnable); } } /** * Run a task as soon as possible not on the main thread * - * @param r + * @param runnable * @see com.boydti.fawe.Fawe#isMainThread() */ - public void taskNowAsync(final Runnable r) { - taskNow(r, Fawe.isMainThread()); + public void taskNowAsync(@NotNull final Runnable runnable) { + taskNow(runnable, Fawe.isMainThread()); } /** * Run a task on the main thread at the next tick or now async * - * @param r + * @param runnable * @param async */ - public void taskSoonMain(final Runnable r, boolean async) { + public void taskSoonMain(@NotNull final Runnable runnable, boolean async) { if (async) { - async(r); + async(runnable); } else { - task(r); + task(runnable); } } @@ -205,18 +204,18 @@ public abstract class TaskManager { /** * Run a task later on the main thread * - * @param r + * @param runnable * @param delay in ticks */ - public abstract void later(final Runnable r, final int delay); + public abstract void later(@NotNull final Runnable runnable, final int delay); /** * Run a task later asynchronously * - * @param r + * @param runnable * @param delay in ticks */ - public abstract void laterAsync(final Runnable r, final int delay); + public abstract void laterAsync(@NotNull final Runnable runnable, final int delay); /** * Cancel a task @@ -295,11 +294,11 @@ public abstract class TaskManager { } } - public T syncWhenFree(final RunnableVal function) { + public T syncWhenFree(@NotNull final RunnableVal function) { return syncWhenFree(function, Integer.MAX_VALUE); } - public void taskWhenFree(Runnable run) { + public void taskWhenFree(@NotNull Runnable run) { if (Fawe.isMainThread()) { run.run(); } else { @@ -317,7 +316,7 @@ public abstract class TaskManager { * @param * @return */ - public T syncWhenFree(final RunnableVal function, int timeout) { + public T syncWhenFree(@NotNull final RunnableVal function, int timeout) { if (Fawe.isMainThread()) { function.run(); return function.value; @@ -366,7 +365,7 @@ public abstract class TaskManager { * @param * @return */ - public T sync(final RunnableVal function, int timeout) { + public T sync(@NotNull final RunnableVal function, int timeout) { return sync((Supplier) function, timeout); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java index 269d9b7b5..5e5274b90 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java @@ -382,7 +382,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool switch (targetMode) { case TARGET_BLOCK_RANGE: return offset(trace(editSession, player, getRange(), true), loc).toBlockPoint(); - case FOWARD_POINT_PITCH: { + case FORWARD_POINT_PITCH: { int d = 0; float pitch = loc.getPitch(); pitch = 23 - (pitch / 4);