Small changes

This commit is contained in:
Indyuce 2022-07-04 10:44:05 +02:00
parent b2ac30100a
commit a4c0597dfa
6 changed files with 21 additions and 34 deletions

View File

@ -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.
* <p>
* 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.
* <p>
* Examples:
* - {@link Neptune_Gift}
* - {@link Ambers}
*/
public Optional<ClassSkill> 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;
}

View File

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

View File

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

View File

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

View File

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

View File

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