forked from Upstream/mmocore
Merge branch 'master' into Skills-update
# Conflicts: # MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java
This commit is contained in:
commit
037fb131ec
@ -172,8 +172,8 @@ public class MMOCore extends JavaPlugin {
|
||||
}
|
||||
|
||||
/*
|
||||
* Resource regeneration. Must check if entity is dead otherwise regen will make
|
||||
* the 'respawn' button glitched plus HURT entity effect bug
|
||||
* Resource regeneration. Must check if entity is dead otherwise regen
|
||||
* will make the 'respawn' button glitched plus HURT entity effect bug
|
||||
*/
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
|
@ -93,7 +93,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
private final List<UUID> friends = new ArrayList<>();
|
||||
private final Set<String> waypoints = new HashSet<>();
|
||||
private final Map<String, Integer> skills = new HashMap<>();
|
||||
private final Map<Integer,BoundSkillInfo> boundSkills = new HashMap<>();
|
||||
private final Map<Integer, BoundSkillInfo> boundSkills = new HashMap<>();
|
||||
private final PlayerProfessions collectSkills = new PlayerProfessions(this);
|
||||
private final PlayerAttributes attributes = new PlayerAttributes(this);
|
||||
private final Map<String, SavedClassInformation> classSlots = new HashMap<>();
|
||||
@ -233,11 +233,10 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
}
|
||||
|
||||
public void clearNodeTimesClaimed() {
|
||||
Map<String, Integer> copy = new HashMap<>(tableItemClaims);
|
||||
copy.forEach((str, val) -> {
|
||||
if (str.startsWith(SkillTreeNode.KEY_PREFIX))
|
||||
tableItemClaims.remove(str);
|
||||
});
|
||||
final Iterator<String> ite = tableItemClaims.keySet().iterator();
|
||||
while (ite.hasNext())
|
||||
if (ite.next().startsWith(SkillTreeNode.KEY_PREFIX))
|
||||
ite.remove();
|
||||
}
|
||||
|
||||
public Set<Map.Entry<String, Integer>> getNodeLevelsEntrySet() {
|
||||
@ -770,9 +769,9 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
final double r = Math.sin((double) t / warpTime * Math.PI);
|
||||
for (double j = 0; j < Math.PI * 2; j += Math.PI / 4)
|
||||
getPlayer().getLocation().getWorld().spawnParticle(Particle.REDSTONE, getPlayer().getLocation().add(
|
||||
Math.cos((double) 5 * t / warpTime + j) * r,
|
||||
(double) 2 * t / warpTime,
|
||||
Math.sin((double) 5 * t / warpTime + j) * r),
|
||||
Math.cos((double) 5 * t / warpTime + j) * r,
|
||||
(double) 2 * t / warpTime,
|
||||
Math.sin((double) 5 * t / warpTime + j) * r),
|
||||
1, new Particle.DustOptions(Color.PURPLE, 1.25f));
|
||||
}
|
||||
}.runTaskTimer(MMOCore.plugin, 0, 1);
|
||||
@ -801,18 +800,18 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
* If it's null, no hologram will be displayed
|
||||
* @param splitExp Should the exp be split among party members
|
||||
*/
|
||||
public void giveExperience(double value, EXPSource source, @Nullable Location hologramLocation, boolean splitExp) {
|
||||
public void giveExperience(double value, @NotNull EXPSource source, @Nullable Location hologramLocation, boolean splitExp) {
|
||||
if (value <= 0) {
|
||||
experience = Math.max(0, experience + value);
|
||||
return;
|
||||
}
|
||||
|
||||
// Splitting exp through party members
|
||||
AbstractParty party;
|
||||
if (splitExp && (party = getParty()) != null) {
|
||||
final AbstractParty party;
|
||||
if (splitExp && (party = getParty()) != null && MMOCore.plugin.configManager.splitMainExp) {
|
||||
final List<PlayerData> nearbyMembers = party.getOnlineMembers().stream()
|
||||
.filter(pd -> {
|
||||
if (equals(pd) || pd.hasReachedMaxLevel())
|
||||
if (equals(pd) || pd.hasReachedMaxLevel() || Math.abs(pd.getLevel() - getLevel()) > MMOCore.plugin.configManager.maxPartyLevelDifference)
|
||||
return false;
|
||||
|
||||
final double maxDis = MMOCore.plugin.configManager.partyMaxExpSplitRange;
|
||||
@ -863,7 +862,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
if (level > oldLevel) {
|
||||
Bukkit.getPluginManager().callEvent(new PlayerLevelUpEvent(this, null, oldLevel, level));
|
||||
if (isOnline()) {
|
||||
new ConfigMessage("level-up").addPlaceholders("level", "" + level).send(getPlayer());
|
||||
new ConfigMessage("level-up").addPlaceholders("level", String.valueOf(level)).send(getPlayer());
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.LEVEL_UP).playTo(getPlayer());
|
||||
new SmallParticleEffect(getPlayer(), Particle.SPELL_INSTANT);
|
||||
}
|
||||
|
@ -99,10 +99,13 @@ public class RPGPlaceholders extends PlaceholderExpansion {
|
||||
return String.valueOf(playerData.getCombat().isInPvpMode());
|
||||
|
||||
else if (identifier.startsWith("since_enter_combat"))
|
||||
return playerData.isInCombat() ? MythicLib.plugin.getMMOConfig().decimal.format((System.currentTimeMillis() - playerData.getCombat().getFirstHit()) / 1000) : "-1";
|
||||
return playerData.isInCombat() ? MythicLib.plugin.getMMOConfig().decimal.format((System.currentTimeMillis() - playerData.getCombat().getLastEntry()) / 1000.) : "-1";
|
||||
|
||||
else if (identifier.startsWith("invulnerability_left"))
|
||||
return MythicLib.plugin.getMMOConfig().decimal.format(Math.max(0, (playerData.getCombat().getInvulnerableTill() - System.currentTimeMillis()) / 1000.));
|
||||
|
||||
else if (identifier.startsWith("since_last_hit"))
|
||||
return playerData.isInCombat() ? MythicLib.plugin.getMMOConfig().decimal.format((System.currentTimeMillis() - playerData.getCombat().getLastHit()) / 1000) : "-1";
|
||||
return playerData.isInCombat() ? MythicLib.plugin.getMMOConfig().decimal.format((System.currentTimeMillis() - playerData.getCombat().getLastHit()) / 1000.) : "-1";
|
||||
|
||||
else if (identifier.startsWith("bound_")) {
|
||||
int slot = Math.max(0, Integer.parseInt(identifier.substring(6)) - 1);
|
||||
@ -195,6 +198,13 @@ public class RPGPlaceholders extends PlaceholderExpansion {
|
||||
return format.toString();
|
||||
}
|
||||
|
||||
/*
|
||||
4) cooldown of region_change
|
||||
5) cooldown of command
|
||||
6) all cooldown you are showing in the in game message
|
||||
|
||||
*/
|
||||
|
||||
else if (identifier.equals("quest")) {
|
||||
PlayerQuests data = playerData.getQuestData();
|
||||
return data.hasCurrent() ? data.getCurrent().getQuest().getName() : "None";
|
||||
|
@ -22,7 +22,7 @@ public class PvPModeListener implements Listener {
|
||||
Validate.isTrue(registerHandler(PvPFlagHandler.FACTORY), "Could not register WG handler for PvP");
|
||||
}
|
||||
|
||||
private boolean registerHandler(Handler.Factory factory) {
|
||||
private boolean registerHandler(Handler.Factory<?> factory) {
|
||||
return WorldGuard.getInstance().getPlatform().getSessionManager().registerHandler(factory, null);
|
||||
}
|
||||
|
||||
@ -42,10 +42,41 @@ public class PvPModeListener implements Listener {
|
||||
if (source == null)
|
||||
return;
|
||||
|
||||
// Check for target's invulnerability BEFORE pvp-mode flag because it can also
|
||||
// happen when the option pvp_mode.invulnerability.apply_to_pvp_flag is on
|
||||
// The first code portion applies to any region, not only PvpMode
|
||||
|
||||
// Check for minimum level
|
||||
final Player target = (Player) event.getEntity();
|
||||
final PlayerData targetData = PlayerData.get(target);
|
||||
final PlayerData targetData = PlayerData.get(target), sourceData = PlayerData.get(source);
|
||||
final int minLevel = MMOCore.plugin.configManager.minCombatLevel;
|
||||
if (minLevel > 0) {
|
||||
|
||||
if (targetData.getLevel() < minLevel) {
|
||||
event.setCancelled(true);
|
||||
if (event.getDamage() > 0)
|
||||
MMOCore.plugin.configManager.getSimpleMessage("pvp-mode.cannot-hit.low-level-target").send(source);
|
||||
return;
|
||||
}
|
||||
|
||||
if (sourceData.getLevel() < minLevel) {
|
||||
event.setCancelled(true);
|
||||
if (event.getDamage() > 0)
|
||||
MMOCore.plugin.configManager.getSimpleMessage("pvp-mode.cannot-hit.low-level-self").send(source);
|
||||
return;
|
||||
}
|
||||
|
||||
final int maxLevelDiff = MMOCore.plugin.configManager.maxCombatLevelDifference;
|
||||
if (maxLevelDiff > 0 && Math.abs(targetData. getLevel() - sourceData.getLevel()) > maxLevelDiff) {
|
||||
event.setCancelled(true);
|
||||
if (event.getDamage() > 0)
|
||||
MMOCore.plugin.configManager.getSimpleMessage("pvp-mode.cannot-hit.high-level-difference").send(source);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for target's invulnerability BEFORE pvp-mode flag because it can also
|
||||
* happen when the option pvp_mode.invulnerability.apply_to_pvp_flag is on
|
||||
*/
|
||||
if (targetData.getCombat().isInvulnerable()) {
|
||||
if (event.getDamage() > 0) {
|
||||
final long left = targetData.getCombat().getInvulnerableTill() - System.currentTimeMillis();
|
||||
@ -57,7 +88,6 @@ public class PvPModeListener implements Listener {
|
||||
}
|
||||
|
||||
// If attacker is still invulnerable and cannot deal damage
|
||||
final PlayerData sourceData = PlayerData.get(source);
|
||||
if (!MMOCore.plugin.configManager.pvpModeInvulnerabilityCanDamage && sourceData.getCombat().isInvulnerable()) {
|
||||
if (event.getDamage() > 0) {
|
||||
final long left = sourceData.getCombat().getInvulnerableTill() - System.currentTimeMillis();
|
||||
@ -72,6 +102,8 @@ public class PvPModeListener implements Listener {
|
||||
if (!MythicLib.plugin.getFlags().isFlagAllowed(target.getLocation(), CustomFlag.PVP_MODE))
|
||||
return;
|
||||
|
||||
// Starting from here, this only applies to PvpMode-regions.
|
||||
|
||||
// Defender has not enabled PvP mode
|
||||
if (!targetData.getCombat().isInPvpMode()) {
|
||||
event.setCancelled(true);
|
||||
|
@ -4,8 +4,8 @@ import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import io.lumine.mythic.lib.api.util.PostLoadObject;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.experience.droptable.ExperienceTable;
|
||||
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
||||
import net.Indyuce.mmocore.experience.droptable.ExperienceTable;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -125,8 +125,7 @@ public class Profession extends PostLoadObject implements ExperienceObject {
|
||||
|
||||
@Override
|
||||
public void giveExperience(PlayerData playerData, double experience, @Nullable Location hologramLocation, EXPSource source) {
|
||||
hologramLocation = !getOption(Profession.ProfessionOption.EXP_HOLOGRAMS) ? null
|
||||
: hologramLocation;
|
||||
hologramLocation = !getOption(Profession.ProfessionOption.EXP_HOLOGRAMS) ? null : hologramLocation;
|
||||
playerData.getCollectionSkills().giveExperience(this, experience, EXPSource.SOURCE, hologramLocation, true);
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,7 @@ public class SimpleExperienceObject implements ExperienceDispenser {
|
||||
|
||||
@Override
|
||||
public void giveExperience(PlayerData playerData, double experience, @Nullable Location hologramLocation, EXPSource source) {
|
||||
hologramLocation = !MMOCore.plugin.getConfig().getBoolean("display-main-class-exp-holograms") ? null
|
||||
: hologramLocation == null ? getPlayerLocation(playerData) : hologramLocation;
|
||||
hologramLocation = !MMOCore.plugin.getConfig().getBoolean("display-main-class-exp-holograms") ? null : hologramLocation;
|
||||
playerData.giveExperience(experience, source, hologramLocation, true);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,6 @@ public class MineBlockExperienceSource extends SpecificExperienceSource<Material
|
||||
}
|
||||
|
||||
private boolean hasSilkTouch(ItemStack item) {
|
||||
|
||||
return item != null && item.hasItemMeta() && item.getItemMeta().hasEnchant(Enchantment.SILK_TOUCH);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,12 @@
|
||||
package net.Indyuce.mmocore.gui;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.SoundEvent;
|
||||
import net.Indyuce.mmocore.api.event.PlayerChangeClassEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||
import net.Indyuce.mmocore.api.player.profess.SavedClassInformation;
|
||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||
import net.Indyuce.mmocore.gui.api.EditableInventory;
|
||||
import net.Indyuce.mmocore.gui.api.GeneratedInventory;
|
||||
import net.Indyuce.mmocore.gui.api.InventoryClickContext;
|
||||
@ -9,21 +14,29 @@ import net.Indyuce.mmocore.gui.api.PluginInventory;
|
||||
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
||||
import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem;
|
||||
import net.Indyuce.mmocore.api.event.PlayerChangeClassEvent;
|
||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||
import net.Indyuce.mmocore.api.SoundEvent;
|
||||
import net.Indyuce.mmocore.api.player.profess.SavedClassInformation;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ClassConfirmation extends EditableInventory {
|
||||
public ClassConfirmation() {
|
||||
super("class-confirm");
|
||||
}
|
||||
|
||||
/**
|
||||
* This enables to configure the name of the
|
||||
* class confirmation GUI (for custom GUI textures).
|
||||
*/
|
||||
private final Map<String, String> specificNames = new HashMap<>();
|
||||
|
||||
public ClassConfirmation() {
|
||||
super("class-confirm");
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryItem load(String function, ConfigurationSection config) {
|
||||
@ -34,12 +47,20 @@ public class ClassConfirmation extends EditableInventory {
|
||||
return new ClassConfirmationInventory(data, this, profess, last);
|
||||
}
|
||||
|
||||
public GeneratedInventory newInventory(PlayerData data, String GUIName, PlayerClass profess, PluginInventory last) {
|
||||
return new ClassConfirmationInventory(data, GUIName, this, profess, last);
|
||||
@Override
|
||||
public void reload(FileConfiguration config) {
|
||||
super.reload(config);
|
||||
|
||||
specificNames.clear();
|
||||
|
||||
if (config.contains("class-specific-name")) {
|
||||
final ConfigurationSection section = config.getConfigurationSection("class-specific-name");
|
||||
for (String key : section.getKeys(false))
|
||||
specificNames.put(key, section.getString(key));
|
||||
}
|
||||
}
|
||||
|
||||
public class UnlockedItem extends InventoryItem<ClassConfirmationInventory> {
|
||||
|
||||
public UnlockedItem(ConfigurationSection config) {
|
||||
super(config);
|
||||
}
|
||||
@ -50,8 +71,8 @@ public class ClassConfirmation extends EditableInventory {
|
||||
SavedClassInformation info = inv.getPlayerData().getClassInfo(profess);
|
||||
Placeholders holders = new Placeholders();
|
||||
|
||||
int nextLevelExp = inv.getPlayerData().getLevelUpExperience();
|
||||
double ratio = (double) info.getExperience() / (double) nextLevelExp;
|
||||
final double nextLevelExp = inv.getPlayerData().getLevelUpExperience();
|
||||
final double ratio = info.getExperience() / nextLevelExp;
|
||||
|
||||
StringBuilder bar = new StringBuilder("" + ChatColor.BOLD);
|
||||
int chars = (int) (ratio * 20);
|
||||
@ -102,17 +123,10 @@ public class ClassConfirmation extends EditableInventory {
|
||||
public class ClassConfirmationInventory extends GeneratedInventory {
|
||||
private final PlayerClass profess;
|
||||
private final PluginInventory last;
|
||||
private String GUIName;
|
||||
|
||||
public ClassConfirmationInventory(PlayerData playerData, EditableInventory editable, PlayerClass profess, PluginInventory last) {
|
||||
super(playerData, editable);
|
||||
this.profess = profess;
|
||||
this.last = last;
|
||||
}
|
||||
|
||||
public ClassConfirmationInventory(PlayerData playerData, String GUIName, EditableInventory editable, PlayerClass profess, PluginInventory last) {
|
||||
super(playerData, editable);
|
||||
this.GUIName = GUIName;
|
||||
this.profess = profess;
|
||||
this.last = last;
|
||||
}
|
||||
@ -140,9 +154,9 @@ public class ClassConfirmation extends EditableInventory {
|
||||
|
||||
@Override
|
||||
public String calculateName() {
|
||||
if (GUIName != null)
|
||||
return GUIName;
|
||||
return getName();
|
||||
final String professKey = MMOCoreUtils.ymlName(profess.getId());
|
||||
final @Nullable String found = specificNames.get(professKey);
|
||||
return found == null ? getName().replace("{class}", profess.getName()) : found;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,18 +2,17 @@ package net.Indyuce.mmocore.gui;
|
||||
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
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.util.MMOCoreUtils;
|
||||
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.InventoryClickContext;
|
||||
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.profess.ClassOption;
|
||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -22,7 +21,9 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ClassSelect extends EditableInventory {
|
||||
@ -42,21 +43,12 @@ public class ClassSelect extends EditableInventory {
|
||||
public class ClassItem extends SimplePlaceholderItem<ProfessSelectionInventory> {
|
||||
private final String name;
|
||||
private final List<String> lore;
|
||||
/**
|
||||
* This enables to configure the name of the class confirmation GUI (for custom GUI textures).
|
||||
*/
|
||||
private final Map<String, String> classGUINames = new HashMap<>();
|
||||
|
||||
public ClassItem(ConfigurationSection config) {
|
||||
super(Material.BARRIER, config);
|
||||
|
||||
this.name = config.getString("name");
|
||||
this.lore = config.getStringList("lore");
|
||||
if (config.contains("class-confirmation-GUI-name")) {
|
||||
ConfigurationSection section = config.getConfigurationSection("class-confirmation-GUI-name");
|
||||
for (String key : section.getKeys(false))
|
||||
classGUINames.put(key, section.getString(key));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasDifferentDisplay() {
|
||||
@ -113,7 +105,6 @@ public class ClassSelect extends EditableInventory {
|
||||
@Override
|
||||
public void whenClicked(InventoryClickContext context, InventoryItem item) {
|
||||
if (item.getFunction().equals("class")) {
|
||||
ClassItem classItem = (ClassItem) item;
|
||||
String classId = context.getClickedItem().getItemMeta().getPersistentDataContainer().get(new NamespacedKey(MMOCore.plugin, "class_id"), PersistentDataType.STRING);
|
||||
if (classId.equals(""))
|
||||
return;
|
||||
@ -124,7 +115,7 @@ public class ClassSelect extends EditableInventory {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerClass profess = MMOCore.plugin.classManager.get(classId);
|
||||
final PlayerClass profess = MMOCore.plugin.classManager.get(classId);
|
||||
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);
|
||||
@ -136,13 +127,9 @@ public class ClassSelect extends EditableInventory {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("already-on-class", "class", profess.getName()).send(player);
|
||||
return;
|
||||
}
|
||||
PlayerClass playerClass = findDeepestSubclass(playerData, profess);
|
||||
String classKey = MMOCoreUtils.ymlName(playerClass.getName());
|
||||
if (classItem.classGUINames.containsKey(classKey)) {
|
||||
InventoryManager.CLASS_CONFIRM.newInventory(playerData,classItem.classGUINames.get(classKey),playerClass, this).open();
|
||||
|
||||
} else
|
||||
InventoryManager.CLASS_CONFIRM.newInventory(playerData,playerClass, this).open();
|
||||
final PlayerClass playerClass = findDeepestSubclass(playerData, profess);
|
||||
InventoryManager.CLASS_CONFIRM.newInventory(playerData, playerClass, this).open();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ public abstract class EditableInventory {
|
||||
private String name;
|
||||
private int slots;
|
||||
|
||||
|
||||
/*
|
||||
* This set is linked so it keeps the order/priority in
|
||||
* which the items are loaded from the config.
|
||||
@ -83,7 +82,6 @@ public abstract class EditableInventory {
|
||||
return adaptorType;
|
||||
}
|
||||
|
||||
|
||||
public FileConfiguration getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
@ -27,14 +27,14 @@ import java.util.logging.Level;
|
||||
public class ConfigManager {
|
||||
public final CommandVerbose commandVerbose = new CommandVerbose();
|
||||
|
||||
public boolean overrideVanillaExp, canCreativeCast, passiveSkillNeedBound, cobbleGeneratorXP, saveDefaultClassInfo, attributesAsClassInfo, splitProfessionExp, disableQuestBossBar,
|
||||
public boolean overrideVanillaExp, canCreativeCast, passiveSkillNeedBound, cobbleGeneratorXP, saveDefaultClassInfo, splitMainExp, splitProfessionExp, disableQuestBossBar,
|
||||
pvpModeEnabled, pvpModeInvulnerabilityCanDamage;
|
||||
public String partyChatPrefix, noSkillBoundPlaceholder;
|
||||
public ChatColor staminaFull, staminaHalf, staminaEmpty;
|
||||
public long combatLogTimer, lootChestExpireTime, lootChestPlayerCooldown, globalSkillCooldown;
|
||||
public double lootChestsChanceWeight, dropItemsChanceWeight, fishingDropsChanceWeight, partyMaxExpSplitRange, pvpModeToggleOnCooldown, pvpModeToggleOffCooldown, pvpModeCombatCooldown,
|
||||
pvpModeCombatTimeout, pvpModeInvulnerabilityTimeRegionChange, pvpModeInvulnerabilityTimeCommand, pvpModeRegionEnterCooldown, pvpModeRegionLeaveCooldown;
|
||||
public int maxPartyLevelDifference, maxBoundActiveSkills, maxBoundPassiveSkills;
|
||||
public int maxPartyLevelDifference, maxBoundActiveSkills, maxBoundPassiveSkills, minCombatLevel, maxCombatLevelDifference;
|
||||
public final List<EntityDamageEvent.DamageCause> combatLogDamageCauses = new ArrayList<>();
|
||||
|
||||
private final FileConfiguration messages;
|
||||
@ -144,6 +144,8 @@ public class ConfigManager {
|
||||
pvpModeInvulnerabilityTimeCommand = config.getDouble("pvp_mode.invulnerability.time.command");
|
||||
pvpModeInvulnerabilityTimeRegionChange = config.getDouble("pvp_mode.invulnerability.time.region_change");
|
||||
pvpModeInvulnerabilityCanDamage = config.getBoolean("pvp_mode.invulnerability.can_damage");
|
||||
minCombatLevel = config.getInt("pvp_mode.min_level");
|
||||
maxCombatLevelDifference = config.getInt("pvp_mode.max_level_difference");
|
||||
|
||||
// Resources
|
||||
staminaFull = getColorOrDefault("stamina-whole", ChatColor.GREEN);
|
||||
|
@ -40,7 +40,7 @@ public class InventoryManager {
|
||||
try {
|
||||
inv.reload(new ConfigFile("/gui", inv.getId()).getConfig());
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.log(Level.WARNING, "Could not load inventory " + inv.getId() + ": " + exception.getMessage());
|
||||
MMOCore.log(Level.WARNING, "Could not load inventory '" + inv.getId() + "': " + exception.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -79,24 +80,23 @@ public abstract class PlayerDataManager {
|
||||
public PlayerData setup(UUID uniqueId) {
|
||||
|
||||
// Load player data if it does not exist
|
||||
if (!data.containsKey(uniqueId)) {
|
||||
PlayerData newData = new PlayerData(MMOPlayerData.get(uniqueId));
|
||||
final @Nullable PlayerData current = data.get(uniqueId);
|
||||
if (current != null)
|
||||
return current;
|
||||
|
||||
// Schedule async data loading
|
||||
Bukkit.getScheduler().runTaskAsynchronously(MMOCore.plugin, () -> {
|
||||
loadData(newData);
|
||||
newData.getStats().updateStats();
|
||||
Bukkit.getPluginManager().callEvent(new AsyncPlayerDataLoadEvent(newData));
|
||||
Bukkit.getScheduler().runTask(MMOCore.plugin, () -> Bukkit.getPluginManager().callEvent(new PlayerDataLoadEvent(newData)));
|
||||
});
|
||||
final PlayerData newData = new PlayerData(MMOPlayerData.get(uniqueId));
|
||||
|
||||
// Update data map
|
||||
data.put(uniqueId, newData);
|
||||
// Schedule async data loading
|
||||
Bukkit.getScheduler().runTaskAsynchronously(MMOCore.plugin, () -> {
|
||||
loadData(newData);
|
||||
newData.getStats().updateStats();
|
||||
Bukkit.getPluginManager().callEvent(new AsyncPlayerDataLoadEvent(newData));
|
||||
Bukkit.getScheduler().runTask(MMOCore.plugin, () -> Bukkit.getPluginManager().callEvent(new PlayerDataLoadEvent(newData)));
|
||||
});
|
||||
|
||||
return newData;
|
||||
}
|
||||
|
||||
return data.get(uniqueId);
|
||||
// Update data map and return
|
||||
data.put(uniqueId, newData);
|
||||
return newData;
|
||||
}
|
||||
|
||||
public DefaultPlayerData getDefaultData() {
|
||||
|
@ -4,7 +4,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.sql.DataSynchronizer;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
@ -118,7 +118,7 @@ public class MMOCoreDataSynchronizer extends DataSynchronizer {
|
||||
}
|
||||
}
|
||||
|
||||
MythicLib.debug("MMOCoreSQL", String.format("{ class: %s, level: %d }", data.getProfess().getId(), data.getLevel()));
|
||||
UtilityMethods.debug(MMOCore.plugin, "SQL", String.format("{ class: %s, level: %d }", data.getProfess().getId(), data.getLevel()));
|
||||
data.setFullyLoaded();
|
||||
}
|
||||
|
||||
@ -138,6 +138,6 @@ public class MMOCoreDataSynchronizer extends DataSynchronizer {
|
||||
data.getQuestData().updateBossBar();
|
||||
|
||||
data.setFullyLoaded();
|
||||
MythicLib.debug("MMOCoreSQL", "Loaded DEFAULT data for: '" + data.getUniqueId() + "' as no saved data was found.");
|
||||
UtilityMethods.debug(MMOCore.plugin, "SQL", "Loaded DEFAULT data for: '" + data.getUniqueId() + "' as no saved data was found.");
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.Indyuce.mmocore.manager.data.mysql;
|
||||
|
||||
import io.lumine.mythic.lib.sql.MMODataSource;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.manager.data.DataProvider;
|
||||
import net.Indyuce.mmocore.manager.data.GuildDataManager;
|
||||
import net.Indyuce.mmocore.manager.data.PlayerDataManager;
|
||||
@ -25,6 +26,8 @@ public class MySQLDataProvider extends MMODataSource implements DataProvider {
|
||||
"stellium","FLOAT"};
|
||||
|
||||
public MySQLDataProvider(FileConfiguration config) {
|
||||
super(MMOCore.plugin);
|
||||
|
||||
this.setup(config);
|
||||
}
|
||||
|
||||
|
@ -1,18 +1,16 @@
|
||||
package net.Indyuce.mmocore.manager.data.mysql;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.OfflinePlayerData;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||
import net.Indyuce.mmocore.api.player.profess.SavedClassInformation;
|
||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||
import net.Indyuce.mmocore.manager.data.PlayerDataManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@ -36,7 +34,7 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
||||
|
||||
@Override
|
||||
public void saveData(PlayerData data, boolean logout) {
|
||||
MythicLib.debug("MMOCoreSQL", "Saving data for: '" + data.getUniqueId() + "'...");
|
||||
UtilityMethods.debug(MMOCore.plugin, "SQL", "Saving data for: '" + data.getUniqueId() + "'...");
|
||||
|
||||
final PlayerDataTableUpdater updater = new PlayerDataTableUpdater(provider, data);
|
||||
updater.addData("class_points", data.getClassPoints());
|
||||
@ -73,8 +71,8 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
||||
|
||||
updater.executeRequest(logout);
|
||||
|
||||
MythicLib.debug("MMOCoreSQL", "Saved data for: " + data.getUniqueId());
|
||||
MythicLib.debug("MMOCoreSQL", String.format("{ class: %s, level: %d }", data.getProfess().getId(), data.getLevel()));
|
||||
UtilityMethods.debug(MMOCore.plugin, "SQL", "Saved data for: " + data.getUniqueId());
|
||||
UtilityMethods.debug(MMOCore.plugin, "SQL", String.format("{ class: %s, level: %d }", data.getProfess().getId(), data.getLevel()));
|
||||
}
|
||||
|
||||
private JsonObject createClassInfoData(PlayerData playerData) {
|
||||
|
@ -1,42 +1,52 @@
|
||||
package net.Indyuce.mmocore.party.provided;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.event.social.PartyChatEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.manager.ConfigManager;
|
||||
import net.Indyuce.mmocore.api.event.social.PartyChatEvent;
|
||||
import net.Indyuce.mmocore.party.AbstractParty;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class PartyListener implements Listener {
|
||||
private final MMOCorePartyModule module;
|
||||
private final MMOCorePartyModule module;
|
||||
|
||||
public PartyListener(MMOCorePartyModule module) {
|
||||
this.module = module;
|
||||
}
|
||||
public PartyListener(MMOCorePartyModule module) {
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void a(AsyncPlayerChatEvent event) {
|
||||
if (!event.getMessage().startsWith(MMOCore.plugin.configManager.partyChatPrefix))
|
||||
return;
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void partyChat(AsyncPlayerChatEvent event) {
|
||||
if (!event.getMessage().startsWith(MMOCore.plugin.configManager.partyChatPrefix))
|
||||
return;
|
||||
|
||||
PlayerData data = PlayerData.get(event.getPlayer());
|
||||
Party party = module.getParty(data);
|
||||
if (party == null)
|
||||
return;
|
||||
PlayerData data = PlayerData.get(event.getPlayer());
|
||||
Party party = module.getParty(data);
|
||||
if (party == null)
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
event.setCancelled(true);
|
||||
|
||||
// Running it in a delayed task is recommended
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(MMOCore.plugin, () -> {
|
||||
ConfigManager.SimpleMessage format = MMOCore.plugin.configManager.getSimpleMessage("party-chat", "player", data.getPlayer().getName(), "message",
|
||||
event.getMessage().substring(MMOCore.plugin.configManager.partyChatPrefix.length()));
|
||||
PartyChatEvent called = new PartyChatEvent(party, data, format.message());
|
||||
Bukkit.getPluginManager().callEvent(called);
|
||||
if (!called.isCancelled())
|
||||
party.getOnlineMembers().forEach(member -> format.send(member.getPlayer()));
|
||||
});
|
||||
}
|
||||
// Running it in a delayed task is recommended
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(MMOCore.plugin, () -> {
|
||||
ConfigManager.SimpleMessage format = MMOCore.plugin.configManager.getSimpleMessage("party-chat", "player", data.getPlayer().getName(), "message",
|
||||
event.getMessage().substring(MMOCore.plugin.configManager.partyChatPrefix.length()));
|
||||
PartyChatEvent called = new PartyChatEvent(party, data, format.message());
|
||||
Bukkit.getPluginManager().callEvent(called);
|
||||
if (!called.isCancelled())
|
||||
party.getOnlineMembers().forEach(member -> format.send(member.getPlayer()));
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void leavePartyOnQuit(PlayerQuitEvent event) {
|
||||
final PlayerData playerData = PlayerData.get(event.getPlayer());
|
||||
final AbstractParty party = playerData.getParty();
|
||||
if (party != null)
|
||||
((Party) party).removeMember(playerData);
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CombatHandler implements Closable {
|
||||
private final PlayerData player;
|
||||
private final long firstHit = System.currentTimeMillis();
|
||||
|
||||
private long lastHit = System.currentTimeMillis(), invulnerableTill;
|
||||
private long lastEntry = System.currentTimeMillis(), lastHit = System.currentTimeMillis(), invulnerableTill;
|
||||
|
||||
private boolean pvpMode;
|
||||
|
||||
@ -33,15 +31,21 @@ public class CombatHandler implements Closable {
|
||||
// Simply refreshing
|
||||
if (isInCombat()) {
|
||||
Bukkit.getScheduler().cancelTask(task.getTaskId());
|
||||
task = Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> quit(false), MMOCore.plugin.configManager.combatLogTimer / 50);
|
||||
task = newTask();
|
||||
|
||||
// Entering combat
|
||||
} else {
|
||||
lastEntry = System.currentTimeMillis();
|
||||
MMOCore.plugin.configManager.getSimpleMessage("now-in-combat").send(player.getPlayer());
|
||||
Bukkit.getPluginManager().callEvent(new PlayerCombatEvent(player, true));
|
||||
task = newTask();
|
||||
}
|
||||
}
|
||||
|
||||
private BukkitTask newTask() {
|
||||
return Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> quit(false), MMOCore.plugin.configManager.combatLogTimer / 50);
|
||||
}
|
||||
|
||||
public boolean isInPvpMode() {
|
||||
return pvpMode;
|
||||
}
|
||||
@ -54,8 +58,8 @@ public class CombatHandler implements Closable {
|
||||
return lastHit;
|
||||
}
|
||||
|
||||
public long getFirstHit() {
|
||||
return firstHit;
|
||||
public long getLastEntry() {
|
||||
return lastEntry;
|
||||
}
|
||||
|
||||
public long getInvulnerableTill() {
|
||||
|
@ -158,7 +158,10 @@ party:
|
||||
# Set to 0 to disable
|
||||
max-exp-split-range: 48
|
||||
|
||||
# When enabled, being in a party also splits profession exp
|
||||
# When enabled, being in a party splits class exp
|
||||
main-exp-split: true
|
||||
|
||||
# When enabled, being in a party splits profession exp
|
||||
profession-exp-split: false
|
||||
|
||||
# Not relevant when not using MMOCore as quest plugin
|
||||
@ -219,19 +222,10 @@ hotbar-swapping:
|
||||
# If the player has to sneak to swap hotbars
|
||||
crouching: true
|
||||
|
||||
# Set this to true to allow players
|
||||
# in creative mode to enter casting mode
|
||||
# Set this to true to allow players in
|
||||
# creative mode to enter casting mode
|
||||
can-creative-cast: false
|
||||
|
||||
# Not implemented yet
|
||||
ability-targeting-options:
|
||||
|
||||
# Prevent heals/buffs on players in a different guild
|
||||
cant-heal-enemies: true
|
||||
|
||||
# Prevent heals/buffs UNLESS the player is in your party/guild
|
||||
cant-heal-neutrals: false
|
||||
|
||||
# Prevents mobs spawned from spawners from giving MMO XP points.
|
||||
prevent-spawner-xp: true
|
||||
|
||||
@ -300,6 +294,14 @@ pvp_mode:
|
||||
# Requires /reload when changed
|
||||
enabled: false
|
||||
|
||||
# Minimum level in order to fight other players.
|
||||
# Set to 0 to fully disable
|
||||
min_level: 0
|
||||
|
||||
# Maximum level difference in order to fight other players.
|
||||
# Set to 0 to fully disable
|
||||
max_level_difference: 10
|
||||
|
||||
# Delay after any attack during which the player will stay in PvP Mode (seconds)
|
||||
# Has to be lower than 'cooldown.combat'
|
||||
combat_timeout: 30
|
||||
@ -316,10 +318,10 @@ pvp_mode:
|
||||
# to end this invulnerable time period.
|
||||
can_damage: false
|
||||
|
||||
# When enabled, leaving a no-PVP zone and entering a PVP zone
|
||||
# will apply the SAME invulnerability time.
|
||||
# When enabled, leaving a no-PVP zone and entering a
|
||||
# PVP zone will apply the SAME invulnerability time.
|
||||
# Requires /reload when changed
|
||||
apply_to_pvp_flag: false
|
||||
apply_to_pvp_flag: true
|
||||
|
||||
cooldown:
|
||||
|
||||
|
@ -1,6 +1,15 @@
|
||||
|
||||
# GUI display name
|
||||
name: Class Confirmation
|
||||
# GUI display name, used by default
|
||||
name: 'Confirmation: {class}'
|
||||
|
||||
# GUI display name which overrides the default one.
|
||||
# This can be used to apply custom textures to the GUI
|
||||
class-specific-name:
|
||||
mage: "Select Mage"
|
||||
rogue: "Select Rogue"
|
||||
marksman: "Select Marksman"
|
||||
warrior: "Select Warrior"
|
||||
paladin: "Select Paladin"
|
||||
|
||||
# Number of slots in your inventory. Must be
|
||||
# between 9 and 54 and must be a multiple of 9.
|
||||
|
@ -16,12 +16,3 @@ items:
|
||||
- '{lore}'
|
||||
- ''
|
||||
- '{attribute-lore}'
|
||||
|
||||
#Customizable name for the confirmation GUI.
|
||||
#If none is provided the GUI name will be "Class Confirmation".
|
||||
class-confirmation-GUI-name:
|
||||
mage: "Select Mage"
|
||||
rogue: "Select Rogue"
|
||||
marksman: "Select Marksman"
|
||||
warrior: "Select Warrior"
|
||||
paladin: "Select Paladin"
|
||||
|
@ -35,6 +35,9 @@ pvp-mode:
|
||||
|
||||
# When you cannot hit another player
|
||||
cannot-hit:
|
||||
high-level-difference: '&cLevel difference is too high to fight this player.'
|
||||
low-level-target: '&cYou cannot fight this player as their level is too low.'
|
||||
low-level-self: '&cYour level is too low to fight other players.'
|
||||
pvp-mode-disabled-target: '&cThis player has not toggled on PvP.'
|
||||
pvp-mode-disabled-self: '&cYou have not toggled on PvP.'
|
||||
invulnerable-self: '&cYou are still out of combat for {left} seconds.'
|
||||
|
Loading…
Reference in New Issue
Block a user