Skip to content

Commit

Permalink
config works now
Browse files Browse the repository at this point in the history
  • Loading branch information
RhythmicSys committed Oct 1, 2022
1 parent 96ffaa5 commit d7135ee
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 17 deletions.
14 changes: 13 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<version>3.3.0</version>
<executions>
<execution>
<phase>package</phase>
Expand All @@ -39,6 +39,12 @@
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>adhdmc.scythe.bstats</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
Expand Down Expand Up @@ -80,5 +86,11 @@
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
2 changes: 2 additions & 0 deletions src/main/java/adhdmc/scythe/Scythe.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import adhdmc.scythe.listeners.InteractListener;
import adhdmc.scythe.listeners.InteractListenerDependsCoreprotect;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bstats.bukkit.Metrics;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
Expand All @@ -27,6 +28,7 @@ public void onEnable() {
instance = this;
logger = this.getLogger();
config = this.getConfig();
Metrics metrics = new Metrics(this, 16540);
try {
Class.forName("net.kyori.adventure.text.minimessage.MiniMessage");
Class.forName("net.kyori.adventure.text.Component");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public ReloadCommand(){
@Override
public void doThing(CommandSender sender, String[] args) {
if (!(sender instanceof Player)|| sender.hasPermission(ConfigHandler.getPermMap().get(ConfigHandler.Permission.RELOAD_COMMAND))) {
ConfigHandler.configParser();
Scythe.getInstance().reloadConfig();
ConfigHandler.configParser();
sender.sendMessage(miniMessage.deserialize(msgs.get(ConfigHandler.Message.CONFIG_RELOAD)));
return;
}
Expand Down
29 changes: 15 additions & 14 deletions src/main/java/adhdmc/scythe/config/ConfigHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
import org.bukkit.block.data.Ageable;
import org.bukkit.block.data.BlockData;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.Plugin;

import java.util.*;
import java.util.logging.Logger;

public class ConfigHandler {
private static final Logger logger = Scythe.getScytheLogger();
private static final FileConfiguration config = Scythe.getScytheConfig();
private static final Plugin instance = Scythe.getInstance();
private static boolean requireHoe;
private static boolean rightClickHarvest;
private static final HashMap<Message, String> messageMap = new HashMap<>();
Expand All @@ -30,13 +31,13 @@ public static void configParser(){
setConfiguredCrops();
requireHoe = false;
rightClickHarvest = true;
requireHoe = config.getBoolean("require-hoe");
rightClickHarvest = config.getBoolean("right-click-to-harvest");
requireHoe = instance.getConfig().getBoolean("require-hoe");
rightClickHarvest = instance.getConfig().getBoolean("right-click-to-harvest");
}

private static void setConfiguredCrops(){
configuredCrops.clear();
List<String> cropList = config.getStringList("crops");
List<String> cropList = instance.getConfig().getStringList("crops");
for (String configCrop : cropList){
if(Material.matchMaterial(configCrop) == null){
logger.warning( messageMap.get(Message.CONSOLE_PREFIX) + configCrop + " is not a valid material. Please check to be sure you spelled everything correctly.");
Expand Down Expand Up @@ -84,25 +85,25 @@ private static void setMessageMap(){
messageMap.clear();
messageMap.put(Message.CONSOLE_PREFIX, "[Scythe] ");
messageMap.put(Message.PREFIX,
config.getString("prefix","<gold><bold>[</bold><yellow>Scythe</yellow><bold>]<reset>"));
instance.getConfig().getString("prefix","<gold><bold>[</bold><yellow>Scythe</yellow><bold>]<reset>"));
messageMap.put(Message.TOGGLE_ON,
config.getString("toggle-on", "<green>Scythe toggled on!"));
instance.getConfig().getString("toggle-on", "<green>Scythe toggled on!"));
messageMap.put(Message.TOGGLE_OFF,
config.getString("toggle-off", "<red>Scythe toggled off!"));
instance.getConfig().getString("toggle-off", "<red>Scythe toggled off!"));
messageMap.put(Message.UNKNOWN_COMMAND,
config.getString("unknown-command", "<red>Unknown Command"));
instance.getConfig().getString("unknown-command", "<red>Unknown Command"));
messageMap.put(Message.CONFIG_RELOAD,
config.getString("config-reload", "<gold>Scythe Config Reloaded!"));
instance.getConfig().getString("config-reload", "<gold>Scythe Config Reloaded!"));
messageMap.put(Message.NO_PERMISSION,
config.getString("no-permission", "<red>You do not have the required Permission to run this command"));
instance.getConfig().getString("no-permission", "<red>You do not have the required Permission to run this command"));
messageMap.put(Message.NOT_A_PLAYER,
config.getString("not-a-player", "Sorry! This command can only be run by a player"));
instance.getConfig().getString("not-a-player", "Sorry! This command can only be run by a player"));
messageMap.put(Message.HELP_MAIN,
config.getString("help-main", "<grey>Scythe allows players to harvest grown crops without needing to replant"));
instance.getConfig().getString("help-main", "<grey>Scythe allows players to harvest grown crops without needing to replant"));
messageMap.put(Message.HELP_TOGGLE,
config.getString("help-toggle", "<yellow>/scythe toggle \n<grey>• Toggle scythe on or off"));
instance.getConfig().getString("help-toggle", "<yellow>/scythe toggle \n<grey>• Toggle scythe on or off"));
messageMap.put(Message.HELP_RELOAD,
config.getString("help-reload", "<yellow>/scythe reload \n<grey>• Reloads config settings"));
instance.getConfig().getString("help-reload", "<yellow>/scythe reload \n<grey>• Reloads config settings"));
}
public static Map<Message, String> getMessageMap() {
return Collections.unmodifiableMap(messageMap);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Scythe
require-hoe: false
allow-right-click-to-harvest: true
right-click-to-harvest: true
#crops the plugin should work on
crops:
- BEETROOTS
Expand Down

0 comments on commit d7135ee

Please sign in to comment.