Skip to content

Commit d7135ee

Browse files
committed
config works now
1 parent 96ffaa5 commit d7135ee

File tree

5 files changed

+32
-17
lines changed

5 files changed

+32
-17
lines changed

pom.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<plugin>
3131
<groupId>org.apache.maven.plugins</groupId>
3232
<artifactId>maven-shade-plugin</artifactId>
33-
<version>3.2.4</version>
33+
<version>3.3.0</version>
3434
<executions>
3535
<execution>
3636
<phase>package</phase>
@@ -39,6 +39,12 @@
3939
</goals>
4040
<configuration>
4141
<createDependencyReducedPom>false</createDependencyReducedPom>
42+
<relocations>
43+
<relocation>
44+
<pattern>org.bstats</pattern>
45+
<shadedPattern>adhdmc.scythe.bstats</shadedPattern>
46+
</relocation>
47+
</relocations>
4248
</configuration>
4349
</execution>
4450
</executions>
@@ -80,5 +86,11 @@
8086
<version>1.18.2-R0.1-SNAPSHOT</version>
8187
<scope>provided</scope>
8288
</dependency>
89+
<dependency>
90+
<groupId>org.bstats</groupId>
91+
<artifactId>bstats-bukkit</artifactId>
92+
<version>3.0.0</version>
93+
<scope>compile</scope>
94+
</dependency>
8395
</dependencies>
8496
</project>

