Merge remote-tracking branch 'origin/master'

# Conflicts:
#	MMOCore-Dist/src/main/java/net/Indyuce/mmocore/listener/PlayerListener.java
This commit is contained in:
Indyuce 2022-10-14 12:32:38 +02:00
commit 817d28c602
9 changed files with 44 additions and 23 deletions

View File

@ -190,7 +190,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
public int getPointSpent(SkillTree skillTree) {
return pointSpent.get(skillTree);
return pointSpent.getOrDefault(skillTree,0);
}
@ -199,7 +199,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
}
public void giveSkillTreePoints(String id, int val) {
skillTreePoints.put(id, skillTreePoints.get(id) + val);
skillTreePoints.put(id, skillTreePoints.getOrDefault(id,0) + val);
}
public int countSkillTreePoints(SkillTree skillTree) {
@ -296,7 +296,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
}
public int getNodeLevel(SkillTreeNode node) {
return nodeLevels.get(node);
return nodeLevels.getOrDefault(node,0);
}
public void setNodeLevel(SkillTreeNode node, int nodeLevel) {

View File

@ -97,8 +97,16 @@ public class PlayerStats {
* This updates the player's PASSIVE skills
*/
final PassiveSkillMap skillMap = data.getMMOPlayerData().getPassiveSkillMap();
if(!MMOCore.plugin.configManager.passiveSkillNeedBound) {
skillMap.removeModifiers("MMOCorePassiveSkill");
for (ClassSkill skill : data.getProfess().getSkills())
if (skill.getSkill().getTrigger().isPassive())
skillMap.addModifier(skill.toPassive(data));
}
// This updates the player's class SCRIPTS
skillMap.removeModifiers("MMOCoreClassScript");
for (PassiveSkill script : data.getProfess().getScripts())

View File

@ -101,7 +101,8 @@ public class PlayerProfessions {
playerData.getItemClaims().put("profession." + entry.getKey(), entry.getValue().getAsInt());
for (Profession profession : MMOCore.plugin.professionManager.getAll()) {
profession.getExperienceTable().claimStatTriggers(playerData, profession);
if (profession.hasExperienceTable())
profession.getExperienceTable().claimStatTriggers(playerData, profession);
}
}

View File

@ -8,6 +8,10 @@ import org.bukkit.inventory.InventoryHolder;
public abstract class PluginInventory implements InventoryHolder {
protected final Player player;
protected final PlayerData playerData;
/**
* If all the clicks sould be cancelled for the inventory
*/
private boolean shouldCancel = true;
public PluginInventory(PlayerData playerData) {
this.playerData = playerData;
@ -19,6 +23,15 @@ public abstract class PluginInventory implements InventoryHolder {
this.playerData = player.getOpenInventory() != null && player.getOpenInventory().getTopInventory().getHolder() instanceof PluginInventory ? ((PluginInventory) player.getOpenInventory().getTopInventory().getHolder()).playerData : PlayerData.get(player);
}
public PluginInventory(Player player, boolean shouldCancel) {
this(player);
this.shouldCancel=shouldCancel;
}
public PluginInventory(PlayerData playerData, boolean shouldCancel) {
this(playerData);
this.shouldCancel=shouldCancel;
}
public PlayerData getPlayerData() {
return playerData;
}
@ -27,6 +40,10 @@ public abstract class PluginInventory implements InventoryHolder {
return player;
}
public boolean shouldCancel() {
return shouldCancel;
}
/**
* Opens classic inventory, throws
*/

View File

@ -30,7 +30,7 @@ public class DepositMenu extends PluginInventory {
private BukkitRunnable updateRunnable;
public DepositMenu(Player player) {
super(player);
super(player,false);
}
@Override

View File

@ -22,7 +22,7 @@ import java.util.logging.Level;
public class ConfigManager {
public final CommandVerbose commandVerbose = new CommandVerbose();
public boolean overrideVanillaExp, canCreativeCast, cobbleGeneratorXP, saveDefaultClassInfo, attributesAsClassInfo, splitProfessionExp, disableQuestBossBar;
public boolean overrideVanillaExp, canCreativeCast, passiveSkillNeedBound, cobbleGeneratorXP, saveDefaultClassInfo, attributesAsClassInfo, splitProfessionExp, disableQuestBossBar;
public String partyChatPrefix, noSkillBoundPlaceholder;
public ChatColor staminaFull, staminaHalf, staminaEmpty;
public long combatLogTimer, lootChestExpireTime, lootChestPlayerCooldown, globalSkillCooldown;
@ -115,7 +115,7 @@ public class ConfigManager {
staminaFull = getColorOrDefault("stamina-whole", ChatColor.GREEN);
staminaHalf = getColorOrDefault("stamina-half", ChatColor.DARK_GREEN);
staminaEmpty = getColorOrDefault("stamina-empty", ChatColor.WHITE);
passiveSkillNeedBound = MMOCore.plugin.getConfig().getBoolean("passive-skill-need-bound");
canCreativeCast = MMOCore.plugin.getConfig().getBoolean("can-creative-cast");
cobbleGeneratorXP = MMOCore.plugin.getConfig().getBoolean("should-cobblestone-generators-give-exp");
saveDefaultClassInfo = MMOCore.plugin.getConfig().getBoolean("save-default-class-info");
@ -135,7 +135,7 @@ public class ConfigManager {
@Deprecated
public PlayerInput newPlayerInput(Player player, InputType type, Consumer<String> output) {
return new ChatInput(player, type, output) ;
return new ChatInput(player, type, output);
}
public void loadDefaultFile(String name) {

View File

@ -1,5 +1,6 @@
package net.Indyuce.mmocore.manager.data.mysql;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
@ -110,7 +111,7 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
if (!isEmpty(result.getString("friends")))
MMOCoreUtils.jsonArrayToList(result.getString("friends")).forEach(str -> data.getFriends().add(UUID.fromString(str)));
if (!isEmpty(result.getString("skills"))) {
JsonObject object = MythicLib.plugin.getJson().parse(result.getString("skills"), JsonObject.class);
JsonObject object=new Gson().fromJson(result.getString("skills"), JsonObject.class);
for (Entry<String, JsonElement> entry : object.entrySet())
data.setSkillLevel(entry.getKey(), entry.getValue().getAsInt());
}

View File

@ -188,6 +188,12 @@ death-exp-loss:
#Default max bound active and passive skills.
#These value can be modified for each class in the class yml.
max-bound-active-skills: 6
#If you want players to bound their passive skills.
#If false, all the passive skills unlocked will be active
#Also set max-bound-passive-skills to 0 if seting passive-skill-need-bound to false.
passive-skill-need-bound: true
max-bound-passive-skills: 3
# Fun extra RPG feature that switches the player's hotbar with

View File

@ -34,7 +34,7 @@ items:
lore: { }
reallocate:
slots: [26]
slots: [45]
function: reallocation
item: CAULDRON
name: '&aReallocate Skill Points'
@ -46,19 +46,7 @@ items:
- '&eCosts 1 skill reallocation point.'
- '&e◆ Skill Reallocation Points: &6{points}'
#switch:
#
# slots: [28]
# function: switch
# item: PLAYER_HEAD
# binding:
# item: PINK_STAINED_GLASS
# name: '&aSwitch to Binding'
# lore: {}
# upgrading:
# item: PINK_STAINED_GLASS
# name: '&aSwitch to Upgrading'
# lore: {}
passive-skill-slot:
slots: [ 7,16,25,34,43,52 ]
function: passive-slot