Merge remote-tracking branch 'origin/master'

This commit is contained in:
Ka0rX 2022-07-26 16:48:31 +02:00
commit 8983a83bed
15 changed files with 86 additions and 122 deletions

View File

@ -7,6 +7,12 @@ public enum ClassOption {
*/ */
DEFAULT, DEFAULT,
/**
* When set to true any player has to have the
* mmocore.class.lower_case_name permission to use the class
*/
NEEDS_PERMISSION,
/** /**
* If the class should in the /class GUI * If the class should in the /class GUI
*/ */

View File

@ -61,8 +61,6 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
private final Map<PlayerResource, ResourceRegeneration> resourceHandlers = new HashMap<>(); private final Map<PlayerResource, ResourceRegeneration> resourceHandlers = new HashMap<>();
private final boolean needsPermission;
@Deprecated @Deprecated
private final Map<String, EventTrigger> eventTriggers = new HashMap<>(); private final Map<String, EventTrigger> eventTriggers = new HashMap<>();
@ -169,8 +167,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 * Must make sure all the resourceHandlers are registered
* when the placer class is initialized. * when the placer class is initialized.
@ -210,7 +206,6 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
expTable = null; expTable = null;
castParticle = new CastingParticle(Particle.SPELL_INSTANT); castParticle = new CastingParticle(Particle.SPELL_INSTANT);
actionBarFormat = ""; actionBarFormat = "";
needsPermission =false;
this.icon = new ItemStack(material); this.icon = new ItemStack(material);
setOption(ClassOption.DISPLAY, false); setOption(ClassOption.DISPLAY, false);
setOption(ClassOption.DEFAULT, false); setOption(ClassOption.DEFAULT, false);
@ -280,10 +275,6 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
return expTable != null; return expTable != null;
} }
public boolean needsPermission() {
return needsPermission;
}
public ItemStack getIcon() { public ItemStack getIcon() {
return icon.clone(); return icon.clone();
} }
@ -305,7 +296,7 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
} }
public boolean hasOption(ClassOption option) { public boolean hasOption(ClassOption option) {
return options.containsKey(option) ? options.get(option) : option.getDefault(); return options.getOrDefault(option, option.getDefault());
} }
@Override @Override

View File

@ -6,7 +6,6 @@ import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.command.rpg.CoinsCommandTreeNode; import net.Indyuce.mmocore.command.rpg.CoinsCommandTreeNode;
import net.Indyuce.mmocore.command.rpg.NoteCommandTreeNode; import net.Indyuce.mmocore.command.rpg.NoteCommandTreeNode;
import net.Indyuce.mmocore.command.rpg.ReloadCommandTreeNode; 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.admin.AdminCommandTreeNode;
import net.Indyuce.mmocore.command.rpg.booster.BoosterCommandTreeNode; import net.Indyuce.mmocore.command.rpg.booster.BoosterCommandTreeNode;
import net.Indyuce.mmocore.command.rpg.debug.DebugCommandTreeNode; import net.Indyuce.mmocore.command.rpg.debug.DebugCommandTreeNode;
@ -27,7 +26,6 @@ public class MMOCoreCommandTreeRoot extends CommandTreeRoot implements CommandEx
super("mmocore", "mmocore.admin"); super("mmocore", "mmocore.admin");
addChild(new ReloadCommandTreeNode(this)); addChild(new ReloadCommandTreeNode(this));
addChild(new TransferDataTreeNode(this));
addChild(new CoinsCommandTreeNode(this)); addChild(new CoinsCommandTreeNode(this));
addChild(new NoteCommandTreeNode(this)); addChild(new NoteCommandTreeNode(this));
addChild(new AdminCommandTreeNode(this)); addChild(new AdminCommandTreeNode(this));

View File

