Skip to content

Commit

Permalink
Added Debug Functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
LoJoSho committed Jul 24, 2022
1 parent 0d1a5e6 commit 1e55ce3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.lojosho.enchantnow.util.EnchantArgProcessing;
import com.lojosho.enchantnow.util.EnchantItem;
import com.lojosho.enchantnow.util.SendDebugUtil;
import com.lojosho.enchantnow.util.SendMessageUtil;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
Expand Down Expand Up @@ -84,6 +85,7 @@ private static void enchantCommandProcess(CommandSender sender, String[] args, I
placeholders =
TagResolver.resolver(Placeholder.parsed("player", player.getName()));
SendMessageUtil.sendConfigMessage(sender, "messages.sendBook", placeholders);
SendDebugUtil.sendDebugMessage(player.getName() + " has recieved a book from " + sender.getName());
return;
}
sender.sendMessage("Improper arguments");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.lojosho.enchantnow.util.EnchantArgProcessing;
import com.lojosho.enchantnow.util.EnchantItem;
import com.lojosho.enchantnow.util.SendDebugUtil;
import com.lojosho.enchantnow.util.SendMessageUtil;
import org.bukkit.Bukkit;
import org.bukkit.Material;
Expand Down Expand Up @@ -90,6 +91,7 @@ private static void addEnchantItem(String[] args, CommandSender sender, ItemStac
}

SendMessageUtil.sendConfigMessage(sender, "messages.sendEnchant");
SendDebugUtil.sendDebugMessage(player.getName() + " has enchanted from " + sender.getName());
return;
}
}
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/com/lojosho/enchantnow/util/SendDebugUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.lojosho.enchantnow.util;

import com.lojosho.enchantnow.EnchantNow;

import java.util.logging.Level;

public class SendDebugUtil {

private static EnchantNow plugin = EnchantNow.getInstance();

public static void sendDebugMessage(String message, Level level) {
if (plugin.getConfig().getBoolean("settings.debug", false)) {
plugin.getLogger().log(level, message);
}
}

public static void sendDebugMessage(String message) {
sendDebugMessage(message, Level.INFO);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.logging.Level;

public class StringToEnchantUtil {

Expand Down Expand Up @@ -62,8 +63,9 @@ public static void setup() {

if (EnchantNow.hasEcoEnchantments()) {
for (EcoEnchant ench : EcoEnchants.values()) {
enchantMap.put(ench.getKey().toString().toUpperCase(Locale.ROOT).replaceAll(".+:", ""), ench);
//EnchantNow.getInstance().getLogger().info("Added " + ench.getKey().toString().replaceAll(".+:", "") + " to the list of enchantments");
String enchant = ench.getKey().toString().toUpperCase(Locale.ROOT).replaceAll(".+:", "");
enchantMap.put(enchant, ench);
SendDebugUtil.sendDebugMessage(enchant + " has been detected and added!", Level.INFO);
}
}

Expand Down

0 comments on commit 1e55ce3

Please sign in to comment.