mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 22:26:46 +01:00
more work on api + remove mcimport command
This commit is contained in:
parent
85b88e568a
commit
d044de5350
@ -1,4 +1,5 @@
|
|||||||
Version 2.2.000
|
Version 2.2.000
|
||||||
|
Removed the mcimport command as its useless (was for mod configs)
|
||||||
mcMMO-API is now the library used for mcMMO API
|
mcMMO-API is now the library used for mcMMO API
|
||||||
Parts of the API have been migrated to mcMMO-API
|
Parts of the API have been migrated to mcMMO-API
|
||||||
(API) mcMMO makes use of jmal (Java Minecraft Abstraction Library) for some abstraction now
|
(API) mcMMO makes use of jmal (Java Minecraft Abstraction Library) for some abstraction now
|
||||||
|
@ -1,336 +0,0 @@
|
|||||||
package com.gmail.nossr50.commands;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.ModConfigType;
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
public class McImportCommand implements CommandExecutor {
|
|
||||||
int fileAmount;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
|
||||||
if (args.length == 0) {
|
|
||||||
importModConfig();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean importModConfig() {
|
|
||||||
String importFilePath = mcMMO.getModDirectory() + File.separator + "import";
|
|
||||||
File importFile = new File(importFilePath, "import.log");
|
|
||||||
mcMMO.p.getLogger().info("Starting import of mod materials...");
|
|
||||||
fileAmount = 0;
|
|
||||||
|
|
||||||
HashMap<ModConfigType, ArrayList<String>> materialNames = new HashMap<>();
|
|
||||||
|
|
||||||
BufferedReader in = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Open the file
|
|
||||||
in = new BufferedReader(new FileReader(importFile));
|
|
||||||
|
|
||||||
String line;
|
|
||||||
String materialName;
|
|
||||||
String modName;
|
|
||||||
|
|
||||||
// While not at the end of the file
|
|
||||||
while ((line = in.readLine()) != null) {
|
|
||||||
String[] split1 = line.split("material ");
|
|
||||||
|
|
||||||
if (split1.length != 2) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] split2 = split1[1].split(" with");
|
|
||||||
|
|
||||||
if (split2.length != 2) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
materialName = split2[0];
|
|
||||||
|
|
||||||
// Categorise each material under a mod config type
|
|
||||||
ModConfigType type = ModConfigType.getModConfigType(materialName);
|
|
||||||
|
|
||||||
if (!materialNames.containsKey(type)) {
|
|
||||||
materialNames.put(type, new ArrayList<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
materialNames.get(type).add(materialName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (FileNotFoundException e) {
|
|
||||||
mcMMO.p.getLogger().warning("Could not find " + importFile.getAbsolutePath() + " ! (No such file or directory)");
|
|
||||||
mcMMO.p.getLogger().warning("Copy and paste latest.log to " + importFile.getParentFile().getAbsolutePath() + " and rename it to import.log");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
tryClose(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
createOutput(materialNames);
|
|
||||||
|
|
||||||
mcMMO.p.getLogger().info("Import finished! Created " + fileAmount + " files!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createOutput(HashMap<ModConfigType, ArrayList<String>> materialNames) {
|
|
||||||
for (ModConfigType modConfigType : materialNames.keySet()) {
|
|
||||||
HashMap<String, ArrayList<String>> materialNamesType = new HashMap<>();
|
|
||||||
|
|
||||||
for (String materialName : materialNames.get(modConfigType)) {
|
|
||||||
String modName = Misc.getModName(materialName);
|
|
||||||
|
|
||||||
if (!materialNamesType.containsKey(modName)) {
|
|
||||||
materialNamesType.put(modName, new ArrayList<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
materialNamesType.get(modName).add(materialName);
|
|
||||||
}
|
|
||||||
|
|
||||||
createOutput(modConfigType, materialNamesType);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void tryClose(Closeable c) {
|
|
||||||
if (c == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
c.close();
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createOutput(ModConfigType modConfigType, HashMap<String, ArrayList<String>> materialNames) {
|
|
||||||
File outputFilePath = new File(mcMMO.getModDirectory() + File.separator + "output");
|
|
||||||
if (!outputFilePath.exists() && !outputFilePath.mkdirs()) {
|
|
||||||
mcMMO.p.getLogger().severe("Could not create output directory! " + outputFilePath.getAbsolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
FileWriter out = null;
|
|
||||||
String type = modConfigType.name().toLowerCase(Locale.ENGLISH);
|
|
||||||
|
|
||||||
for (String modName : materialNames.keySet()) {
|
|
||||||
File outputFile = new File(outputFilePath, modName + "." + type + ".yml");
|
|
||||||
mcMMO.p.getLogger().info("Creating " + outputFile.getName());
|
|
||||||
try {
|
|
||||||
if (outputFile.exists() && !outputFile.delete()) {
|
|
||||||
mcMMO.p.getLogger().severe("Not able to delete old output file! " + outputFile.getAbsolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!outputFile.createNewFile()) {
|
|
||||||
mcMMO.p.getLogger().severe("Could not create output file! " + outputFile.getAbsolutePath());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuilder writer = new StringBuilder();
|
|
||||||
HashMap<String, ArrayList<String>> configSections = getConfigSections(modConfigType, modName, materialNames);
|
|
||||||
|
|
||||||
if (configSections == null) {
|
|
||||||
mcMMO.p.getLogger().severe("Something went wrong!! type is " + type);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write the file, go through each rootSkilland write all the materials
|
|
||||||
for (String configSection : configSections.keySet()) {
|
|
||||||
if (configSection.equals("UNIDENTIFIED")) {
|
|
||||||
writer.append("# This isn't a valid config section and all materials in this category need to be").append("\r\n");
|
|
||||||
writer.append("# copy and pasted to a valid section of this config file.").append("\r\n");
|
|
||||||
}
|
|
||||||
writer.append(configSection).append(":").append("\r\n");
|
|
||||||
|
|
||||||
for (String line : configSections.get(configSection)) {
|
|
||||||
writer.append(line).append("\r\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.append("\r\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
out = new FileWriter(outputFile);
|
|
||||||
out.write(writer.toString());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return;
|
|
||||||
} finally {
|
|
||||||
tryClose(out);
|
|
||||||
fileAmount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private HashMap<String, ArrayList<String>> getConfigSections(ModConfigType type, String modName, HashMap<String, ArrayList<String>> materialNames) {
|
|
||||||
switch (type) {
|
|
||||||
case BLOCKS:
|
|
||||||
return getConfigSectionsBlocks(modName, materialNames);
|
|
||||||
case TOOLS:
|
|
||||||
return getConfigSectionsTools(modName, materialNames);
|
|
||||||
case ARMOR:
|
|
||||||
return getConfigSectionsArmor(modName, materialNames);
|
|
||||||
case UNKNOWN:
|
|
||||||
return getConfigSectionsUnknown(modName, materialNames);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private HashMap<String, ArrayList<String>> getConfigSectionsBlocks(String modName, HashMap<String, ArrayList<String>> materialNames) {
|
|
||||||
HashMap<String, ArrayList<String>> configSections = new HashMap<>();
|
|
||||||
|
|
||||||
// Go through all the materials and categorise them under a skill
|
|
||||||
for (String materialName : materialNames.get(modName)) {
|
|
||||||
String skillName = "UNIDENTIFIED";
|
|
||||||
if (materialName.contains("ORE")) {
|
|
||||||
skillName = "Mining";
|
|
||||||
}
|
|
||||||
else if (materialName.contains("LOG") || materialName.contains("LEAVES")) {
|
|
||||||
skillName = "Woodcutting";
|
|
||||||
}
|
|
||||||
else if (materialName.contains("GRASS") || materialName.contains("FLOWER") || materialName.contains("CROP")) {
|
|
||||||
skillName = "Herbalism";
|
|
||||||
}
|
|
||||||
else if (materialName.contains("DIRT") || materialName.contains("SAND")) {
|
|
||||||
skillName = "Excavation";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!configSections.containsKey(rootSkillName)) {
|
|
||||||
configSections.put(rootSkillName, new ArrayList<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<String> skillContents = configSections.get(rootSkillName);
|
|
||||||
skillContents.add(" " + materialName + "|0:");
|
|
||||||
skillContents.add(" " + " " + "XP_Gain: 99");
|
|
||||||
skillContents.add(" " + " " + "Double_Drops_Enabled: true");
|
|
||||||
|
|
||||||
if (rootSkillName.equals("Mining")) {
|
|
||||||
skillContents.add(" " + " " + "Smelting_XP_Gain: 9");
|
|
||||||
}
|
|
||||||
else if (rootSkillName.equals("Woodcutting")) {
|
|
||||||
skillContents.add(" " + " " + "Is_Log: " + materialName.contains("LOG"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return configSections;
|
|
||||||
}
|
|
||||||
|
|
||||||
private HashMap<String, ArrayList<String>> getConfigSectionsTools(String modName, HashMap<String, ArrayList<String>> materialNames) {
|
|
||||||
HashMap<String, ArrayList<String>> configSections = new HashMap<>();
|
|
||||||
|
|
||||||
// Go through all the materials and categorise them under a tool type
|
|
||||||
for (String materialName : materialNames.get(modName)) {
|
|
||||||
String toolType = "UNIDENTIFIED";
|
|
||||||
if (materialName.contains("PICKAXE")) {
|
|
||||||
toolType = "Pickaxes";
|
|
||||||
}
|
|
||||||
else if (materialName.contains("AXE")) {
|
|
||||||
toolType = "Axes";
|
|
||||||
}
|
|
||||||
else if (materialName.contains("BOW")) {
|
|
||||||
toolType = "Bows";
|
|
||||||
}
|
|
||||||
else if (materialName.contains("HOE")) {
|
|
||||||
toolType = "Hoes";
|
|
||||||
}
|
|
||||||
else if (materialName.contains("SHOVEL") || materialName.contains("SPADE")) {
|
|
||||||
toolType = "Shovels";
|
|
||||||
}
|
|
||||||
else if (materialName.contains("SWORD")) {
|
|
||||||
toolType = "Swords";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!configSections.containsKey(toolType)) {
|
|
||||||
configSections.put(toolType, new ArrayList<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<String> skillContents = configSections.get(toolType);
|
|
||||||
skillContents.add(" " + materialName + ":");
|
|
||||||
skillContents.add(" " + " " + "XP_Modifier: 1.0");
|
|
||||||
skillContents.add(" " + " " + "Tier: 1");
|
|
||||||
skillContents.add(" " + " " + "Ability_Enabled: true");
|
|
||||||
addRepairableLines(materialName, skillContents);
|
|
||||||
}
|
|
||||||
|
|
||||||
return configSections;
|
|
||||||
}
|
|
||||||
|
|
||||||
private HashMap<String, ArrayList<String>> getConfigSectionsArmor(String modName, HashMap<String, ArrayList<String>> materialNames) {
|
|
||||||
HashMap<String, ArrayList<String>> configSections = new HashMap<>();
|
|
||||||
|
|
||||||
// Go through all the materials and categorise them under an armor type
|
|
||||||
for (String materialName : materialNames.get(modName)) {
|
|
||||||
String toolType = "UNIDENTIFIED";
|
|
||||||
if (materialName.contains("BOOT") || materialName.contains("SHOE")) {
|
|
||||||
toolType = "Boots";
|
|
||||||
}
|
|
||||||
else if (materialName.contains("CHESTPLATE") || materialName.contains("CHEST")) {
|
|
||||||
toolType = "Chestplates";
|
|
||||||
}
|
|
||||||
else if (materialName.contains("HELM") || materialName.contains("HAT")) {
|
|
||||||
toolType = "Helmets";
|
|
||||||
}
|
|
||||||
else if (materialName.contains("LEGGINGS") || materialName.contains("LEGS") || materialName.contains("PANTS")) {
|
|
||||||
toolType = "Leggings";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!configSections.containsKey(toolType)) {
|
|
||||||
configSections.put(toolType, new ArrayList<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<String> skillContents = configSections.get(toolType);
|
|
||||||
skillContents.add(" " + materialName + ":");
|
|
||||||
addRepairableLines(materialName, skillContents);
|
|
||||||
}
|
|
||||||
|
|
||||||
return configSections;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addRepairableLines(String materialName, ArrayList<String> skillContents) {
|
|
||||||
skillContents.add(" " + " " + "Repairable: true");
|
|
||||||
skillContents.add(" " + " " + "Repair_Material: REPAIR_MATERIAL_NAME");
|
|
||||||
skillContents.add(" " + " " + "Repair_Material_Data_Value: 0");
|
|
||||||
skillContents.add(" " + " " + "Repair_Material_Quantity: 9");
|
|
||||||
skillContents.add(" " + " " + "Repair_Material_Pretty_Name: Repair Item Name");
|
|
||||||
skillContents.add(" " + " " + "Repair_MinimumLevel: 0");
|
|
||||||
skillContents.add(" " + " " + "Repair_XpMultiplier: 1.0");
|
|
||||||
|
|
||||||
Material material = Material.matchMaterial(materialName);
|
|
||||||
short durability = (material == null) ? (short) 9999 : material.getMaxDurability();
|
|
||||||
skillContents.add(" " + " " + "Durability: " + ((durability > 0) ? durability : (short) 9999));
|
|
||||||
}
|
|
||||||
|
|
||||||
private HashMap<String, ArrayList<String>> getConfigSectionsUnknown(String modName, HashMap<String, ArrayList<String>> materialNames) {
|
|
||||||
HashMap<String, ArrayList<String>> configSections = new HashMap<>();
|
|
||||||
|
|
||||||
// Go through all the materials and print them
|
|
||||||
for (String materialName : materialNames.get(modName)) {
|
|
||||||
String configKey = "UNIDENTIFIED";
|
|
||||||
|
|
||||||
if (!configSections.containsKey(configKey)) {
|
|
||||||
configSections.put(configKey, new ArrayList<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<String> skillContents = configSections.get(configKey);
|
|
||||||
skillContents.add(" " + materialName);
|
|
||||||
}
|
|
||||||
|
|
||||||
return configSections;
|
|
||||||
}
|
|
||||||
}
|
|
@ -355,16 +355,24 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Hardcore Mode */
|
/* Hardcore Mode */
|
||||||
|
@Deprecated
|
||||||
public boolean getHardcoreStatLossEnabled(PrimarySkillType primarySkillType) { return config.getBoolean("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(primarySkillType.toString()), false); }
|
public boolean getHardcoreStatLossEnabled(PrimarySkillType primarySkillType) { return config.getBoolean("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(primarySkillType.toString()), false); }
|
||||||
|
public boolean getHardcoreStatLossEnabled(@NotNull RootSkill rootSkill) { return config.getBoolean("Hardcore.Death_Stat_Loss.Enabled." + rootSkill.getRawSkillName(), false); }
|
||||||
|
@Deprecated
|
||||||
public void setHardcoreStatLossEnabled(PrimarySkillType primarySkillType, boolean enabled) { config.set("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(primarySkillType.toString()), enabled); }
|
public void setHardcoreStatLossEnabled(PrimarySkillType primarySkillType, boolean enabled) { config.set("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(primarySkillType.toString()), enabled); }
|
||||||
|
public void setHardcoreStatLossEnabled(@NotNull RootSkill rootSkill, boolean enabled) { config.set("Hardcore.Death_Stat_Loss.Enabled." + rootSkill.getRawSkillName(), enabled); }
|
||||||
|
|
||||||
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss.Penalty_Percentage", 75.0D); }
|
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss.Penalty_Percentage", 75.0D); }
|
||||||
public void setHardcoreDeathStatPenaltyPercentage(double value) { config.set("Hardcore.Death_Stat_Loss.Penalty_Percentage", value); }
|
public void setHardcoreDeathStatPenaltyPercentage(double value) { config.set("Hardcore.Death_Stat_Loss.Penalty_Percentage", value); }
|
||||||
|
|
||||||
public int getHardcoreDeathStatPenaltyLevelThreshold() { return config.getInt("Hardcore.Death_Stat_Loss.Level_Threshold", 0); }
|
public int getHardcoreDeathStatPenaltyLevelThreshold() { return config.getInt("Hardcore.Death_Stat_Loss.Level_Threshold", 0); }
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public boolean getHardcoreVampirismEnabled(PrimarySkillType primarySkillType) { return config.getBoolean("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(primarySkillType.toString()), false); }
|
public boolean getHardcoreVampirismEnabled(PrimarySkillType primarySkillType) { return config.getBoolean("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(primarySkillType.toString()), false); }
|
||||||
|
public boolean getHardcoreVampirismEnabled(@NotNull RootSkill rootSkill) { return config.getBoolean("Hardcore.Vampirism.Enabled." + rootSkill.getRawSkillName(), false); }
|
||||||
|
@Deprecated
|
||||||
public void setHardcoreVampirismEnabled(PrimarySkillType primarySkillType, boolean enabled) { config.set("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(primarySkillType.toString()), enabled); }
|
public void setHardcoreVampirismEnabled(PrimarySkillType primarySkillType, boolean enabled) { config.set("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(primarySkillType.toString()), enabled); }
|
||||||
|
public void setHardcoreVampirismEnabled(@NotNull RootSkill rootSkill, boolean enabled) { config.set("Hardcore.Vampirism.Enabled." + rootSkill.getRawSkillName(), enabled); }
|
||||||
|
|
||||||
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism.Leech_Percentage", 5.0D); }
|
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism.Leech_Percentage", 5.0D); }
|
||||||
public void setHardcoreVampirismStatLeechPercentage(double value) { config.set("Hardcore.Vampirism.Leech_Percentage", value); }
|
public void setHardcoreVampirismStatLeechPercentage(double value) { config.set("Hardcore.Vampirism.Leech_Percentage", value); }
|
||||||
@ -576,8 +584,12 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public boolean getTruncateSkills() { return config.getBoolean("General.TruncateSkills", false); }
|
public boolean getTruncateSkills() { return config.getBoolean("General.TruncateSkills", false); }
|
||||||
|
|
||||||
/* PVP & PVE Settings */
|
/* PVP & PVE Settings */
|
||||||
|
@Deprecated
|
||||||
public boolean getPVPEnabled(PrimarySkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVP", true); }
|
public boolean getPVPEnabled(PrimarySkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVP", true); }
|
||||||
|
public boolean getPVPEnabled(RootSkill skill) { return config.getBoolean("Skills." + skill.getRawSkillName() + ".Enabled_For_PVP", true); }
|
||||||
|
@Deprecated
|
||||||
public boolean getPVEEnabled(PrimarySkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVE", true); }
|
public boolean getPVEEnabled(PrimarySkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVE", true); }
|
||||||
|
public boolean getPVEEnabled(RootSkill skill) { return config.getBoolean("Skills." + skill.getRawSkillName() + ".Enabled_For_PVE", true); }
|
||||||
|
|
||||||
//public float getMasterVolume() { return (float) config.getDouble("Sounds.MasterVolume", 1.0); }
|
//public float getMasterVolume() { return (float) config.getDouble("Sounds.MasterVolume", 1.0); }
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import com.gmail.nossr50.skills.SkillManager;
|
|||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.text.StringUtils;
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
import com.neetgames.mcmmo.player.MMOPlayer;
|
import com.neetgames.mcmmo.player.MMOPlayer;
|
||||||
|
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||||
import com.neetgames.mcmmo.skill.AbstractRootSkill;
|
import com.neetgames.mcmmo.skill.AbstractRootSkill;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Tameable;
|
import org.bukkit.entity.Tameable;
|
||||||
@ -47,8 +48,8 @@ public class CoreRootSkill extends AbstractRootSkill {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRootSkillPermitted(@NotNull MMOPlayer mmoPlayer) {
|
public boolean isRootSkillPermitted(@NotNull OnlineMMOPlayer mmoPlayer) {
|
||||||
return Permissions.skillEnabled(mmoPlayer, this);
|
return Permissions.skillEnabled((Player) mmoPlayer.getServerAPIPlayerImpl(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,6 +22,7 @@ import com.neetgames.mcmmo.skill.RootSkill;
|
|||||||
import com.neetgames.mcmmo.skill.SkillIdentity;
|
import com.neetgames.mcmmo.skill.SkillIdentity;
|
||||||
import com.neetgames.mcmmo.skill.SuperSkill;
|
import com.neetgames.mcmmo.skill.SuperSkill;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -31,8 +32,9 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class CoreSkills {
|
public class CoreSkills {
|
||||||
|
|
||||||
|
//TODO: Should these be immutable?
|
||||||
private static final @NotNull ImmutableSet<CoreRootSkill> CORE_ROOT_SKILLS;
|
private static final @NotNull ImmutableSet<CoreRootSkill> CORE_ROOT_SKILLS;
|
||||||
private static final @NotNull ImmutableSet<CoreRootSkill> CORE_CHILD_SKILLS; //Could make this a marker interface
|
private static final @NotNull ImmutableSet<CoreRootSkill> CORE_CHILD_SKILLS;
|
||||||
private static final @NotNull ImmutableSet<CoreRootSkill> CORE_NON_CHILD_SKILLS;
|
private static final @NotNull ImmutableSet<CoreRootSkill> CORE_NON_CHILD_SKILLS;
|
||||||
private static final @NotNull ImmutableSet<CoreSkill> CORE_SUB_SKILLS;
|
private static final @NotNull ImmutableSet<CoreSkill> CORE_SUB_SKILLS;
|
||||||
private static final @NotNull ImmutableSet<SuperSkill> CORE_SUPER_SKILLS;
|
private static final @NotNull ImmutableSet<SuperSkill> CORE_SUPER_SKILLS;
|
||||||
@ -47,10 +49,60 @@ public class CoreSkills {
|
|||||||
FISHING_ID, HERBALISM_ID, MINING_ID, REPAIR_ID, SALVAGE_ID, SMELTING_ID, SWORDS_ID, TAMING_ID, UNARMED_ID,
|
FISHING_ID, HERBALISM_ID, MINING_ID, REPAIR_ID, SALVAGE_ID, SMELTING_ID, SWORDS_ID, TAMING_ID, UNARMED_ID,
|
||||||
WOODCUTTING_ID, TRIDENTS_ID, CROSSBOWS_ID;
|
WOODCUTTING_ID, TRIDENTS_ID, CROSSBOWS_ID;
|
||||||
|
|
||||||
public static final @NotNull SuperSkill SKULL_SPLITTER, GIGA_DRILL_BREAKER, GREEN_TERRA, SUPER_BREAKER,
|
// public static final @NotNull SuperSkill SKULL_SPLITTER, GIGA_DRILL_BREAKER, GREEN_TERRA, SUPER_BREAKER,
|
||||||
BLAST_MINING, SERRATED_STRIKES, CALL_OF_THE_WILD, BERSERK, TREE_FELLER, TRIDENTS_SUPER, SUPER_SHOT_GUN;
|
// BLAST_MINING, SERRATED_STRIKES, CALL_OF_THE_WILD, BERSERK, TREE_FELLER, TRIDENTS_SUPER, SUPER_SHOT_GUN;
|
||||||
|
|
||||||
public static final @NotNull CoreSkill ROLL;
|
// public static @NotNull CoreSkill
|
||||||
|
// /* Acrobatics */
|
||||||
|
// DODGE, ROLL,
|
||||||
|
//
|
||||||
|
// /* Alchemy */
|
||||||
|
// CATALYSIS, CONCOCTIONS,
|
||||||
|
//
|
||||||
|
// /* Archery */
|
||||||
|
// ARROW_RETRIEVAL, DAZE, SKILLSHOT, LIMIT_BREAK_ARCHERY,
|
||||||
|
//
|
||||||
|
// /* Axes */
|
||||||
|
// ARMOR_IMPACT, AXE_MASTERY, LIMIT_BREAK_AXES, CRITICAL_STRIKES, GREATER_IMPACT, SKULL_SPLITTER,
|
||||||
|
//
|
||||||
|
// /* Excavation */
|
||||||
|
// ARCHAEOLOGY, GIGA_DRILL_BREAKER,
|
||||||
|
//
|
||||||
|
// /* Fishing */
|
||||||
|
// FISHERMANS_DIET, ICE_FISHING, MAGIC_HUNTER, MASTER_ANGLER, TREASURE_HUNTER, SHAKE,
|
||||||
|
//
|
||||||
|
// /* Herbalism */
|
||||||
|
// DOUBLE_DROPS_HERBALISM, FARMERS_DIET, GREEN_TERRA, GREEN_THUMB, HYLIAN_LUCK, SHROOM_THUMB,
|
||||||
|
//
|
||||||
|
// /* Mining */
|
||||||
|
// BIGGER_BOMBS, BLAST_MINING, DEMOLITIONS_EXPERTISE, DOUBLE_DROPS, SUPER_BREAKER,
|
||||||
|
//
|
||||||
|
// /* Repair */
|
||||||
|
// ARCANE_FORGING, REPAIR_MASTERY, SUPER_REPAIR,
|
||||||
|
//
|
||||||
|
// /* Salvage */
|
||||||
|
// SCRAP_COLLECTOR, ARCANE_SALVAGE,
|
||||||
|
//
|
||||||
|
// /* Smelting */
|
||||||
|
// FUEL_EFFICIENCY, SECOND_SMELT, UNDERSTANDING_THE_ART,
|
||||||
|
//
|
||||||
|
// /* Swords */
|
||||||
|
// COUNTER_ATTACK, RUPTURE, SERRATED_STRIKES, STAB, LIMIT_BREAK_SWORDS,
|
||||||
|
//
|
||||||
|
// /* Taming */
|
||||||
|
// BEAST_LORE, CALL_OF_THE_WILD, ENVIRONMENTALLY_AWARE, FAST_FOOD_SERVICE, GORE, HOLY_HOUND, PUMMEL, SHARPENED_CLAWS, SHOCK_PROOF, THICK_FUR,
|
||||||
|
//
|
||||||
|
// /* Archery */
|
||||||
|
// ARROW_DEFLECT, BERSERK, BLOCK_CRACKER, DISARM, STEEL_ARM_STYLE, IRON_GRIP, LIMIT_BREAK_UNARMED,
|
||||||
|
//
|
||||||
|
// /* Woodcutting */
|
||||||
|
// KNOCK_ON_WOOD, HARVEST_LUMBER, LEAF_BLOWER, TREE_FELLER,
|
||||||
|
//
|
||||||
|
// /* Tridents */
|
||||||
|
// MULTI_TASKING, LIMIT_BREAK_TRIDENTS,
|
||||||
|
//
|
||||||
|
// /* Crossbows */
|
||||||
|
// SUPER_SHOTGUN, LIMIT_BREAK_CROSSBOWS;
|
||||||
|
|
||||||
private static final @NotNull HackySkillMappings hackySkillMappings = new HackySkillMappings();
|
private static final @NotNull HackySkillMappings hackySkillMappings = new HackySkillMappings();
|
||||||
|
|
||||||
@ -138,35 +190,41 @@ public class CoreSkills {
|
|||||||
CORE_NON_CHILD_SKILLS = ImmutableSet.copyOf(generateNonChildSkillSet());
|
CORE_NON_CHILD_SKILLS = ImmutableSet.copyOf(generateNonChildSkillSet());
|
||||||
CORE_SUB_SKILLS = ImmutableSet.copyOf(subSkillSet);
|
CORE_SUB_SKILLS = ImmutableSet.copyOf(subSkillSet);
|
||||||
CORE_SUPER_SKILLS = ImmutableSet.copyOf(superSkillSet);
|
CORE_SUPER_SKILLS = ImmutableSet.copyOf(superSkillSet);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Init core skills
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a set of built in {@link RootSkill}s for mcMMO
|
* Returns a set of built in {@link RootSkill}s for mcMMO
|
||||||
* No guarantees for whether or not the skills are registered or active or inactive
|
* No guarantees for whether or not the skills are registered or active or inactive
|
||||||
*
|
*
|
||||||
* @return a set of all root skills built into mcMMO
|
* @return a set of all {@link RootSkill} built into mcMMO
|
||||||
*/
|
*/
|
||||||
public static @NotNull Set<CoreRootSkill> getCoreRootSkills() {
|
public static @NotNull Set<CoreRootSkill> getCoreRootSkills() {
|
||||||
return CORE_ROOT_SKILLS;
|
return CORE_ROOT_SKILLS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a set of built in skills for mcMMO
|
* Returns a set of built in {@link CoreSkill}s for mcMMO
|
||||||
* No guarantees for whether or not the skills are registered or active or inactive
|
* No guarantees for whether or not the skills are registered or active or inactive
|
||||||
*
|
*
|
||||||
* @return a set of all root skills built into mcMMO
|
* @return a set of all {@link CoreSkill} built into mcMMO
|
||||||
*/
|
*/
|
||||||
public static @NotNull Set<CoreSkill> getCoreSkills() {
|
public static @NotNull Set<CoreSkill> getCoreSkills() {
|
||||||
return CORE_SUB_SKILLS;
|
return CORE_SUB_SKILLS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a set of built in skills for mcMMO
|
* Returns a set of built in {@link SuperSkill}s for mcMMO
|
||||||
* No guarantees for whether or not the skills are registered or active or inactive
|
* No guarantees for whether or not the skills are registered or active or inactive
|
||||||
*
|
*
|
||||||
* @return a set of all root skills built into mcMMO
|
* @return a set of all {@link SuperSkill} built into mcMMO
|
||||||
*/
|
*/
|
||||||
public static @NotNull Set<SuperSkill> getCoreSkills() {
|
public static @NotNull Set<SuperSkill> getCoreSuperSkills() {
|
||||||
return CORE_SUPER_SKILLS;
|
return CORE_SUPER_SKILLS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.gmail.nossr50.datatypes.skills;
|
||||||
|
|
||||||
|
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||||
|
import com.neetgames.mcmmo.skill.RootSkill;
|
||||||
|
import com.neetgames.mcmmo.skill.SuperSkill;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public class SuperCoreSkill extends CoreSkill implements SuperSkill {
|
||||||
|
|
||||||
|
private final int defaultCooldown;
|
||||||
|
|
||||||
|
public SuperCoreSkill(@NotNull String pluginName, @NotNull String skillName, @Nullable String permission, @NotNull RootSkill parentSkill, int defaultCooldown) {
|
||||||
|
super(pluginName, skillName, permission, parentSkill);
|
||||||
|
this.defaultCooldown = defaultCooldown;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDefaultCooldown() {
|
||||||
|
return defaultCooldown;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCooldown(@NotNull OnlineMMOPlayer onlineMMOPlayer) {
|
||||||
|
//TODO: Move implementation
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,7 @@ import org.bukkit.permissions.Permissible;
|
|||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
||||||
import org.bukkit.permissions.PermissionDefault;
|
import org.bukkit.permissions.PermissionDefault;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@ -141,7 +142,9 @@ public final class Permissions {
|
|||||||
* SKILLS
|
* SKILLS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static boolean skillEnabled(Permissible permissible, PrimarySkillType skill) {return permissible.hasPermission("mcmmo.skills." + skill.toString().toLowerCase(Locale.ENGLISH)); }
|
public static boolean skillEnabled(Permissible permissible, PrimarySkillType skill) {return permissible.hasPermission("mcmmo.skills." + skill.toString().toLowerCase(Locale.ENGLISH)); }
|
||||||
|
public static boolean skillEnabled(@NotNull Permissible permissible, @NotNull RootSkill rootSkill) {return permissible.hasPermission("mcmmo.skills." + rootSkill.getRawSkillName().toLowerCase(Locale.ENGLISH)); }
|
||||||
public static boolean vanillaXpBoost(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.ability." + skill.toString().toLowerCase(Locale.ENGLISH) + ".vanillaxpboost"); }
|
public static boolean vanillaXpBoost(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.ability." + skill.toString().toLowerCase(Locale.ENGLISH) + ".vanillaxpboost"); }
|
||||||
public static boolean isSubSkillEnabled(Permissible permissible, SubSkillType subSkillType) { return permissible.hasPermission(subSkillType.getPermissionNodeAddress()); }
|
public static boolean isSubSkillEnabled(Permissible permissible, SubSkillType subSkillType) { return permissible.hasPermission(subSkillType.getPermissionNodeAddress()); }
|
||||||
public static boolean isSubSkillEnabled(Permissible permissible, AbstractSubSkill abstractSubSkill) { return permissible.hasPermission(abstractSubSkill.getPermissionNode()); }
|
public static boolean isSubSkillEnabled(Permissible permissible, AbstractSubSkill abstractSubSkill) { return permissible.hasPermission(abstractSubSkill.getPermissionNode()); }
|
||||||
|
@ -418,15 +418,6 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new McscoreboardCommand());
|
command.setExecutor(new McscoreboardCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerMcImportCommand() {
|
|
||||||
PluginCommand command = mcMMO.p.getCommand("mcimport");
|
|
||||||
command.setDescription("Import mod config files"); //TODO: Localize
|
|
||||||
command.setPermission("mcmmo.commands.mcimport");
|
|
||||||
command.setPermissionMessage(permissionsMessage);
|
|
||||||
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcimport"));
|
|
||||||
command.setExecutor(new McImportCommand());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void registerReloadLocaleCommand() {
|
private static void registerReloadLocaleCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("mcmmoreloadlocale");
|
PluginCommand command = mcMMO.p.getCommand("mcmmoreloadlocale");
|
||||||
command.setDescription("Reloads locale"); // TODO: Localize
|
command.setDescription("Reloads locale"); // TODO: Localize
|
||||||
@ -456,7 +447,6 @@ public final class CommandRegistrationManager {
|
|||||||
registerXPBarCommand();
|
registerXPBarCommand();
|
||||||
registerMmoInfoCommand();
|
registerMmoInfoCommand();
|
||||||
registerMmoDebugCommand();
|
registerMmoDebugCommand();
|
||||||
registerMcImportCommand();
|
|
||||||
registerMcabilityCommand();
|
registerMcabilityCommand();
|
||||||
registerMcgodCommand();
|
registerMcgodCommand();
|
||||||
registerMcChatSpyCommand();
|
registerMcChatSpyCommand();
|
||||||
|
@ -69,9 +69,6 @@ commands:
|
|||||||
mcgod:
|
mcgod:
|
||||||
description: Toggle mcMMO god-mode on/off
|
description: Toggle mcMMO god-mode on/off
|
||||||
permission: mcmmo.commands.mcgod
|
permission: mcmmo.commands.mcgod
|
||||||
mcimport:
|
|
||||||
description: Import mod config files
|
|
||||||
permission: mcmmo.commands.mcimport
|
|
||||||
mcstats:
|
mcstats:
|
||||||
aliases: [stats]
|
aliases: [stats]
|
||||||
description: Shows your mcMMO stats and xp
|
description: Shows your mcMMO stats and xp
|
||||||
@ -859,7 +856,6 @@ permissions:
|
|||||||
mcmmo.commands.mcchatspy.others: true
|
mcmmo.commands.mcchatspy.others: true
|
||||||
mcmmo.commands.mcgod: true
|
mcmmo.commands.mcgod: true
|
||||||
mcmmo.commands.mcgod.others: true
|
mcmmo.commands.mcgod.others: true
|
||||||
mcmmo.commands.mcimport: true
|
|
||||||
mcmmo.commands.mcpurge: true
|
mcmmo.commands.mcpurge: true
|
||||||
mcmmo.commands.mcrank.others.all: true
|
mcmmo.commands.mcrank.others.all: true
|
||||||
mcmmo.commands.mcrefresh: true
|
mcmmo.commands.mcrefresh: true
|
||||||
@ -976,8 +972,6 @@ permissions:
|
|||||||
description: Allows access to the mcnotify command
|
description: Allows access to the mcnotify command
|
||||||
mcmmo.commands.mcpurge:
|
mcmmo.commands.mcpurge:
|
||||||
description: Allows access to the mcpurge command
|
description: Allows access to the mcpurge command
|
||||||
mcmmo.commands.mcimport:
|
|
||||||
description: Allows access to the mcimport command
|
|
||||||
mcmmo.commands.mcrank:
|
mcmmo.commands.mcrank:
|
||||||
description: Allows access to the mcrank command
|
description: Allows access to the mcrank command
|
||||||
mcmmo.commands.mcrank.others.*:
|
mcmmo.commands.mcrank.others.*:
|
||||||
|
Loading…
Reference in New Issue
Block a user