MMOCore 1.5

Cleaned up a lot of the source code.
Memory/performance improvements.
Requires MMOLib 1.5
This commit is contained in:
ASangarin 2020-11-30 21:05:41 +01:00
parent b87e1a3a4f
commit a0cc6ded7e
133 changed files with 366 additions and 422 deletions

Binary file not shown.

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.Indyuce</groupId>
<artifactId>MMOCore</artifactId>
<version>1.4.12</version>
<version>1.5</version>
<name>MMOCore</name>
<description>Offer your players a brand new RPG experience.</description>
@ -99,9 +99,9 @@
<systemPath>${basedir}/lib/MMOItems.jar</systemPath>
</dependency>
<dependency>
<groupId>net.Indyuce</groupId>
<groupId>net.mmogroup</groupId>
<artifactId>MMOLib</artifactId>
<version>1.3</version>
<version>1.5</version>
<scope>system</scope>
<systemPath>${basedir}/lib/MMOLib.jar</systemPath>
</dependency>
@ -110,7 +110,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12-R1-1.16-R2</version>
<version>amalgam</version>
<scope>system</scope>
<systemPath>${basedir}/lib/spigot.jar</systemPath>
</dependency>

View File

@ -372,7 +372,6 @@ public class MMOCore extends JavaPlugin {
for (Guild guild : dataProvider.getGuildManager().getAll())
dataProvider.getGuildManager().save(guild);
dataProvider.close();
mineManager.resetRemainingBlocks();

View File

@ -38,7 +38,7 @@ public class PlayerActionBar extends BukkitRunnable {
for (PlayerData data : PlayerData.getAll())
if (data.isOnline() && !data.getPlayer().isDead() && !data.isCasting() && data.canSeeActionBar()) {
data.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(MMOCore.plugin.placeholderParser.parse(data.getPlayer(),
MMOLib.plugin.parseColors(new String(data.getProfess().hasActionBar() ? data.getProfess().getActionBar() : config.format)
MMOLib.plugin.parseColors((data.getProfess().hasActionBar() ? data.getProfess().getActionBar() : config.format)
.replace("{health}", digit.format(data.getPlayer().getHealth()))
.replace("{max_health}", "" + StatType.MAX_HEALTH.format(data.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()))
.replace("{mana_icon}", data.getProfess().getManaDisplay().getIcon())
@ -56,7 +56,7 @@ public class PlayerActionBar extends BukkitRunnable {
}
}
private class ActionBarConfig {
private static class ActionBarConfig {
private final boolean enabled;
private final int ticks, timeout;
private final String digit, format;

View File

@ -28,7 +28,7 @@ public class Waypoint {
stellium = section.getDouble("stellium");
radiusSquared = Math.pow(section.getDouble("radius"), 2);
def = section.getBoolean("default");
sneak = section.contains("sneak") ? section.getBoolean("sneak") : true;
sneak = !section.contains("sneak") || section.getBoolean("sneak");
dynamic = section.getBoolean("dynamic");
}
@ -75,7 +75,7 @@ public class Waypoint {
}
private Location readLocation(String string) {
String[] split = string.split("\\ ");
String[] split = string.split(" ");
World world = Bukkit.getWorld(split[0]);
Validate.notNull(world, "Could not find world " + world);

View File

@ -55,7 +55,7 @@ public class BlockInfo {
}
Optional<Trigger> opt = triggers.stream().filter(trigger -> (trigger instanceof ExperienceTrigger)).findFirst();
experience = opt.isPresent() ? (ExperienceTrigger) opt.get() : null;
experience = (ExperienceTrigger) opt.orElse(null);
}
public boolean hasVanillaDrops() {
@ -110,7 +110,7 @@ public class BlockInfo {
return triggers;
}
public class RegeneratingBlock {
public static class RegeneratingBlock {
private final BlockData data;
private final Location loc;
private final BlockInfo regenerating;

View File

@ -6,18 +6,18 @@ import org.bukkit.block.Block;
import net.Indyuce.mmocore.api.block.BlockInfo.RegeneratingBlock;
public interface BlockType {
public void place(Location loc, RegeneratingBlock regenerating);
void place(Location loc, RegeneratingBlock regenerating);
/**
* Generates a key used to store the BlockInfo instance in the manager map,
* the key depends on the block type to make sure there is no interference
*/
public String generateKey();
String generateKey();
/**
* GenerateKey() determines if the block is handled by that block type,
* breakRestrictions(Block) applies some extra break restrictions; returns
* TRUE if the block can be broken
*/
public boolean breakRestrictions(Block block);
boolean breakRestrictions(Block block);
}

View File

@ -14,7 +14,7 @@ public class BiomeCondition extends Condition {
super(config);
config.validate("name");
names = Arrays.asList(config.getString("name").toUpperCase().split("\\,"));
names = Arrays.asList(config.getString("name").toUpperCase().split(","));
}
@Override

View File

@ -12,7 +12,7 @@ public class WorldCondition extends Condition {
super(config);
config.validate("name");
names = Arrays.asList(config.getString("name").split("\\,"));
names = Arrays.asList(config.getString("name").split(","));
}
@Override

View File

@ -24,7 +24,7 @@ public class MMDropTableDropItem extends DropItem {
String id = config.getString("id");
try {
dropTable = MythicMobs.inst().getDropManager().getDropTable(id).get();
dropTable = MythicMobs.inst().getDropManager().getDropTable(id).orElse(null);
} catch (NoSuchElementException exception) {
throw new IllegalArgumentException("Could not find MM drop table with ID '" + id + "'");
}

View File

@ -59,6 +59,6 @@ public class FishingDropItem {
public ItemStack collect(LootBuilder builder) {
dropItem.collect(builder);
return builder.getLoot().stream().findAny().get();
return builder.getLoot().stream().findAny().orElse(null);
}
}

View File

@ -40,7 +40,7 @@ public class Withdraw implements Listener {
withdrawing.add(player.getUniqueId());
MMOCore.plugin.configManager.getSimpleMessage("withdrawing").send(player);
Bukkit.getPluginManager().registerEvents(this, MMOCore.plugin);
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> close(), 20 * 20);
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, this::close, 20 * 20);
}
public void close() {

View File

@ -24,7 +24,7 @@ public class PlayerChangeClassEvent extends PlayerDataEvent implements Cancellab
}
public boolean isSubclass() {
return getData().getProfess().getSubclasses().stream().filter(sub -> sub.getProfess().equals(newClass)).count() > 0;
return getData().getProfess().getSubclasses().stream().anyMatch(sub -> sub.getProfess().equals(newClass));
}
@Override

View File

@ -6,5 +6,5 @@ public enum EXPSource {
VANILLA,
QUEST,
FISHING,
OTHER;
OTHER
}

View File

@ -22,6 +22,7 @@ import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.util.math.particle.SmallParticleEffect;
@SuppressWarnings("ALL")
public class PlayerProfessions {
private final Map<String, Integer> exp = new HashMap<>();
private final Map<String, Integer> level = new HashMap<>();
@ -177,12 +178,12 @@ public class PlayerProfessions {
playerData.getStats().updateStats();
}
String bar = "" + ChatColor.BOLD;
StringBuilder bar = new StringBuilder("" + ChatColor.BOLD);
int chars = (int) ((double) exp / needed * 20);
for (int j = 0; j < 20; j++)
bar += (j == chars ? "" + ChatColor.WHITE + ChatColor.BOLD : "") + "|";
bar.append(j == chars ? "" + ChatColor.WHITE + ChatColor.BOLD : "").append("|");
if(playerData.isOnline())
MMOCore.plugin.configManager.getSimpleMessage("exp-notification", "profession", profession.getName(), "progress", bar, "ratio",
MMOCore.plugin.configManager.getSimpleMessage("exp-notification", "profession", profession.getName(), "progress", bar.toString(), "ratio",
MMOCore.plugin.configManager.decimal.format((double) exp / needed * 100)).send(playerData.getPlayer());
}
}

View File

@ -30,14 +30,14 @@ public class BrewPotionExperienceSource extends ExperienceSource<PotionMeta> {
super(profession);
if (config.contains("effect"))
for (String key : config.getString("effect").split("\\,"))
for (String key : config.getString("effect").split(","))
types.add(PotionType.valueOf(key.toUpperCase().replace("-", "_")));
}
@Override
public boolean matches(PlayerData player, PotionMeta meta) {
return hasRightClass(player)
&& (types.isEmpty() || new ArrayList<>(types).stream().filter(type -> meta.getBasePotionData().getType() == type).count() > 0);
&& (types.isEmpty() || new ArrayList<>(types).stream().anyMatch(type -> meta.getBasePotionData().getType() == type));
}
@Override
@ -46,7 +46,7 @@ public class BrewPotionExperienceSource extends ExperienceSource<PotionMeta> {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void a(BrewEvent event) {
Optional<Player> playerOpt = getNearbyPlayer(event.getBlock().getLocation(), 10);
Optional<Player> playerOpt = getNearbyPlayer(event.getBlock().getLocation());
if (!playerOpt.isPresent())
return;
@ -76,9 +76,8 @@ public class BrewPotionExperienceSource extends ExperienceSource<PotionMeta> {
return null;
}
private Optional<Player> getNearbyPlayer(Location loc, double d) {
double d2 = d * d;
return loc.getWorld().getPlayers().stream().filter(player -> player.getLocation().distanceSquared(loc) < d2).findAny();
private Optional<Player> getNearbyPlayer(Location loc) {
return loc.getWorld().getPlayers().stream().filter(player -> player.getLocation().distanceSquared(loc) < 100).findAny();
}
public class PotionUpgrade {

View File

@ -2,7 +2,6 @@ package net.Indyuce.mmocore.api.experience.source;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@ -27,7 +26,7 @@ public class EnchantItemExperienceSource extends ExperienceSource<Void> {
super(profession);
if (config.contains("enchant"))
for (String key : config.getString("enchant").split("\\,"))
for (String key : config.getString("enchant").split(","))
enchants.add(MMOLib.plugin.getVersion().getWrapper().getEnchantmentFromString(key.toLowerCase().replace("-", "_")));
}
@ -48,9 +47,7 @@ public class EnchantItemExperienceSource extends ExperienceSource<Void> {
Map<Enchantment, Integer> ench = new HashMap<>(event.getEnchantsToAdd());
if (!source.enchants.isEmpty())
for (Iterator<Enchantment> iterator = ench.keySet().iterator(); iterator.hasNext();)
if (!source.enchants.contains(iterator.next()))
iterator.remove();
ench.keySet().removeIf(enchantment -> !source.enchants.contains(enchantment));
if (ench.isEmpty())
continue;

View File

@ -30,9 +30,7 @@ public class KillMobExperienceSource extends SpecificExperienceSource<Entity> {
return new ExperienceManager<KillMobExperienceSource>() {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void a(EntityKillEntityEvent event) {
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, new Runnable() {
@Override
public void run() {
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> {
if (event.getTarget().isDead() && event.getEntity() instanceof Player && !event.getEntity().hasMetadata("NPC")
&& !event.getTarget().hasMetadata("spawner_spawned")) {
PlayerData data = PlayerData.get((Player) event.getEntity());
@ -41,7 +39,6 @@ public class KillMobExperienceSource extends SpecificExperienceSource<Entity> {
if (source.matches(data, event.getTarget()))
source.giveExperience(data, 1, event.getTarget().getLocation());
}
}
}, 2);
}
};

View File

@ -32,7 +32,7 @@ public class SmeltItemExperienceSource extends SpecificExperienceSource<ItemStac
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void a(BlockCookEvent event) {
Optional<Player> player = getNearestPlayer(event.getBlock().getLocation(), 10);
Optional<Player> player = getNearestPlayer(event.getBlock().getLocation());
if (!player.isPresent())
return;
@ -48,12 +48,11 @@ public class SmeltItemExperienceSource extends SpecificExperienceSource<ItemStac
};
}
private Optional<Player> getNearestPlayer(Location loc, double d) {
final double d2 = d * d;
final Player[] nearby = loc.getWorld().getPlayers().stream().filter(player -> player.getLocation().distanceSquared(loc) < d2)
private Optional<Player> getNearestPlayer(Location loc) {
final Player[] nearby = loc.getWorld().getPlayers().stream().filter(player -> player.getLocation().distanceSquared(loc) < 100)
.toArray(Player[]::new);
Player selected = null;
double lastDist = d2;
double lastDist = 100;
for (Player p : nearby) {
double currDist = p.getLocation().distance(loc);
if (currDist < lastDist) {

View File

@ -77,7 +77,7 @@ public class LootChest {
effectRunnable.cancel();
}
public class ReplacedBlock {
public static class ReplacedBlock {
private final Material material;
private final BlockData data;
private final Location loc;

View File

@ -1,13 +1,8 @@
package net.Indyuce.mmocore.api.loot;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Optional;
import java.util.Random;
import java.util.Set;
import java.util.logging.Level;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.event.LootChestSpawnEvent;
import net.Indyuce.mmocore.api.player.PlayerData;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -17,9 +12,13 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.event.LootChestSpawnEvent;
import net.Indyuce.mmocore.api.player.PlayerData;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Optional;
import java.util.Random;
import java.util.Set;
import java.util.logging.Level;
public class LootChestRegion {
private final String id;
@ -120,7 +119,7 @@ public class LootChestRegion {
s += tier.chance;
}
return tiers.stream().findAny().get();
return tiers.stream().findAny().orElse(null);
}
public Location getRandomLocation(Location center) {
@ -168,7 +167,7 @@ public class LootChestRegion {
return !loc.getBlock().getType().isSolid() && loc.clone().add(0, -1, 0).getBlock().getType().isSolid();
}
public class LootChestRunnable extends BukkitRunnable {
public static class LootChestRunnable extends BukkitRunnable {
private final LootChestRegion region;
public LootChestRunnable(LootChestRegion region) {
@ -179,9 +178,8 @@ public class LootChestRegion {
@Override
public void run() {
Optional<PlayerData> found = region.getBounds().getPlayers().filter(data -> data.canSpawnLootChest()).findAny();
if (found.isPresent())
region.spawnChest(found.get());
Optional<PlayerData> found = region.getBounds().getPlayers().filter(PlayerData::canSpawnLootChest).findAny();
found.ifPresent(region::spawnChest);
}
}
}

View File

@ -40,7 +40,7 @@ public class RegionBounds {
}
public Stream<PlayerData> getPlayers() {
return world.getPlayers().stream().filter(player -> isInRegion(player)).map(player -> PlayerData.get(player));
return world.getPlayers().stream().filter(this::isInRegion).map(PlayerData::get);
}
public boolean isInRegion(Player player) {

View File

@ -405,7 +405,10 @@ public class PlayerData extends OfflinePlayerData {
if(!isOnline()) return;
new BukkitRunnable() {
int x = getPlayer().getLocation().getBlockX(), y = getPlayer().getLocation().getBlockY(), z = getPlayer().getLocation().getBlockZ(), t;
final int x = getPlayer().getLocation().getBlockX();
final int y = getPlayer().getLocation().getBlockY();
final int z = getPlayer().getLocation().getBlockZ();
int t;
public void run() {
if(!isOnline()) return;
@ -772,7 +775,7 @@ public class PlayerData extends OfflinePlayerData {
@Override
public boolean equals(Object obj) {
return obj != null && obj instanceof PlayerData && ((PlayerData) obj).getUniqueId().equals(getUniqueId());
return obj instanceof PlayerData && ((PlayerData) obj).getUniqueId().equals(getUniqueId());
}
public static PlayerData get(OfflinePlayer player) {

View File

@ -113,7 +113,7 @@ public class PlayerAttributes {
private final Map<String, StatModifier> map = new HashMap<>();
public AttributeInstance(PlayerAttribute attribute) {
id = new String(attribute.getId());
id = attribute.getId();
}
public int getBase() {

View File

@ -22,11 +22,11 @@ public enum ClassOption {
private final boolean def;
private ClassOption() {
ClassOption() {
this(false);
}
private ClassOption(boolean def) {
ClassOption(boolean def) {
this.def = def;
}

View File

@ -321,7 +321,7 @@ public class PlayerClass extends PostLoadObject {
@Override
public boolean equals(Object obj) {
return obj != null && obj instanceof PlayerClass && ((PlayerClass) obj).id.equals(id);
return obj instanceof PlayerClass && ((PlayerClass) obj).id.equals(id);
}
public String getActionBar() {

View File

@ -164,7 +164,7 @@ public class SavedClassInformation {
player.setSkillPoints(skillPoints);
player.setAttributePoints(attributePoints);
player.setAttributeReallocationPoints(attributeReallocationPoints);
skills.forEach((id, level) -> player.setSkillLevel(id, level));
skills.forEach(player::setSkillLevel);
attributes.forEach((id, pts) -> player.getAttributes().setBaseAttribute(id, pts));
/*

View File

@ -3,5 +3,5 @@ package net.Indyuce.mmocore.api.player.profess.event;
import org.bukkit.event.Listener;
public interface EventTriggerHandler extends Listener {
public boolean handles(String event);
boolean handles(String event);
}

View File

@ -61,12 +61,12 @@ public class ManaDisplayOptions {
}
public String generateBar(double mana, double max) {
String format = "";
StringBuilder format = new StringBuilder();
double ratio = 20 * mana / max;
for (double j = 1; j < 20; j++)
format += "" + (ratio >= j ? full : ratio >= j - .5 ? half : empty) + barCharacter;
format.append(ratio >= j ? full : ratio >= j - .5 ? half : empty).append(barCharacter);
return format;
return format.toString();
}
}

View File

@ -12,21 +12,20 @@ import net.Indyuce.mmocore.api.player.stats.StatType;
public enum PlayerResource {
HEALTH(StatType.HEALTH_REGENERATION, ClassOption.OFF_COMBAT_HEALTH_REGEN, (data) -> data.getPlayer().getHealth(),
(data) -> data.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue(), (data, d) -> data.heal(d)),
MANA(StatType.MANA_REGENERATION, ClassOption.OFF_COMBAT_MANA_REGEN, (data) -> data.getMana(),
(data) -> data.getStats().getStat(StatType.MAX_MANA), (data, d) -> data.giveMana(d)),
STAMINA(StatType.STAMINA_REGENERATION, ClassOption.OFF_COMBAT_STAMINA_REGEN, (data) -> data.getStamina(),
(data) -> data.getStats().getStat(StatType.MAX_STAMINA), (data, d) -> data.giveStamina(d)),
STELLIUM(StatType.STELLIUM_REGENERATION, ClassOption.OFF_COMBAT_STELLIUM_REGEN, (data) -> data.getStellium(),
(data) -> data.getStats().getStat(StatType.MAX_STELLIUM), (data, d) -> data.giveStellium(d));
(data) -> data.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue(), PlayerData::heal),
MANA(StatType.MANA_REGENERATION, ClassOption.OFF_COMBAT_MANA_REGEN, PlayerData::getMana,
(data) -> data.getStats().getStat(StatType.MAX_MANA), PlayerData::giveMana),
STAMINA(StatType.STAMINA_REGENERATION, ClassOption.OFF_COMBAT_STAMINA_REGEN, PlayerData::getStamina,
(data) -> data.getStats().getStat(StatType.MAX_STAMINA), PlayerData::giveStamina),
STELLIUM(StatType.STELLIUM_REGENERATION, ClassOption.OFF_COMBAT_STELLIUM_REGEN, PlayerData::getStellium,
(data) -> data.getStats().getStat(StatType.MAX_STELLIUM), PlayerData::giveStellium);
private final StatType regenStat;
private final ClassOption offCombatRegen;
private final Function<PlayerData, Double> current, max;
private final BiConsumer<PlayerData, Double> regen;
private PlayerResource(StatType regenStat, ClassOption offCombatRegen, Function<PlayerData, Double> current, Function<PlayerData, Double> max,
BiConsumer<PlayerData, Double> regen) {
PlayerResource(StatType regenStat, ClassOption offCombatRegen, Function<PlayerData, Double> current, Function<PlayerData, Double> max, BiConsumer<PlayerData, Double> regen) {
this.regenStat = regenStat;
this.offCombatRegen = offCombatRegen;
this.current = current;

View File

@ -89,7 +89,7 @@ public class ResourceHandler {
private final BiFunction<PlayerData, PlayerResource, Double> calculation;
private HandlerType(BiFunction<PlayerData, PlayerResource, Double> calculation) {
HandlerType(BiFunction<PlayerData, PlayerResource, Double> calculation) {
this.calculation = calculation;
}

View File

@ -115,7 +115,7 @@ public class Party {
* this class makes controling entries and departures and APPLYING PARTY
* STAT ATTRIBUTES much easier
*/
public class PartyMembers {
public static class PartyMembers {
private final List<PlayerData> members = new ArrayList<>();
public PlayerData get(int count) {
@ -129,13 +129,13 @@ public class Party {
public void add(PlayerData player) {
members.add(player);
members.forEach(member -> applyAttributes(member));
members.forEach(this::applyAttributes);
}
public void remove(PlayerData player) {
members.remove(player);
members.forEach(member -> applyAttributes(member));
members.forEach(this::applyAttributes);
clearAttributes(player);
}

View File

@ -21,7 +21,9 @@ import net.Indyuce.mmocore.manager.InventoryManager;
public class Guild {
private final GuildMembers members = new GuildMembers();
private final Map<UUID, Long> invites = new HashMap<>();
private String guildId, guildName, guildTag;
private final String guildId;
private final String guildName;
private final String guildTag;
/*
* owner changes when the old owner leaves guild
@ -122,7 +124,7 @@ public class Guild {
MMOCore.plugin.requestManager.registerRequest(request);
}
public class GuildMembers {
public static class GuildMembers {
private final List<UUID> members = new ArrayList<>();
public UUID get(int count) {

View File

@ -12,7 +12,7 @@ public class PlayerStats {
/**
* Utilclass to easily manipulate the MMOLib stat map
*
* @param data
* @param data Playerdata
*/
public PlayerStats(PlayerData data) {
this.data = data;

View File

@ -87,11 +87,12 @@ public enum StatType {
private LinearValue defaultInfo;
private DecimalFormat format;
private StatType() {
StatType() {
// completely custom stat.
}
private StatType(String profession) {
@SuppressWarnings("SameParameterValue")
StatType(String profession) {
this.profession = profession;
}

View File

@ -1,5 +1,17 @@
package net.Indyuce.mmocore.api.quest;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.mmogroup.mmolib.MMOLib;
import org.bukkit.NamespacedKey;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.configuration.ConfigurationSection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@ -7,21 +19,6 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.logging.Level;
import org.bukkit.NamespacedKey;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.configuration.ConfigurationSection;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.mmogroup.mmolib.MMOLib;
public class PlayerQuests {
private final PlayerData playerData;
private final BossBar bossbar;
@ -32,7 +29,9 @@ public class PlayerQuests {
public PlayerQuests(PlayerData playerData) {
this.playerData = playerData;
bossbar = MMOLib.plugin.getVersion().getWrapper().createBossBar(new NamespacedKey(MMOCore.plugin, "quest_bar_" + playerData.getUniqueId().toString()), "", BarColor.PURPLE, BarStyle.SEGMENTED_20, new BarFlag[0]);
bossbar = MMOLib.plugin.getVersion().getWrapper().createBossBar(
new NamespacedKey(MMOCore.plugin, "quest_bar_" + playerData.getUniqueId().toString()),
"", BarColor.PURPLE, BarStyle.SEGMENTED_20);
if(playerData.isOnline())
bossbar.addPlayer(playerData.getPlayer());
}

View File

@ -117,7 +117,7 @@ public class Quest extends PostLoadObject {
}
public int getLevelRestriction(Profession profession) {
return profession == null ? mainLevelRestriction : levelRestrictions.containsKey(profession) ? levelRestrictions.get(profession) : 0;
return profession == null ? mainLevelRestriction : levelRestrictions.getOrDefault(profession, 0);
}
public QuestProgress generateNewProgress(PlayerData player) {
@ -130,6 +130,6 @@ public class Quest extends PostLoadObject {
@Override
public boolean equals(Object obj) {
return obj != null && obj instanceof Quest && ((Quest) obj).id.equals(id);
return obj instanceof Quest && ((Quest) obj).id.equals(id);
}
}

View File

@ -41,6 +41,6 @@ public class ManaTrigger extends Trigger {
public enum Operation {
GIVE,
SET,
TAKE;
TAKE
}
}

View File

@ -41,6 +41,6 @@ public class StaminaTrigger extends Trigger {
public enum Operation {
GIVE,
SET,
TAKE;
TAKE
}
}

View File

@ -1,7 +1,6 @@
package net.Indyuce.mmocore.api.skill;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import net.Indyuce.mmocore.api.player.PlayerData;
@ -126,12 +125,10 @@ public class PlayerSkillData {
* skill was cast
*/
public void refresh() {
for (Iterator<CachedModifier> iterator = cache.values().iterator(); iterator.hasNext();)
if (iterator.next().isTimedOut())
iterator.remove();
cache.values().removeIf(CachedModifier::isTimedOut);
}
public class CachedModifier {
public static class CachedModifier {
private final long date = System.currentTimeMillis();
private final double value;

View File

@ -211,7 +211,7 @@ public abstract class Skill {
private String applyPlaceholders(Map<String, String> placeholders, String str) {
while (str.contains("{") && str.substring(str.indexOf("{")).contains("}")) {
String holder = str.substring(str.indexOf("{") + 1, str.indexOf("}"));
str = str.replace("{" + holder + "}", placeholders.containsKey(holder) ? placeholders.get(holder) : "PHE");
str = str.replace("{" + holder + "}", placeholders.getOrDefault(holder, "PHE"));
}
return str;
}

View File

@ -90,6 +90,6 @@ public class SkillResult {
LOCKED,
// no reason specified
OTHER;
OTHER
}
}

View File

@ -21,7 +21,7 @@ public class TargetSkillResult extends SkillResult {
if (!result.hasHit())
abort();
else
target = (LivingEntity) result.getHit();
target = result.getHit();
}
}

View File

@ -3,6 +3,7 @@ package net.Indyuce.mmocore.api.util;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit;
@ -41,10 +42,7 @@ public class MMOCoreUtils {
if (isLastSpace && ch >= 'a' && ch <= 'z') {
builder.setCharAt(item, (char) (ch + ('A' - 'a')));
isLastSpace = false;
} else if (ch != ' ')
isLastSpace = false;
else
isLastSpace = true;
} else isLastSpace = ch == ' ';
}
return builder.toString();
}
@ -54,7 +52,7 @@ public class MMOCoreUtils {
}
public static ItemStack readIcon(String string) throws IllegalArgumentException {
String[] split = string.split("\\:");
String[] split = string.split(":");
Material material = Material.valueOf(split[0].toUpperCase().replace("-", "_").replace(" ", "_"));
return split.length > 1 ? MMOLib.plugin.getVersion().getWrapper().textureItem(material, Integer.parseInt(split[1])) : new ItemStack(material);
}
@ -72,8 +70,8 @@ public class MMOCoreUtils {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
dataOutput.writeInt(items.length);
for (int i = 0; i < items.length; i++)
dataOutput.writeObject(items[i]);
for (ItemStack item : items)
dataOutput.writeObject(item);
dataOutput.close();
return Base64Coder.encodeLines(outputStream.toByteArray());
} catch (Exception e) {
@ -104,7 +102,7 @@ public class MMOCoreUtils {
if (input > 3999)
return ">3999";
String result = "";
StringBuilder result = new StringBuilder();
for (int j = 0; j < romanChars.length; j++) {
int i = romanChars.length - j - 1;
@ -112,12 +110,12 @@ public class MMOCoreUtils {
String c = romanChars[i];
while (input >= q) {
result += c;
result.append(c);
input -= q;
}
}
return result;
return result.toString();
}
/*
@ -142,8 +140,7 @@ public class MMOCoreUtils {
for (int x = -1; x < 2; x++)
for (int z = -1; z < 2; z++)
for (Entity entity : loc.getWorld().getChunkAt(cx + x, cz + z).getEntities())
entities.add(entity);
entities.addAll(Arrays.asList(loc.getWorld().getChunkAt(cx + x, cz + z).getEntities()));
return entities;
}
@ -159,8 +156,7 @@ public class MMOCoreUtils {
// party check
if (target instanceof Player) {
PlayerData targetData = PlayerData.get((Player) target);
if (targetData.hasParty() && targetData.getParty().getMembers().has(player))
return false;
return !targetData.hasParty() || !targetData.getParty().getMembers().has(player);
}
return true;

View File

@ -18,7 +18,7 @@ public class ActionBarRunnable extends BukkitRunnable {
@Override
public void run() {
Bukkit.getOnlinePlayers().forEach(player -> sendActionBar(player));
Bukkit.getOnlinePlayers().forEach(this::sendActionBar);
}
private void sendActionBar(Player player) {

View File

@ -63,6 +63,7 @@ public class ConfigItem {
damage = cache.damage;
texture = cache.texture;
modeldata = cache.modeldata;
unbreakable = cache.unbreakable;
}
public ItemStack getItem(int amount) {

View File

@ -1,9 +1,9 @@
package net.Indyuce.mmocore.api.util.math.format;
public class DelayFormat {
private int display = charArray.length;
private int display;
private static final long[] millisArray = { 31557081600l, 2629756800l, 86400000l, 3600000l, 60000l, 1000l };
private static final long[] millisArray = {31557081600L, 2629756800L, 86400000L, 3600000L, 60000L, 1000L};
private static final String[] charArray = { "y", "M", "d", "h", "m", "s" };
public DelayFormat() {
@ -15,15 +15,15 @@ public class DelayFormat {
}
public String format(long ms) {
String format = "";
StringBuilder format = new StringBuilder();
for (int j = 0; j < charArray.length && display > 0; j++)
if (ms > millisArray[j]) {
format += (ms / millisArray[j]) + charArray[j] + " ";
format.append(ms / millisArray[j]).append(charArray[j]).append(" ");
ms = ms % millisArray[j];
display--;
}
return format.equals("") ? "Now!" : format.substring(0, format.length() - 1);
return format.toString().equals("") ? "Now!" : format.substring(0, format.length() - 1);
}
}

View File

@ -13,7 +13,7 @@ public class RandomAmount {
}
public RandomAmount(String value) {
String[] split = value.split("\\-");
String[] split = value.split("-");
min = Double.parseDouble(split[0]);
max = split.length > 1 ? Double.parseDouble(split[1]) : 0;
}

View File

@ -49,9 +49,9 @@ public enum ChestParticleEffect {
}.runTaskTimer(MMOCore.plugin, 0, 1);
});
private BiConsumer<Location, Particle> func;
private final BiConsumer<Location, Particle> func;
private ChestParticleEffect(BiConsumer<Location, Particle> func) {
ChestParticleEffect(BiConsumer<Location, Particle> func) {
this.func = func;
}

View File

@ -18,7 +18,7 @@ public class ParabolicProjectile extends BukkitRunnable {
private final int speed;
// calculation
private Location loc;
private final Location loc;
private int j;
// private static final Random random = new Random();

View File

@ -10,7 +10,7 @@ import net.Indyuce.mmocore.MMOCore;
public class PotionParticles extends BukkitRunnable {
private double r, g, b;
private ThrownPotion potion;
private final ThrownPotion potion;
private boolean valid = true;
public PotionParticles(ThrownPotion potion) {

View File

@ -34,7 +34,7 @@ public class ClassCommand extends BukkitCommand {
MMOCommandEvent event = new MMOCommandEvent(data, "class");
Bukkit.getServer().getPluginManager().callEvent(event);
if(event.isCancelled()) return true;
if (data.getProfess().getSubclasses().stream().filter(sub -> sub.getLevel() <= data.getLevel()).count() > 0)
if (data.getProfess().getSubclasses().stream().anyMatch(sub -> sub.getLevel() <= data.getLevel()))
InventoryManager.SUBCLASS_SELECT.newInventory(data).open();
else
InventoryManager.CLASS_SELECT.newInventory(data).open();

View File

@ -46,7 +46,7 @@ public class FriendsCommand extends BukkitCommand {
}
Request request = MMOCore.plugin.requestManager.getRequest(uuid);
if (request == null || !(request instanceof FriendRequest))
if (!(request instanceof FriendRequest))
return true;
if (request.isTimedOut()) {
@ -60,9 +60,9 @@ public class FriendsCommand extends BukkitCommand {
}
if (args[0].equalsIgnoreCase("accept"))
((FriendRequest) request).accept();
request.accept();
if (args[0].equalsIgnoreCase("deny"))
((FriendRequest) request).deny();
request.deny();
return true;
}

View File

@ -47,7 +47,7 @@ public class GuildCommand extends BukkitCommand {
}
Request request = MMOCore.plugin.requestManager.getRequest(uuid);
if (request == null || !(request instanceof GuildInvite))
if (!(request instanceof GuildInvite))
return true;
if (request.isTimedOut()) {
@ -61,9 +61,9 @@ public class GuildCommand extends BukkitCommand {
}
if (args[0].equalsIgnoreCase("accept"))
((GuildInvite) request).accept();
request.accept();
if (args[0].equalsIgnoreCase("deny"))
((GuildInvite) request).deny();
request.deny();
return true;
}

View File

@ -47,7 +47,7 @@ public class PartyCommand extends BukkitCommand {
}
Request request = MMOCore.plugin.requestManager.getRequest(uuid);
if (request == null || !(request instanceof PartyInvite))
if (!(request instanceof PartyInvite))
return true;
if (request.isTimedOut()) {
@ -61,9 +61,9 @@ public class PartyCommand extends BukkitCommand {
}
if (args[0].equalsIgnoreCase("accept"))
((PartyInvite) request).accept();
request.accept();
if (args[0].equalsIgnoreCase("deny"))
((PartyInvite) request).deny();
request.deny();
return true;
}

View File

@ -34,7 +34,7 @@ public class WithdrawCommand extends BukkitCommand {
return true;
}
int amount = 0;
int amount;
try {
amount = Integer.parseInt(amountArgument);
Validate.isTrue(amount >= 0);

View File

@ -21,7 +21,7 @@ public class ReloadCommandTreeNode extends CommandTreeNode {
MMOCore.plugin.reloadConfig();
MMOCore.plugin.reloadPlugin();
PlayerData.getAll().forEach(data -> data.update());
PlayerData.getAll().forEach(PlayerData::update);
ms = System.currentTimeMillis() - ms;
sender.sendMessage(ChatColor.YELLOW + MMOCore.plugin.getName() + " " + MMOCore.plugin.getDescription().getVersion() + " successfully reloaded.");

View File

@ -1,5 +1,6 @@
package net.Indyuce.mmocore.command.rpg.admin;
import net.Indyuce.mmocore.api.player.PlayerData;
import org.bukkit.command.CommandSender;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
@ -19,15 +20,15 @@ public class AdminCommandTreeNode extends CommandTreeNode {
addChild(new LevelCommandTreeNode(this));
addChild(new AttributeCommandTreeNode(this));
addChild(new PointsCommandTreeNode("skill", this, (data, points) -> data.setSkillPoints(points), (data, points) -> data.giveSkillPoints(points), (data) -> data.getSkillPoints()));
addChild(new PointsCommandTreeNode("class", this, (data, points) -> data.setClassPoints(points), (data, points) -> data.giveClassPoints(points), (data) -> data.getClassPoints()));
addChild(new PointsCommandTreeNode("attribute", this, (data, points) -> data.setAttributePoints(points), (data, points) -> data.giveAttributePoints(points), (data) -> data.getAttributePoints()));
addChild(new PointsCommandTreeNode("attr-realloc", this, (data, points) -> data.setAttributeReallocationPoints(points), (data, points) -> data.giveAttributeReallocationPoints(points), (data) -> data.getAttributeReallocationPoints()));
addChild(new PointsCommandTreeNode("skill", this, PlayerData::setSkillPoints, PlayerData::giveSkillPoints, PlayerData::getSkillPoints));
addChild(new PointsCommandTreeNode("class", this, PlayerData::setClassPoints, PlayerData::giveClassPoints, PlayerData::getClassPoints));
addChild(new PointsCommandTreeNode("attribute", this, PlayerData::setAttributePoints, PlayerData::giveAttributePoints, PlayerData::getAttributePoints));
addChild(new PointsCommandTreeNode("attr-realloc", this, PlayerData::setAttributeReallocationPoints, PlayerData::giveAttributeReallocationPoints, PlayerData::getAttributeReallocationPoints));
addChild(new ResourceCommandTreeNode("health", this, (data, value) -> data.getPlayer().setHealth(value), (data, value) -> data.heal(value), (data, value) -> data.heal(-value), (data) -> data.getPlayer().getHealth()));
addChild(new ResourceCommandTreeNode("mana", this, (data, value) -> data.setMana(value), (data, value) -> data.giveMana(value), (data, value) -> data.giveMana(-value), (data) -> data.getMana()));
addChild(new ResourceCommandTreeNode("stamina", this, (data, value) -> data.setStamina(value), (data, value) -> data.giveStamina(value), (data, value) -> data.giveStamina(-value), (data) -> data.getStamina()));
addChild(new ResourceCommandTreeNode("stellium", this, (data, value) -> data.setStellium(value), (data, value) -> data.giveStellium(value), (data, value) -> data.giveStellium(-value), (data) -> data.getStellium()));
addChild(new ResourceCommandTreeNode("health", this, (data, value) -> data.getPlayer().setHealth(value), PlayerData::heal, (data, value) -> data.heal(-value), (data) -> data.getPlayer().getHealth()));
addChild(new ResourceCommandTreeNode("mana", this, PlayerData::setMana, PlayerData::giveMana, (data, value) -> data.giveMana(-value), PlayerData::getMana));
addChild(new ResourceCommandTreeNode("stamina", this, PlayerData::setStamina, PlayerData::giveStamina, (data, value) -> data.giveStamina(-value), PlayerData::getStamina));
addChild(new ResourceCommandTreeNode("stellium", this, PlayerData::setStellium, PlayerData::giveStellium, (data, value) -> data.giveStellium(-value), PlayerData::getStellium));
}
@Override

View File

@ -52,7 +52,7 @@ public class AttributeCommandTreeNode extends CommandTreeNode {
}
PlayerAttribute attribute = MMOCore.plugin.attributeManager.get(format);
int amount = 0;
int amount;
try {
amount = Integer.parseInt(args[5]);
} catch (Exception e) {

View File

@ -20,15 +20,11 @@ public class ExperienceCommandTreeNode extends CommandTreeNode {
public ExperienceCommandTreeNode(CommandTreeNode parent) {
super(parent, "exp");
addChild(new ActionCommandTreeNode(this, "set", (data, value) -> data.setExperience(value),
(professions, profession, value) -> professions.setExperience(profession, value)));
addChild(new ActionCommandTreeNode(this, "give",
(data, value) -> data.giveExperience(value, data.getPlayer().getLocation(), EXPSource.COMMAND),
(professions, profession, value) -> professions.giveExperience(profession, value,
professions.getPlayerData().getPlayer().getLocation(), EXPSource.COMMAND)));
addChild(new ActionCommandTreeNode(this, "set", PlayerData::setExperience, PlayerProfessions::setExperience));
addChild(new ActionCommandTreeNode(this, "give", (data, value) -> data.giveExperience(value, data.getPlayer().getLocation(), EXPSource.COMMAND), (professions, profession, value) -> professions.giveExperience(profession, value, professions.getPlayerData().getPlayer().getLocation(), EXPSource.COMMAND)));
}
public class ActionCommandTreeNode extends CommandTreeNode {
public static class ActionCommandTreeNode extends CommandTreeNode {
private final BiConsumer<PlayerData, Integer> main;
private final TriConsumer<PlayerProfessions, Profession, Integer> profession;
@ -55,7 +51,7 @@ public class ExperienceCommandTreeNode extends CommandTreeNode {
return CommandResult.FAILURE;
}
int amount = 0;
int amount;
try {
amount = Integer.parseInt(args[5]);
} catch (NumberFormatException exception) {

View File

@ -28,7 +28,7 @@ public class HideActionBarCommandTreeNode extends CommandTreeNode {
return CommandResult.FAILURE;
}
int amount = 0;
int amount;
try {
amount = Integer.parseInt(args[3]);
} catch (Exception e) {

View File

@ -20,15 +20,12 @@ public class LevelCommandTreeNode extends CommandTreeNode {
public LevelCommandTreeNode(CommandTreeNode parent) {
super(parent, "level");
addChild(new ActionCommandTreeNode(this, "set", (data, value) -> data.setLevel(value),
(professions, profession, value) -> professions.setLevel(profession, value)));
addChild(new ActionCommandTreeNode(this, "give", (data, value) -> data.giveLevels(value, EXPSource.COMMAND),
(professions, profession, value) -> professions.giveLevels(profession, value, EXPSource.COMMAND)));
addChild(new ActionCommandTreeNode(this, "take", (data, value) -> data.takeLevels(value),
(professions, profession, value) -> professions.takeLevels(profession, value)));
addChild(new ActionCommandTreeNode(this, "set", PlayerData::setLevel, PlayerProfessions::setLevel));
addChild(new ActionCommandTreeNode(this, "give", (data, value) -> data.giveLevels(value, EXPSource.COMMAND), (professions, profession, value) -> professions.giveLevels(profession, value, EXPSource.COMMAND)));
addChild(new ActionCommandTreeNode(this, "take", PlayerData::takeLevels, PlayerProfessions::takeLevels));
}
public class ActionCommandTreeNode extends CommandTreeNode {
public static class ActionCommandTreeNode extends CommandTreeNode {
private final BiConsumer<PlayerData, Integer> main;
private final TriConsumer<PlayerProfessions, Profession, Integer> profession;
@ -55,7 +52,7 @@ public class LevelCommandTreeNode extends CommandTreeNode {
return CommandResult.FAILURE;
}
int amount = 0;
int amount;
try {
amount = Integer.parseInt(args[5]);
} catch (NumberFormatException exception) {

View File

@ -50,7 +50,7 @@ public class PointsCommandTreeNode extends CommandTreeNode {
return CommandResult.FAILURE;
}
int amount = 0;
int amount;
try {
amount = Integer.parseInt(args[4]);
} catch (Exception e) {

View File

@ -28,7 +28,7 @@ public class ResetCommandTreeNode extends CommandTreeNode {
return CommandResult.THROW_USAGE;
}
public class ResetAllCommandTreeNode extends CommandTreeNode {
public static class ResetAllCommandTreeNode extends CommandTreeNode {
public ResetAllCommandTreeNode(CommandTreeNode parent) {
super(parent, "all");
@ -53,7 +53,7 @@ public class ResetCommandTreeNode extends CommandTreeNode {
data.getCollectionSkills().setExperience(profession, 0);
data.getCollectionSkills().setLevel(profession, 0);
}
MMOCore.plugin.classManager.getAll().forEach(profess -> data.unloadClassInfo(profess));
MMOCore.plugin.classManager.getAll().forEach(data::unloadClassInfo);
data.setClassPoints(0);
data.setSkillPoints(0);
@ -71,7 +71,7 @@ public class ResetCommandTreeNode extends CommandTreeNode {
}
}
public class ResetWaypointsCommandTreeNode extends CommandTreeNode {
public static class ResetWaypointsCommandTreeNode extends CommandTreeNode {
public ResetWaypointsCommandTreeNode(CommandTreeNode parent) {
super(parent, "waypoints");
@ -95,7 +95,7 @@ public class ResetCommandTreeNode extends CommandTreeNode {
}
}
public class ResetQuestsCommandTreeNode extends CommandTreeNode {
public static class ResetQuestsCommandTreeNode extends CommandTreeNode {
public ResetQuestsCommandTreeNode(CommandTreeNode parent) {
super(parent, "quests");
@ -120,7 +120,7 @@ public class ResetCommandTreeNode extends CommandTreeNode {
}
}
public class ResetSkillsCommandTreeNode extends CommandTreeNode {
public static class ResetSkillsCommandTreeNode extends CommandTreeNode {
public ResetSkillsCommandTreeNode(CommandTreeNode parent) {
super(parent, "skills");
@ -190,7 +190,7 @@ public class ResetCommandTreeNode extends CommandTreeNode {
}
}
public class ResetLevelsCommandTreeNode extends CommandTreeNode {
public static class ResetLevelsCommandTreeNode extends CommandTreeNode {
public ResetLevelsCommandTreeNode(CommandTreeNode parent) {
super(parent, "levels");

View File

@ -51,7 +51,7 @@ public class ResourceCommandTreeNode extends CommandTreeNode {
return CommandResult.FAILURE;
}
double amount = 0;
double amount;
try {
amount = Double.parseDouble(args[4]);
} catch (Exception e) {

View File

@ -17,9 +17,7 @@ public class StatValueCommandTreeNode extends CommandTreeNode {
for (StatType stat : StatType.values())
list.add(stat.name());
}));
addParameter(new Parameter("(formatted)", (explorer, list) -> {
list.add("true");
}));
addParameter(new Parameter("(formatted)", (explorer, list) -> list.add("true")));
}
@Override

View File

@ -32,7 +32,7 @@ public class StartCommandTreeNode extends CommandTreeNode {
return CommandResult.FAILURE;
}
Quest quest = null;
Quest quest;
try {
quest = MMOCore.plugin.questManager.get(args[3].replace("_", "-").toLowerCase());
} catch (Exception exception) {

View File

@ -9,7 +9,7 @@ import net.citizensnpcs.api.npc.NPC;
public class CitizenInteractEvent extends PlayerEvent {
private static final HandlerList handlers = new HandlerList();
private NPC npc;
private final NPC npc;
public CitizenInteractEvent(Player who, NPC npc) {
super(who);

View File

@ -13,8 +13,9 @@ import net.Indyuce.mmocore.api.quest.objective.Objective;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class GetItemObjective extends Objective {
private Material material;
private int required, npcId;
private final Material material;
private final int required;
private final int npcId;
public GetItemObjective(ConfigurationSection section, MMOLineConfig config) {
super(section);

View File

@ -10,7 +10,7 @@ import net.Indyuce.mmocore.api.quest.objective.Objective;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class TalktoCitizenObjective extends Objective {
private int id;
private final int id;
public TalktoCitizenObjective(ConfigurationSection section, MMOLineConfig config) {
super(section);

View File

@ -6,11 +6,11 @@ import org.bukkit.entity.Player;
public interface FlagPlugin {
// public boolean isPvpAllowed(Location loc);
public boolean isFlagAllowed(Player player, CustomFlag flag);
boolean isFlagAllowed(Player player, CustomFlag flag);
public boolean isFlagAllowed(Location loc, CustomFlag flag);
boolean isFlagAllowed(Location loc, CustomFlag flag);
public enum CustomFlag {
enum CustomFlag {
SKILLS;
public String getPath() {

View File

@ -1,22 +1,20 @@
package net.Indyuce.mmocore.comp.holograms;
import java.util.Arrays;
import java.util.UUID;
import com.Zrips.CMI.CMI;
import com.Zrips.CMI.Modules.Holograms.CMIHologram;
import net.Indyuce.mmocore.MMOCore;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import com.Zrips.CMI.CMI;
import com.Zrips.CMI.Modules.Holograms.CMIHologram;
import net.Indyuce.mmocore.MMOCore;
import java.util.Collections;
import java.util.UUID;
public class CMIPlugin extends HologramSupport {
@Override
public void displayIndicator(Location loc, String format, Player player) {
final CMIHologram hologram = new CMIHologram("MMOItems_" + UUID.randomUUID().toString(), loc);
hologram.setLines(Arrays.asList(format));
hologram.setLines(Collections.singletonList(format));
if (player != null)
hologram.hide(player.getUniqueId());
CMI.getInstance().getHologramManager().addHologram(hologram);

View File

@ -15,7 +15,7 @@ import com.sainttx.holograms.api.line.TextLine;
import net.Indyuce.mmocore.MMOCore;
public class HologramsPlugin extends HologramSupport {
private HologramManager hologramManager = JavaPlugin.getPlugin(HologramPlugin.class).getHologramManager();
private final HologramManager hologramManager = JavaPlugin.getPlugin(HologramPlugin.class).getHologramManager();
@Override
public void displayIndicator(Location loc, String message, Player player) {

View File

@ -16,6 +16,6 @@ public class HolographicDisplaysPlugin extends HologramSupport {
hologram.appendTextLine(format);
if (player != null)
hologram.getVisibilityManager().hideTo(player);
Bukkit.getScheduler().scheduleSyncDelayedTask(MMOCore.plugin, () -> hologram.delete(), 20);
Bukkit.getScheduler().scheduleSyncDelayedTask(MMOCore.plugin, hologram::delete, 20);
}
}

View File

@ -12,8 +12,9 @@ import io.lumine.xikage.mythicmobs.io.MythicLineConfig;
import net.Indyuce.mmocore.api.util.item.CurrencyItem;
public class CurrencyItemDrop extends Drop implements IMultiDrop {
private String key;
private int minw, maxw;
private final String key;
private final int minw;
private final int maxw;
private static final Random random = new Random();

View File

@ -19,7 +19,8 @@ import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.item.NBTItem;
public class GoldPouchDrop extends Drop implements IMultiDrop {
private int min, max;
private final int min;
private final int max;
private static final Random random = new Random();
@ -58,8 +59,8 @@ public class GoldPouchDrop extends Drop implements IMultiDrop {
private int getAvailableSlot(ItemStack[] content) {
int slot;
while (content[slot = random.nextInt(content.length)] != null && content[slot].getType() != Material.AIR)
continue;
while (content[slot = random.nextInt(content.length)] != null)
if(content[slot].getType() == Material.AIR) break;
return slot;
}
}

View File

@ -27,9 +27,7 @@ public class KillMythicFactionExperienceSource extends SpecificExperienceSource<
return new ExperienceManager<KillMythicFactionExperienceSource>() {
@EventHandler
public void a(MythicMobDeathEvent event) {
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, new Runnable() {
@Override
public void run() {
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> {
if (!event.getEntity().isDead()) return;
if (!event.getMob().hasFaction()) return;
if (!(event.getKiller() instanceof Player) || event.getKiller().hasMetadata("NPC")) return;
@ -38,7 +36,6 @@ public class KillMythicFactionExperienceSource extends SpecificExperienceSource<
for (KillMythicFactionExperienceSource source : getSources())
if (source.matches(data, event.getMob().getFaction()))
source.giveExperience(data, 1, event.getEntity().getLocation());
}
}, 2);
}
};

View File

@ -27,9 +27,7 @@ public class KillMythicMobExperienceSource extends SpecificExperienceSource<Stri
return new ExperienceManager<KillMythicMobExperienceSource>() {
@EventHandler
public void a(MythicMobDeathEvent event) {
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, new Runnable() {
@Override
public void run() {
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> {
if (!event.getEntity().isDead()) return;
if (!(event.getKiller() instanceof Player) || event.getKiller().hasMetadata("NPC")) return;
@ -37,7 +35,6 @@ public class KillMythicMobExperienceSource extends SpecificExperienceSource<Stri
for (KillMythicMobExperienceSource source : getSources())
if (source.matches(data, event.getMobType().getInternalName()))
source.giveExperience(data, 1, event.getEntity().getLocation());
}
}, 2);
}
};

View File

@ -4,17 +4,16 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.logging.Level;
import net.mmogroup.mmolib.api.util.EnumUtils;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Entity;
import com.google.common.base.Enums;
import com.google.common.base.Optional;
import io.lumine.xikage.mythicmobs.MythicMobs;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
@ -38,7 +37,7 @@ public class MythicMobSkill extends Skill {
String mmId = config.getString("mythicmobs-skill-id");
Validate.notNull(mmId, "Could not find MM skill ID");
java.util.Optional<io.lumine.xikage.mythicmobs.skills.Skill> opt = MythicMobs.inst().getSkillManager().getSkill(mmId);
Optional<io.lumine.xikage.mythicmobs.skills.Skill> opt = MythicMobs.inst().getSkillManager().getSkill(mmId);
Validate.isTrue(opt.isPresent(), "Could not find MM skill " + mmId);
skill = opt.get();
@ -57,7 +56,7 @@ public class MythicMobSkill extends Skill {
if (config.isConfigurationSection("disable-anti-cheat"))
for (String key : config.getKeys(false)) {
Optional<CheatType> cheatType = Enums.getIfPresent(CheatType.class, key.toUpperCase());
Optional<CheatType> cheatType = EnumUtils.getIfPresent(CheatType.class, key.toUpperCase());
if (cheatType.isPresent() && config.isInt("disable-anti-cheat." + key))
antiCheat.put(cheatType.get(), config.getInt("disable-anti-cheat." + key));
else
@ -65,7 +64,7 @@ public class MythicMobSkill extends Skill {
}
if (config.isString("passive-type")) {
Optional<PassiveSkillType> passiveType = Enums.getIfPresent(PassiveSkillType.class, config.getString("passive-type").toUpperCase());
Optional<PassiveSkillType> passiveType = EnumUtils.getIfPresent(PassiveSkillType.class, config.getString("passive-type").toUpperCase());
Validate.isTrue(passiveType.isPresent(), "Invalid passive skill type");
setPassive();
Bukkit.getPluginManager().registerEvents(passiveType.get().getHandler(this), MMOCore.plugin);

View File

@ -1,14 +1,13 @@
package net.Indyuce.mmocore.comp.mythicmobs.skill;
import java.util.Arrays;
import org.bukkit.entity.Entity;
import org.bukkit.event.Listener;
import io.lumine.xikage.mythicmobs.MythicMobs;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.skill.SkillResult;
import org.bukkit.entity.Entity;
import org.bukkit.event.Listener;
import java.util.Collections;
public abstract class PassiveMythicMobSkillHandler implements Listener {
protected final MythicMobSkill skill;
@ -35,7 +34,7 @@ public abstract class PassiveMythicMobSkillHandler implements Listener {
data.getSkillData().cacheModifiers(skill.getInternalName(), cast);
if (MMOCore.plugin.hasAntiCheat())
MMOCore.plugin.antiCheatSupport.disableAntiCheat(data.getPlayer(), skill.getAntiCheat());
MythicMobs.inst().getAPIHelper().castSkill(data.getPlayer(), skill.getInternalName(), target, data.getPlayer().getEyeLocation(),
Arrays.asList(data.getPlayer()), null, 1);
MythicMobs.inst().getAPIHelper().castSkill(data.getPlayer(), skill.getInternalName(), target,
data.getPlayer().getEyeLocation(), Collections.singletonList(data.getPlayer()), null, 1);
}
}

View File

@ -3,5 +3,5 @@ package net.Indyuce.mmocore.comp.placeholder;
import org.bukkit.OfflinePlayer;
public interface PlaceholderParser {
public String parse(OfflinePlayer player, String string);
String parse(OfflinePlayer player, String string);
}

View File

@ -43,6 +43,8 @@ public class RPGPlaceholders extends PlaceholderExpansion {
@Override
public String onRequest(@Nullable OfflinePlayer player, @NotNull String identifier) {
final String subIdent = identifier.substring(10).toLowerCase().replace("_", "-");
if(identifier.equals("mana_icon"))
return PlayerData.get(player).getProfess().getManaDisplay().getIcon();
if(identifier.equals("mana_name"))
@ -127,7 +129,7 @@ public class RPGPlaceholders extends PlaceholderExpansion {
else if (identifier.startsWith("attribute_"))
return String.valueOf(PlayerData.get(player).getAttributes()
.getAttribute(MMOCore.plugin.attributeManager.get(identifier.substring(10).toLowerCase().replace("_", "-"))));
.getAttribute(MMOCore.plugin.attributeManager.get(subIdent)));
else if (identifier.equals("mana"))
return MMOCore.plugin.configManager.decimal.format(PlayerData.get(player).getMana());
@ -144,7 +146,7 @@ public class RPGPlaceholders extends PlaceholderExpansion {
}
else if (identifier.startsWith("exp_boost_")) {
String format = identifier.substring(10).toLowerCase().replace("_", "-").replace(" ", "-");
String format = subIdent.replace(" ", "-");
Profession profession = format.equals("main") ? null : MMOCore.plugin.professionManager.get(format);
return MMOCore.plugin.configManager.decimal.format((MMOCore.plugin.boosterManager.getMultiplier(profession) - 1) * 100);
}

View File

@ -14,11 +14,11 @@ public class RegionCondition extends Condition {
super(config);
config.validate("name");
names = Arrays.asList(config.getString("name").split("\\,"));
names = Arrays.asList(config.getString("name").split(","));
}
@Override
public boolean isMet(ConditionInstance entity) {
return entity.getRegionStream().filter(str -> names.contains(str)).count() > 0;
return entity.getRegionStream().anyMatch(names::contains);
}
}

View File

@ -5,5 +5,5 @@ import java.util.List;
import org.bukkit.Location;
public interface RegionHandler {
public List<String> getRegions(Location loc);
List<String> getRegions(Location loc);
}

View File

@ -42,6 +42,6 @@ public class MoneyTrigger extends Trigger {
public enum Operation {
GIVE,
SET,
TAKE;
TAKE
}
}

View File

@ -43,7 +43,7 @@ public class AttributeView extends EditableInventory {
return new SkillViewerInventory(data, this);
}
public class AttributeItem extends InventoryPlaceholderItem {
public static class AttributeItem extends InventoryPlaceholderItem {
private final PlayerAttribute attribute;
public AttributeItem(String function, ConfigurationSection config) {

View File

@ -50,13 +50,13 @@ public class ClassConfirmation extends EditableInventory {
int nextLevelExp = inv.getPlayerData().getLevelUpExperience();
double ratio = (double) info.getExperience() / (double) nextLevelExp;
String bar = "" + ChatColor.BOLD;
StringBuilder bar = new StringBuilder("" + ChatColor.BOLD);
int chars = (int) (ratio * 20);
for (int j = 0; j < 20; j++)
bar += (j == chars ? "" + ChatColor.WHITE + ChatColor.BOLD : "") + "|";
bar.append(j == chars ? "" + ChatColor.WHITE + ChatColor.BOLD : "").append("|");
holders.register("percent", decimal.format(ratio * 100));
holders.register("progress", bar);
holders.register("progress", bar.toString());
holders.register("class", profess.getName());
holders.register("unlocked_skills", info.getSkillKeys().size());
holders.register("class_skills", profess.getSkills().size());

View File

@ -236,7 +236,7 @@ public class PlayerStats extends EditableInventory {
return item;
}
public class PartyMoraleItem extends InventoryPlaceholderItem {
public static class PartyMoraleItem extends InventoryPlaceholderItem {
public PartyMoraleItem(ConfigurationSection config) {
super(config);
}
@ -260,7 +260,7 @@ public class PlayerStats extends EditableInventory {
}
public class PlayerProfileItem extends InventoryPlaceholderItem {
public static class PlayerProfileItem extends InventoryPlaceholderItem {
public PlayerProfileItem(ConfigurationSection config) {
super(config);
}
@ -284,10 +284,10 @@ public class PlayerStats extends EditableInventory {
int nextLevelExp = inv.getPlayerData().getLevelUpExperience();
double ratio = (double) data.getExperience() / (double) nextLevelExp;
String bar = "" + ChatColor.BOLD;
StringBuilder bar = new StringBuilder("" + ChatColor.BOLD);
int chars = (int) (ratio * 20);
for (int j = 0; j < 20; j++)
bar += (j == chars ? "" + ChatColor.WHITE + ChatColor.BOLD : "") + "|";
bar.append(j == chars ? "" + ChatColor.WHITE + ChatColor.BOLD : "").append("|");
holders.register("percent", decimal.format(ratio * 100));
holders.register("exp", "" + data.getExperience());
@ -295,7 +295,7 @@ public class PlayerStats extends EditableInventory {
holders.register("class_points", "" + data.getClassPoints());
holders.register("skill_points", "" + data.getSkillPoints());
holders.register("attribute_points", "" + data.getAttributePoints());
holders.register("progress", bar);
holders.register("progress", bar.toString());
holders.register("next_level", "" + nextLevelExp);
if(data.isOnline())
holders.register("player", "" + data.getPlayer().getName());

View File

@ -1,21 +1,5 @@
package net.Indyuce.mmocore.gui;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.player.PlayerData;
@ -29,6 +13,20 @@ import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
import net.Indyuce.mmocore.gui.api.item.Placeholders;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.item.NBTItem;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class QuestViewer extends EditableInventory {
public QuestViewer() {
@ -127,18 +125,13 @@ public class QuestViewer extends EditableInventory {
*/
int reqCount = quest.countLevelRestrictions();
boolean started = inv.getPlayerData().getQuestData().hasCurrent(quest), completed = inv.getPlayerData().getQuestData().hasFinished(quest),
cooldown = completed ? inv.getPlayerData().getQuestData().checkCooldownAvailability(quest) : false;
cooldown = completed && inv.getPlayerData().getQuestData().checkCooldownAvailability(quest);
for (Iterator<String> iterator = lore.iterator(); iterator.hasNext();) {
String next = iterator.next();
if ((next.startsWith("{level_req}") && reqCount < 1) || (next.startsWith("{started}") && !started)
|| (next.startsWith("{!started}") && started) || (next.startsWith("{completed}") && !completed)
|| (next.startsWith("{completed_cannot_redo}") && !(completed && !quest.isRedoable()))
|| (next.startsWith("{completed_can_redo}") && !(cooldown && quest.isRedoable()))
|| (next.startsWith("{completed_delay}") && !(completed && !cooldown)))
iterator.remove();
}
lore.removeIf(next -> (next.startsWith("{level_req}") && reqCount < 1) ||
(next.startsWith("{started}") && !started) || (next.startsWith("{!started}") && started)
|| (next.startsWith("{completed}") && !completed) || (next.startsWith("{completed_cannot_redo}") &&
!(completed && !quest.isRedoable())) || (next.startsWith("{completed_can_redo}") && !(cooldown && quest.isRedoable()))
|| (next.startsWith("{completed_delay}") && !(completed && !cooldown)));
/*
* replace level requirements

View File

@ -1,7 +1,6 @@
package net.Indyuce.mmocore.gui;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.lang.Validate;
@ -238,12 +237,7 @@ public class SkillList extends EditableInventory {
boolean unlocked = skill.getUnlockLevel() <= inv.getPlayerData().getLevel();
for (Iterator<String> iterator = lore.iterator(); iterator.hasNext();) {
String next = iterator.next();
if ((next.startsWith("{unlocked}") && !unlocked) || (next.startsWith("{locked}") && unlocked) || (next.startsWith("{max_level}")
&& (!skill.hasMaxLevel() || skill.getMaxLevel() > inv.getPlayerData().getSkillLevel(skill.getSkill()))))
iterator.remove();
}
lore.removeIf(next -> (next.startsWith("{unlocked}") && !unlocked) || (next.startsWith("{locked}") && unlocked) || (next.startsWith("{max_level}") && (!skill.hasMaxLevel() || skill.getMaxLevel() > inv.getPlayerData().getSkillLevel(skill.getSkill()))));
for (int j = 0; j < lore.size(); j++)
lore.set(j, ChatColor.GRAY + holders.apply(inv.getPlayer(), lore.get(j)));
@ -253,7 +247,7 @@ public class SkillList extends EditableInventory {
*/
ItemStack item = skill.getSkill().getIcon();
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(holders.apply(inv.getPlayer(), new String(getName())));
meta.setDisplayName(holders.apply(inv.getPlayer(), getName()));
meta.addItemFlags(ItemFlag.values());
meta.setLore(lore);
item.setItemMeta(meta);

View File

@ -99,7 +99,7 @@ public abstract class InventoryPlaceholderItem extends InventoryItem {
applyTexture(texture, (SkullMeta) meta);
if (hasName())
meta.setDisplayName(placeholders.apply(inv.getPlayer(), new String(getName())));
meta.setDisplayName(placeholders.apply(inv.getPlayer(), getName()));
if (hideFlags())
meta.addItemFlags(ItemFlag.values());

View File

@ -24,7 +24,7 @@ public class Placeholders {
while (str.contains("{") && str.substring(str.indexOf("{")).contains("}")) {
String holder = str.substring(str.indexOf("{") + 1, str.indexOf("}"));
str = str.replace("{" + holder + "}", placeholders.containsKey(holder) ? placeholders.get(holder) : "PHE");
str = str.replace("{" + holder + "}", placeholders.getOrDefault(holder, "PHE"));
}
return str;
}

View File

@ -70,7 +70,6 @@ public class DepositMenu extends PluginInventory {
int worth = NBTItem.get(event.getCurrentItem()).getInteger("RpgWorth");
if (worth < 1) {
event.setCancelled(true);
return;
}
// in deposit menu

View File

@ -27,7 +27,7 @@ public class GoldPouch extends PluginInventory {
@Override
public Inventory getInventory() {
Inventory inv = (Inventory) Bukkit.createInventory(this, 18, ChatColor.UNDERLINE + "Gold Pouch");
Inventory inv = Bukkit.createInventory(this, 18, ChatColor.UNDERLINE + "Gold Pouch");
inv.setContents(MMOCoreUtils.itemStackArrayFromBase64(nbt.getString("RpgPouchInventory")));
return inv;
}

View File

@ -66,7 +66,7 @@ public class EditableFriendList extends EditableInventory {
return new FriendListInventory(data, this);
}
public class OfflineFriendItem extends InventoryPlaceholderItem {
public static class OfflineFriendItem extends InventoryPlaceholderItem {
public OfflineFriendItem(ConfigurationSection config) {
super(config);
}
@ -98,7 +98,7 @@ public class EditableFriendList extends EditableInventory {
}
}
public class OnlineFriendItem extends InventoryPlaceholderItem {
public static class OnlineFriendItem extends InventoryPlaceholderItem {
public OnlineFriendItem(ConfigurationSection config) {
super(config);
}
@ -134,7 +134,7 @@ public class EditableFriendList extends EditableInventory {
}
}
public class FriendItem extends NoPlaceholderItem {
public static class FriendItem extends NoPlaceholderItem {
private final OnlineFriendItem online;
private final OfflineFriendItem offline;

View File

@ -38,7 +38,7 @@ public class EditableGuildAdmin extends EditableInventory {
return function.equals("member") ? new MemberItem(config) : new NoPlaceholderItem(config);
}
public class MemberDisplayItem extends InventoryPlaceholderItem {
public static class MemberDisplayItem extends InventoryPlaceholderItem {
public MemberDisplayItem(ConfigurationSection config) {
super(config);
}
@ -75,7 +75,7 @@ public class EditableGuildAdmin extends EditableInventory {
}
}
public class MemberItem extends InventoryItem {
public static class MemberItem extends InventoryItem {
private final InventoryPlaceholderItem empty;
private final MemberDisplayItem member;

View File

@ -39,7 +39,7 @@ public class EditableGuildView extends EditableInventory {
return function.equals("member") ? new MemberItem(config) : (function.equals("next") || function.equals("previous") || function.equals("disband") || function.equals("invite")) ? new ConditionalItem(function, config) : new NoPlaceholderItem(config);
}
public class MemberDisplayItem extends InventoryPlaceholderItem {
public static class MemberDisplayItem extends InventoryPlaceholderItem {
public MemberDisplayItem(ConfigurationSection config) {
super(config);
}
@ -123,7 +123,8 @@ public class EditableGuildView extends EditableInventory {
GuildViewInventory inv = (GuildViewInventory) invpar;
if (function.equals("next"))
if (inv.getPage() == (int) Math.ceil((inv.getPlayerData().getGuild().getMembers().count() + 20) / inv.getByFunction("member").getSlots().size()))
if (inv.getPage() == (inv.getPlayerData().getGuild().getMembers().count() + 20)
/ inv.getByFunction("member").getSlots().size())
return null;
if (function.equals("previous") && inv.getPage() == 1)
return null;
@ -144,7 +145,8 @@ public class EditableGuildView extends EditableInventory {
public GuildViewInventory(PlayerData playerData, EditableInventory editable) {
super(playerData, editable);
maxpages = (int) Math.ceil((playerData.getGuild().getMembers().count() + 20) / editable.getByFunction("member").getSlots().size());
maxpages = (playerData.getGuild().getMembers().count() + 20)
/ editable.getByFunction("member").getSlots().size();
}
@Override
@ -186,7 +188,7 @@ public class EditableGuildView extends EditableInventory {
if (!playerData.getGuild().getOwner().equals(playerData.getUniqueId()))
return;
/**
/*
* if (playerData.getGuild().getMembers().count() >= max) {
* MMOCore.plugin.configManager.getSimpleMessage("guild-is-full").send(player);
* player.playSound(player.getLocation(),

View File

@ -38,7 +38,7 @@ public class EditablePartyView extends EditableInventory {
return function.equals("member") ? new MemberItem(config) : new NoPlaceholderItem(config);
}
public class MemberDisplayItem extends InventoryPlaceholderItem {
public static class MemberDisplayItem extends InventoryPlaceholderItem {
public MemberDisplayItem(ConfigurationSection config) {
super(config);
}
@ -77,7 +77,7 @@ public class EditablePartyView extends EditableInventory {
}
}
public class MemberItem extends InventoryItem {
public static class MemberItem extends InventoryItem {
private final InventoryPlaceholderItem empty;
private final MemberDisplayItem member;

View File

@ -63,7 +63,7 @@ public class SpellCast implements Listener {
runTaskTimer(MMOCore.plugin, 0, 1);
}
@EventHandler(ignoreCancelled = false)
@EventHandler()
public void onSkillCast(PlayerItemHeldEvent event) {
Player player = event.getPlayer();
if(!playerData.isOnline()) return;
@ -108,18 +108,17 @@ public class SpellCast implements Listener {
}
private String getFormat(PlayerData data) {
String str = "";
if(!data.isOnline()) return str;
StringBuilder str = new StringBuilder();
if(!data.isOnline()) return str.toString();
for (int j = 0; j < data.getBoundSkills().size(); j++) {
SkillInfo skill = data.getBoundSkill(j);
str += (str.isEmpty() ? "" : split)
+ (onCooldown(data, skill) ? onCooldown.replace("{cooldown}", "" + data.getSkillData().getCooldown(skill) / 1000)
: noMana(data, skill) ? noMana : ready)
.replace("{index}", "" + (j + 1 + (data.getPlayer().getInventory().getHeldItemSlot() <= j ? 1 : 0)))
.replace("{skill}", data.getBoundSkill(j).getSkill().getName());
str.append((str.length() == 0) ? "" : split).append((onCooldown(data, skill)
? onCooldown .replace("{cooldown}", "" + data.getSkillData().getCooldown(skill) / 1000)
: noMana(data, skill) ? noMana : ready).replace("{index}", "" + (j + 1 + (data.getPlayer().getInventory().getHeldItemSlot()
<= j ? 1 : 0))).replace("{skill}", data.getBoundSkill(j).getSkill().getName()));
}
return str;
return str.toString();
}
/*

View File

@ -32,7 +32,7 @@ import net.Indyuce.mmocore.manager.profession.FishingManager.FishingDropTable;
import net.mmogroup.mmolib.version.VersionSound;
public class FishingListener implements Listener {
private Set<UUID> fishing = new HashSet<>();
private final Set<UUID> fishing = new HashSet<>();
private static final Random random = new Random();

Some files were not shown because too many files have changed in this diff Show More