Finish Config Client and Settings GUI

This commit is contained in:
Kam committed 2024-03-15 17:54:01 -04:00
1 parent 386cfe5075
commit a9e4b99bfc
4 files changed
+37 -2

No files matched your search

@@ -76,6 +76,9 @@ public class PacketHandlerClient extends PacketHandlerServer{
player.addChatMessage(new ChatComponentTranslation(npc.getCommandSenderName() + ": " + text));
}
else if(type == EnumPacketClient.CHAT){
if(!ConfigClient.ChatAlerts)
return;
String message = "";
String str;
while((str = Server.readString(buffer)) != null && !str.isEmpty())
@@ -84,6 +87,9 @@ public class PacketHandlerClient extends PacketHandlerServer{
player.addChatMessage(new ChatComponentTranslation(message));
}
else if(type == EnumPacketClient.MESSAGE || type == EnumPacketClient.PARTY_MESSAGE){
if(!ConfigClient.BannerAlerts)
return;
String description = StatCollector.translateToLocal(Server.readString(buffer));
String message = Server.readString(buffer);
Achievement ach = type == EnumPacketClient.MESSAGE ? new MessageAchievement(message, description) : new MessageAchievement(CustomItems.bag == null ? Items.paper : CustomItems.bag, message, description);
@@ -60,6 +60,9 @@ public class GuiSettings extends GuiCNPCInventory implements ITextfieldListener,
y += 22;
this.addLabel(new GuiNpcLabel(6, "settings.chatAlerts", guiLeft + 8, guiTop + 14 + y));
this.addButton(new GuiNpcButton(6, guiLeft + 105, guiTop + 9 + y, 50, 20, new String[]{"gui.no", "gui.yes"}, ConfigClient.ChatAlerts?1:0));
this.addLabel(new GuiNpcLabel(14,"settings.trackScale", guiLeft + 8 + 155, guiTop + 14 + y));
this.addTextField(new GuiNpcTextField(14, this, this.fontRendererObj, guiLeft + 107 + 160, guiTop + 9 + y, 45, 20, ConfigClient.TrackingScale + ""));
getTextField(14).integersOnly = true;
@@ -67,6 +70,9 @@ public class GuiSettings extends GuiCNPCInventory implements ITextfieldListener,
y += 22;
this.addLabel(new GuiNpcLabel(7, "settings.bannerAlerts", guiLeft + 8, guiTop + 14 + y));
this.addButton(new GuiNpcButton(7, guiLeft + 105, guiTop + 9 + y, 50, 20, new String[]{"gui.no", "gui.yes"}, ConfigClient.BannerAlerts?1:0));
y += 22;
y += 22;
@@ -138,6 +144,14 @@ public class GuiSettings extends GuiCNPCInventory implements ITextfieldListener,
GuiYesNo yesNoSkin = new GuiYesNo(this, "Confirm", StatCollector.translateToLocal("settings.confirmClearSkin"), 1);
displayGuiScreen(yesNoSkin);
}
if(button.id == 6){
ConfigClient.ChatAlerts = button.getValue() == 1;
ConfigClient.ChatAlertsProperty.set(ConfigClient.ChatAlerts);
}
if(button.id == 7){
ConfigClient.BannerAlerts = button.getValue() == 1;
ConfigClient.BannerAlertsProperty.set(ConfigClient.BannerAlerts);
}
}
@@ -6,6 +6,7 @@ import net.minecraftforge.common.config.Property;
import noppes.npcs.CustomNpcs;
import noppes.npcs.config.legacy.LegacyConfig;
import org.apache.logging.log4j.Level;
import tv.twitch.chat.Chat;
import java.io.File;
@@ -63,6 +64,12 @@ public class ConfigClient
public static Property DialogSoundProperty;
public static boolean DialogSound = true;
public static Property ChatAlertsProperty;
public static boolean ChatAlerts = true;
public static Property BannerAlertsProperty;
public static boolean BannerAlerts = true;
public static void init(File configFile)
{
config = new Configuration(configFile);
@@ -104,12 +111,18 @@ public class ConfigClient
TrackingScaleProperty = config.get(QUESTING, "Tracking Scale", 100, "Client sided! Adjusts the scaling of the Quest Tracking");
TrackingScale = TrackingScaleProperty.getInt(100);
DialogSpeedProperty = config.get(VISUAL, "Dialog Speed", 10, "Only set for gradual dialogs");
DialogSpeedProperty = config.get(VISUAL, "Dialog Speed", true, "Only set for gradual dialogs");
DialogSpeed = DialogSpeedProperty.getInt(10);
DialogSoundProperty = config.get(VISUAL, "Dialog Sound", 10, "Only for dialogs with sounds");
DialogSoundProperty = config.get(VISUAL, "Dialog Sound", true, "Only for dialogs with sounds");
DialogSound = DialogSoundProperty.getBoolean(true);
ChatAlertsProperty = config.get(VISUAL, "All Chat Alerts", true, "Universal enable/disable for Banner Alerts");
ChatAlerts = ChatAlertsProperty.getBoolean(true);
BannerAlertsProperty = config.get(VISUAL, "All Banner Alerts", true, "Universal enable/disable for Banner Alerts");
BannerAlerts = BannerAlertsProperty.getBoolean(true);
// Convert to Legacy
if(CustomNpcs.legacyExist){
EnableChatBubbles = LegacyConfig.EnableChatBubbles;