Skip to content

Commit

Permalink
Amelia/fixes (#7)
Browse files Browse the repository at this point in the history
* Fix log warnings

* Fix spelling

* Update gradle plugin

* isEmpty()

* Log warnings

* Proper debug logs

* Fix end game msg not working on loss in non eggwars games
  • Loading branch information
Fesaa authored Aug 8, 2023
1 parent c193532 commit 4aa5a1a
Show file tree
Hide file tree
Showing 31 changed files with 183 additions and 228 deletions.
33 changes: 15 additions & 18 deletions core/src/main/java/org/cubepanion/core/Cubepanion.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.cubepanion.core.commands.PartyCommands;
import org.cubepanion.core.commands.StatCommands;
import org.cubepanion.core.commands.TeamColourCommand;
import org.cubepanion.core.config.Cubepanionconfig;
import org.cubepanion.core.config.CubepanionConfig;
import org.cubepanion.core.generated.DefaultReferenceStorage;
import org.cubepanion.core.gui.hud.nametags.RespawnTags;
import org.cubepanion.core.listener.GameShutdownEventListener;
Expand All @@ -45,7 +45,7 @@
import org.cubepanion.core.versionlinkers.VotingLink;

@AddonMain
public class Cubepanion extends LabyAddon<Cubepanionconfig> {
public class Cubepanion extends LabyAddon<CubepanionConfig> {

public static Weave weave;
public static List<ChestLocation> chestLocations = new ArrayList<>();
Expand All @@ -57,7 +57,6 @@ public class Cubepanion extends LabyAddon<Cubepanionconfig> {

public Cubepanion() {
instance = this;
LOGGER.init();
}

public static Cubepanion get() {
Expand All @@ -72,19 +71,15 @@ public static void updateRPC() {

@Override
protected void enable() {
LOGGER.info(this.getClass(), "Starting Cubepanion");
LOGGER.setLog(logger());
LOGGER.info(getClass(), "Starting Cubepanion");
this.registerSettingCategory();

if (Laby.labyAPI().labyModLoader().isAddonDevelopmentEnvironment()) {
LOGGER.info(getClass(),"Enabling debug");
LOGGER.setDebug(true);
LOGGER.info(this.getClass(), "Dev environment found. Setting values");

LOGGER.info(this.getClass(), "Set Cubepanionconfig#debug true");
this.configuration().getDebug().set(true);

LOGGER.info(this.getClass(), "Set LeaderboardAPIConfig#errorInfo true");
LOGGER.debug(getClass(), "Set LeaderboardAPIConfig#errorInfo true");
this.configuration().getLeaderboardAPIConfig().getErrorInfo().set(true);

weave = Weave.Dev();
} else {
weave = Weave.Production();
Expand All @@ -96,22 +91,24 @@ protected void enable() {
QOLMapSelectorLink qolMapSelectorLink = storage.getQOLMapSelectorLink();
ChestFinderLink chestFinderLink = storage.getChestFinderLink();
if (votingLink == null) {
LOGGER.warn(this.getClass(), "VotingLink is null. Some features will not work.");
LOGGER.warn(getClass(), "VotingLink is null. Some features will not work.");
}
if (leaderboardTrackerLink == null) {
LOGGER.warn(this.getClass(), "LeaderboardTrackerLink is null. Some features will not work.");
LOGGER.warn(getClass(), "LeaderboardTrackerLink is null. Some features will not work.");
}
if (qolMapSelectorLink == null) {
LOGGER.warn(this.getClass(), "QOLMapSelectorLink is null. Some features will not work.");
LOGGER.warn(getClass(), "QOLMapSelectorLink is null. Some features will not work.");
}
if (chestFinderLink == null) {
LOGGER.warn(this.getClass(), "ChestFinderLink is null. Some features will not work.");
LOGGER.warn(getClass(), "ChestFinderLink is null. Some features will not work.");
}

this.manager = new CubepanionManager(this);
this.rpcManager = new DiscordRPCManager(this);
this.widgetManager = new WidgetManager(this);

LOGGER.setManager(this.manager);

this.registerCommand(new PartyCommands("party", this));
this.registerCommand(new PartyCommands("p", this));
this.registerCommand(new AppealSiteCommand(this));
Expand Down Expand Up @@ -142,7 +139,7 @@ protected void enable() {

this.widgetManager.register();

LOGGER.info(this.getClass(), "Cubepanion has successfully registered all her components.");
LOGGER.info(getClass(), "Cubepanion has successfully registered all her components.");
}

public CubepanionManager getManager() {
Expand All @@ -156,7 +153,7 @@ public Component prefix() {
}

@Override
protected Class<Cubepanionconfig> configurationClass() {
return Cubepanionconfig.class;
protected Class<CubepanionConfig> configurationClass() {
return CubepanionConfig.class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.labymod.api.client.component.event.ClickEvent;
import net.labymod.api.client.component.format.TextDecoration;
import org.cubepanion.core.Cubepanion;
import org.cubepanion.core.config.Cubepanionconfig;
import org.cubepanion.core.config.CubepanionConfig;
import org.cubepanion.core.managers.CubepanionManager;
import org.cubepanion.core.managers.submanagers.FriendTrackerManager;
import org.cubepanion.core.utils.Colours;
Expand Down Expand Up @@ -49,7 +49,7 @@ public OnlineFriendTrackerCommand() {
@Override
public boolean execute(String prefix, String[] arguments) {
CubepanionManager manager = Cubepanion.get().getManager();
Cubepanionconfig config = Cubepanion.get().configuration();
CubepanionConfig config = Cubepanion.get().configuration();
if (!config.getCommandSystemSubConfig().getFriendsTrackerCommand().get()
|| !config.getCommandSystemSubConfig().getEnabled().get()
|| !manager.onCubeCraft()) {
Expand All @@ -67,7 +67,7 @@ public boolean execute(String prefix, String[] arguments) {
switch (arguments[0]) {
case "help" -> reply = reply.append(this.help);
case "track" -> {
if (friendTrackerManager.getTracking().size() == 0) {
if (friendTrackerManager.getTracking().isEmpty()) {
reply = reply.append(
this.componentGetterError.apply("notTrackingAnyOneSuggestion")
.color(Colours.Primary)
Expand All @@ -86,7 +86,7 @@ public boolean execute(String prefix, String[] arguments) {
}
}
case "untrack" -> {
if (friendTrackerManager.getTracking().size() == 0) {
if (friendTrackerManager.getTracking().isEmpty()) {
reply = reply.append(
this.componentGetterError.apply("notTrackingAnyOne").color(Colours.Error));
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@ public class AutomationConfig extends Config {
@KeyBindSetting
@SettingRequires("whereAmI")
private final ConfigProperty<Key> copyBungeecord = new ConfigProperty<>(Key.NONE);
private ResourceLocation friendMessageResourceLocation;

public AutomationConfig() {
this.friendMessageResourceLocation = ResourceLocation.create("minecraft",
this.friendMessageSoundId.get());

this.friendMessageSoundId.addChangeListener(
(type, oldValue, newValue) -> this.friendMessageResourceLocation = ResourceLocation.create(
"minecraft", newValue));
}

public ConfigProperty<Boolean> displayWhereAmI() {
return this.whereAmI;
Expand All @@ -67,7 +57,7 @@ public ConfigProperty<Boolean> friendMessageSound() {
}

public ResourceLocation getFriendMessageSoundId() {
return friendMessageResourceLocation;
return ResourceLocation.create("minecraft",this.friendMessageSoundId.get());
}

public EndGameSubConfig getEndGameSubConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

@ConfigName("settings")
@SpriteTexture("setting_icons.png")
public class Cubepanionconfig extends AddonConfig {
public class CubepanionConfig extends AddonConfig {

@SwitchSetting
private final ConfigProperty<Boolean> enabled = new ConfigProperty<>(true);
Expand All @@ -33,10 +33,8 @@ public class Cubepanionconfig extends AddonConfig {
@SwitchSetting
private final ConfigProperty<Boolean> debug = new ConfigProperty<>(false);

public Cubepanionconfig() {
this.debug.addChangeListener((type, oldValue, newValue) -> {
LOGGER.setEnabled(newValue);
});
public CubepanionConfig() {
this.debug.addChangeListener((ignored, _ignored, val) -> LOGGER.setDebug(val));
}

@Override
Expand Down
12 changes: 1 addition & 11 deletions core/src/main/java/org/cubepanion/core/config/QOLConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ public class QOLConfig extends Config {
@SettingRequires(value = "reminderToVote")
private final ConfigProperty<String> reminderToVoteSoundId = new ConfigProperty<>(
"entity.lightning_bolt.impact");
private ResourceLocation reminderToVoteResourceLocation;

public QOLConfig() {
this.reminderToVoteResourceLocation = ResourceLocation.create("minecraft",
this.reminderToVoteSoundId.get());

this.reminderToVoteSoundId.addChangeListener(
(type, oldValue, newValue) -> this.reminderToVoteResourceLocation = ResourceLocation.create(
"minecraft", newValue));
}

public ConfigProperty<Boolean> getRespawnTimer() {
return this.respawnTimer;
Expand All @@ -56,7 +46,7 @@ public ConfigProperty<Boolean> getReminderToVote() {
}

public ResourceLocation getVoteReminderResourceLocation() {
return reminderToVoteResourceLocation;
return ResourceLocation.create("minecraft",this.reminderToVoteSoundId.get());
}

public ConfigProperty<Boolean> getNoDropSkyBlock() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,46 +21,20 @@ public class ArmourBreakSoundsSubConfig extends Config {
@TextFieldSetting
private final ConfigProperty<String> soundIdBoots = new ConfigProperty<>(
"entity.lightning_bolt.impact");
private ResourceLocation helmetResourceLocation;
private ResourceLocation chestplateResourceLocation;
private ResourceLocation leggingsResourceLocation;
private ResourceLocation bootsResourceLocation;

public ArmourBreakSoundsSubConfig() {
this.helmetResourceLocation = ResourceLocation.create("minecraft", this.soundIdHelmet.get());
this.chestplateResourceLocation = ResourceLocation.create("minecraft",
this.soundIdChestplate.get());
this.leggingsResourceLocation = ResourceLocation.create("minecraft",
this.soundIdLeggings.get());
this.bootsResourceLocation = ResourceLocation.create("minecraft", this.soundIdBoots.get());

this.soundIdHelmet.addChangeListener(
(type, oldValue, newValue) -> this.helmetResourceLocation = ResourceLocation.create(
"minecraft", newValue));
this.soundIdChestplate.addChangeListener(
(type, oldValue, newValue) -> this.chestplateResourceLocation = ResourceLocation.create(
"minecraft", newValue));
this.soundIdLeggings.addChangeListener(
(type, oldValue, newValue) -> this.leggingsResourceLocation = ResourceLocation.create(
"minecraft", newValue));
this.soundIdBoots.addChangeListener(
(type, oldValue, newValue) -> this.bootsResourceLocation = ResourceLocation.create(
"minecraft", newValue));
}

public ResourceLocation getSoundIdBoots() {
return helmetResourceLocation;
return ResourceLocation.create("minecraft", this.soundIdHelmet.get());
}

public ResourceLocation getSoundIdChestplate() {
return chestplateResourceLocation;
return ResourceLocation.create("minecraft",this.soundIdChestplate.get());
}

public ResourceLocation getSoundIdHelmet() {
return leggingsResourceLocation;
return ResourceLocation.create("minecraft", this.soundIdLeggings.get());
}

public ResourceLocation getSoundIdLeggings() {
return bootsResourceLocation;
return ResourceLocation.create("minecraft", this.soundIdBoots.get());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.cubepanion.core.config.subconfig;

import net.labymod.api.client.chat.ChatExecutor;
import net.labymod.api.client.gui.screen.widget.widgets.input.SwitchWidget.SwitchSetting;
import net.labymod.api.client.gui.screen.widget.widgets.input.TextFieldWidget.TextFieldSetting;
import net.labymod.api.client.gui.screen.widget.widgets.input.dropdown.DropdownWidget.DropdownSetting;
Expand Down Expand Up @@ -45,7 +46,34 @@ public ConfigProperty<String> getCustomMessage() {
}

public enum GameEndMessage {
GG, WP, GOOD_GAME, WELL_PLAYED, NONE
GG, WP, GOOD_GAME, WELL_PLAYED, NONE;

public void send(ChatExecutor chat, EndGameSubConfig config, boolean party) {
if (this != GameEndMessage.NONE) {
chat.chat(this.toReadable(), false);
}
if (!config.getCustomMessage().isDefaultValue()) {
chat.chat((party ? "!" : "") + config.getCustomMessage().get(), false);
}
}

private String toReadable() {
switch (this) {
case GG -> {
return "gg";
}
case WP -> {
return "wp";
}
case GOOD_GAME -> {
return "Good game";
}
case WELL_PLAYED -> {
return "Well played";
}
}
return "";
}
}
}

Loading

0 comments on commit 4aa5a1a

Please sign in to comment.