@ -15,6 +15,7 @@ public class AdminCommandTreeNode extends CommandTreeNode {
addChild(new InfoCommandTreeNode(this)); addChild(new InfoCommandTreeNode(this));
addChild(new ClassCommandTreeNode(this)); addChild(new ClassCommandTreeNode(this));
addChild(new ForceClassCommandTreeNode(this)); addChild(new ForceClassCommandTreeNode(this));
addChild(new TransferDataTreeNode(this));
addChild(new ExperienceCommandTreeNode(this)); addChild(new ExperienceCommandTreeNode(this));
addChild(new LevelCommandTreeNode(this)); addChild(new LevelCommandTreeNode(this));

View File

@ -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 io.lumine.mythic.lib.command.api.CommandTreeNode;
import net.Indyuce.mmocore.MMOCore; 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 * This command allows to transfer data from your actual storage type
* in the data storage type. * to the other one which lets the user switch between storage types.
*/ */
public class TransferDataTreeNode extends CommandTreeNode { public class TransferDataTreeNode extends CommandTreeNode {
public TransferDataTreeNode(CommandTreeNode parent) { public TransferDataTreeNode(CommandTreeNode parent) {
super(parent, "transferdata"); super(parent, "transferdata");
} }
@Override @Override
public CommandResult execute(CommandSender commandSender, String[] strings) { public CommandResult execute(CommandSender commandSender, String[] strings) {
DataProvider provider=null; DataProvider provider = null;
try { try {
@ -46,7 +44,7 @@ public class TransferDataTreeNode extends CommandTreeNode {
} catch (Exception e) { } catch (Exception e) {
commandSender.sendMessage("Couldn't transfer properly the data."); commandSender.sendMessage("Couldn't transfer properly the data.");
e.printStackTrace(); e.printStackTrace();
if(provider!=null&&provider instanceof MySQLDataProvider) { if (provider != null && provider instanceof MySQLDataProvider) {
((MySQLDataProvider) provider).close(); ((MySQLDataProvider) provider).close();
} }
return CommandResult.FAILURE; return CommandResult.FAILURE;
@ -58,14 +56,12 @@ public class TransferDataTreeNode extends CommandTreeNode {
@Override @Override
public void run() { public void run() {
if(finalProvider !=null&& finalProvider instanceof MySQLDataProvider) { if (finalProvider != null && finalProvider instanceof MySQLDataProvider) {
((MySQLDataProvider) finalProvider).close(); ((MySQLDataProvider) finalProvider).close();
} }
} }
}.runTaskLater(MMOCore.plugin,200); }.runTaskLater(MMOCore.plugin, 200);
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} }
} }

View File

@ -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.ItemTag;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmocore.MMOCore; 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.api.player.profess.PlayerClass;
import net.Indyuce.mmocore.gui.api.EditableInventory; import net.Indyuce.mmocore.gui.api.EditableInventory;
import net.Indyuce.mmocore.gui.api.GeneratedInventory; import net.Indyuce.mmocore.gui.api.GeneratedInventory;
import net.Indyuce.mmocore.gui.api.item.InventoryItem; import net.Indyuce.mmocore.gui.api.item.InventoryItem;
import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem; import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem;
import net.Indyuce.mmocore.manager.InventoryManager; 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.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
@ -116,7 +116,7 @@ public class ClassSelect extends EditableInventory {
} }
PlayerClass profess = MMOCore.plugin.classManager.get(tag); 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); MMOCore.plugin.soundManager.getSound(SoundEvent.CANT_SELECT_CLASS).playTo(player);
new ConfigMessage("no-permission-for-class").send(player); new ConfigMessage("no-permission-for-class").send(player);
return; return;

View File

@ -2,7 +2,6 @@ package net.Indyuce.mmocore.gui;
import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.UtilityMethods; 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.api.stat.modifier.StatModifier;
import io.lumine.mythic.lib.version.VersionMaterial; import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
@ -124,13 +123,13 @@ public class PlayerStats extends EditableInventory {
public String apply(Player player, String str) { public String apply(Player player, String str) {
while (str.contains("{") && str.substring(str.indexOf("{")).contains("}")) { 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; String replaced;
if (holder.endsWith("_base")) { if (holder.endsWith("_base")) {
StatInfo info = StatInfo.valueOf(UtilityMethods.enumName(holder.substring(0, holder.length() - 5))); StatInfo info = StatInfo.valueOf(UtilityMethods.enumName(holder.substring(0, holder.length() - 5)));
replaced = info.format(stats.getBase(info.name)); replaced = info.format(stats.getBase(info.name));
} else if (holder.endsWith("_extra")) { } 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)); replaced = info.format(MythicLib.plugin.getStats().getTotalValue(info.name, stats.getMap()) - stats.getBase(info.name));
} else if (holder.startsWith("attribute_")) { } else if (holder.startsWith("attribute_")) {
PlayerAttribute attr = MMOCore.plugin.attributeManager.get(holder.substring(10).replace("_", "-").toLowerCase()); PlayerAttribute attr = MMOCore.plugin.attributeManager.get(holder.substring(10).replace("_", "-").toLowerCase());

View File

@ -8,7 +8,6 @@ import net.Indyuce.mmocore.manager.data.yaml.YAMLGuildDataManager;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.concurrent.CompletableFuture;
public class MySQLDataProvider extends MMODataSource implements DataProvider { public class MySQLDataProvider extends MMODataSource implements DataProvider {
private final MySQLPlayerDataManager playerManager = new MySQLPlayerDataManager(this); private final MySQLPlayerDataManager playerManager = new MySQLPlayerDataManager(this);

View File

@ -38,6 +38,7 @@ max-level: 100
# because it is a subclass of mage # because it is a subclass of mage
options: options:
display: false display: false
needs-permission: false
exp-table: class_exp_table exp-table: class_exp_table
@ -99,9 +100,6 @@ skills:
level: 15 level: 15
max-level: 30 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. # Experience sources for main class experience.
main-exp-sources: main-exp-sources:
- 'killmob{type=ZOMBIE;amount=1-3}' - 'killmob{type=ZOMBIE;amount=1-3}'

View File

@ -11,6 +11,7 @@ display:
options: options:
default: true default: true
display: false display: false
needs-permission: false # False by default
# Only regens when out of combat # Only regens when out of combat
off-combat-health-regen: false off-combat-health-regen: false
@ -19,11 +20,6 @@ options:
# Must match an existing exp curve filename from the 'expcurves' folder # Must match an existing exp curve filename from the 'expcurves' folder
exp-curve: levels 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. # Experience sources for main class experience.
main-exp-sources: main-exp-sources:
- 'killmob{type=ZOMBIE;amount=1-3}' - 'killmob{type=ZOMBIE;amount=1-3}'

View File

@ -75,6 +75,7 @@ resource:
options: options:
off-combat-health-regen: true off-combat-health-regen: true
needs-permission: false
attributes: attributes:
max-health: max-health:
@ -139,11 +140,6 @@ skills:
level: 15 level: 15
max-level: 30 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. # Experience sources for main class experience.
main-exp-sources: main-exp-sources:
- 'killmob{type=ZOMBIE;amount=1-3}' - 'killmob{type=ZOMBIE;amount=1-3}'

View File

@ -73,8 +73,8 @@ skills:
attributes: attributes:
knockback-resistance: knockback-resistance:
base: 15 base: .15
per-level: 1 per-level: .01
speed-malus-reduction: speed-malus-reduction:
base: 10 base: 10
per-level: 2 per-level: 2
@ -85,11 +85,6 @@ attributes:
base: .105 base: .105
per-level: 0 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. # Experience sources for main class experience.
main-exp-sources: main-exp-sources:
- 'killmob{type=ZOMBIE;amount=1-3}' - 'killmob{type=ZOMBIE;amount=1-3}'

View File

@ -60,8 +60,8 @@ skills:
attributes: attributes:
knockback-resistance: knockback-resistance:
base: 30 base: .3
per-level: 1 per-level: .01
speed-malus-reduction: speed-malus-reduction:
base: 30 base: 30
per-level: 2 per-level: 2
@ -75,11 +75,6 @@ attributes:
base: .095 base: .095
per-level: 0 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. # Experience sources for main class experience.
main-exp-sources: main-exp-sources:
- 'killmob{type=ZOMBIE;amount=1-3}' - 'killmob{type=ZOMBIE;amount=1-3}'

View File

@ -38,6 +38,8 @@ options:
off-combat-mana-regen: true off-combat-mana-regen: true
off-combat-health-regen: true off-combat-health-regen: true
needs-permission: false
cast-particle: cast-particle:
particle: SPELL_WITCH particle: SPELL_WITCH
@ -78,11 +80,6 @@ attributes:
base: .105 base: .105
per-level: 0 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. # Experience sources for main class experience.
main-exp-sources: main-exp-sources:
- 'killmob{type=ZOMBIE;amount=1-3}' - 'killmob{type=ZOMBIE;amount=1-3}'

View File

@ -72,6 +72,7 @@ cast-particle:
# Rage only decays when out of combat # Rage only decays when out of combat
options: options:
off-combat-mana-regen: true off-combat-mana-regen: true
needs-permission: false
skills: skills:
DEEP_WOUND: DEEP_WOUND:
@ -115,10 +116,6 @@ attributes:
base: 4.2 base: 4.2
per-level: 0.05 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. # Experience sources for main class experience.
main-exp-sources: main-exp-sources:
- 'killmob{type=ZOMBIE;amount=1-3}' - 'killmob{type=ZOMBIE;amount=1-3}'