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

@ -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("_", "-");
}
}

View File

@ -61,8 +61,6 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
private final Map<PlayerResource, ResourceRegeneration> resourceHandlers = new HashMap<>();
private final boolean needsPermission;
@Deprecated
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
* when the placer class is initialized.
@ -210,7 +206,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);
@ -280,10 +275,6 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
return expTable != null;
}
public boolean needsPermission() {
return needsPermission;
}
public ItemStack getIcon() {
return icon.clone();
}
@ -305,7 +296,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

View File

@ -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("<profession/main>", (explorer, list) -> {
MMOCore.plugin.professionManager.getAll().forEach(profession -> list.add(profession.getId()));
list.add("main");
});
public static final Parameter QUEST = new Parameter("<quest>",
(explorer, list) -> MMOCore.plugin.questManager.getAll().forEach(quest -> list.add(quest.getId())));
public static final Parameter PROFESSION = new Parameter("<profession/main>", (explorer, list) -> {
MMOCore.plugin.professionManager.getAll().forEach(profession -> list.add(profession.getId()));
list.add("main");
});
public static final Parameter QUEST = new Parameter("<quest>",
(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));
}
}

View File

@ -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));

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 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;
}
}

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.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;

View File

@ -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,13 +123,13 @@ 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());

View File

@ -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);

View File

@ -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}'

View File

@ -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}'

View File

@ -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}'

View File

@ -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
@ -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}'

View File

@ -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
@ -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}'

View File

@ -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}'

View File

@ -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}'