diff options
Diffstat (limited to 'src/main')
31 files changed, 491 insertions, 208 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/Config.java b/src/main/java/kr/syeyoung/dungeonsguide/Config.java deleted file mode 100644 index eec433f9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/Config.java +++ /dev/null @@ -1,59 +0,0 @@ -package kr.syeyoung.dungeonsguide; - -import net.minecraftforge.common.config.Configuration; -import net.minecraftforge.common.config.Property; - -public class Config { - public static Configuration configuration; - - public static final String CATEGORY_ADVANCED = "Advanced"; - public static final String CATEGORY_PUZZLE_SOLVER = "Solver"; - public static final String CATEGORY_QOL = "Tooltips"; - - public static boolean DEBUG = true; - - public static boolean solver_riddle; - public static boolean solver_kahoot; - public static boolean solver_blaze; - public static boolean solver_tictactoe; - public static boolean solver_icepath; - public static boolean solver_icesilverfish; - public static boolean solver_waterpuzzle; - public static boolean solver_box; - public static boolean solver_creeper; - public static boolean solver_teleport; - - - public static boolean itemtooltip_dungeonstat; - public static boolean itemtooltip_price; - - public static void syncConfig(boolean load) { // Gets called from preInit - try { - // Load config - if (load) - configuration.load(); - - // Read props from config - solver_riddle = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "riddle", "true", "Riddle puzzle solver", Property.Type.BOOLEAN).getBoolean(); - solver_kahoot = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "kahoot", "true", "Omnicrescent puzzle solver", Property.Type.BOOLEAN).getBoolean(); - solver_teleport = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "teleport", "true", "Teleport puzzle solver", Property.Type.BOOLEAN).getBoolean(); - solver_creeper = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "creeper", "true", "Creeper puzzle solver", Property.Type.BOOLEAN).getBoolean(); - solver_blaze = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "blaze", "true", "Blaze puzzle solver", Property.Type.BOOLEAN).getBoolean(); - solver_tictactoe = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "tictactoe", "true", "Tictactoe puzzle solver", Property.Type.BOOLEAN).getBoolean(); - solver_icepath = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "icepath", "true", "Icepath puzzle solver", Property.Type.BOOLEAN).getBoolean(); - solver_icesilverfish = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "silverfish", "true", "Silverfish puzzle solver", Property.Type.BOOLEAN).getBoolean(); - solver_waterpuzzle = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "water", "true", "Water puzzle solver", Property.Type.BOOLEAN).getBoolean(); - solver_box = configuration.get(Config.CATEGORY_PUZZLE_SOLVER, "box", "true", "Box puzzle solver", Property.Type.BOOLEAN).getBoolean(); - - itemtooltip_dungeonstat = configuration.get(Config.CATEGORY_QOL, "dungeonstat", "true", "Show what floor dungeon item was obtained", Property.Type.BOOLEAN).getBoolean(); - itemtooltip_price = configuration.get(Config.CATEGORY_QOL, "price", "true", "Show prices of any item", Property.Type.BOOLEAN).getBoolean(); - - DEBUG = configuration.get(Config.CATEGORY_ADVANCED, "debug","false", "Enable debug mode", Property.Type.BOOLEAN).getBoolean(); // Comment - } catch (Exception e) { - // Failed reading/writing, just continue - } finally { - // Save props to config IF config changed - if (configuration.hasChanged()) configuration.save(); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/a.java b/src/main/java/kr/syeyoung/dungeonsguide/a.java index 23875cb7..2ce0e96c 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/a.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/a.java @@ -40,77 +40,77 @@ public class a d.init(a); } -// @EventHandler -// public void a(FMLPreInitializationEvent a) { -// b b = new b(); -// String c = null; -// try { -// c = b.b(); -// if (c != null) { -// this.a = this; -// URL.setURLStreamHandlerFactory(new c(b)); -// LaunchClassLoader d = (LaunchClassLoader) a.class.getClassLoader(); -// d.addURL(new URL("z:///")); -// -// try { -// this.d = new e(b); -// this.d.pre(a); -// } catch (Exception e) { -// e.printStackTrace(); -// -// a(new String[]{ -// "Couldn't load Dungeons Guide", -// "Please contact developer if this problem persists after restart" -// }); -// } -// return; -// } -// } catch (IOException e) { -// e.printStackTrace(); -// } catch (AuthenticationException e) { -// e.printStackTrace(); -// } catch (NoSuchAlgorithmException e) { -// e.printStackTrace(); -// } catch (NoSuchPaddingException e) { -// e.printStackTrace(); -// } catch (InvalidKeyException e) { -// e.printStackTrace(); -// } catch (InvalidAlgorithmParameterException e) { -// e.printStackTrace(); -// } catch (IllegalBlockSizeException e) { -// e.printStackTrace(); -// } catch (BadPaddingException e) { -// e.printStackTrace(); -// } catch (CertificateException e) { -// e.printStackTrace(); -// } catch (KeyStoreException e) { -// e.printStackTrace(); -// } catch (KeyManagementException e) { -// e.printStackTrace(); -// } -// -// a(new String[]{ -// "Can't validate current installation of Dungeons Guide", -// "Steps to fix", -// "1. check if other people can't join minecraft servers.", -// "2. restart minecraft launcher", -// "3. make sure you're on the right account", -// "4. restart your computer", -// "If the problem persists after following these steps, please contact developer", -// "If you haven't purchased the mod, please consider doing so" -// }); -// } @EventHandler - public void pre(FMLPreInitializationEvent event) { - a = this; - URL.setURLStreamHandlerFactory(new c(null)); + public void a(FMLPreInitializationEvent a) { + b b = new b(); + String c = null; + try { + c = b.b(); + if (c != null) { + this.a = this; + URL.setURLStreamHandlerFactory(new c(b)); + LaunchClassLoader d = (LaunchClassLoader) a.class.getClassLoader(); + d.addURL(new URL("z:///")); + try { - d = new e(null); - d.pre(event); + this.d = new e(b); + this.d.pre(a); } catch (Exception e) { e.printStackTrace(); + + a(new String[]{ + "Couldn't load Dungeons Guide", + "Please contact developer if this problem persists after restart" + }); } + return; + } + } catch (IOException e) { + e.printStackTrace(); + } catch (AuthenticationException e) { + e.printStackTrace(); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } catch (NoSuchPaddingException e) { + e.printStackTrace(); + } catch (InvalidKeyException e) { + e.printStackTrace(); + } catch (InvalidAlgorithmParameterException e) { + e.printStackTrace(); + } catch (IllegalBlockSizeException e) { + e.printStackTrace(); + } catch (BadPaddingException e) { + e.printStackTrace(); + } catch (CertificateException e) { + e.printStackTrace(); + } catch (KeyStoreException e) { + e.printStackTrace(); + } catch (KeyManagementException e) { + e.printStackTrace(); + } + + a(new String[]{ + "Can't validate current installation of Dungeons Guide", + "Steps to fix", + "1. check if other people can't join minecraft servers.", + "2. restart minecraft launcher", + "3. make sure you're on the right account", + "4. restart your computer", + "If the problem persists after following these steps, please contact developer", + "If you haven't purchased the mod, please consider doing so" + }); } +// @EventHandler +// public void pre(FMLPreInitializationEvent event) { +// a = this; +// URL.setURLStreamHandlerFactory(new c(null)); +// try { +// d = new e(null); +// d.pre(event); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } public void a(final String[] a) { final GuiScreen b = new GuiErrorScreen(null, null) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/CategoryEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/config/CategoryEditPane.java index 95079857..0a0aea98 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/CategoryEditPane.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/CategoryEditPane.java @@ -1,18 +1,13 @@ package kr.syeyoung.dungeonsguide.config; -import kr.syeyoung.dungeonsguide.Config; -import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.roomedit.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; import kr.syeyoung.dungeonsguide.roomedit.elements.*; import kr.syeyoung.dungeonsguide.roomedit.panes.DynamicEditor; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditRegistry; import net.minecraftforge.common.config.ConfigCategory; import net.minecraftforge.common.config.Property; -import scala.actors.threadpool.Arrays; import java.awt.*; import java.util.*; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/Config.java b/src/main/java/kr/syeyoung/dungeonsguide/config/Config.java new file mode 100644 index 00000000..aff6a02f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/Config.java @@ -0,0 +1,23 @@ +package kr.syeyoung.dungeonsguide.config; + +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStreamReader; + +public class Config { + public static JsonObject configuration; + + + public static void loadConfig(File f) throws FileNotFoundException { + configuration = (JsonObject) new JsonParser().parse(new InputStreamReader(new FileInputStream(f))); + + + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/GuiConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/GuiConfig.java index 5e5b8aac..e8bfc6bd 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/GuiConfig.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/GuiConfig.java @@ -1,10 +1,7 @@ package kr.syeyoung.dungeonsguide.config; -import kr.syeyoung.dungeonsguide.Config; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.roomedit.MPanel; import kr.syeyoung.dungeonsguide.roomedit.elements.MTabbedPane; -import kr.syeyoung.dungeonsguide.roomedit.panes.*; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; @@ -26,8 +23,8 @@ public class GuiConfig extends GuiScreen { mainPanel.add(tabbedPane); tabbedPane.setBackground2(new Color(17, 17, 17, 179)); - for (String cate:Config.configuration.getCategoryNames()) - tabbedPane.addTab(cate, new CategoryEditPane(Config.configuration.getCategory(cate))); +// for (String cate:Config.configuration.getCategoryNames()) +// tabbedPane.addTab(cate, new CategoryEditPane(Config.configuration.getCategory(cate))); this.tabbedPane = tabbedPane; } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCBoolean.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCBoolean.java new file mode 100644 index 00000000..ba4e44be --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCBoolean.java @@ -0,0 +1,21 @@ +package kr.syeyoung.dungeonsguide.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; + +public class TCBoolean implements TypeConverter<Boolean> { + @Override + public String getTypeString() { + return "boolean"; + } + + @Override + public Boolean deserialize(JsonElement element) { + return element.getAsBoolean(); + } + + @Override + public JsonElement serialize(Boolean element) { + return new JsonPrimitive(element); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCInteger.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCInteger.java new file mode 100644 index 00000000..3b5195de --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCInteger.java @@ -0,0 +1,21 @@ +package kr.syeyoung.dungeonsguide.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; + +public class TCInteger implements TypeConverter<Integer> { + @Override + public String getTypeString() { + return "integer"; + } + + @Override + public Integer deserialize(JsonElement element) { + return element.getAsInt(); + } + + @Override + public JsonElement serialize(Integer element) { + return new JsonPrimitive(element); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCRectangle.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCRectangle.java new file mode 100644 index 00000000..2d571da7 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCRectangle.java @@ -0,0 +1,35 @@ +package kr.syeyoung.dungeonsguide.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; +import org.w3c.dom.css.Rect; + +import java.awt.*; + +public class TCRectangle implements TypeConverter<Rectangle> { + @Override + public String getTypeString() { + return "rect"; + } + + @Override + public Rectangle deserialize(JsonElement element) { + Rectangle rectangle = new Rectangle(); + rectangle.x = ((JsonObject)element).get("x").getAsInt(); + rectangle.y = ((JsonObject)element).get("y").getAsInt(); + rectangle.width = ((JsonObject)element).get("width").getAsInt(); + rectangle.height = ((JsonObject)element).get("height").getAsInt(); + return rectangle; + } + + @Override + public JsonElement serialize(Rectangle element) { + JsonObject object = new JsonObject(); + object.addProperty("x", element.x); + object.addProperty("y", element.y); + object.addProperty("width", element.width); + object.addProperty("height", element.height); + return object; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCString.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCString.java new file mode 100644 index 00000000..fa28c1b6 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCString.java @@ -0,0 +1,21 @@ +package kr.syeyoung.dungeonsguide.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; + +public class TCString implements TypeConverter<String> { + @Override + public String getTypeString() { + return "string"; + } + + @Override + public String deserialize(JsonElement element) { + return element.getAsString(); + } + + @Override + public JsonElement serialize(String element) { + return new JsonPrimitive(element); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverter.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverter.java new file mode 100644 index 00000000..b5b69be0 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverter.java @@ -0,0 +1,11 @@ +package kr.syeyoung.dungeonsguide.config.types; + +import com.google.gson.JsonElement; + +public interface TypeConverter<T> { + String getTypeString(); + + T deserialize(JsonElement element); + + JsonElement serialize(T element); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java new file mode 100644 index 00000000..82bfe3fc --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java @@ -0,0 +1,21 @@ +package kr.syeyoung.dungeonsguide.config.types; + +import kr.syeyoung.dungeonsguide.roomedit.Parameter; + +import java.util.HashMap; +import java.util.Map; + +public class TypeConverterRegistry { + private static Map<String, TypeConverter> typeConverterMap = new HashMap<String, TypeConverter>(); + + public static void register(TypeConverter typeConverter) { + typeConverterMap.put(typeConverter.getTypeString(), typeConverter); + } + + public static TypeConverter getTypeConverter(String type_string) { + return typeConverterMap.get(type_string); + } + public static <T> TypeConverter<T> getTypeConverter(String type_string, Class<T> t) { + return (TypeConverter<T>)typeConverterMap.get(type_string); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java index ac713082..43675f61 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java @@ -95,6 +95,7 @@ public class RoomMatcher { } roomInfo.setBlocks(data); + roomInfo.setUserMade(true); return roomInfo; } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/e.java b/src/main/java/kr/syeyoung/dungeonsguide/e.java index 8cd34154..aeefe8c8 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/e.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/e.java @@ -1,9 +1,11 @@ package kr.syeyoung.dungeonsguide; import kr.syeyoung.dungeonsguide.commands.*; +import kr.syeyoung.dungeonsguide.config.Config; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; import kr.syeyoung.dungeonsguide.eventlistener.DungeonListener; import kr.syeyoung.dungeonsguide.eventlistener.ItemGuiListener; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.utils.AhUtils; import lombok.Getter; import net.minecraft.client.Minecraft; @@ -18,10 +20,7 @@ import org.apache.commons.io.IOUtils; import javax.crypto.BadPaddingException; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; @@ -41,7 +40,7 @@ public class e implements c { } public static void sendDebugChat(IChatComponent iChatComponent) { - if (Config.DEBUG) + if (FeatureRegistry.DEBUG.isEnabled()) Minecraft.getMinecraft().thePlayer.addChatMessage(iChatComponent); } @@ -80,12 +79,15 @@ public class e implements c { } public void pre(FMLPreInitializationEvent event) { configDir = new File(event.getModConfigurationDirectory(),"dungeonsguide"); - File configFile = new File(configDir, "config.conf"); + File configFile = new File(configDir, "config.json"); if (!configFile.exists()) { configDir.mkdirs(); } - Config.configuration = new Configuration(configFile); - Config.syncConfig( true ); + try { + Config.loadConfig( configFile ); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } } private void copy(InputStream inputStream, File f) throws IOException { FileOutputStream fos = new FileOutputStream(f); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java index 118626f5..f1dd3bff 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java @@ -1,12 +1,13 @@ package kr.syeyoung.dungeonsguide.eventlistener; -import kr.syeyoung.dungeonsguide.Config; +import kr.syeyoung.dungeonsguide.config.Config; import kr.syeyoung.dungeonsguide.Keybinds; import kr.syeyoung.dungeonsguide.SkyblockStatus; import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonDoor; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.e; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonAddSet; import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonParameterEdit; @@ -78,7 +79,7 @@ public class DungeonListener { if (postRender.type != RenderGameOverlayEvent.ElementType.TEXT) return; SkyblockStatus skyblockStatus = (SkyblockStatus) e.getDungeonsGuide().getSkyblockStatus(); if (!skyblockStatus.isOnDungeon()) return; - if (Config.DEBUG) { + if (FeatureRegistry.DEBUG.isEnabled()) { int[] textureData = dynamicTexture.getTextureData(); MapUtils.getImage().getRGB(0, 0, 128, 128, textureData, 0, 128); dynamicTexture.updateDynamicTexture(); @@ -95,10 +96,10 @@ public class DungeonListener { DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; if (dungeonRoom == null) { - if (Config.DEBUG) + if (FeatureRegistry.DEBUG.isEnabled()) fontRenderer.drawString("Where are you?!", 5, 128, 0xFFFFFF); } else { - if (Config.DEBUG) { + if (FeatureRegistry.DEBUG.isEnabled()) { fontRenderer.drawString("you're in the room... " + dungeonRoom.getColor() + " / " + dungeonRoom.getShape(), 5, 128, 0xFFFFFF); fontRenderer.drawString("room uuid: " + dungeonRoom.getDungeonRoomInfo().getUuid() + (dungeonRoom.getDungeonRoomInfo().isRegistered() ? "" : " (not registered)"), 5, 138, 0xFFFFFF); fontRenderer.drawString("room name: " + dungeonRoom.getDungeonRoomInfo().getName(), 5, 148, 0xFFFFFF); @@ -162,7 +163,7 @@ public class DungeonListener { DungeonContext context = skyblockStatus.getContext(); if (context == null) return; - if (Config.DEBUG) { + if (FeatureRegistry.DEBUG.isEnabled()) { for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { for(DungeonDoor door : dungeonRoom.getDoors()) { RenderUtils.renderDoor(door, renderWorldLastEvent.partialTicks); @@ -208,7 +209,7 @@ public class DungeonListener { @SubscribeEvent public void onKeyInput(InputEvent.KeyInputEvent keyInputEvent) { - if (Config.DEBUG && Keybinds.editingSession.isKeyDown() ){ + if (FeatureRegistry.DEBUG.isEnabled() && Keybinds.editingSession.isKeyDown() ){ EditingContext ec = EditingContext.getEditingContext(); if (ec == null) { DungeonContext context = e.getDungeonsGuide().getSkyblockStatus().getContext(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/ItemGuiListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/ItemGuiListener.java index 829513bf..ba7499db 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/ItemGuiListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/ItemGuiListener.java @@ -1,14 +1,11 @@ package kr.syeyoung.dungeonsguide.eventlistener; -import kr.syeyoung.dungeonsguide.Config; +import kr.syeyoung.dungeonsguide.config.Config; import kr.syeyoung.dungeonsguide.e; import kr.syeyoung.dungeonsguide.utils.AhUtils; import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.scoreboard.ScoreObjective; -import net.minecraft.scoreboard.Scoreboard; import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java new file mode 100644 index 00000000..4964ee5f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java @@ -0,0 +1,64 @@ +package kr.syeyoung.dungeonsguide.features; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import kr.syeyoung.dungeonsguide.config.types.TypeConverter; +import kr.syeyoung.dungeonsguide.config.types.TypeConverterRegistry; +import lombok.Getter; +import lombok.Setter; + +import java.util.*; + +public abstract class AbstractFeature { + @Getter + private final String category; + @Getter + private final String name; + + @Getter + private final String description; + + @Getter + private final String key; + + protected Map<String, FeatureParameter> parameters = new HashMap<String, FeatureParameter>(); + + protected AbstractFeature(String category, String name, String description, String key) { + this.category = category; + this.name = name; + this.description = description; + this.key = key; + } + + @Getter + @Setter + private boolean enabled = false; + + public void drawWorld(float partialTicks) {} + public void drawScreen(float partialTicks) {} + + public List<FeatureParameter> getParameters() { return new ArrayList<FeatureParameter>(parameters.values()); } + + + + public void loadConfig(JsonObject jsonObject) { // gets key, calls it + enabled = jsonObject.get("$enabled").getAsBoolean(); + for (Map.Entry<String, FeatureParameter> parameterEntry : parameters.entrySet()) { + JsonElement element = jsonObject.get(parameterEntry.getKey()); + if (element == null) continue; + TypeConverter typeConverter = TypeConverterRegistry.getTypeConverter(parameterEntry.getValue().getValue_type()); + parameterEntry.getValue().setValue(typeConverter.deserialize(element)); + } + } + + public JsonObject saveConfig() { + JsonObject object = new JsonObject(); + for (Map.Entry<String, FeatureParameter> parameterEntry : parameters.entrySet()) { + TypeConverter typeConverter = TypeConverterRegistry.getTypeConverter(parameterEntry.getValue().getValue_type()); + JsonElement obj = typeConverter.serialize(parameterEntry.getValue().getValue()); + object.add(parameterEntry.getKey(), obj); + } + object.addProperty("$enabled", isEnabled()); + return object; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureParameter.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureParameter.java new file mode 100644 index 00000000..98532d1b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureParameter.java @@ -0,0 +1,16 @@ +package kr.syeyoung.dungeonsguide.features; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class FeatureParameter<T> { + private String key; + + private String name; + private String description; + + private T value; + private String value_type; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java new file mode 100644 index 00000000..67d1e971 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java @@ -0,0 +1,49 @@ +package kr.syeyoung.dungeonsguide.features; + +import lombok.Getter; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class FeatureRegistry { + @Getter + private static List<AbstractFeature> featureList = new ArrayList<AbstractFeature>(); + private static Map<String, AbstractFeature> featureByKey = new HashMap<String, AbstractFeature>(); + @Getter + private static Map<String, List<AbstractFeature>> featuresByCategory = new HashMap<String, List<AbstractFeature>>(); + + public static AbstractFeature getFeatureByKey(String key) { + return featureByKey.get(key); + } + + public static AbstractFeature register(AbstractFeature abstractFeature) { + featureList.add(abstractFeature); + featureByKey.put(abstractFeature.getKey(), abstractFeature); + List<AbstractFeature> features = featuresByCategory.get(abstractFeature.getCategory()); + if (features == null) + features = new ArrayList<AbstractFeature>(); + features.add(abstractFeature); + featuresByCategory.put(abstractFeature.getCategory(), features); + + return abstractFeature; + } + + public static final AbstractFeature SOLVER_RIDDLE = register(new SimpleFeature("solver", "Riddle Puzzle (3 weirdo) Solver", "Highlights the correct box after clicking on all 3 weirdos", "solver.riddle")); + public static final AbstractFeature SOLVER_KAHOOT = register(new SimpleFeature("solver", "Trivia Puzzle (Omnicrescent) Solver", "Highlights the correct solution for trivia puzzle", "solver.trivia")); + public static final AbstractFeature SOLVER_BLAZE = register(new SimpleFeature("solver", "Blaze Puzzle Solver", "Highlights the blaze that needs to be killed in an blaze room", "solver.blaze")); + public static final AbstractFeature SOLVER_TICTACTOE = register(new SimpleFeature("solver", "Tictactoe Solver", "Shows the best move that could be taken by player in the tictactoe room", "solver.tictactoe")); + public static final AbstractFeature SOLVER_ICEPATH = register(new SimpleFeature("solver", "Icepath Puzzle Solver (Advanced)", "Calculates solution for icepath puzzle and displays it to user", "solver.icepath")); + public static final AbstractFeature SOLVER_SILVERFISH = register(new SimpleFeature("solver", "Silverfish Puzzle Solver (Advanced)", "Actively calculates solution for silverfish puzzle and displays it to user", "solver.silverfish")); + public static final AbstractFeature SOLVER_WATERPUZZLE = register(new SimpleFeature("solver", "Waterboard Puzzle Solver (Advanced)", "Calculates solution for waterboard puzzle and displays it to user", "solver.waterboard")); + public static final AbstractFeature SOLVER_BOX = register(new SimpleFeature("solver", "Box Puzzle Solver (Advanced)", "Calculates solution for box puzzle room, and displays it to user", "solver.box")); + public static final AbstractFeature SOLVER_CREEPER = register(new SimpleFeature("solver", "Creeper Puzzle Solver", "Draws line between prismarine lamps in creeper room", "solver.creeper")); + public static final AbstractFeature SOLVER_TELEPORT = register(new SimpleFeature("solver", "Teleport Puzzle Solver", "Shows teleport pads you've visited in a teleport maze room", "solver.teleport")); + + public static final AbstractFeature TOOLTIP_DUNGEONSTAT = register(new SimpleFeature("tooltip", "Dungeon Item Stats", "Shows quality of dungeon items (floor, percentage)", "tooltip.dungeonitem")); + public static final AbstractFeature TOOLTIP_PRICE = register(new SimpleFeature("tooltip", "Item Price", "Shows price of items", "tooltip.price")); + + public static final AbstractFeature DEBUG = register(new SimpleFeature("advanced", "Debug", "Toggles debug mode", "debug")); + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java new file mode 100644 index 00000000..d7b58dbc --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java @@ -0,0 +1,73 @@ +package kr.syeyoung.dungeonsguide.features; + +import com.google.gson.JsonObject; +import kr.syeyoung.dungeonsguide.config.types.TypeConverterRegistry; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.OpenGlHelper; +import org.lwjgl.opengl.GL11; + +import java.awt.*; + +@Getter +public abstract class GuiFeature extends AbstractFeature { + @Setter + private Rectangle featureRect; + @Setter(value = AccessLevel.PROTECTED) + private boolean keepRatio; + @Setter(value = AccessLevel.PROTECTED) + private int defaultWidth; + @Setter(value = AccessLevel.PROTECTED) + private int defaultHeight; + + protected GuiFeature(String category, String name, String description, String key, boolean keepRatio, int width, int height) { + super(category, name, description, key); + this.keepRatio = keepRatio; + this.defaultWidth = width; + this.defaultHeight = height; + this.featureRect = new Rectangle(0, 0, width, height); + } + + @Override + public void drawScreen(float partialTicks) { + clip(new ScaledResolution(Minecraft.getMinecraft()), featureRect.x, featureRect.y, featureRect.width, featureRect.height); + GL11.glPushAttrib(GL11.GL_SCISSOR_BIT); + GL11.glEnable(GL11.GL_SCISSOR_TEST); + + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + GL11.glPushMatrix(); + GL11.glTranslated(featureRect.x, featureRect.y, 0); + drawHUD(partialTicks); + GL11.glPopMatrix(); + + GL11.glDisable(GL11.GL_SCISSOR_TEST); + GL11.glPopAttrib(); + } + + public abstract void drawHUD(float partialTicks); + + + private void clip(ScaledResolution resolution, int x, int y, int width, int height) { + int scale = resolution.getScaleFactor(); + GL11.glScissor((x ) * scale, Minecraft.getMinecraft().displayHeight - (y + height) * scale, (width) * scale, height * scale); + } + + @Override + public void loadConfig(JsonObject jsonObject) { + super.loadConfig(jsonObject); + featureRect = TypeConverterRegistry.getTypeConverter("rect", Rectangle.class).deserialize(jsonObject.get("$bounds")); + } + + @Override + public JsonObject saveConfig() { + JsonObject object = super.saveConfig(); + object.add("$bounds", TypeConverterRegistry.getTypeConverter("rect", Rectangle.class).serialize(featureRect)); + return object; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/SimpleFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/SimpleFeature.java new file mode 100644 index 00000000..cdeaaa44 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/SimpleFeature.java @@ -0,0 +1,10 @@ +package kr.syeyoung.dungeonsguide.features; + +public class SimpleFeature extends AbstractFeature { + protected SimpleFeature(String category, String name, String key) { + super(category, name, name, key); + } + protected SimpleFeature(String category, String name, String description, String key) { + super(category, name, description, key); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java index 4bd7993e..541d5ccc 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java @@ -1,9 +1,9 @@ package kr.syeyoung.dungeonsguide.roomprocessor; -import kr.syeyoung.dungeonsguide.Config; -import kr.syeyoung.dungeonsguide.e; +import kr.syeyoung.dungeonsguide.config.Config; import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonMechanic; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonRoomEdit; import lombok.Getter; @@ -34,7 +34,7 @@ public class GeneralRoomProcessor implements RoomProcessor { @Override public void drawWorld(float partialTicks) { - if (Config.DEBUG && (EditingContext.getEditingContext() == null || EditingContext.getEditingContext().getCurrent() instanceof GuiDungeonRoomEdit)) { + if (FeatureRegistry.DEBUG.isEnabled() && (EditingContext.getEditingContext() == null || EditingContext.getEditingContext().getCurrent() instanceof GuiDungeonRoomEdit)) { for (Map.Entry<String, DungeonMechanic> value : dungeonRoom.getDungeonRoomInfo().getMechanics().entrySet()) { if (value.getValue() == null) continue;; value.getValue().highlight(new Color(0,255,255,50), value.getKey(), dungeonRoom, partialTicks); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java index f3b0cf4b..38acb3c8 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java @@ -1,16 +1,12 @@ package kr.syeyoung.dungeonsguide.roomprocessor; import com.google.common.base.Predicate; -import kr.syeyoung.dungeonsguide.Config; +import kr.syeyoung.dungeonsguide.config.Config; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.entity.monster.EntityBlaze; import net.minecraft.util.BlockPos; import net.minecraft.util.Vec3; import net.minecraft.world.World; @@ -18,8 +14,6 @@ import org.jetbrains.annotations.Nullable; import java.awt.*; import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; import java.util.List; public class RoomProcessorBlazeSolver extends GeneralRoomProcessor { @@ -78,7 +72,7 @@ public class RoomProcessorBlazeSolver extends GeneralRoomProcessor { @Override public void drawWorld(float partialTicks) { super.drawWorld(partialTicks); - if (!Config.solver_blaze) return; + if (!FeatureRegistry.SOLVER_BLAZE.isEnabled()) return; if (next == null) return; Vec3 pos = next.getPositionEyes(partialTicks); RenderUtils.highlightBox(next, new Color(0,255,0,100), partialTicks, false); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java index a6653fdc..d0c5be1c 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java @@ -1,23 +1,17 @@ package kr.syeyoung.dungeonsguide.roomprocessor; import com.google.common.base.Predicate; -import kr.syeyoung.dungeonsguide.Config; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.config.Config; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import kr.syeyoung.dungeonsguide.utils.TextUtils; import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; import net.minecraft.util.Vec3; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; -import scala.actors.threadpool.Arrays; import java.awt.*; import java.util.ArrayList; @@ -116,7 +110,7 @@ public class RoomProcessorCreeperSolver extends GeneralRoomProcessor { @Override public void drawWorld(float partialTicks) { super.drawWorld(partialTicks); - if (!Config.solver_creeper) return; + if (!FeatureRegistry.SOLVER_CREEPER.isEnabled()) return; World w = getDungeonRoom().getContext().getWorld(); for (int i = 0; i < poses.size(); i++) { BlockPos[] poset = poses.get(i); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorIcePath.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorIcePath.java index 2f30c506..42f27628 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorIcePath.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorIcePath.java @@ -1,10 +1,11 @@ package kr.syeyoung.dungeonsguide.roomprocessor; import com.google.common.base.Predicate; -import kr.syeyoung.dungeonsguide.Config; +import kr.syeyoung.dungeonsguide.config.Config; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import net.minecraft.entity.Entity; import net.minecraft.entity.monster.EntitySilverfish; @@ -119,7 +120,7 @@ public class RoomProcessorIcePath extends GeneralRoomProcessor { @Override public void drawWorld(float partialTicks) { super.drawWorld(partialTicks); - if (!Config.solver_icesilverfish) return; + if (!FeatureRegistry.SOLVER_SILVERFISH.isEnabled()) return; if (!err) RenderUtils.drawLines(solution, new Color(0,255,0, 255), partialTicks, false); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRiddle.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRiddle.java index 5ebec35d..dc2d65e2 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRiddle.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRiddle.java @@ -1,9 +1,9 @@ package kr.syeyoung.dungeonsguide.roomprocessor; import com.google.common.base.Predicate; -import kr.syeyoung.dungeonsguide.Config; +import kr.syeyoung.dungeonsguide.config.Config; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import kr.syeyoung.dungeonsguide.utils.TextUtils; import net.minecraft.block.Block; @@ -39,7 +39,7 @@ public class RoomProcessorRiddle extends GeneralRoomProcessor { @Override public void chatReceived(IChatComponent chat) { super.chatReceived(chat); - if (!Config.solver_riddle) return; + if (!FeatureRegistry.SOLVER_RIDDLE.isEnabled()) return; String ch2 = chat.getUnformattedText(); if (!ch2.startsWith("§e[NPC] ")) { return; @@ -88,7 +88,7 @@ public class RoomProcessorRiddle extends GeneralRoomProcessor { @Override public void drawWorld(float partialTicks) { super.drawWorld(partialTicks); - if (!Config.solver_riddle) return; + if (!FeatureRegistry.SOLVER_RIDDLE.isEnabled()) return; if (chest != null) { RenderUtils.highlightBlock(chest, new Color(0,255,0, 50),partialTicks); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java index 844789fb..f523ffa9 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java @@ -1,7 +1,8 @@ package kr.syeyoung.dungeonsguide.roomprocessor; -import kr.syeyoung.dungeonsguide.Config; +import kr.syeyoung.dungeonsguide.config.Config; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; @@ -63,7 +64,7 @@ public class RoomProcessorTeleportMazeSolver extends GeneralRoomProcessor { @Override public void drawWorld(float partialTicks) { super.drawWorld(partialTicks); - if (!Config.solver_teleport) return; + if (!FeatureRegistry.SOLVER_TELEPORT.isEnabled()) return; for (BlockPos bpos:visitedPortals) { RenderUtils.highlightBlock(bpos, new Color(255,0,0,100), partialTicks); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTicTacToeSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTicTacToeSolver.java index 353a3ed6..03c2f4e2 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTicTacToeSolver.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTicTacToeSolver.java @@ -1,20 +1,18 @@ package kr.syeyoung.dungeonsguide.roomprocessor; -import kr.syeyoung.dungeonsguide.Config; +import kr.syeyoung.dungeonsguide.config.Config; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.init.Blocks; import net.minecraft.item.ItemMap; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; -import net.minecraft.util.MinecraftError; import net.minecraft.world.World; import net.minecraft.world.storage.MapData; @@ -139,7 +137,6 @@ public class RoomProcessorTicTacToeSolver extends GeneralRoomProcessor { @Override public void tick() { super.tick(); - if (!Config.solver_tictactoe) return; if (board == null) return; if (gameEnded) return; byte[][] board = buildBoardState(); @@ -170,7 +167,7 @@ public class RoomProcessorTicTacToeSolver extends GeneralRoomProcessor { @Override public void drawWorld(float partialTicks) { super.drawWorld(partialTicks); - if (!Config.solver_tictactoe) return; + if (!FeatureRegistry.SOLVER_TICTACTOE.isEnabled()) return; if (chosePos != -1) { BlockPos block = board.getOffsetPointList().get(chosePos).getBlockPos(getDungeonRoom()); RenderUtils.highlightBlock(block, new Color(0,255,255,50), partialTicks); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTrivia.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTrivia.java index 1b56768a..cf2538f2 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTrivia.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTrivia.java @@ -1,8 +1,9 @@ package kr.syeyoung.dungeonsguide.roomprocessor; -import kr.syeyoung.dungeonsguide.Config; +import kr.syeyoung.dungeonsguide.config.Config; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import kr.syeyoung.dungeonsguide.utils.SkyblockUtils; import kr.syeyoung.dungeonsguide.utils.TextUtils; @@ -73,7 +74,7 @@ public class RoomProcessorTrivia extends GeneralRoomProcessor { @Override public void chatReceived(IChatComponent chat) { super.chatReceived(chat); - if (!Config.solver_kahoot) return; + if (!FeatureRegistry.SOLVER_KAHOOT.isEnabled()) return; String ch2 = chat.getUnformattedText(); if (chat.getFormattedText().contains("§r§6§lQuestion ")) { questionDialogStart = true; @@ -149,7 +150,7 @@ public class RoomProcessorTrivia extends GeneralRoomProcessor { @Override public void drawWorld(float partialTicks) { super.drawWorld(partialTicks); - if (!Config.solver_kahoot) return; + if (!FeatureRegistry.SOLVER_KAHOOT.isEnabled()) return; if (correctAnswer == null) return; OffsetPoint op = (OffsetPoint) getDungeonRoom().getDungeonRoomInfo().getProperties().get(correctAnswer); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/boxpuzzle/RoomProcessorBoxSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/boxpuzzle/RoomProcessorBoxSolver.java index 1ed35e55..a8f31e78 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/boxpuzzle/RoomProcessorBoxSolver.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/boxpuzzle/RoomProcessorBoxSolver.java @@ -1,17 +1,15 @@ package kr.syeyoung.dungeonsguide.roomprocessor.boxpuzzle; -import kr.syeyoung.dungeonsguide.Config; +import kr.syeyoung.dungeonsguide.config.Config; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor; import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessorGenerator; import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.AllArgsConstructor; -import lombok.Data; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.entity.RenderIronGolem; import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; @@ -79,7 +77,7 @@ public class RoomProcessorBoxSolver extends GeneralRoomProcessor { @Override public void tick() { super.tick(); - if (!Config.solver_box) return; + if (!FeatureRegistry.SOLVER_BOX.isEnabled()) return; if (bugged) return; byte[][] currboard = buildCurrentState(); if (puzzleSolvingThread == null) { @@ -296,7 +294,7 @@ public class RoomProcessorBoxSolver extends GeneralRoomProcessor { @Override public void chatReceived(IChatComponent chat) { - if (!Config.solver_box) return; + if (!FeatureRegistry.SOLVER_BOX.isEnabled()) return; if (chat.getFormattedText().toLowerCase().contains("recalc")) { if (calcDone) { calcReq = true; @@ -311,7 +309,7 @@ public class RoomProcessorBoxSolver extends GeneralRoomProcessor { @Override public void drawScreen(float partialTicks) { super.drawScreen(partialTicks); - if (!Config.solver_box) return; + if (!FeatureRegistry.SOLVER_BOX.isEnabled()) return; FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; fr.drawString("Type \"recalc\" in chat to recalculate the solution", 0, 0, 0xFFFFFFFF); } @@ -319,7 +317,7 @@ public class RoomProcessorBoxSolver extends GeneralRoomProcessor { @Override public void drawWorld(float partialTicks) { super.drawWorld(partialTicks); - if (!Config.solver_box) return; + if (!FeatureRegistry.SOLVER_BOX.isEnabled()) return; if (bugged) return; if (!calcDone) return; if (solution == null) return; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/icefill/RoomProcessorIcePath2.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/icefill/RoomProcessorIcePath2.java index 6ec948a9..7d2e09a3 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/icefill/RoomProcessorIcePath2.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/icefill/RoomProcessorIcePath2.java @@ -1,8 +1,9 @@ package kr.syeyoung.dungeonsguide.roomprocessor.icefill; -import kr.syeyoung.dungeonsguide.Config; +import kr.syeyoung.dungeonsguide.config.Config; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor; import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessorGenerator; import kr.syeyoung.dungeonsguide.utils.RenderUtils; @@ -12,7 +13,6 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; import java.awt.*; -import java.util.ArrayList; import java.util.Queue; import java.util.Arrays; import java.util.LinkedList; @@ -81,6 +81,7 @@ public class RoomProcessorIcePath2 extends GeneralRoomProcessor { @Override public void tick() { super.tick(); + if (!FeatureRegistry.SOLVER_ICEPATH.isEnabled()) return; while (!messageQueue.isEmpty()){ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(messageQueue.poll())); } @@ -88,7 +89,7 @@ public class RoomProcessorIcePath2 extends GeneralRoomProcessor { @Override public void drawWorld(float partialTicks) { - if (!Config.solver_icepath) return; + if (!FeatureRegistry.SOLVER_ICEPATH.isEnabled()) return; for (List<BlockPos> solution:this.solution) RenderUtils.drawLines(solution, new Color(0,255,0, 255), partialTicks, true); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/RoomProcessorWaterPuzzle.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/RoomProcessorWaterPuzzle.java index c4787d48..ace719c9 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/RoomProcessorWaterPuzzle.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/RoomProcessorWaterPuzzle.java @@ -1,16 +1,13 @@ package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle; -import kr.syeyoung.dungeonsguide.Config; +import kr.syeyoung.dungeonsguide.config.Config; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor; -import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessor; -import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessorBlazeSolver; import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessorGenerator; import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; import net.minecraft.util.BlockPos; import java.awt.*; @@ -50,7 +47,7 @@ public class RoomProcessorWaterPuzzle extends GeneralRoomProcessor { @Override public void tick() { super.tick(); - if (!Config.solver_waterpuzzle) return; + if (!FeatureRegistry.SOLVER_WATERPUZZLE.isEnabled()) return; if (!argumentsFulfilled) return; try { waterBoard.tick(); @@ -67,7 +64,7 @@ public class RoomProcessorWaterPuzzle extends GeneralRoomProcessor { @Override public void drawWorld(float partialTicks) { super.drawWorld(partialTicks); - if (!Config.solver_waterpuzzle) return; + if (!FeatureRegistry.SOLVER_WATERPUZZLE.isEnabled()) return; if (!argumentsFulfilled) return; if (waterBoard == null) return; |