diff options
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/handlers/CrystalWaypoints.java')
-rw-r--r-- | src/main/java/com/thatgravyboat/skyblockhud/handlers/CrystalWaypoints.java | 98 |
1 files changed, 51 insertions, 47 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/CrystalWaypoints.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/CrystalWaypoints.java index cd016e6..079e108 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/CrystalWaypoints.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/CrystalWaypoints.java @@ -6,6 +6,9 @@ import com.thatgravyboat.skyblockhud.api.events.LocationChangeEvent; import com.thatgravyboat.skyblockhud.commands.SimpleCommand; import com.thatgravyboat.skyblockhud.location.LocationCategory; import com.thatgravyboat.skyblockhud.location.LocationHandler; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.command.ICommandSender; import net.minecraft.util.BlockPos; @@ -14,28 +17,26 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; - public class CrystalWaypoints { public static final HashMap<String, BlockPos> waypoints = new HashMap<>(); @SubscribeEvent public void onRenderLast(RenderWorldLastEvent event) { - waypoints.forEach((text, pos) -> { - GlStateManager.disableCull(); - GlStateManager.disableDepth(); - Utils.renderWaypointText(text, pos,event.partialTicks); - }); + waypoints.forEach( + (text, pos) -> { + GlStateManager.disableCull(); + GlStateManager.disableDepth(); + Utils.renderWaypointText(text, pos, event.partialTicks); + } + ); GlStateManager.enableCull(); GlStateManager.enableDepth(); } @SubscribeEvent public void onLocationChange(LocationChangeEvent event) { - if (!event.newLocation.getCategory().equals(LocationCategory.CRYSTALHOLLOWS)){ + if (!event.newLocation.getCategory().equals(LocationCategory.CRYSTALHOLLOWS)) { waypoints.clear(); } } @@ -43,48 +44,51 @@ public class CrystalWaypoints { public static class WaypointCommand extends SimpleCommand { public WaypointCommand() { - super("sbhpoints", new ProcessCommandRunnable() { - @Override - public void processCommand(ICommandSender sender, String[] args) { - String subCommand = args[0].toLowerCase(); - String name = String.join(" ", Arrays.copyOfRange(args, 1, args.length)); - switch (subCommand) { - case "add": - if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.CRYSTALHOLLOWS)){ - if (!CrystalWaypoints.waypoints.containsKey(name)){ - CrystalWaypoints.waypoints.put(name, sender.getPosition().add(0.5,0.5,0.5)); - }else { - sender.addChatMessage(new ChatComponentText("[" + EnumChatFormatting.RED + EnumChatFormatting.BOLD + "SkyBlockHud" + EnumChatFormatting.RESET + "] : " + EnumChatFormatting.GRAY + "Waypoint already exists!")); + super( + "sbhpoints", + new ProcessCommandRunnable() { + @Override + public void processCommand(ICommandSender sender, String[] args) { + String subCommand = args[0].toLowerCase(); + String name = String.join(" ", Arrays.copyOfRange(args, 1, args.length)); + switch (subCommand) { + case "add": + if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.CRYSTALHOLLOWS)) { + if (!CrystalWaypoints.waypoints.containsKey(name)) { + CrystalWaypoints.waypoints.put(name, sender.getPosition().add(0.5, 0.5, 0.5)); + } else { + sender.addChatMessage(new ChatComponentText("[" + EnumChatFormatting.RED + EnumChatFormatting.BOLD + "SkyBlockHud" + EnumChatFormatting.RESET + "] : " + EnumChatFormatting.GRAY + "Waypoint already exists!")); + } } - } - break; - case "remove": - if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.CRYSTALHOLLOWS)){ - if (CrystalWaypoints.waypoints.containsKey(name)){ - CrystalWaypoints.waypoints.remove(name); - }else { - sender.addChatMessage(new ChatComponentText("[" + EnumChatFormatting.RED + EnumChatFormatting.BOLD + "SkyBlockHud" + EnumChatFormatting.RESET + "] : " + EnumChatFormatting.GRAY + "Waypoint doesnt exist!")); + break; + case "remove": + if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.CRYSTALHOLLOWS)) { + if (CrystalWaypoints.waypoints.containsKey(name)) { + CrystalWaypoints.waypoints.remove(name); + } else { + sender.addChatMessage(new ChatComponentText("[" + EnumChatFormatting.RED + EnumChatFormatting.BOLD + "SkyBlockHud" + EnumChatFormatting.RESET + "] : " + EnumChatFormatting.GRAY + "Waypoint doesnt exist!")); + } } - } - break; - case "clear": - CrystalWaypoints.waypoints.clear(); - break; + break; + case "clear": + CrystalWaypoints.waypoints.clear(); + break; + } } - } - }, new TabCompleteRunnable() { - @Override - public List<String> tabComplete(ICommandSender sender, String[] args, BlockPos pos) { - if (args.length == 2 && args[0].equalsIgnoreCase("remove")) { - return getListOfStringsMatchingLastWord(args, waypoints.keySet()); + }, + new TabCompleteRunnable() { + @Override + public List<String> tabComplete(ICommandSender sender, String[] args, BlockPos pos) { + if (args.length == 2 && args[0].equalsIgnoreCase("remove")) { + return getListOfStringsMatchingLastWord(args, waypoints.keySet()); + } + if (args.length == 1) { + return getListOfStringsMatchingLastWord(args, Lists.newArrayList("add", "clear", "remove")); + } + return null; } - if (args.length == 1) { - return getListOfStringsMatchingLastWord(args, Lists.newArrayList("add", "clear", "remove")); - } - return null; } - }); + ); } - } } |