From a4c0597dfa407f203a1429a6a7459e26e696f45a Mon Sep 17 00:00:00 2001 From: Indyuce Date: Mon, 4 Jul 2022 10:44:05 +0200 Subject: [PATCH] Small changes --- .../api/player/profess/PlayerClass.java | 29 +++++-------------- .../gui/social/party/EditablePartyView.java | 15 +++++----- .../mmocore/manager/ConfigManager.java | 4 +-- .../mmocore/skill/list/Neptune_Gift.java | 2 -- .../mmocore/util/HashableLocation.java | 3 +- src/main/resources/default/messages.yml | 2 +- 6 files changed, 21 insertions(+), 34 deletions(-) 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 48246532..765b54e5 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 @@ -8,9 +8,6 @@ import io.lumine.mythic.lib.api.MMOLineConfig; import io.lumine.mythic.lib.api.util.PostLoadObject; import io.lumine.mythic.lib.version.VersionMaterial; import net.Indyuce.mmocore.MMOCore; -import net.Indyuce.mmocore.experience.EXPSource; -import net.Indyuce.mmocore.skill.list.Ambers; -import net.Indyuce.mmocore.skill.list.Neptune_Gift; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.profess.event.EventTrigger; import net.Indyuce.mmocore.api.player.profess.resource.ManaDisplayOptions; @@ -18,6 +15,7 @@ import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource; import net.Indyuce.mmocore.api.player.profess.resource.ResourceRegeneration; import net.Indyuce.mmocore.api.util.MMOCoreUtils; import net.Indyuce.mmocore.api.util.math.formula.LinearValue; +import net.Indyuce.mmocore.experience.EXPSource; import net.Indyuce.mmocore.experience.ExpCurve; import net.Indyuce.mmocore.experience.ExperienceObject; import net.Indyuce.mmocore.experience.droptable.ExperienceTable; @@ -188,11 +186,12 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject { } /** - * Used to generate the default Human class if no one is - * specified after loading all the player classes. This is - * a very basic class that will make sure MMOCore can still - * continue to run without having to stop the server because - * some option was not provided + * Used to generate the default Human class if no one is specified + * after loading all the player classes. + *

+ * This is a very basic class that will make sure MMOCore can still + * continue to run without having to stop the server because some + * option was not provided. */ public PlayerClass(String id, String name, Material material) { super(null); @@ -371,19 +370,6 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject { return getSkill(skill.getHandler().getId()); } - /** - * Reduces map checkups when skills are being checked on events that are - * commonly called like EntityDamageEvent or regen events. - *

- * Examples: - * - {@link Neptune_Gift} - * - {@link Ambers} - */ - public Optional findSkill(RegisteredSkill skill) { - ClassSkill found = skills.get(skill.getHandler().getId()); - return found == null ? Optional.empty() : Optional.of(found); - } - @Nullable public ClassSkill getSkill(String id) { return skills.get(id); @@ -404,6 +390,7 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject { return obj instanceof PlayerClass && ((PlayerClass) obj).id.equals(id); } + @Nullable public String getActionBar() { return actionBarFormat; } diff --git a/src/main/java/net/Indyuce/mmocore/gui/social/party/EditablePartyView.java b/src/main/java/net/Indyuce/mmocore/gui/social/party/EditablePartyView.java index e15d038a..ec740dcd 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/social/party/EditablePartyView.java +++ b/src/main/java/net/Indyuce/mmocore/gui/social/party/EditablePartyView.java @@ -1,14 +1,14 @@ package net.Indyuce.mmocore.gui.social.party; import net.Indyuce.mmocore.MMOCore; -import net.Indyuce.mmocore.api.util.input.PlayerInput; -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.api.player.PlayerData; +import net.Indyuce.mmocore.api.util.input.PlayerInput; import net.Indyuce.mmocore.api.util.math.format.DelayFormat; 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.Placeholders; +import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem; import net.Indyuce.mmocore.party.provided.Party; import org.apache.commons.lang.Validate; import org.bukkit.*; @@ -148,7 +148,7 @@ public class EditablePartyView extends EditableInventory { return; } - MMOCore.plugin.configManager.newPlayerInput(player, PlayerInput.InputType.PARTY_INVITE, (input) -> { + MMOCore.plugin.configManager.newPlayerInput(player, PlayerInput.InputType.PARTY_INVITE, input -> { Player target = Bukkit.getPlayer(input); if (target == null) { MMOCore.plugin.configManager.getSimpleMessage("not-online-player", "player", input).send(player); @@ -172,8 +172,9 @@ public class EditablePartyView extends EditableInventory { return; } - if (Math.abs(targetData.getLevel() - party.getLevel()) > MMOCore.plugin.configManager.maxPartyLevelDifference) { - MMOCore.plugin.configManager.getSimpleMessage("high-level-difference", "player", target.getName()).send(player); + int levelDifference = Math.abs(targetData.getLevel() - party.getLevel()); + if (levelDifference > MMOCore.plugin.configManager.maxPartyLevelDifference) { + MMOCore.plugin.configManager.getSimpleMessage("high-level-difference", "player", target.getName(), "diff", String.valueOf(levelDifference)).send(player); player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1); open(); return; diff --git a/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java b/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java index c9ca4bbf..4cf47a9f 100644 --- a/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java +++ b/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java @@ -92,7 +92,7 @@ public class ConfigManager { commandVerbose.reload(MMOCore.plugin.getConfig().getConfigurationSection("command-verbose")); messages = new ConfigFile("messages").getConfig(); - chatInput = MMOCore.plugin.getConfig().getBoolean("use-chat-input"); + chatInput = true; // MMOCore.plugin.getConfig().getBoolean("use-chat-input") partyChatPrefix = MMOCore.plugin.getConfig().getString("party.chat-prefix"); combatLogTimer = MMOCore.plugin.getConfig().getInt("combat-log.timer") * 1000L; lootChestExpireTime = Math.max(MMOCore.plugin.getConfig().getInt("loot-chests.chest-expire-time"), 1) * 20; @@ -147,7 +147,7 @@ public class ConfigManager { } public SimpleMessage getSimpleMessage(String key, String... placeholders) { - String format = messages.getString(key, ""); + String format = messages.getString(key, "{MessageNotFound:\"" + key + "\"}"); for (int j = 0; j < placeholders.length - 1; j += 2) format = format.replace("{" + placeholders[j] + "}", placeholders[j + 1]); return new SimpleMessage(MythicLib.plugin.parseColors(format)); diff --git a/src/main/java/net/Indyuce/mmocore/skill/list/Neptune_Gift.java b/src/main/java/net/Indyuce/mmocore/skill/list/Neptune_Gift.java index bf45e0f4..71c036f3 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/list/Neptune_Gift.java +++ b/src/main/java/net/Indyuce/mmocore/skill/list/Neptune_Gift.java @@ -5,7 +5,6 @@ import io.lumine.mythic.lib.skill.SkillMetadata; import io.lumine.mythic.lib.skill.handler.SkillHandler; import io.lumine.mythic.lib.skill.result.def.SimpleSkillResult; import net.Indyuce.mmocore.api.event.PlayerResourceUpdateEvent; -import net.Indyuce.mmocore.api.player.PlayerData; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -29,7 +28,6 @@ public class Neptune_Gift extends SkillHandler implements Lis @EventHandler public void a(PlayerResourceUpdateEvent event) { - PlayerData data = event.getData(); if (event.getPlayer().getLocation().getBlock().getType() == Material.WATER) { PassiveSkill skill = event.getData().getMMOPlayerData().getPassiveSkillMap().getSkill(this); if (skill == null) diff --git a/src/main/java/net/Indyuce/mmocore/util/HashableLocation.java b/src/main/java/net/Indyuce/mmocore/util/HashableLocation.java index 0ef2336e..1bc63bd6 100644 --- a/src/main/java/net/Indyuce/mmocore/util/HashableLocation.java +++ b/src/main/java/net/Indyuce/mmocore/util/HashableLocation.java @@ -2,6 +2,7 @@ package net.Indyuce.mmocore.util; import org.bukkit.Location; import org.bukkit.World; +import org.jetbrains.annotations.NotNull; import java.util.Objects; @@ -9,7 +10,7 @@ public class HashableLocation { private final World world; private final int x, y, z; - public HashableLocation(Location loc) { + public HashableLocation(@NotNull Location loc) { this.world = loc.getWorld(); this.x = loc.getBlockX(); this.y = loc.getBlockY(); diff --git a/src/main/resources/default/messages.yml b/src/main/resources/default/messages.yml index 5ff5d69a..aed2994b 100644 --- a/src/main/resources/default/messages.yml +++ b/src/main/resources/default/messages.yml @@ -118,7 +118,7 @@ party-joined-other: '&6{player}&e joined your party!' transfer-party-ownership: '&eYou were transfered the party ownership.' kick-from-party: '&eYou successfully kicked &6{player}&e.' party-invite-cooldown: '&cPlease wait {cooldown} before inviting {player}.' -high-level-difference: '&cYou cannot invite {player} as the level difference is too high.' +high-level-difference: '&cYou cannot invite {player} as the level difference is too high ({diff}).' # Guilds guild-chat: '&a[{tag}] {player}: {message}'