From b125dac15513e1b5240accec657d3026d07bcef7 Mon Sep 17 00:00:00 2001 From: Indyuce Date: Tue, 26 Jul 2022 12:41:01 +0200 Subject: [PATCH 1/4] Fixed attribute stats display --- src/main/java/net/Indyuce/mmocore/gui/PlayerStats.java | 5 ++--- src/main/resources/default/classes/marksman.yml | 4 ++-- src/main/resources/default/classes/paladin.yml | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/Indyuce/mmocore/gui/PlayerStats.java b/src/main/java/net/Indyuce/mmocore/gui/PlayerStats.java index 5cdfa0a3..f24730c4 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/PlayerStats.java +++ b/src/main/java/net/Indyuce/mmocore/gui/PlayerStats.java @@ -2,7 +2,6 @@ package net.Indyuce.mmocore.gui; import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.UtilityMethods; -import io.lumine.mythic.lib.api.stat.handler.StatHandler; import io.lumine.mythic.lib.api.stat.modifier.StatModifier; import io.lumine.mythic.lib.version.VersionMaterial; import net.Indyuce.mmocore.MMOCore; @@ -124,14 +123,14 @@ public class PlayerStats extends EditableInventory { public String apply(Player player, String str) { while (str.contains("{") && str.substring(str.indexOf("{")).contains("}")) { - String holder = str.substring(str.indexOf("{") + 1, str.indexOf("}")); + final String holder = str.substring(str.indexOf("{") + 1, str.indexOf("}")); String replaced; if (holder.endsWith("_base")) { StatInfo info = StatInfo.valueOf(UtilityMethods.enumName(holder.substring(0, holder.length() - 5))); replaced = info.format(stats.getBase(info.name)); } else if (holder.endsWith("_extra")) { - StatInfo info = StatInfo.valueOf(UtilityMethods.enumName(holder.substring(0, holder.length() - 5))); + StatInfo info = StatInfo.valueOf(UtilityMethods.enumName(holder.substring(0, holder.length() - 6))); replaced = info.format(MythicLib.plugin.getStats().getTotalValue(info.name, stats.getMap()) - stats.getBase(info.name)); } else if (holder.startsWith("attribute_")) { PlayerAttribute attr = MMOCore.plugin.attributeManager.get(holder.substring(10).replace("_", "-").toLowerCase()); diff --git a/src/main/resources/default/classes/marksman.yml b/src/main/resources/default/classes/marksman.yml index 6839af0f..06421f86 100644 --- a/src/main/resources/default/classes/marksman.yml +++ b/src/main/resources/default/classes/marksman.yml @@ -73,8 +73,8 @@ skills: attributes: knockback-resistance: - base: 15 - per-level: 1 + base: .15 + per-level: .01 speed-malus-reduction: base: 10 per-level: 2 diff --git a/src/main/resources/default/classes/paladin.yml b/src/main/resources/default/classes/paladin.yml index b60418f6..5ce9fb64 100644 --- a/src/main/resources/default/classes/paladin.yml +++ b/src/main/resources/default/classes/paladin.yml @@ -60,8 +60,8 @@ skills: attributes: knockback-resistance: - base: 30 - per-level: 1 + base: .3 + per-level: .01 speed-malus-reduction: base: 30 per-level: 2 From 7d2d8a59b2689fd6402b18451b4cee4816c1072a Mon Sep 17 00:00:00 2001 From: Indyuce Date: Tue, 26 Jul 2022 15:20:13 +0200 Subject: [PATCH 2/4] Class option for class permission --- .../api/player/profess/ClassOption.java | 80 ++++++++++--------- .../api/player/profess/PlayerClass.java | 11 +-- .../net/Indyuce/mmocore/gui/ClassSelect.java | 10 +-- 3 files changed, 49 insertions(+), 52 deletions(-) diff --git a/src/main/java/net/Indyuce/mmocore/api/player/profess/ClassOption.java b/src/main/java/net/Indyuce/mmocore/api/player/profess/ClassOption.java index d0f6a72a..22978d97 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/profess/ClassOption.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/profess/ClassOption.java @@ -2,51 +2,57 @@ package net.Indyuce.mmocore.api.player.profess; public enum ClassOption { - /** - * If the class should be applied to newcomers - */ - DEFAULT, + /** + * If the class should be applied to newcomers + */ + DEFAULT, - /** - * If the class should in the /class GUI - */ - DISPLAY(true), + /** + * When set to true any player has to have the + * mmocore.class.lower_case_name permission to use the class + */ + NEEDS_PERMISSION, - /** - * Health only regens when out of combat - */ - OFF_COMBAT_HEALTH_REGEN, + /** + * If the class should in the /class GUI + */ + DISPLAY(true), - /** - * Mana only regens when out of combat - */ - OFF_COMBAT_MANA_REGEN, + /** + * Health only regens when out of combat + */ + OFF_COMBAT_HEALTH_REGEN, - /** - * Stamina only regens when out of combat - */ - OFF_COMBAT_STAMINA_REGEN, + /** + * Mana only regens when out of combat + */ + OFF_COMBAT_MANA_REGEN, - /** - * Stellium only regens when out of combat - */ - OFF_COMBAT_STELLIUM_REGEN; + /** + * Stamina only regens when out of combat + */ + OFF_COMBAT_STAMINA_REGEN, - private final boolean def; + /** + * Stellium only regens when out of combat + */ + OFF_COMBAT_STELLIUM_REGEN; - ClassOption() { - this(false); - } + private final boolean def; - ClassOption(boolean def) { - this.def = def; - } + ClassOption() { + this(false); + } - public boolean getDefault() { - return def; - } + ClassOption(boolean def) { + this.def = def; + } - public String getPath() { - return name().toLowerCase().replace("_", "-"); - } + public boolean getDefault() { + return def; + } + + public String getPath() { + return name().toLowerCase().replace("_", "-"); + } } \ No newline at end of file diff --git a/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java b/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java index 5be54c20..320fdea3 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java @@ -60,8 +60,6 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject { private final Map resourceHandlers = new HashMap<>(); - private final boolean needsPermission; - @Deprecated private final Map eventTriggers = new HashMap<>(); @@ -168,8 +166,6 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject { } } - needsPermission =config.contains("needs-permission")?config.getBoolean("needs-permission"):false; - /* * Must make sure all the resourceHandlers are registered * when the placer class is initialized. @@ -209,7 +205,6 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject { expTable = null; castParticle = new CastingParticle(Particle.SPELL_INSTANT); actionBarFormat = ""; - needsPermission =false; this.icon = new ItemStack(material); setOption(ClassOption.DISPLAY, false); setOption(ClassOption.DEFAULT, false); @@ -279,10 +274,6 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject { return expTable != null; } - public boolean needsPermission() { - return needsPermission; - } - public ItemStack getIcon() { return icon.clone(); } @@ -304,7 +295,7 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject { } public boolean hasOption(ClassOption option) { - return options.containsKey(option) ? options.get(option) : option.getDefault(); + return options.getOrDefault(option, option.getDefault()); } @Override diff --git a/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java b/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java index 80ffed86..dea606ac 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java +++ b/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java @@ -4,16 +4,16 @@ import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.NBTItem; import net.Indyuce.mmocore.MMOCore; +import net.Indyuce.mmocore.api.ConfigMessage; +import net.Indyuce.mmocore.api.SoundEvent; +import net.Indyuce.mmocore.api.player.PlayerData; +import net.Indyuce.mmocore.api.player.profess.ClassOption; import net.Indyuce.mmocore.api.player.profess.PlayerClass; import net.Indyuce.mmocore.gui.api.EditableInventory; import net.Indyuce.mmocore.gui.api.GeneratedInventory; import net.Indyuce.mmocore.gui.api.item.InventoryItem; import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem; import net.Indyuce.mmocore.manager.InventoryManager; -import net.Indyuce.mmocore.api.ConfigMessage; -import net.Indyuce.mmocore.api.SoundEvent; -import net.Indyuce.mmocore.api.player.PlayerData; -import net.Indyuce.mmocore.api.player.profess.ClassOption; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.event.inventory.InventoryClickEvent; @@ -116,7 +116,7 @@ public class ClassSelect extends EditableInventory { } PlayerClass profess = MMOCore.plugin.classManager.get(tag); - if(profess.needsPermission()&&!player.hasPermission("mmocore.class."+profess.getName().toLowerCase())) { + if (profess.hasOption(ClassOption.NEEDS_PERMISSION) && !player.hasPermission("mmocore.class." + profess.getId().toLowerCase())) { MMOCore.plugin.soundManager.getSound(SoundEvent.CANT_SELECT_CLASS).playTo(player); new ConfigMessage("no-permission-for-class").send(player); return; From a7e2773ff7774a32e8c7aed3d3427dc016bafc23 Mon Sep 17 00:00:00 2001 From: Indyuce Date: Tue, 26 Jul 2022 15:22:47 +0200 Subject: [PATCH 3/4] Default class configs fixed --- src/main/resources/default/classes/arcane-mage.yml | 4 +--- src/main/resources/default/classes/human.yml | 6 +----- src/main/resources/default/classes/mage.yml | 6 +----- src/main/resources/default/classes/marksman.yml | 5 ----- src/main/resources/default/classes/paladin.yml | 5 ----- src/main/resources/default/classes/rogue.yml | 7 ++----- src/main/resources/default/classes/warrior.yml | 5 +---- 7 files changed, 6 insertions(+), 32 deletions(-) diff --git a/src/main/resources/default/classes/arcane-mage.yml b/src/main/resources/default/classes/arcane-mage.yml index 1236f2c5..7dd9fa9b 100644 --- a/src/main/resources/default/classes/arcane-mage.yml +++ b/src/main/resources/default/classes/arcane-mage.yml @@ -38,6 +38,7 @@ max-level: 100 # because it is a subclass of mage options: display: false + needs-permission: false exp-table: class_exp_table @@ -99,9 +100,6 @@ skills: level: 15 max-level: 30 -#If true the player will need to have the mmocore.class.{class_name} permission -needs-permission: false - # Experience sources for main class experience. main-exp-sources: - 'killmob{type=ZOMBIE;amount=1-3}' diff --git a/src/main/resources/default/classes/human.yml b/src/main/resources/default/classes/human.yml index a570a890..804904be 100644 --- a/src/main/resources/default/classes/human.yml +++ b/src/main/resources/default/classes/human.yml @@ -11,6 +11,7 @@ display: options: default: true display: false + needs-permission: false # False by default # Only regens when out of combat off-combat-health-regen: false @@ -19,11 +20,6 @@ options: # Must match an existing exp curve filename from the 'expcurves' folder exp-curve: levels - -#If true the player will need to have the mmocore.class.{class_name} permission -needs-permission: false - - # Experience sources for main class experience. main-exp-sources: - 'killmob{type=ZOMBIE;amount=1-3}' diff --git a/src/main/resources/default/classes/mage.yml b/src/main/resources/default/classes/mage.yml index 25448b53..322efc2b 100644 --- a/src/main/resources/default/classes/mage.yml +++ b/src/main/resources/default/classes/mage.yml @@ -75,6 +75,7 @@ resource: options: off-combat-health-regen: true + needs-permission: false attributes: max-health: @@ -139,11 +140,6 @@ skills: level: 15 max-level: 30 - -#If true the player will need to have the mmocore.class.{class_name} permission -needs-permission: false - - # Experience sources for main class experience. main-exp-sources: - 'killmob{type=ZOMBIE;amount=1-3}' diff --git a/src/main/resources/default/classes/marksman.yml b/src/main/resources/default/classes/marksman.yml index 06421f86..64c6d2b4 100644 --- a/src/main/resources/default/classes/marksman.yml +++ b/src/main/resources/default/classes/marksman.yml @@ -85,11 +85,6 @@ attributes: base: .105 per-level: 0 - -#If true the player will need to have the mmocore.class.{class_name} permission -needs-permission: false - - # Experience sources for main class experience. main-exp-sources: - 'killmob{type=ZOMBIE;amount=1-3}' diff --git a/src/main/resources/default/classes/paladin.yml b/src/main/resources/default/classes/paladin.yml index 5ce9fb64..952f90f4 100644 --- a/src/main/resources/default/classes/paladin.yml +++ b/src/main/resources/default/classes/paladin.yml @@ -75,11 +75,6 @@ attributes: base: .095 per-level: 0 - -#If true the player will need to have the mmocore.class.{class_name} permission -needs-permission: false - - # Experience sources for main class experience. main-exp-sources: - 'killmob{type=ZOMBIE;amount=1-3}' diff --git a/src/main/resources/default/classes/rogue.yml b/src/main/resources/default/classes/rogue.yml index 62f23276..85070e3e 100644 --- a/src/main/resources/default/classes/rogue.yml +++ b/src/main/resources/default/classes/rogue.yml @@ -38,6 +38,8 @@ options: off-combat-mana-regen: true off-combat-health-regen: true + needs-permission: false + cast-particle: particle: SPELL_WITCH @@ -78,11 +80,6 @@ attributes: base: .105 per-level: 0 - - -#If true the player will need to have the mmocore.class.{class_name} permission -needs-permission: false - # Experience sources for main class experience. main-exp-sources: - 'killmob{type=ZOMBIE;amount=1-3}' diff --git a/src/main/resources/default/classes/warrior.yml b/src/main/resources/default/classes/warrior.yml index 12e8a92d..dd10fb90 100644 --- a/src/main/resources/default/classes/warrior.yml +++ b/src/main/resources/default/classes/warrior.yml @@ -72,6 +72,7 @@ cast-particle: # Rage only decays when out of combat options: off-combat-mana-regen: true + needs-permission: false skills: DEEP_WOUND: @@ -115,10 +116,6 @@ attributes: base: 4.2 per-level: 0.05 - -#If true the player will need to have the mmocore.class.{class_name} permission -needs-permission: false - # Experience sources for main class experience. main-exp-sources: - 'killmob{type=ZOMBIE;amount=1-3}' From 7c79f9cee3fb436a0342f3aa833e385e6b236140 Mon Sep 17 00:00:00 2001 From: Indyuce Date: Tue, 26 Jul 2022 15:33:23 +0200 Subject: [PATCH 4/4] Moved /mmocore admin transferdata --- .../command/MMOCoreCommandTreeRoot.java | 36 +++++++++---------- .../rpg/admin/AdminCommandTreeNode.java | 1 + .../rpg/{ => admin}/TransferDataTreeNode.java | 18 ++++------ .../manager/data/mysql/MySQLDataProvider.java | 1 - 4 files changed, 25 insertions(+), 31 deletions(-) rename src/main/java/net/Indyuce/mmocore/command/rpg/{ => admin}/TransferDataTreeNode.java (82%) diff --git a/src/main/java/net/Indyuce/mmocore/command/MMOCoreCommandTreeRoot.java b/src/main/java/net/Indyuce/mmocore/command/MMOCoreCommandTreeRoot.java index 11466232..048ffb48 100644 --- a/src/main/java/net/Indyuce/mmocore/command/MMOCoreCommandTreeRoot.java +++ b/src/main/java/net/Indyuce/mmocore/command/MMOCoreCommandTreeRoot.java @@ -6,7 +6,6 @@ import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.command.rpg.CoinsCommandTreeNode; import net.Indyuce.mmocore.command.rpg.NoteCommandTreeNode; import net.Indyuce.mmocore.command.rpg.ReloadCommandTreeNode; -import net.Indyuce.mmocore.command.rpg.TransferDataTreeNode; import net.Indyuce.mmocore.command.rpg.admin.AdminCommandTreeNode; import net.Indyuce.mmocore.command.rpg.booster.BoosterCommandTreeNode; import net.Indyuce.mmocore.command.rpg.debug.DebugCommandTreeNode; @@ -16,24 +15,23 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.TabCompleter; public class MMOCoreCommandTreeRoot extends CommandTreeRoot implements CommandExecutor, TabCompleter { - public static final Parameter PROFESSION = new Parameter("", (explorer, list) -> { - MMOCore.plugin.professionManager.getAll().forEach(profession -> list.add(profession.getId())); - list.add("main"); - }); - public static final Parameter QUEST = new Parameter("", - (explorer, list) -> MMOCore.plugin.questManager.getAll().forEach(quest -> list.add(quest.getId()))); + public static final Parameter PROFESSION = new Parameter("", (explorer, list) -> { + MMOCore.plugin.professionManager.getAll().forEach(profession -> list.add(profession.getId())); + list.add("main"); + }); + public static final Parameter QUEST = new Parameter("", + (explorer, list) -> MMOCore.plugin.questManager.getAll().forEach(quest -> list.add(quest.getId()))); - public MMOCoreCommandTreeRoot() { - super("mmocore", "mmocore.admin"); + public MMOCoreCommandTreeRoot() { + super("mmocore", "mmocore.admin"); - addChild(new ReloadCommandTreeNode(this)); - addChild(new TransferDataTreeNode(this)); - addChild(new CoinsCommandTreeNode(this)); - addChild(new NoteCommandTreeNode(this)); - addChild(new AdminCommandTreeNode(this)); - addChild(new DebugCommandTreeNode(this)); - addChild(new BoosterCommandTreeNode(this)); - addChild(new WaypointsCommandTreeNode(this)); - addChild(new QuestCommandTreeNode(this)); - } + addChild(new ReloadCommandTreeNode(this)); + addChild(new CoinsCommandTreeNode(this)); + addChild(new NoteCommandTreeNode(this)); + addChild(new AdminCommandTreeNode(this)); + addChild(new DebugCommandTreeNode(this)); + addChild(new BoosterCommandTreeNode(this)); + addChild(new WaypointsCommandTreeNode(this)); + addChild(new QuestCommandTreeNode(this)); + } } diff --git a/src/main/java/net/Indyuce/mmocore/command/rpg/admin/AdminCommandTreeNode.java b/src/main/java/net/Indyuce/mmocore/command/rpg/admin/AdminCommandTreeNode.java index 6065fce1..6d8ad6bf 100644 --- a/src/main/java/net/Indyuce/mmocore/command/rpg/admin/AdminCommandTreeNode.java +++ b/src/main/java/net/Indyuce/mmocore/command/rpg/admin/AdminCommandTreeNode.java @@ -15,6 +15,7 @@ public class AdminCommandTreeNode extends CommandTreeNode { addChild(new InfoCommandTreeNode(this)); addChild(new ClassCommandTreeNode(this)); addChild(new ForceClassCommandTreeNode(this)); + addChild(new TransferDataTreeNode(this)); addChild(new ExperienceCommandTreeNode(this)); addChild(new LevelCommandTreeNode(this)); diff --git a/src/main/java/net/Indyuce/mmocore/command/rpg/TransferDataTreeNode.java b/src/main/java/net/Indyuce/mmocore/command/rpg/admin/TransferDataTreeNode.java similarity index 82% rename from src/main/java/net/Indyuce/mmocore/command/rpg/TransferDataTreeNode.java rename to src/main/java/net/Indyuce/mmocore/command/rpg/admin/TransferDataTreeNode.java index e7d8f9ad..c5760a9c 100644 --- a/src/main/java/net/Indyuce/mmocore/command/rpg/TransferDataTreeNode.java +++ b/src/main/java/net/Indyuce/mmocore/command/rpg/admin/TransferDataTreeNode.java @@ -1,4 +1,4 @@ -package net.Indyuce.mmocore.command.rpg; +package net.Indyuce.mmocore.command.rpg.admin; import io.lumine.mythic.lib.command.api.CommandTreeNode; import net.Indyuce.mmocore.MMOCore; @@ -12,19 +12,17 @@ import org.bukkit.scheduler.BukkitRunnable; /** - * This command allows to transfer data from your actual datatype (yaml or sql) to the other one to make a change - * in the data storage type. + * This command allows to transfer data from your actual storage type + * to the other one which lets the user switch between storage types. */ public class TransferDataTreeNode extends CommandTreeNode { - - public TransferDataTreeNode(CommandTreeNode parent) { super(parent, "transferdata"); } @Override public CommandResult execute(CommandSender commandSender, String[] strings) { - DataProvider provider=null; + DataProvider provider = null; try { @@ -46,7 +44,7 @@ public class TransferDataTreeNode extends CommandTreeNode { } catch (Exception e) { commandSender.sendMessage("Couldn't transfer properly the data."); e.printStackTrace(); - if(provider!=null&&provider instanceof MySQLDataProvider) { + if (provider != null && provider instanceof MySQLDataProvider) { ((MySQLDataProvider) provider).close(); } return CommandResult.FAILURE; @@ -58,14 +56,12 @@ public class TransferDataTreeNode extends CommandTreeNode { @Override public void run() { - if(finalProvider !=null&& finalProvider instanceof MySQLDataProvider) { + if (finalProvider != null && finalProvider instanceof MySQLDataProvider) { ((MySQLDataProvider) finalProvider).close(); } } - }.runTaskLater(MMOCore.plugin,200); - + }.runTaskLater(MMOCore.plugin, 200); return CommandResult.SUCCESS; - } } diff --git a/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLDataProvider.java b/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLDataProvider.java index 84645801..f4fcb651 100644 --- a/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLDataProvider.java +++ b/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLDataProvider.java @@ -8,7 +8,6 @@ import net.Indyuce.mmocore.manager.data.yaml.YAMLGuildDataManager; import org.bukkit.configuration.file.FileConfiguration; import java.sql.SQLException; -import java.util.concurrent.CompletableFuture; public class MySQLDataProvider extends MMODataSource implements DataProvider { private final MySQLPlayerDataManager playerManager = new MySQLPlayerDataManager(this);