diff --git a/build.gradle b/build.gradle index 1f90aa8..67c1d63 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,3 @@ - apply from: project.file("gradle/versions.gradle") buildscript { diff --git a/gradle/foxcore.gradle b/gradle/foxcore.gradle index 34332e0..572c652 100644 --- a/gradle/foxcore.gradle +++ b/gradle/foxcore.gradle @@ -11,7 +11,7 @@ buildscript { apply plugin: 'com.github.johnrengelman.shadow' -publishing{ +publishing { publications { library(MavenPublication) { from components.java @@ -36,8 +36,8 @@ publishing{ } } -if(System.env.TRAVIS && !Boolean.valueOf(System.env.TRAVIS_PULL_REQUEST)){ - if(System.env.TRAVIS_TAG){ +if (System.env.TRAVIS && !Boolean.valueOf(System.env.TRAVIS_PULL_REQUEST)) { + if (System.env.TRAVIS_TAG) { travisPublish.dependsOn 'publishLibraryPublicationToFDSReleasesRepository' } else { travisPublish.dependsOn 'publishLibraryPublicationToFDSSnapshotsRepository' diff --git a/gradle/publish.gradle b/gradle/publish.gradle index cdbade0..9ac4456 100644 --- a/gradle/publish.gradle +++ b/gradle/publish.gradle @@ -29,6 +29,6 @@ publishing { } } -task travisPublish{ +task travisPublish { group = 'publishing' } \ No newline at end of file diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/common/util/FCCUtil.java b/src/main/java/net/foxdenstudio/sponge/foxcore/common/util/FCCUtil.java index 8dd5b9d..35f1579 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/common/util/FCCUtil.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/common/util/FCCUtil.java @@ -28,15 +28,15 @@ import com.flowpowered.math.vector.Vector3f; import org.spongepowered.api.command.CommandException; import org.spongepowered.api.text.Text; -import org.spongepowered.api.text.format.TextColor; import java.util.Arrays; import java.util.regex.Pattern; -import static org.spongepowered.api.text.format.TextColors.*; - public final class FCCUtil { + public static final String[] colorNames = {"black", "darkblue", "darkgreen", "darkaqua", "darkred", "darkpurple", "gold", "gray", + "darkgray", "blue", "green", "aqua", "red", "lightpurple", "yellow", "white"}; + public static double parseCoordinate(double sPos, String arg) throws NumberFormatException { if (arg.equals("~")) { return sPos; @@ -138,9 +138,6 @@ public static FCPattern parseUserRegex(String regex) throws CommandException { } else throw new CommandException(Text.of("Regex missing a second slash!")); } - public static final String[] colorNames = {"black", "darkblue", "darkgreen", "darkaqua", "darkred", "darkpurple", "gold", "gray", - "darkgray", "blue", "green", "aqua", "red", "lightpurple", "yellow", "white"}; - public static int colorCodeFromName(String name) { for (int i = 0; i < colorNames.length; i++) { if (colorNames[i].equalsIgnoreCase(name)) return i; @@ -152,6 +149,10 @@ public static boolean checkPermissionString(String permission) { return permission.matches("[a-zA-Z0-9\\-_.]") && !permission.matches("^.*\\.\\..*$") && !permission.startsWith(".") && !permission.endsWith("."); } + public static String toCapitalCase(String str) { + return str.substring(0, 1).toUpperCase() + str.substring(1).toLowerCase(); + } + public static class FCPattern { public Pattern pattern; public boolean matchAny; @@ -167,8 +168,4 @@ public boolean matches(String string) { } } - public static String toCapitalCase(String str){ - return str.substring(0,1).toUpperCase() + str.substring(1).toLowerCase(); - } - } diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/mod/FCClientNetworkManager.java b/src/main/java/net/foxdenstudio/sponge/foxcore/mod/FCClientNetworkManager.java index ffbe63f..edf0762 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/mod/FCClientNetworkManager.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/mod/FCClientNetworkManager.java @@ -47,13 +47,12 @@ public class FCClientNetworkManager { private static FCClientNetworkManager instance; - - private FMLEmbeddedChannel fmlEmbeddedChannel; - private final Map clientChannels = new HashMap<>(); - private final Map clientPacketIDMapping = new HashMap<>(); public final Map serverChannelMapping = new HashMap<>(); public final Map serverPacketMapping = new HashMap<>(); + private final Map clientChannels = new HashMap<>(); + private final Map clientPacketIDMapping = new HashMap<>(); public boolean hasServer = false; + private FMLEmbeddedChannel fmlEmbeddedChannel; private int nextAvailableChannelIndex = 1; private int nextAvailablePacketIndex = 0; private boolean locked = false; diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/mod/FoxCoreClientMain.java b/src/main/java/net/foxdenstudio/sponge/foxcore/mod/FoxCoreClientMain.java index e2943d7..e36d5f2 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/mod/FoxCoreClientMain.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/mod/FoxCoreClientMain.java @@ -71,6 +71,7 @@ public void preInit(FMLPreInitializationEvent event) { public void load(FMLInitializationEvent event) { logger.info("Registering event handlers"); MinecraftForge.EVENT_BUS.register(renderHandler = new RenderHandler(Minecraft.getMinecraft())); + //MinecraftForge.EVENT_BUS.register(new GuiRenderListener()); //MinecraftForge.EVENT_BUS.register(RenderManager.instance()); MinecraftForge.EVENT_BUS.register(this); logger.info("Registering MinecraftForge networking channels"); diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/mod/render/HighlightList.java b/src/main/java/net/foxdenstudio/sponge/foxcore/mod/render/HighlightList.java index 5be7da0..8ea866d 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/mod/render/HighlightList.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/mod/render/HighlightList.java @@ -29,7 +29,6 @@ import net.minecraft.client.Minecraft; import java.util.ArrayList; -import java.util.Collections; import java.util.ConcurrentModificationException; import static org.lwjgl.opengl.GL11.*; diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/gui/GuiRenderListener.java b/src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/gui/GuiRenderListener.java new file mode 100644 index 0000000..eaad869 --- /dev/null +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/gui/GuiRenderListener.java @@ -0,0 +1,46 @@ +package net.foxdenstudio.sponge.foxcore.mod.rendernew.gui; + +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import static org.lwjgl.opengl.GL11.*; + +/** + * Created by Fox on 12/20/2016. + */ +public class GuiRenderListener { + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void render(RenderGameOverlayEvent.Post event) { + if (event.getType() != RenderGameOverlayEvent.ElementType.ALL) return; + glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT); + glPushMatrix(); + + glColor3f(1, 1, 1); + + + glBegin(GL_QUADS); + + glTexCoord2d(0, 0); + glVertex2d(0, 0); + + glTexCoord2d(0, 1); + glVertex2d(0, 500); + + glTexCoord2d(1, 1); + glVertex2d(500, 500); + + glTexCoord2d(1, 0); + glVertex2d(500, 0); + + glEnd(); + + glPopMatrix(); + glPopAttrib(); + } + + +} diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/world/RenderList.java b/src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/world/RenderList.java index 76190e2..4a321cd 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/world/RenderList.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/world/RenderList.java @@ -12,7 +12,7 @@ public class RenderList extends ArrayList { public void sortZ(double x, double y, double z) { try { - for(Geometry geo : this){ + for (Geometry geo : this) { geo.distance = geo.position.distanceSquared(x, y, z); } this.sort((o1, o2) -> o1.distance > o2.distance ? -1 : (o1.distance < o2.distance ? 1 : 0)); diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/world/RenderManager.java b/src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/world/RenderManager.java index 1b7d11c..fd65036 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/world/RenderManager.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/world/RenderManager.java @@ -26,7 +26,7 @@ private RenderManager(Minecraft mc) { this.mc = mc; this.list = new RenderList(); - list.addAll(new Highlight(new Vector3i(0,80,0)).getGeometry()); + list.addAll(new Highlight(new Vector3i(0, 80, 0)).getGeometry()); } public static RenderManager instance() { diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/world/geometry/Geometry.java b/src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/world/geometry/Geometry.java index 3118f4f..bde5aa0 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/world/geometry/Geometry.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/world/geometry/Geometry.java @@ -3,8 +3,6 @@ import com.flowpowered.math.vector.Vector3d; import com.flowpowered.math.vector.Vector3f; -import java.util.Vector; - /** * Created by Fox on 12/4/2016. */ @@ -18,5 +16,4 @@ public abstract class Geometry { abstract public void render(); - } diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/world/geometry/GeometryLine.java b/src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/world/geometry/GeometryLine.java index 25039fb..632fa1f 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/world/geometry/GeometryLine.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/mod/rendernew/world/geometry/GeometryLine.java @@ -14,7 +14,6 @@ public class GeometryLine extends Geometry { Vector3d localStart, localEnd; - public GeometryLine(Vector3d start, Vector3d end, Vector3f color, float opacity) { this.start = start; this.end = end; diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/FCServerNetworkManager.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/FCServerNetworkManager.java index 1115fd0..f7281fb 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/FCServerNetworkManager.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/FCServerNetworkManager.java @@ -42,12 +42,10 @@ public class FCServerNetworkManager { private static FCServerNetworkManager instance; - - private ChannelBinding.RawDataChannel rawDataChannel; - private final Map serverChannels = new HashMap<>(); private final Map serverPacketIDMapping = new HashMap<>(); private final Map playerConfigs = new HashMap<>(); + private ChannelBinding.RawDataChannel rawDataChannel; private int nextAvailableChannelIndex = 1; private int nextAvailablePacketIndex = 0; private boolean locked = false; @@ -202,9 +200,9 @@ public boolean hasClientChannel(Player player) { } public class PlayerConfig { - public boolean hasClient = false; final Map clientChannelMapping = new HashMap<>(); final Map clientPacketMapping = new HashMap<>(); + public boolean hasClient = false; } } diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/FoxCoreMain.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/FoxCoreMain.java index d23d4dc..9c00299 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/FoxCoreMain.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/FoxCoreMain.java @@ -74,8 +74,8 @@ ) public final class FoxCoreMain { + private static final UUID FOX_UUID = UUID.fromString("f275f223-1643-4fac-9fb8-44aaf5b4b371"); private static FoxCoreMain instance; - @Inject private Logger logger; @Inject @@ -87,9 +87,7 @@ public final class FoxCoreMain { private Path configDirectory; @Inject private PluginContainer container; - private FCCommandDispatcher fcDispatcher; - private FCServerNetworkManager.ServerChannel foxcoreNetworkChannel; public static FoxCoreMain instance() { @@ -215,8 +213,6 @@ public FCServerNetworkManager.ServerChannel getFoxcoreNetworkChannel() { return foxcoreNetworkChannel; } - private static final UUID FOX_UUID = UUID.fromString("f275f223-1643-4fac-9fb8-44aaf5b4b371"); - @Listener public void playerJoin(ClientConnectionEvent.Join event) { Player player = event.getTargetEntity(); diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandHUD.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandHUD.java index d06625b..e4f906b 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandHUD.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandHUD.java @@ -22,6 +22,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.stream.Stream; /** * Created by Fox on 4/14/2016. @@ -94,7 +95,7 @@ public List getSuggestions(CommandSource source, String arguments, @Null .parse(); if (parse.current.type == AdvCmdParser.CurrentElement.ElementType.ARGUMENT && parse.current.index == 0) - return ImmutableList.of("on", "off", "reset").stream() + return Stream.of("on", "off", "reset") .filter(new StartsWithPredicate(parse.current.token)) .map(args -> parse.current.prefix + args) .collect(GuavaCollectors.toImmutableList()); diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandPosition.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandPosition.java index 95b12c5..4a85954 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandPosition.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandPosition.java @@ -34,7 +34,6 @@ import org.spongepowered.api.command.CommandException; import org.spongepowered.api.command.CommandResult; import org.spongepowered.api.command.CommandSource; -import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.text.Text; import org.spongepowered.api.text.format.TextColors; import org.spongepowered.api.world.Locatable; diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandTest.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandTest.java index a780225..4c89ea7 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandTest.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandTest.java @@ -27,12 +27,10 @@ import com.google.common.collect.ImmutableList; -import net.foxdenstudio.sponge.foxcore.plugin.FoxCoreMain; import net.foxdenstudio.sponge.foxcore.plugin.command.util.AdvCmdParser; import org.spongepowered.api.command.CommandException; import org.spongepowered.api.command.CommandResult; import org.spongepowered.api.command.CommandSource; -import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.text.Text; import org.spongepowered.api.text.format.TextColors; import org.spongepowered.api.world.Location; @@ -61,7 +59,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm for (int i = 0; i < parse.args.length; i++) { builder.append(Text.of(TextColors.RESET, parse.args[i])); - if(i < parse.args.length - 1) builder.append(Text.of(TextColors.GOLD, ", ")); + if (i < parse.args.length - 1) builder.append(Text.of(TextColors.GOLD, ", ")); } builder.append(Text.of(TextColors.GOLD, "\"\n")); diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandWand.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandWand.java index e4f5eca..7eaee0f 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandWand.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandWand.java @@ -63,6 +63,7 @@ import javax.annotation.Nullable; import java.util.List; import java.util.Optional; +import java.util.stream.Stream; import static net.foxdenstudio.sponge.foxcore.plugin.util.Aliases.PLAYER_ALIASES; import static net.foxdenstudio.sponge.foxcore.plugin.util.Aliases.isIn; @@ -226,7 +227,7 @@ public List getSuggestions(CommandSource source, String arguments, @Null .map(args -> parse.current.prefix + args) .collect(GuavaCollectors.toImmutableList()); else if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.LONGFLAGKEY)) - return ImmutableList.of("player", "hand", "item").stream() + return Stream.of("player", "hand", "item") .filter(new StartsWithPredicate(parse.current.token)) .map(args -> parse.current.prefix + args) .collect(GuavaCollectors.toImmutableList()); @@ -247,7 +248,7 @@ else if (isIn(ITEM_ALIASES, parse.current.key)) { .map(args -> parse.current.prefix + args) .collect(GuavaCollectors.toImmutableList()); } else if (isIn(HAND_ALIASES, parse.current.key)) { - return ImmutableList.of("main", "off", "both").stream() + return Stream.of("main", "off", "both") .filter(new StartsWithPredicate(parse.current.token)) .map(args -> parse.current.prefix + args) .collect(GuavaCollectors.toImmutableList()); diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/FCCommandDispatcher.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/FCCommandDispatcher.java index 818c545..758028d 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/FCCommandDispatcher.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/FCCommandDispatcher.java @@ -31,7 +31,6 @@ import org.spongepowered.api.command.dispatcher.Disambiguator; import org.spongepowered.api.command.dispatcher.Dispatcher; import org.spongepowered.api.command.dispatcher.SimpleDispatcher; -import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.text.Text; import org.spongepowered.api.text.action.TextActions; import org.spongepowered.api.text.format.TextColors; diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/util/AdvCmdParser.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/util/AdvCmdParser.java index b3a373d..f3fe0ec 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/util/AdvCmdParser.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/util/AdvCmdParser.java @@ -43,8 +43,7 @@ */ public final class AdvCmdParser { - public static final FlagMapper - DEFAULT_MAPPER = map -> key -> value -> { + public static final FlagMapper DEFAULT_MAPPER = map -> key -> value -> { map.put(key, value); return true; }; @@ -159,7 +158,7 @@ public ParseResult parse() throws CommandException { List argsList = new ArrayList<>(); // Matcher for identifying arguments and flags. Matcher matcher = pattern.matcher(arguments); - boolean lastIsCurrent = !(arguments.length() == 0) && (inQuote || !arguments.substring(arguments.length() - 1).matches("[\"' ]")); + boolean lastIsCurrent = !arguments.isEmpty() && (inQuote || !arguments.substring(arguments.length() - 1).matches("[\"' ]")); // Whether or not the jump key was used. boolean jump = false; // Stores flags that were not accepted by the mapper, to be given to the final block, if it exists. @@ -216,7 +215,8 @@ public ParseResult parse() throws CommandException { // Parses result as a short flag. Limit behavior is the same as long flags // multiple letters are treated as multiple flags. Repeating letters add a second flag with a repetition // Example: "-aab" becomes flags "a", "aa", and "b" - } else if (result.startsWith("-") && result.substring(1).matches("^.*[^\\d\\.].*$") + } else if (result.startsWith("-") && (result.length() < 2 || !result.substring(1, 2).matches("[0-9.]")) + && result.substring(1).matches("^.*[^\\d.].*$") && (extractSubFlags || limit <= 0 || argsList.size() < limit || (parseLastFlags && argsList.size() <= limit && !jump))) { if (result.equals("-")) { parseResult.current = new CurrentElement(CurrentElement.ElementType.SHORTFLAG, "", 0, ""); @@ -306,7 +306,7 @@ public ParseResult parse() throws CommandException { } } } - for(String flag : extraFlags){ + for (String flag : extraFlags) { finalBlock = flag + " " + finalBlock; } diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/util/ProcessResult.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/util/ProcessResult.java index 9c5ef5c..1b47e2a 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/util/ProcessResult.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/util/ProcessResult.java @@ -36,7 +36,9 @@ public final class ProcessResult { private static final ProcessResult FAILURE = of(false); private final boolean success; - private final @Nullable Text message; + private final + @Nullable + Text message; private ProcessResult(boolean success, @Nullable Text message) { this.success = success; @@ -51,7 +53,7 @@ public static ProcessResult of(boolean success, Text message) { return new ProcessResult(success, message); } - public static ProcessResult of(boolean success, String message){ + public static ProcessResult of(boolean success, String message) { return of(success, Text.of(message)); } diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/selection/ISelection.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/selection/ISelection.java index 265dd8f..7065908 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/selection/ISelection.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/selection/ISelection.java @@ -23,7 +23,7 @@ public interface ISelection extends Iterable, IWorldBounded, IModifiab Optional bounds(); - default boolean isEmpty(){ + default boolean isEmpty() { return size() == 0; } } diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/selection/RasterSelection.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/selection/RasterSelection.java index a85640e..aeeaa48 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/selection/RasterSelection.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/selection/RasterSelection.java @@ -35,6 +35,26 @@ public RasterSelection(HashSet positions) { this.positions = positions; } + public static void main(String[] args) { + HashSet set = new HashSet<>(); + //Random random = new Random(); + System.out.println("Generating values"); + int x = 0; + for (int i = 0; i < 50000000; i++) { + set.add(new Vector3i(x++, x++, x++)); + } + RasterSelection selection = new RasterSelection(set); + System.out.println("Starting calculation"); + long start = System.currentTimeMillis(); + selection.calculateBounds(); + long end = System.currentTimeMillis(); + System.out.println("Time: " + (end - start)); + + try (DB db = DBMaker.memoryDB().make()) { + + } + } + @Override public Text overview() { return Text.EMPTY; @@ -122,26 +142,6 @@ public boolean isEmpty() { return this.positions.isEmpty(); } - public static void main(String[] args) { - HashSet set = new HashSet<>(); - //Random random = new Random(); - System.out.println("Generating values"); - int x = 0; - for (int i = 0; i < 50000000; i++) { - set.add(new Vector3i(x++, x++, x++)); - } - RasterSelection selection = new RasterSelection(set); - System.out.println("Starting calculation"); - long start = System.currentTimeMillis(); - selection.calculateBounds(); - long end = System.currentTimeMillis(); - System.out.println("Time: " + (end - start)); - - try(DB db = DBMaker.memoryDB().make()){ - - } - } - @Override public ProcessResult modify(CommandSource source, String arguments) throws CommandException { return null; diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/state/IStateField.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/state/IStateField.java index 002be12..04e0874 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/state/IStateField.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/state/IStateField.java @@ -26,15 +26,10 @@ package net.foxdenstudio.sponge.foxcore.plugin.state; import com.google.common.collect.ImmutableList; -import net.foxdenstudio.sponge.foxcore.plugin.command.util.ProcessResult; import net.foxdenstudio.sponge.foxcore.plugin.util.IModifiable; -import org.spongepowered.api.command.CommandException; import org.spongepowered.api.command.CommandSource; import org.spongepowered.api.text.Text; -import org.spongepowered.api.world.Location; -import org.spongepowered.api.world.World; -import javax.annotation.Nullable; import java.util.List; import java.util.Optional; diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/state/PositionStateField.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/state/PositionStateField.java index c371556..5237249 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/state/PositionStateField.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/state/PositionStateField.java @@ -52,6 +52,7 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; +import java.util.stream.Stream; import static net.foxdenstudio.sponge.foxcore.plugin.util.Aliases.COLOR_ALIASES; import static net.foxdenstudio.sponge.foxcore.plugin.util.Aliases.isIn; @@ -110,7 +111,7 @@ public List modifySuggestions(CommandSource source, String arguments, @N .parse(); if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) { if (parse.current.index == 0) { - return ImmutableList.of("add", "remove").stream() + return Stream.of("add", "remove") .filter(new StartsWithPredicate(parse.current.token)) .collect(GuavaCollectors.toImmutableList()); } else if (parse.current.index < 4 && parse.args[0].equals("add")) { @@ -221,7 +222,7 @@ public List addSuggestions(CommandSource source, String arguments) throw if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT) && parse.current.index < 3 && parse.current.token.isEmpty()) { return ImmutableList.of(parse.current.prefix + "~"); } else if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.LONGFLAGKEY)) - return ImmutableList.of("color").stream() + return Stream.of("color") .filter(new StartsWithPredicate(parse.current.token)) .map(args -> parse.current.prefix + args) .collect(GuavaCollectors.toImmutableList()); diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/util/FCPUtil.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/util/FCPUtil.java index 1bcaa4d..89fb6a3 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/util/FCPUtil.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/util/FCPUtil.java @@ -41,6 +41,9 @@ */ public class FCPUtil { + public static final TextColor[] colors = {BLACK, DARK_BLUE, DARK_GREEN, DARK_AQUA, DARK_RED, DARK_PURPLE, GOLD, GRAY, + DARK_GRAY, BLUE, GREEN, AQUA, RED, LIGHT_PURPLE, YELLOW, WHITE}; + public static Text readableBooleanText(boolean bool) { return bool ? Text.of(TextColors.GREEN, "True") : Text.of(TextColors.RED, "False"); } @@ -108,9 +111,6 @@ public static void updatePositions(Player player) { FoxCoreMain.instance().getFoxcoreNetworkChannel().sendPacket(player, new ServerPositionPacket(getPositions(player))); } - public static final TextColor[] colors = {BLACK, DARK_BLUE, DARK_GREEN, DARK_AQUA, DARK_RED, DARK_PURPLE, GOLD, GRAY, - DARK_GRAY, BLUE, GREEN, AQUA, RED, LIGHT_PURPLE, YELLOW, WHITE}; - public static Optional textColorFromName(String name) { int code = FCCUtil.colorCodeFromName(name); if (code >= 0) return Optional.of(colors[code]); diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/util/Position.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/util/Position.java index e7d2fde..b721345 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/util/Position.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/util/Position.java @@ -22,31 +22,31 @@ public Position(Vector2i v) { } public Position(Vector2i v, double z) { - this(v, z,Color.WHITE); + this(v, z, Color.WHITE); } public Position(Vector2i v, int z) { - this(v, z,Color.WHITE); + this(v, z, Color.WHITE); } public Position(Vector3i v) { - this(v,Color.WHITE); + this(v, Color.WHITE); } public Position(Vector4i v) { - this(v,Color.WHITE); + this(v, Color.WHITE); } public Position(VectorNi v) { - this(v,Color.WHITE); + this(v, Color.WHITE); } public Position(double x, double y, double z) { - this(x, y, z,Color.WHITE); + this(x, y, z, Color.WHITE); } public Position(int x, int y, int z) { - this(x, y, z,Color.WHITE); + this(x, y, z, Color.WHITE); } public Position(Color color) { @@ -127,16 +127,16 @@ public int hashCode() { return result; } - public enum Color{ - WHITE(TextColors.WHITE, new Vector3f(1,1,1)), - RED(TextColors.RED, new Vector3f(1,0,0)), - ORANGE(TextColors.GOLD, new Vector3f(1,0.5,0)), - YELLOW(TextColors.YELLOW, new Vector3f(1,1,0)), - GREEN(TextColors.GREEN, new Vector3f(0,1,0)), - AQUA(TextColors.AQUA, new Vector3f(0,1,1)), - BLUE(TextColors.BLUE, new Vector3f(0,0,1)), - MAGENTA(TextColors.LIGHT_PURPLE, new Vector3f(1,0,1)), - BLACK(TextColors.DARK_GRAY, new Vector3f(0,0,0)); + public enum Color { + WHITE(TextColors.WHITE, new Vector3f(1, 1, 1)), + RED(TextColors.RED, new Vector3f(1, 0, 0)), + ORANGE(TextColors.GOLD, new Vector3f(1, 0.5, 0)), + YELLOW(TextColors.YELLOW, new Vector3f(1, 1, 0)), + GREEN(TextColors.GREEN, new Vector3f(0, 1, 0)), + AQUA(TextColors.AQUA, new Vector3f(0, 1, 1)), + BLUE(TextColors.BLUE, new Vector3f(0, 0, 1)), + MAGENTA(TextColors.LIGHT_PURPLE, new Vector3f(1, 0, 1)), + BLACK(TextColors.DARK_GRAY, new Vector3f(0, 0, 0)); private static final Random random = new Random(); @@ -148,31 +148,31 @@ public enum Color{ this.rgbColor = rgbColor; } - public TextColor getTextColor() { - return textColor; - } - - public Vector3f getRgbColor() { - return rgbColor; - } - - public static Color randomColor(){ + public static Color randomColor() { Color[] values = Color.values(); return values[random.nextInt(values.length)]; } - public static Color from(int index){ + public static Color from(int index) { Color[] values = Color.values(); - if(index < 0 || index >= values.length) return null; + if (index < 0 || index >= values.length) return null; return values[index]; } - public static Color from(String name){ - for(Color color : values()){ - if(color.name().equalsIgnoreCase(name)) return color; + public static Color from(String name) { + for (Color color : values()) { + if (color.name().equalsIgnoreCase(name)) return color; } return null; } + public TextColor getTextColor() { + return textColor; + } + + public Vector3f getRgbColor() { + return rgbColor; + } + } } diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/wand/FCWandRegistry.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/wand/FCWandRegistry.java index 92ec47e..4dc5257 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/wand/FCWandRegistry.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/wand/FCWandRegistry.java @@ -42,7 +42,7 @@ public IWandFactory getBuilderFromAlias(String alias) { return null; } - public Set getTypes(){ + public Set getTypes() { return ImmutableSet.copyOf(wandBuilders.keySet()); } } diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/wand/IWand.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/wand/IWand.java index e099ccc..6bc25f9 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/wand/IWand.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/wand/IWand.java @@ -10,7 +10,6 @@ import org.spongepowered.api.text.Text; import java.util.List; -import java.util.Optional; /** * Created by Fox on 4/30/2016. diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/wand/data/ImmutableWandData.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/wand/data/ImmutableWandData.java index 990cd5c..30e10d9 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/wand/data/ImmutableWandData.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/wand/data/ImmutableWandData.java @@ -46,7 +46,7 @@ public class ImmutableWandData extends AbstractImmutableData { public WandData(IWand wand) { this.wand = wand; - if(wand == null) { + if (wand == null) { type = ""; } else { type = wand.type(); @@ -67,7 +67,7 @@ public WandData() { this(null); } - WandData(IWand wand, int id, String type){ + WandData(IWand wand, int id, String type) { this.wand = wand; this.id = id; this.type = type; diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/wand/data/WandKeys.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/wand/data/WandKeys.java index fd77db1..edef6a7 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/wand/data/WandKeys.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/wand/data/WandKeys.java @@ -36,14 +36,16 @@ public class WandKeys { public static final Key> TYPE = KeyFactory.makeSingleKey( TypeToken.of(String.class), - new TypeToken>() {}, + new TypeToken>() { + }, DataQuery.of("type"), "foxcore:wandtype", "Wand Type"); public static final Key> ID = KeyFactory.makeSingleKey( TypeToken.of(Integer.class), - new TypeToken>() {}, + new TypeToken>() { + }, DataQuery.of("id"), "foxcore:wandID", "Wand ID" @@ -51,7 +53,8 @@ public class WandKeys { public static final Key> WAND = KeyFactory.makeSingleKey( TypeToken.of(IWand.class), - new TypeToken>() {}, + new TypeToken>() { + }, DataQuery.of("wand"), "foxcore:wanddata", "Wand Data" diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/wand/types/PositionWand.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/wand/types/PositionWand.java index 0ab8c61..a6ea8eb 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/wand/types/PositionWand.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/wand/types/PositionWand.java @@ -119,8 +119,8 @@ public List getLore() { return ImmutableList.of(getItemName(), getColorText()); } - private Text getColorText(){ - if(rainbow){ + private Text getColorText() { + if (rainbow) { return Text.of("Color: ", RED, "R", GOLD, "a", diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index d23fd7f..f73b486 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -1,19 +1,21 @@ [ -{ -"modid": "foxcorecui", -"name": "FoxCore Client User Interface", -"description": "Client mod for working with FoxCore selections", -"version": "", -"credits": "Written by gravityfox", -"logoFile": "", -"mcversion": "", -"url": "", -"updateUrl": "", -"authors": [ "gravityfox" ], -"parent":"", -"screenshots": [], -"dependencies": [ -"mod_MinecraftForge" -] -} + { + "modid": "foxcorecui", + "name": "FoxCore Client User Interface", + "description": "Client mod for working with FoxCore selections", + "version": "", + "credits": "Written by gravityfox", + "logoFile": "", + "mcversion": "", + "url": "", + "updateUrl": "", + "authors": [ + "gravityfox" + ], + "parent": "", + "screenshots": [], + "dependencies": [ + "mod_MinecraftForge" + ] + } ] \ No newline at end of file