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

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.config.hocon;
import com.gmail.nossr50.config.ConfigConstants;
import com.gmail.nossr50.mcMMO;
import ninja.leaping.configurate.ConfigurationOptions;
import ninja.leaping.configurate.ValueType;
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
@ -52,6 +53,8 @@ import java.util.Objects;
* @param <T> the class type of the config
*/
public class SerializedConfigLoader<T> {
private final mcMMO pluginRef;
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" +
"\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;
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;
this.parent = parent;
this.path = getPathFromFileName(fileName);
@ -119,7 +123,7 @@ public class SerializedConfigLoader<T> {
}
private Path getPathFromFileName(String fileName) {
File configFile = new File(ConfigConstants.getConfigFolder(), fileName);
File configFile = new File(ConfigConstants.getConfigFolder(pluginRef), fileName);
return configFile.toPath();
}

View File

@ -986,7 +986,7 @@ public class McMMOPlayer {
* 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
*/
if (tool.inHand(inHand) && !getToolPreparationMode(tool)) {
if (tool.inHand(pluginRef, inHand) && !getToolPreparationMode(tool)) {
if (primarySkillType != PrimarySkillType.WOODCUTTING && primarySkillType != PrimarySkillType.AXES) {
int timeRemaining = calculateTimeRemaining(ability);

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.datatypes.skills;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
@ -33,7 +34,7 @@ public enum ToolType {
* @param itemStack The item to check
* @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) {
case AXE:
return pluginRef.getItemTools().isAxe(itemStack);

View File

@ -2,12 +2,12 @@ package com.gmail.nossr50.util.nbt;
import com.gmail.nossr50.mcMMO;
import net.minecraft.server.v1_13_R2.NBTBase;
import net.minecraft.server.v1_13_R2.NBTList;
import net.minecraft.server.v1_13_R2.NBTTagCompound;
import net.minecraft.server.v1_14_R1.NBTBase;
import net.minecraft.server.v1_14_R1.NBTList;
import net.minecraft.server.v1_14_R1.NBTTagCompound;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_13_R2.util.CraftNBTTagConfigSerializer;
import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_14_R1.util.CraftNBTTagConfigSerializer;
import org.bukkit.inventory.ItemStack;
public class NBTManager {
@ -31,7 +31,7 @@ public class NBTManager {
public NBTTagCompound getNBT(ItemStack itemStack) {
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();
return rootTag;
}