aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2023-05-17 00:30:49 +0200
committermakamys <makamys@outlook.com>2023-05-17 00:30:49 +0200
commit41ee8305ac16e0727c767574672b731845db4bb2 (patch)
treed55798b9d132b280562e84a50f1ea7f228404f2f /src
parente09b4eae63b8793fcf1530d5babea7764a0dae8f (diff)
downloadNeodymium-41ee8305ac16e0727c767574672b731845db4bb2.tar.gz
Neodymium-41ee8305ac16e0727c767574672b731845db4bb2.tar.bz2
Neodymium-41ee8305ac16e0727c767574672b731845db4bb2.zip
Fix all warnings turning off advanced opengl when clicked
Diffstat (limited to 'src')
-rw-r--r--src/main/java/makamys/neodymium/Compat.java8
-rw-r--r--src/main/java/makamys/neodymium/command/NeodymiumCommand.java10
2 files changed, 10 insertions, 8 deletions
diff --git a/src/main/java/makamys/neodymium/Compat.java b/src/main/java/makamys/neodymium/Compat.java
index 47a3dfb..2d39d2f 100644
--- a/src/main/java/makamys/neodymium/Compat.java
+++ b/src/main/java/makamys/neodymium/Compat.java
@@ -40,7 +40,7 @@ public class Compat {
public static void getCompatibilityWarnings(List<Warning> warns, List<Warning> criticalWarns, boolean statusCommand){
if(Minecraft.getMinecraft().gameSettings.advancedOpengl) {
- warns.add(new Warning("Advanced OpenGL is enabled, performance may be poor." + (statusCommand ? " Click here to disable it." : "")).action(Compat::disableAdvancedOpenGL));
+ warns.add(new Warning("Advanced OpenGL is enabled, performance may be poor." + (statusCommand ? " Click here to disable it." : "")).chatAction("neodymium disable_advanced_opengl"));
}
try {
@@ -131,14 +131,14 @@ public class Compat {
public static class Warning {
public String text;
- public Runnable action;
+ public String chatAction;
public Warning(String text) {
this.text = text;
}
- public Warning action(Runnable action) {
- this.action = action;
+ public Warning chatAction(String command) {
+ this.chatAction = command;
return this;
}
}
diff --git a/src/main/java/makamys/neodymium/command/NeodymiumCommand.java b/src/main/java/makamys/neodymium/command/NeodymiumCommand.java
index 3040ba9..dcab050 100644
--- a/src/main/java/makamys/neodymium/command/NeodymiumCommand.java
+++ b/src/main/java/makamys/neodymium/command/NeodymiumCommand.java
@@ -113,17 +113,19 @@ public class NeodymiumCommand extends CommandBase {
List<Warning> warns = allWarns.getLeft();
List<Warning> criticalWarns = allWarns.getRight();
for(Warning line : warns) {
- addColoredChatMessageWithAction(sender, "* " + line.text, HELP_WARNING_COLOR, line.action);
+ addColoredChatMessageWithAction(sender, "* " + line.text, HELP_WARNING_COLOR, line.chatAction);
}
for(Warning line : criticalWarns) {
- addColoredChatMessageWithAction(sender, "* " + line.text, ERROR_COLOR, line.action);
+ addColoredChatMessageWithAction(sender, "* " + line.text, ERROR_COLOR, line.chatAction);
}
}
- private void addColoredChatMessageWithAction(ICommandSender sender, String text, EnumChatFormatting color, Runnable action) {
+ private void addColoredChatMessageWithAction(ICommandSender sender, String text, EnumChatFormatting color, String command) {
ChatComponentText msg = new ChatComponentText(text);
msg.getChatStyle().setColor(color);
- msg.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "neodymium disable_advanced_opengl"));
+ if(command != null) {
+ msg.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command));
+ }
sender.addChatMessage(msg);
}