src/main/java/adhdmc/scythe/Scythe.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import adhdmc.scythe.listeners.InteractListener;
1010
import adhdmc.scythe.listeners.InteractListenerDependsCoreprotect;
1111
import net.kyori.adventure.text.minimessage.MiniMessage;
12+
import org.bstats.bukkit.Metrics;
1213
import org.bukkit.configuration.file.FileConfiguration;
1314
import org.bukkit.plugin.Plugin;
1415
import org.bukkit.plugin.java.JavaPlugin;
@@ -27,6 +28,7 @@ public void onEnable() {
2728
instance = this;
2829
logger = this.getLogger();
2930
config = this.getConfig();
31+
Metrics metrics = new Metrics(this, 16540);
3032
try {
3133
Class.forName("net.kyori.adventure.text.minimessage.MiniMessage");
3234
Class.forName("net.kyori.adventure.text.Component");

src/main/java/adhdmc/scythe/commands/subcommands/ReloadCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public ReloadCommand(){
2222
@Override
2323
public void doThing(CommandSender sender, String[] args) {
2424
if (!(sender instanceof Player)|| sender.hasPermission(ConfigHandler.getPermMap().get(ConfigHandler.Permission.RELOAD_COMMAND))) {
25-
ConfigHandler.configParser();
2625
Scythe.getInstance().reloadConfig();
26+
ConfigHandler.configParser();
2727
sender.sendMessage(miniMessage.deserialize(msgs.get(ConfigHandler.Message.CONFIG_RELOAD)));
2828
return;
2929
}

src/main/java/adhdmc/scythe/config/ConfigHandler.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
import org.bukkit.block.data.Ageable;
1111
import org.bukkit.block.data.BlockData;
1212
import org.bukkit.configuration.file.FileConfiguration;
13+
import org.bukkit.plugin.Plugin;
1314

1415
import java.util.*;
1516
import java.util.logging.Logger;
1617

1718
public class ConfigHandler {
1819
private static final Logger logger = Scythe.getScytheLogger();
19-
private static final FileConfiguration config = Scythe.getScytheConfig();
20+
private static final Plugin instance = Scythe.getInstance();
2021
private static boolean requireHoe;
2122
private static boolean rightClickHarvest;
2223
private static final HashMap<Message, String> messageMap = new HashMap<>();
@@ -30,13 +31,13 @@ public static void configParser(){
3031
setConfiguredCrops();
3132
requireHoe = false;
3233
rightClickHarvest = true;
33-
requireHoe = config.getBoolean("require-hoe");
34-
rightClickHarvest = config.getBoolean("right-click-to-harvest");
34+
requireHoe = instance.getConfig().getBoolean("require-hoe");
35+
rightClickHarvest = instance.getConfig().getBoolean("right-click-to-harvest");
3536
}
3637

3738
private static void setConfiguredCrops(){
3839
configuredCrops.clear();
39-
List<String> cropList = config.getStringList("crops");
40+
List<String> cropList = instance.getConfig().getStringList("crops");
4041
for (String configCrop : cropList){
4142
if(Material.matchMaterial(configCrop) == null){
4243
logger.warning( messageMap.get(Message.CONSOLE_PREFIX) + configCrop + " is not a valid material. Please check to be sure you spelled everything correctly.");
@@ -84,25 +85,25 @@ private static void setMessageMap(){
8485
messageMap.clear();
8586
messageMap.put(Message.CONSOLE_PREFIX, "[Scythe] ");
8687
messageMap.put(Message.PREFIX,
87-
config.getString("prefix","<gold><bold>[</bold><yellow>Scythe</yellow><bold>]<reset>"));
88+
instance.getConfig().getString("prefix","<gold><bold>[</bold><yellow>Scythe</yellow><bold>]<reset>"));
8889
messageMap.put(Message.TOGGLE_ON,
89-
config.getString("toggle-on", "<green>Scythe toggled on!"));
90+
instance.getConfig().getString("toggle-on", "<green>Scythe toggled on!"));
9091
messageMap.put(Message.TOGGLE_OFF,
91-
config.getString("toggle-off", "<red>Scythe toggled off!"));
92+
instance.getConfig().getString("toggle-off", "<red>Scythe toggled off!"));
9293
messageMap.put(Message.UNKNOWN_COMMAND,
93-
config.getString("unknown-command", "<red>Unknown Command"));
94+
instance.getConfig().getString("unknown-command", "<red>Unknown Command"));
9495
messageMap.put(Message.CONFIG_RELOAD,
95-
config.getString("config-reload", "<gold>Scythe Config Reloaded!"));
96+
instance.getConfig().getString("config-reload", "<gold>Scythe Config Reloaded!"));
9697
messageMap.put(Message.NO_PERMISSION,
97-
config.getString("no-permission", "<red>You do not have the required Permission to run this command"));
98+
instance.getConfig().getString("no-permission", "<red>You do not have the required Permission to run this command"));
9899
messageMap.put(Message.NOT_A_PLAYER,
99-
config.getString("not-a-player", "Sorry! This command can only be run by a player"));
100+
instance.getConfig().getString("not-a-player", "Sorry! This command can only be run by a player"));
100101
messageMap.put(Message.HELP_MAIN,
101-
config.getString("help-main", "<grey>Scythe allows players to harvest grown crops without needing to replant"));
102+
instance.getConfig().getString("help-main", "<grey>Scythe allows players to harvest grown crops without needing to replant"));
102103
messageMap.put(Message.HELP_TOGGLE,
103-
config.getString("help-toggle", "<yellow>/scythe toggle \n<grey>• Toggle scythe on or off"));
104+
instance.getConfig().getString("help-toggle", "<yellow>/scythe toggle \n<grey>• Toggle scythe on or off"));
104105
messageMap.put(Message.HELP_RELOAD,
105-
config.getString("help-reload", "<yellow>/scythe reload \n<grey>• Reloads config settings"));
106+
instance.getConfig().getString("help-reload", "<yellow>/scythe reload \n<grey>• Reloads config settings"));
106107
}
107108
public static Map<Message, String> getMessageMap() {
108109
return Collections.unmodifiableMap(messageMap);

src/main/resources/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Scythe
22
require-hoe: false
3-
allow-right-click-to-harvest: true
3+
right-click-to-harvest: true
44
#crops the plugin should work on
55
crops:
66
- BEETROOTS

0 commit comments

Comments
 (0)