Fixing a few more things

This commit is contained in:
nossr50 2019-09-23 16:18:36 -07:00
parent 50e955d07e
commit b0803df7c5
5 changed files with 85 additions and 78 deletions

View File

@ -1,5 +1,7 @@
package com.gmail.nossr50.config; package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
@ -40,72 +42,72 @@ public class ConfigConstants {
EXAMPLE_BLACKLIST_WORLDS_LIST_DEFAULT.add(EXAMPLE_BLACKLIST_WORLDS[2]); EXAMPLE_BLACKLIST_WORLDS_LIST_DEFAULT.add(EXAMPLE_BLACKLIST_WORLDS[2]);
} }
// /** /**
// * Return the data folder for mcMMO * Return the data folder for mcMMO
// * *
// * @return the File for the data folder used by mcMMO * @return the File for the data folder used by mcMMO
// */ */
// public static File getDataFolder() { public static File getDataFolder(mcMMO pluginRef) {
// return pluginRef.getDataFolder(); return pluginRef.getDataFolder();
// } }
//
// public static File getConfigFolder() { public static File getConfigFolder(mcMMO pluginRef) {
// return new File(getDataFolder(), FOLDER_NAME_CONFIG); return new File(getDataFolder(pluginRef), FOLDER_NAME_CONFIG);
// } }
//
// public static File getDefaultsFolder() { public static File getDefaultsFolder(mcMMO pluginRef) {
// return new File(getConfigFolder().getAbsolutePath(), FOLDER_NAME_DEFAULTS); return new File(getConfigFolder(pluginRef).getAbsolutePath(), FOLDER_NAME_DEFAULTS);
// } }
//
// public static File getDefaultsConfigFolder() { public static File getDefaultsConfigFolder(mcMMO pluginRef) {
// return new File(getDefaultsFolder().getAbsolutePath(), FOLDER_NAME_CONFIG); return new File(getDefaultsFolder(pluginRef).getAbsolutePath(), FOLDER_NAME_CONFIG);
// } }
//
// public static File getDefaultsSkillFolder() { public static File getDefaultsSkillFolder(mcMMO pluginRef) {
// return new File(getDefaultsConfigFolder().getAbsolutePath(), FOLDER_NAME_SKILLS); return new File(getDefaultsConfigFolder(pluginRef).getAbsolutePath(), FOLDER_NAME_SKILLS);
// } }
//
// public static File getDefaultsXPFolder() { public static File getDefaultsXPFolder(mcMMO pluginRef) {
// return new File(getDefaultsConfigFolder().getAbsolutePath(), FOLDER_NAME_EXPERIENCE); return new File(getDefaultsConfigFolder(pluginRef).getAbsolutePath(), FOLDER_NAME_EXPERIENCE);
// } }
//
// public static File getConfigSkillFolder() { public static File getConfigSkillFolder(mcMMO pluginRef) {
// return new File(getConfigFolder().getAbsolutePath(), FOLDER_NAME_SKILLS); return new File(getConfigFolder(pluginRef).getAbsolutePath(), FOLDER_NAME_SKILLS);
// } }
//
// public static File getConfigXPFolder() { public static File getConfigXPFolder(mcMMO pluginRef) {
// return new File(getConfigFolder().getAbsolutePath(), FOLDER_NAME_EXPERIENCE); return new File(getConfigFolder(pluginRef).getAbsolutePath(), FOLDER_NAME_EXPERIENCE);
// } }
//
// /** /**
// * Creates all directories used by mcMMO config files * Creates all directories used by mcMMO config files
// */ */
// public static void makeAllConfigDirectories() { public static void makeAllConfigDirectories(mcMMO pluginRef) {
// /* CONFIG DIRECTORY */ /* CONFIG DIRECTORY */
//
// if (!getConfigFolder().exists()) if (!getConfigFolder(pluginRef).exists())
// getConfigFolder().mkdirs(); getConfigFolder(pluginRef).mkdirs();
//
// /* DEFAULT DIRECTORIES */ /* DEFAULT DIRECTORIES */
//
// if (!getDefaultsFolder().exists()) if (!getDefaultsFolder(pluginRef).exists())
// getDefaultsFolder().mkdirs(); getDefaultsFolder(pluginRef).mkdirs();
//
// if (!getDefaultsConfigFolder().exists()) if (!getDefaultsConfigFolder(pluginRef).exists())
// getDefaultsConfigFolder().mkdirs(); getDefaultsConfigFolder(pluginRef).mkdirs();
//
// if (!getDefaultsSkillFolder().exists()) if (!getDefaultsSkillFolder(pluginRef).exists())
// getDefaultsSkillFolder().mkdirs(); getDefaultsSkillFolder(pluginRef).mkdirs();
//
// if (!getDefaultsXPFolder().exists()) if (!getDefaultsXPFolder(pluginRef).exists())
// getDefaultsXPFolder().mkdirs(); getDefaultsXPFolder(pluginRef).mkdirs();
//
// /* CONFIG SUBDIRECTORIES */ /* CONFIG SUBDIRECTORIES */
//
// if (!getConfigSkillFolder().exists()) if (!getConfigSkillFolder(pluginRef).exists())
// getConfigSkillFolder().mkdirs(); getConfigSkillFolder(pluginRef).mkdirs();
//
// if (!getConfigXPFolder().exists()) if (!getConfigXPFolder(pluginRef).exists())
// getConfigXPFolder().mkdirs(); getConfigXPFolder(pluginRef).mkdirs();
// } }
} }

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.config.hocon; package com.gmail.nossr50.config.hocon;
import com.gmail.nossr50.config.ConfigConstants; import com.gmail.nossr50.config.ConfigConstants;
import com.gmail.nossr50.mcMMO;
import ninja.leaping.configurate.ConfigurationOptions; import ninja.leaping.configurate.ConfigurationOptions;
import ninja.leaping.configurate.ValueType; import ninja.leaping.configurate.ValueType;
import ninja.leaping.configurate.commented.CommentedConfigurationNode; import ninja.leaping.configurate.commented.CommentedConfigurationNode;
@ -52,6 +53,8 @@ import java.util.Objects;
* @param <T> the class type of the config * @param <T> the class type of the config
*/ */
public class SerializedConfigLoader<T> { public class SerializedConfigLoader<T> {
private final mcMMO pluginRef;
private static final String CONFIG_HEADER = "Configuration files are now in the HOCON file format!\n" + private static final String CONFIG_HEADER = "Configuration files are now in the HOCON file format!\n" +
"\nHOCON is a lot less strict than YAML, so don't worry about the number of spaces and such!\n" + "\nHOCON is a lot less strict than YAML, so don't worry about the number of spaces and such!\n" +
"\nIt is recommended that you use a nice text editor to view and edit these files" + "\nIt is recommended that you use a nice text editor to view and edit these files" +
@ -80,7 +83,8 @@ public class SerializedConfigLoader<T> {
*/ */
private ObjectMapper<T>.BoundInstance configMapper; private ObjectMapper<T>.BoundInstance configMapper;
public SerializedConfigLoader(Class<T> clazz, String fileName, String rootNodeName, SerializedConfigLoader parent) { public SerializedConfigLoader(mcMMO pluginRef, Class<T> clazz, String fileName, String rootNodeName, SerializedConfigLoader parent) {
this.pluginRef = pluginRef;
ROOT_NODE_ADDRESS = rootNodeName; ROOT_NODE_ADDRESS = rootNodeName;
this.parent = parent; this.parent = parent;
this.path = getPathFromFileName(fileName); this.path = getPathFromFileName(fileName);
@ -119,7 +123,7 @@ public class SerializedConfigLoader<T> {
} }
private Path getPathFromFileName(String fileName) { private Path getPathFromFileName(String fileName) {
File configFile = new File(ConfigConstants.getConfigFolder(), fileName); File configFile = new File(ConfigConstants.getConfigFolder(pluginRef), fileName);
return configFile.toPath(); return configFile.toPath();
} }

View File

@ -986,7 +986,7 @@ public class McMMOPlayer {
* Woodcutting & Axes need to be treated differently. * Woodcutting & Axes need to be treated differently.
* Basically the tool always needs to ready and we check to see if the cooldown is over when the user takes action * Basically the tool always needs to ready and we check to see if the cooldown is over when the user takes action
*/ */
if (tool.inHand(inHand) && !getToolPreparationMode(tool)) { if (tool.inHand(pluginRef, inHand) && !getToolPreparationMode(tool)) {
if (primarySkillType != PrimarySkillType.WOODCUTTING && primarySkillType != PrimarySkillType.AXES) { if (primarySkillType != PrimarySkillType.WOODCUTTING && primarySkillType != PrimarySkillType.AXES) {
int timeRemaining = calculateTimeRemaining(ability); int timeRemaining = calculateTimeRemaining(ability);

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.datatypes.skills; package com.gmail.nossr50.datatypes.skills;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -33,7 +34,7 @@ public enum ToolType {
* @param itemStack The item to check * @param itemStack The item to check
* @return true if the item is the right type, false otherwise * @return true if the item is the right type, false otherwise
*/ */
public boolean inHand(ItemStack itemStack) { public boolean inHand(mcMMO pluginRef, ItemStack itemStack) {
switch (this) { switch (this) {
case AXE: case AXE:
return pluginRef.getItemTools().isAxe(itemStack); return pluginRef.getItemTools().isAxe(itemStack);

View File

@ -2,12 +2,12 @@ package com.gmail.nossr50.util.nbt;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import net.minecraft.server.v1_13_R2.NBTBase; import net.minecraft.server.v1_14_R1.NBTBase;
import net.minecraft.server.v1_13_R2.NBTList; import net.minecraft.server.v1_14_R1.NBTList;
import net.minecraft.server.v1_13_R2.NBTTagCompound; import net.minecraft.server.v1_14_R1.NBTTagCompound;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_13_R2.util.CraftNBTTagConfigSerializer; import org.bukkit.craftbukkit.v1_14_R1.util.CraftNBTTagConfigSerializer;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class NBTManager { public class NBTManager {
@ -31,7 +31,7 @@ public class NBTManager {
public NBTTagCompound getNBT(ItemStack itemStack) { public NBTTagCompound getNBT(ItemStack itemStack) {
Bukkit.broadcastMessage("Checking NBT for "+itemStack.toString()); Bukkit.broadcastMessage("Checking NBT for "+itemStack.toString());
net.minecraft.server.v1_13_R2.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack); net.minecraft.server.v1_14_R1.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
NBTTagCompound rootTag = nmsItemStack.getTag(); NBTTagCompound rootTag = nmsItemStack.getTag();
return rootTag; return rootTag;
} }