Skip to content

Commit

Permalink
I made some minor changes.
Browse files Browse the repository at this point in the history
And then IDEA reformatted my code.
  • Loading branch information
gravityfox committed Dec 21, 2016
1 parent 30c8dd1 commit b563c94
Show file tree
Hide file tree
Showing 34 changed files with 170 additions and 139 deletions.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

apply from: project.file("gradle/versions.gradle")

buildscript {
Expand Down
6 changes: 3 additions & 3 deletions gradle/foxcore.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {

apply plugin: 'com.github.johnrengelman.shadow'

publishing{
publishing {
publications {
library(MavenPublication) {
from components.java
Expand All @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion gradle/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ publishing {
}
}

task travisPublish{
task travisPublish {
group = 'publishing'
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,12 @@
public class FCClientNetworkManager {

private static FCClientNetworkManager instance;

private FMLEmbeddedChannel fmlEmbeddedChannel;
private final Map<String, ClientChannel> clientChannels = new HashMap<>();
private final Map<String, Integer> clientPacketIDMapping = new HashMap<>();
public final Map<Integer, String> serverChannelMapping = new HashMap<>();
public final Map<Integer, String> serverPacketMapping = new HashMap<>();
private final Map<String, ClientChannel> clientChannels = new HashMap<>();
private final Map<String, Integer> clientPacketIDMapping = new HashMap<>();
public boolean hasServer = false;
private FMLEmbeddedChannel fmlEmbeddedChannel;
private int nextAvailableChannelIndex = 1;
private int nextAvailablePacketIndex = 0;
private boolean locked = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class RenderList extends ArrayList<Geometry> {

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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -18,5 +16,4 @@ public abstract class Geometry {
abstract public void render();



}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@
public class FCServerNetworkManager {

private static FCServerNetworkManager instance;

private ChannelBinding.RawDataChannel rawDataChannel;

private final Map<String, ServerChannel> serverChannels = new HashMap<>();
private final Map<String, Integer> serverPacketIDMapping = new HashMap<>();
private final Map<Player, PlayerConfig> playerConfigs = new HashMap<>();
private ChannelBinding.RawDataChannel rawDataChannel;
private int nextAvailableChannelIndex = 1;
private int nextAvailablePacketIndex = 0;
private boolean locked = false;
Expand Down Expand Up @@ -202,9 +200,9 @@ public boolean hasClientChannel(Player player) {
}

public class PlayerConfig {
public boolean hasClient = false;
final Map<Integer, String> clientChannelMapping = new HashMap<>();
final Map<Integer, String> clientPacketMapping = new HashMap<>();
public boolean hasClient = false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() {
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -94,7 +95,7 @@ public List<String> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -226,7 +227,7 @@ public List<String> 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());
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -159,7 +158,7 @@ public ParseResult parse() throws CommandException {
List<String> 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.
Expand Down Expand Up @@ -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, "");
Expand Down Expand Up @@ -306,7 +306,7 @@ public ParseResult parse() throws CommandException {
}
}
}
for(String flag : extraFlags){
for (String flag : extraFlags) {
finalBlock = flag + " " + finalBlock;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
}

Expand Down
Loading

0 comments on commit b563c94

Please sign in to comment.