Merge remote-tracking branch 'origin/master'

# Conflicts:
#	pom.xml
This commit is contained in:
Jules 2022-03-22 19:59:27 +01:00
commit d8517eb94e
131 changed files with 2212 additions and 1746 deletions

18
MMOCore (1).iml Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="MavenCustomPomFilePath">
<option name="mavenPomFileUrl" value="file://$MODULE_DIR$/dependency-reduced-pom.xml" />
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$/src/main/java">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
</content>
<content url="file://$MODULE_DIR$/src/main/resources">
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>net.Indyuce</groupId> <groupId>net.Indyuce</groupId>
<artifactId>MMOCore</artifactId> <artifactId>MMOCore</artifactId>
<version>1.9.1</version> <version>1.9.2</version>
<name>MMOCore</name> <name>MMOCore</name>
<description>Offer your players a brand new RPG experience!!</description> <description>Offer your players a brand new RPG experience!!</description>
@ -140,14 +140,14 @@
<dependency> <dependency>
<groupId>io.lumine</groupId> <groupId>io.lumine</groupId>
<artifactId>MythicLib-dist</artifactId> <artifactId>MythicLib-dist</artifactId>
<version>1.3</version> <version>1.3.1</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.lumine</groupId> <groupId>io.lumine</groupId>
<artifactId>MythicMobs-Dist</artifactId> <artifactId>Mythic-Dist</artifactId>
<version>5.0.0-SNAPSHOT</version> <version>5.0.1</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>

View File

@ -45,9 +45,6 @@ import net.Indyuce.mmocore.party.PartyModule;
import net.Indyuce.mmocore.party.PartyModuleType; import net.Indyuce.mmocore.party.PartyModuleType;
import net.Indyuce.mmocore.party.provided.MMOCorePartyModule; import net.Indyuce.mmocore.party.provided.MMOCorePartyModule;
import net.Indyuce.mmocore.skill.cast.SkillCastingMode; import net.Indyuce.mmocore.skill.cast.SkillCastingMode;
import net.Indyuce.mmocore.skill.list.Ambers;
import net.Indyuce.mmocore.skill.list.Neptune_Gift;
import net.Indyuce.mmocore.skill.list.Sneaky_Picky;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -64,11 +61,10 @@ import java.util.logging.Level;
public class MMOCore extends LuminePlugin { public class MMOCore extends LuminePlugin {
public static MMOCore plugin; public static MMOCore plugin;
public ConfigManager configManager; public final WaypointManager waypointManager = new WaypointManager();
public WaypointManager waypointManager; public final SoundManager soundManager = new SoundManager();
public SoundManager soundManager; public final RequestManager requestManager = new RequestManager();
public RequestManager requestManager; public final ConfigItemManager configItems = new ConfigItemManager();
public ConfigItemManager configItems;
public final PlayerActionBar actionBarManager = new PlayerActionBar(); public final PlayerActionBar actionBarManager = new PlayerActionBar();
public final SkillManager skillManager = new SkillManager(); public final SkillManager skillManager = new SkillManager();
public final ClassManager classManager = new ClassManager(); public final ClassManager classManager = new ClassManager();
@ -82,7 +78,18 @@ public class MMOCore extends LuminePlugin {
public final LootChestManager lootChests = new LootChestManager(); public final LootChestManager lootChests = new LootChestManager();
public final MMOLoadManager loadManager = new MMOLoadManager(); public final MMOLoadManager loadManager = new MMOLoadManager();
public final RestrictionManager restrictionManager = new RestrictionManager(); public final RestrictionManager restrictionManager = new RestrictionManager();
@Deprecated
public final SkillTreeManager skillTreeManager = new SkillTreeManager();
// Profession managers
public final CustomBlockManager mineManager = new CustomBlockManager();
public final FishingManager fishingManager = new FishingManager();
public final AlchemyManager alchemyManager = new AlchemyManager();
public final EnchantManager enchantManager = new EnchantManager();
public final SmithingManager smithingManager = new SmithingManager();
@NotNull
public ConfigManager configManager;
public VaultEconomy economy; public VaultEconomy economy;
public RegionHandler regionHandler = new DefaultRegionHandler(); public RegionHandler regionHandler = new DefaultRegionHandler();
public PlaceholderParser placeholderParser = new DefaultParser(); public PlaceholderParser placeholderParser = new DefaultParser();
@ -92,13 +99,6 @@ public class MMOCore extends LuminePlugin {
@NotNull @NotNull
public PartyModule partyModule; public PartyModule partyModule;
// Profession managers
public final CustomBlockManager mineManager = new CustomBlockManager();
public final FishingManager fishingManager = new FishingManager();
public final AlchemyManager alchemyManager = new AlchemyManager();
public final EnchantManager enchantManager = new EnchantManager();
public final SmithingManager smithingManager = new SmithingManager();
public boolean shouldDebugSQL = false; public boolean shouldDebugSQL = false;
private static final int MYTHICLIB_COMPATIBILITY_INDEX = 7; private static final int MYTHICLIB_COMPATIBILITY_INDEX = 7;
@ -130,11 +130,6 @@ public class MMOCore extends LuminePlugin {
if (Bukkit.getPluginManager().getPlugin("MythicMobs") != null) if (Bukkit.getPluginManager().getPlugin("MythicMobs") != null)
loadManager.registerLoader(new MythicMobsMMOLoader()); loadManager.registerLoader(new MythicMobsMMOLoader());
// Register MMOCore specific skills
MythicLib.plugin.getSkills().registerSkillHandler(new Ambers());
MythicLib.plugin.getSkills().registerSkillHandler(new Neptune_Gift());
MythicLib.plugin.getSkills().registerSkillHandler(new Sneaky_Picky());
} }
public void enable() { public void enable() {
@ -388,7 +383,8 @@ public class MMOCore extends LuminePlugin {
* @param clearBefore True when issuing a plugin reload * @param clearBefore True when issuing a plugin reload
*/ */
public void initializePlugin(boolean clearBefore) { public void initializePlugin(boolean clearBefore) {
reloadConfig(); if (clearBefore)
reloadConfig();
configManager = new ConfigManager(); configManager = new ConfigManager();
@ -413,16 +409,18 @@ public class MMOCore extends LuminePlugin {
questManager.initialize(clearBefore); questManager.initialize(clearBefore);
lootChests.initialize(clearBefore); lootChests.initialize(clearBefore);
restrictionManager.initialize(clearBefore); restrictionManager.initialize(clearBefore);
waypointManager.initialize(clearBefore);
waypointManager = new WaypointManager(new ConfigFile("waypoints").getConfig()); requestManager.initialize(clearBefore);
requestManager = new RequestManager(); soundManager.initialize(clearBefore);
soundManager = new SoundManager(new ConfigFile("sounds").getConfig()); configItems.initialize(clearBefore);
configItems = new ConfigItemManager(new ConfigFile("items").getConfig());
if (getConfig().isConfigurationSection("action-bar")) if (getConfig().isConfigurationSection("action-bar"))
actionBarManager.reload(getConfig().getConfigurationSection("action-bar")); actionBarManager.reload(getConfig().getConfigurationSection("action-bar"));
StatType.load(); StatType.load();
if (clearBefore)
PlayerData.getAll().forEach(PlayerData::update);
} }
public static void log(String message) { public static void log(String message) {

View File

@ -2,12 +2,9 @@ package net.Indyuce.mmocore.api;
import io.lumine.mythic.lib.api.player.EquipmentSlot; import io.lumine.mythic.lib.api.player.EquipmentSlot;
import io.lumine.mythic.lib.player.PlayerMetadata; import io.lumine.mythic.lib.player.PlayerMetadata;
import io.lumine.mythic.lib.skill.SimpleSkill;
import io.lumine.mythic.lib.skill.Skill;
import io.lumine.mythic.lib.skill.handler.SkillHandler; import io.lumine.mythic.lib.skill.handler.SkillHandler;
import io.lumine.mythic.lib.skill.result.SkillResult; import io.lumine.mythic.lib.skill.result.SkillResult;
import io.lumine.mythic.lib.skill.trigger.TriggerMetadata; import io.lumine.mythic.lib.skill.trigger.TriggerMetadata;
import io.lumine.mythic.lib.skill.trigger.TriggerType;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.party.AbstractParty; import net.Indyuce.mmocore.party.AbstractParty;
@ -18,6 +15,8 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import java.util.Objects;
public class MMOCoreAPI { public class MMOCoreAPI {
private final JavaPlugin plugin; private final JavaPlugin plugin;
@ -87,7 +86,7 @@ public class MMOCoreAPI {
public SkillResult cast(PlayerData playerData, RegisteredSkill skill, int level) { public SkillResult cast(PlayerData playerData, RegisteredSkill skill, int level) {
PlayerMetadata casterMeta = playerData.getMMOPlayerData().getStatMap().cache(EquipmentSlot.MAIN_HAND); PlayerMetadata casterMeta = playerData.getMMOPlayerData().getStatMap().cache(EquipmentSlot.MAIN_HAND);
TriggerMetadata triggerMeta = new TriggerMetadata(casterMeta, null, null); TriggerMetadata triggerMeta = new TriggerMetadata(casterMeta, null, null);
return new CastableSkill(new ClassSkill(skill, 0), level).cast(triggerMeta); return new CastableSkill(new ClassSkill(skill, 0, 0), level).cast(triggerMeta);
} }
/** /**
@ -110,8 +109,7 @@ public class MMOCoreAPI {
public SkillResult cast(PlayerData playerData, SkillHandler<?> skill, int level) { public SkillResult cast(PlayerData playerData, SkillHandler<?> skill, int level) {
PlayerMetadata casterMeta = playerData.getMMOPlayerData().getStatMap().cache(EquipmentSlot.MAIN_HAND); PlayerMetadata casterMeta = playerData.getMMOPlayerData().getStatMap().cache(EquipmentSlot.MAIN_HAND);
TriggerMetadata triggerMeta = new TriggerMetadata(casterMeta, null, null); TriggerMetadata triggerMeta = new TriggerMetadata(casterMeta, null, null);
RegisteredSkill registered = MMOCore.plugin.skillManager.getSkill(skill.getId()); RegisteredSkill registered = Objects.requireNonNull(MMOCore.plugin.skillManager.getSkill(skill.getId()), "Could not find registered skill with such handler");
Skill cast = registered == null ? new SimpleSkill(TriggerType.CAST, skill) : new CastableSkill(new ClassSkill(registered, 0), level); return new CastableSkill(new ClassSkill(registered, 0, 0), level).cast(triggerMeta);
return cast.cast(triggerMeta);
} }
} }

View File

@ -1,91 +0,0 @@
package net.Indyuce.mmocore.api;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
public class Waypoint {
private final String id, name;
private final Location loc;
private final double radiusSquared, stellium;
private final boolean def, sneak, dynamic;
public Waypoint(ConfigurationSection section) {
Validate.notNull(section, "Could not load config section");
id = section.getName();
name = section.getString("name");
Validate.notNull(name, "Could not load waypoint name");
String format = section.getString("location");
Validate.notNull(format, "Could not read location");
loc = readLocation(format);
stellium = section.getDouble("stellium");
radiusSquared = Math.pow(section.getDouble("radius"), 2);
def = section.getBoolean("default");
sneak = !section.contains("sneak") || section.getBoolean("sneak");
dynamic = section.getBoolean("dynamic");
}
public Location getLocation() {
return loc;
}
public String getName() {
return name;
}
public double getStelliumCost() {
return stellium;
}
public boolean hasSneakEnabled() {
return sneak;
}
public String getId() {
return id;
}
public boolean isDefault() {
return def;
}
public boolean isDynamic() {
return dynamic;
}
public boolean isOnWaypoint(Player player) {
return player.getWorld().equals(loc.getWorld()) && player.getLocation().distanceSquared(loc) < radiusSquared;
}
@Override
public String toString() {
return id;
}
@Override
public boolean equals(Object object) {
return object instanceof Waypoint && ((Waypoint) object).id.equals(id);
}
private Location readLocation(String string) {
String[] split = string.split(" ");
World world = Bukkit.getWorld(split[0]);
Validate.notNull(world, "Could not find world with name '" + split[0]+"'");
double x = Double.parseDouble(split[1]);
double y = Double.parseDouble(split[2]);
double z = Double.parseDouble(split[3]);
float yaw = split.length > 4 ? (float) Double.parseDouble(split[4]) : 0;
float pitch = split.length > 5 ? (float) Double.parseDouble(split[5]) : 0;
return new Location(world, x, y, z, yaw, pitch);
}
}

View File

@ -17,7 +17,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.util.item.CurrencyItem; import net.Indyuce.mmocore.util.item.CurrencyItemBuilder;
import io.lumine.mythic.lib.api.util.SmartGive; import io.lumine.mythic.lib.api.util.SmartGive;
public class Withdraw implements Listener { public class Withdraw implements Listener {
@ -101,9 +101,9 @@ public class Withdraw implements Listener {
SmartGive smart = new SmartGive(player); SmartGive smart = new SmartGive(player);
if (note > 0) if (note > 0)
smart.give(new CurrencyItem("NOTE", note).build()); smart.give(new CurrencyItemBuilder("NOTE", note).build());
ItemStack coinsItem = new CurrencyItem("GOLD_COIN", 1).build(); ItemStack coinsItem = new CurrencyItemBuilder("GOLD_COIN", 1).build();
coinsItem.setAmount(coins); coinsItem.setAmount(coins);
smart.give(coinsItem); smart.give(coinsItem);
} }

View File

@ -97,6 +97,11 @@ public class PlayerResourceUpdateEvent extends PlayerDataEvent implements Cancel
*/ */
SKILL_COST, SKILL_COST,
/**
* When consuming stellium to use a waypoint
*/
USE_WAYPOINT,
/** /**
* Used by quests triggers * Used by quests triggers
* - {@link net.Indyuce.mmocore.api.quest.trigger.ManaTrigger} * - {@link net.Indyuce.mmocore.api.quest.trigger.ManaTrigger}

View File

@ -1,6 +1,6 @@
package net.Indyuce.mmocore.api.load; package net.Indyuce.mmocore.api.load;
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser; import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import net.Indyuce.mmocore.api.block.BlockType; import net.Indyuce.mmocore.api.block.BlockType;
@ -14,7 +14,6 @@ import net.Indyuce.mmocore.loot.droptable.condition.WorldCondition;
import net.Indyuce.mmocore.loot.droptable.dropitem.DropItem; import net.Indyuce.mmocore.loot.droptable.dropitem.DropItem;
import net.Indyuce.mmocore.loot.droptable.dropitem.DropTableDropItem; import net.Indyuce.mmocore.loot.droptable.dropitem.DropTableDropItem;
import net.Indyuce.mmocore.loot.droptable.dropitem.GoldDropItem; import net.Indyuce.mmocore.loot.droptable.dropitem.GoldDropItem;
import net.Indyuce.mmocore.loot.droptable.dropitem.MMDropTableDropItem;
import net.Indyuce.mmocore.loot.droptable.dropitem.NoteDropItem; import net.Indyuce.mmocore.loot.droptable.dropitem.NoteDropItem;
import net.Indyuce.mmocore.loot.droptable.dropitem.VanillaDropItem; import net.Indyuce.mmocore.loot.droptable.dropitem.VanillaDropItem;
import net.Indyuce.mmocore.experience.source.BrewPotionExperienceSource; import net.Indyuce.mmocore.experience.source.BrewPotionExperienceSource;
@ -88,9 +87,6 @@ public class DefaultMMOLoader extends MMOLoader {
if (config.getKey().equals("gold") || config.getKey().equals("coin")) if (config.getKey().equals("gold") || config.getKey().equals("coin"))
return new GoldDropItem(config); return new GoldDropItem(config);
if (config.getKey().equals("mmdroptable"))
return new MMDropTableDropItem(config);
return null; return null;
} }

View File

@ -4,7 +4,7 @@ import io.lumine.mythic.lib.api.MMOLineConfig;
import net.Indyuce.mmocore.api.block.BlockType; import net.Indyuce.mmocore.api.block.BlockType;
import net.Indyuce.mmocore.loot.droptable.condition.Condition; import net.Indyuce.mmocore.loot.droptable.condition.Condition;
import net.Indyuce.mmocore.loot.droptable.dropitem.DropItem; import net.Indyuce.mmocore.loot.droptable.dropitem.DropItem;
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser; import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
import net.Indyuce.mmocore.experience.source.type.ExperienceSource; import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
import net.Indyuce.mmocore.api.quest.objective.Objective; import net.Indyuce.mmocore.api.quest.objective.Objective;
import net.Indyuce.mmocore.api.quest.trigger.Trigger; import net.Indyuce.mmocore.api.quest.trigger.Trigger;

View File

@ -1,12 +1,15 @@
package net.Indyuce.mmocore.api.player; package net.Indyuce.mmocore.api.player;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.player.MMOPlayerData; import io.lumine.mythic.lib.api.player.MMOPlayerData;
import io.lumine.mythic.lib.player.TemporaryPlayerData; import io.lumine.mythic.lib.player.TemporaryPlayerData;
import io.lumine.mythic.lib.player.cooldown.CooldownMap; import io.lumine.mythic.lib.player.cooldown.CooldownMap;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.ConfigMessage; import net.Indyuce.mmocore.api.ConfigMessage;
import net.Indyuce.mmocore.api.SoundEvent; import net.Indyuce.mmocore.api.SoundEvent;
import net.Indyuce.mmocore.api.Waypoint; import net.Indyuce.mmocore.player.Unlockable;
import net.Indyuce.mmocore.waypoint.CostType;
import net.Indyuce.mmocore.waypoint.Waypoint;
import net.Indyuce.mmocore.api.event.PlayerExperienceGainEvent; import net.Indyuce.mmocore.api.event.PlayerExperienceGainEvent;
import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent; import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent;
import net.Indyuce.mmocore.api.event.PlayerResourceUpdateEvent; import net.Indyuce.mmocore.api.event.PlayerResourceUpdateEvent;
@ -22,7 +25,7 @@ import net.Indyuce.mmocore.api.player.stats.StatType;
import net.Indyuce.mmocore.api.quest.PlayerQuests; import net.Indyuce.mmocore.api.quest.PlayerQuests;
import net.Indyuce.mmocore.api.util.Closable; import net.Indyuce.mmocore.api.util.Closable;
import net.Indyuce.mmocore.api.util.MMOCoreUtils; import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import net.Indyuce.mmocore.api.util.math.particle.SmallParticleEffect; import net.Indyuce.mmocore.loot.chest.particle.SmallParticleEffect;
import net.Indyuce.mmocore.experience.EXPSource; import net.Indyuce.mmocore.experience.EXPSource;
import net.Indyuce.mmocore.experience.ExperienceObject; import net.Indyuce.mmocore.experience.ExperienceObject;
import net.Indyuce.mmocore.experience.ExperienceTableClaimer; import net.Indyuce.mmocore.experience.ExperienceTableClaimer;
@ -35,6 +38,7 @@ import net.Indyuce.mmocore.party.provided.Party;
import net.Indyuce.mmocore.skill.ClassSkill; import net.Indyuce.mmocore.skill.ClassSkill;
import net.Indyuce.mmocore.skill.RegisteredSkill; import net.Indyuce.mmocore.skill.RegisteredSkill;
import net.Indyuce.mmocore.skill.cast.SkillCastingHandler; import net.Indyuce.mmocore.skill.cast.SkillCastingHandler;
import net.Indyuce.mmocore.waypoint.WaypointOption;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
@ -382,7 +386,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
} }
public boolean hasWaypoint(Waypoint waypoint) { public boolean hasWaypoint(Waypoint waypoint) {
return waypoint.isDefault() || waypoints.contains(waypoint.getId()); return waypoint.hasOption(WaypointOption.DEFAULT) || waypoints.contains(waypoint.getId());
} }
public void unlockWaypoint(Waypoint waypoint) { public void unlockWaypoint(Waypoint waypoint) {
@ -455,9 +459,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
* *
* @param waypoint Target waypoint * @param waypoint Target waypoint
*/ */
public void warp(Waypoint waypoint) { public void warp(Waypoint waypoint, CostType costType) {
if (!isOnline())
return;
/* /*
* This cooldown is only used internally to make sure the player is not * This cooldown is only used internally to make sure the player is not
@ -466,7 +468,8 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
*/ */
setLastActivity(PlayerActivity.USE_WAYPOINT); setLastActivity(PlayerActivity.USE_WAYPOINT);
giveStellium(-waypoint.getStelliumCost(), PlayerResourceUpdateEvent.UpdateReason.SKILL_COST); final double cost = waypoint.getCost(costType);
giveStellium(-cost, PlayerResourceUpdateEvent.UpdateReason.USE_WAYPOINT);
new BukkitRunnable() { new BukkitRunnable() {
final int x = getPlayer().getLocation().getBlockX(); final int x = getPlayer().getLocation().getBlockX();
@ -481,7 +484,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|| getPlayer().getLocation().getBlockZ() != z) { || getPlayer().getLocation().getBlockZ() != z) {
MMOCore.plugin.soundManager.getSound(SoundEvent.WARP_CANCELLED).playTo(getPlayer()); MMOCore.plugin.soundManager.getSound(SoundEvent.WARP_CANCELLED).playTo(getPlayer());
MMOCore.plugin.configManager.getSimpleMessage("warping-canceled").send(getPlayer()); MMOCore.plugin.configManager.getSimpleMessage("warping-canceled").send(getPlayer());
giveStellium(waypoint.getStelliumCost(), PlayerResourceUpdateEvent.UpdateReason.SKILL_REGENERATION); giveStellium(cost, PlayerResourceUpdateEvent.UpdateReason.USE_WAYPOINT);
cancel(); cancel();
return; return;
} }
@ -534,10 +537,6 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
return; return;
} }
// Experience hologram
if (hologramLocation != null && isOnline())
MMOCoreUtils.displayIndicator(hologramLocation.add(.5, 1.5, .5), MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + value).message());
value = MMOCore.plugin.boosterManager.calculateExp(null, value); value = MMOCore.plugin.boosterManager.calculateExp(null, value);
value *= 1 + getStats().getStat(StatType.ADDITIONAL_EXPERIENCE) / 100; value *= 1 + getStats().getStat(StatType.ADDITIONAL_EXPERIENCE) / 100;
@ -555,6 +554,10 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
if (event.isCancelled()) if (event.isCancelled())
return; return;
// Experience hologram
if (hologramLocation != null && isOnline())
MMOCoreUtils.displayIndicator(hologramLocation, MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", String.valueOf(event.getExperience())).message());
experience = Math.max(0, experience + event.getExperience()); experience = Math.max(0, experience + event.getExperience());
// Calculate the player's next level // Calculate the player's next level

View File

@ -1,15 +0,0 @@
package net.Indyuce.mmocore.api.player;
/**
* Some item that can be unlocked
*
* @see {@link PlayerData#unlock(Unlockable)} and {@link PlayerData#hasUnlocked(Unlockable)}
*/
public interface Unlockable {
/**
* Format being used is the minecraft's default
* namespaced key format, e.g skill_tree:strength_1_5
*/
String getUnlockNamespacedKey();
}

View File

@ -14,12 +14,12 @@ import net.Indyuce.mmocore.api.player.profess.resource.ResourceRegeneration;
import net.Indyuce.mmocore.api.player.stats.StatType; import net.Indyuce.mmocore.api.player.stats.StatType;
import net.Indyuce.mmocore.api.util.MMOCoreUtils; import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import net.Indyuce.mmocore.api.util.math.formula.LinearValue; import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
import net.Indyuce.mmocore.api.util.math.particle.CastingParticle; import net.Indyuce.mmocore.loot.chest.particle.CastingParticle;
import net.Indyuce.mmocore.experience.ExpCurve; import net.Indyuce.mmocore.experience.ExpCurve;
import net.Indyuce.mmocore.experience.ExperienceObject; import net.Indyuce.mmocore.experience.ExperienceObject;
import net.Indyuce.mmocore.experience.droptable.ExperienceTable; import net.Indyuce.mmocore.experience.droptable.ExperienceTable;
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser; import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
import net.Indyuce.mmocore.experience.provider.MainExperienceDispenser; import net.Indyuce.mmocore.experience.dispenser.ClassExperienceDispenser;
import net.Indyuce.mmocore.experience.source.type.ExperienceSource; import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
import net.Indyuce.mmocore.player.playerclass.ClassTrigger; import net.Indyuce.mmocore.player.playerclass.ClassTrigger;
import net.Indyuce.mmocore.player.playerclass.ClassTriggerType; import net.Indyuce.mmocore.player.playerclass.ClassTriggerType;
@ -155,7 +155,7 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
} }
if (config.contains("main-exp-sources")) { if (config.contains("main-exp-sources")) {
ExperienceDispenser dispenser = new MainExperienceDispenser(this); ExperienceDispenser dispenser = new ClassExperienceDispenser(this);
for (String key : config.getStringList("main-exp-sources")) for (String key : config.getStringList("main-exp-sources"))
try { try {
ExperienceSource<?> source = MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key), dispenser); ExperienceSource<?> source = MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key), dispenser);
@ -375,6 +375,7 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
return found == null ? Optional.empty() : Optional.of(found); return found == null ? Optional.empty() : Optional.of(found);
} }
@Nullable
public ClassSkill getSkill(String id) { public ClassSkill getSkill(String id) {
return skills.get(id); return skills.get(id);
} }

View File

@ -12,6 +12,10 @@ public class ManaDisplayOptions {
private final String name, icon; private final String name, icon;
private final char barCharacter; private final char barCharacter;
public ChatColor getFull() { return full; }
public ChatColor getHalf() { return half; }
public ChatColor getEmpty() { return empty; }
public static final ManaDisplayOptions DEFAULT = new ManaDisplayOptions(ChatColor.AQUA, ChatColor.BLUE, ChatColor.WHITE, "Mana", public static final ManaDisplayOptions DEFAULT = new ManaDisplayOptions(ChatColor.AQUA, ChatColor.BLUE, ChatColor.WHITE, "Mana",
AltChar.listSquare.charAt(0), ChatColor.BLUE + AltChar.star2); AltChar.listSquare.charAt(0), ChatColor.BLUE + AltChar.star2);

View File

@ -68,6 +68,7 @@ public enum StatType {
PROJECTILE_DAMAGE, PROJECTILE_DAMAGE,
WEAPON_DAMAGE, WEAPON_DAMAGE,
SKILL_DAMAGE, SKILL_DAMAGE,
UNARMED_DAMAGE,
UNDEAD_DAMAGE, UNDEAD_DAMAGE,
// Misc damage stats // Misc damage stats

View File

@ -1,19 +1,24 @@
package net.Indyuce.mmocore.api.quest.trigger; package net.Indyuce.mmocore.api.quest.trigger;
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
import net.Indyuce.mmocore.experience.dispenser.ProfessionExperienceDispenser;
import net.Indyuce.mmocore.experience.dispenser.SimpleExperienceDispenser;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.experience.EXPSource; import net.Indyuce.mmocore.experience.EXPSource;
import net.Indyuce.mmocore.experience.ExperienceInfo;
import net.Indyuce.mmocore.experience.Profession;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.util.math.formula.RandomAmount; import net.Indyuce.mmocore.api.util.math.formula.RandomAmount;
import io.lumine.mythic.lib.api.MMOLineConfig; import io.lumine.mythic.lib.api.MMOLineConfig;
import org.jetbrains.annotations.NotNull;
public class ExperienceTrigger extends Trigger { public class ExperienceTrigger extends Trigger {
@NotNull
private final RandomAmount amount; private final RandomAmount amount;
private final Profession profession; @NotNull
private final EXPSource source; private final EXPSource source;
@NotNull
private final ExperienceDispenser dispenser;
public ExperienceTrigger(MMOLineConfig config) { public ExperienceTrigger(MMOLineConfig config) {
super(config); super(config);
@ -23,26 +28,15 @@ public class ExperienceTrigger extends Trigger {
if (config.contains("profession")) { if (config.contains("profession")) {
String id = config.getString("profession").toLowerCase().replace("_", "-"); String id = config.getString("profession").toLowerCase().replace("_", "-");
Validate.isTrue(MMOCore.plugin.professionManager.has(id), "Could not find profession"); Validate.isTrue(MMOCore.plugin.professionManager.has(id), "Could not find profession");
profession = MMOCore.plugin.professionManager.get(id); dispenser = new ProfessionExperienceDispenser(MMOCore.plugin.professionManager.get(id));
} else } else
profession = null; dispenser = new SimpleExperienceDispenser();
amount = new RandomAmount(config.getString("amount")); amount = new RandomAmount(config.getString("amount"));
source = config.contains("source") ? EXPSource.valueOf(config.getString("source").toUpperCase()) : EXPSource.QUEST; source = config.contains("source") ? EXPSource.valueOf(config.getString("source").toUpperCase()) : EXPSource.QUEST;
} }
@Override @Override
public void apply(PlayerData player) { public void apply(PlayerData player) {
if (profession == null) dispenser.giveExperience(player, amount.calculateInt(), null, source);
player.giveExperience(amount.calculateInt(), source);
else
player.getCollectionSkills().giveExperience(profession, amount.calculateInt(), source);
}
/*
* experience must be accessible from the custom mine event. this method
* allows to generate an experience info instance for easy manipulations
*/
public ExperienceInfo newInfo() {
return new ExperienceInfo(amount.calculateInt(), profession);
} }
} }

View File

@ -1,7 +1,6 @@
package net.Indyuce.mmocore.api.util; package net.Indyuce.mmocore.api.util;
import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.version.VersionMaterial; import io.lumine.mythic.lib.version.VersionMaterial;
import io.lumine.mythic.utils.holograms.Hologram; import io.lumine.mythic.utils.holograms.Hologram;
import io.lumine.mythic.utils.serialize.Position; import io.lumine.mythic.utils.serialize.Position;
@ -66,6 +65,7 @@ public class MMOCoreUtils {
*/ */
public static void displayIndicator(Location loc, String message) { public static void displayIndicator(Location loc, String message) {
Hologram holo = Hologram.create(Position.of(loc), Arrays.asList(message)); Hologram holo = Hologram.create(Position.of(loc), Arrays.asList(message));
holo.spawn();
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> holo.despawn(), 20); Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> holo.despawn(), 20);
} }
@ -184,8 +184,11 @@ public class MMOCoreUtils {
/** /**
* Method used when mining a custom block or fishing, as the corresponding * Method used when mining a custom block or fishing, as the corresponding
* interaction event is cancelled durability is not handled. This method is * interaction event is cancelled durability is not handled. This method is
* needed and actually calls a damage event so that MMOItems can listen to * needed and actually calls a damage event so that MMOItems can listen to it.
* it * <p>
* This method only supports item types which DO have a durability bar like
* fishing rods or pickaxes. This shouldn't cause any issue because you can
* only use fishing rods to fish and pickaxes to mine stuff.
* *
* @param player Player holding the item with durability * @param player Player holding the item with durability
* @param slot The slot of the item with durability * @param slot The slot of the item with durability
@ -193,26 +196,28 @@ public class MMOCoreUtils {
*/ */
public static void decreaseDurability(Player player, EquipmentSlot slot, int damage) { public static void decreaseDurability(Player player, EquipmentSlot slot, int damage) {
ItemStack item = player.getInventory().getItem(slot); ItemStack item = player.getInventory().getItem(slot);
NBTItem nbt = NBTItem.get(item); if (!item.hasItemMeta() || !(item.getItemMeta() instanceof Damageable) || item.getItemMeta().isUnbreakable())
if (!nbt.hasTag("MMOITEMS_MAX_DURABILITY")) {
return; return;
}
PlayerItemDamageEvent event = new PlayerItemDamageEvent(player, item, damage); PlayerItemDamageEvent event = new PlayerItemDamageEvent(player, item, damage);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) if (event.isCancelled())
return; return;
ItemMeta meta = item.getItemMeta();
if (!nbt.getBoolean("Unbreakable") && item.getItemMeta() instanceof Damageable) { if (event.getDamage() + ((Damageable) meta).getDamage() >= item.getType().getMaxDurability()) {
ItemMeta meta = item.getItemMeta(); player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1F, 1F);
((Damageable) meta).setDamage(((Damageable) meta).getDamage() + damage); player.getInventory().setItem(slot, null);
} else {
((Damageable) meta).setDamage(((Damageable) meta).getDamage() + event.getDamage());
item.setItemMeta(meta); item.setItemMeta(meta);
if (((Damageable) meta).getDamage() >= item.getType().getMaxDurability()) {
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1F, 1F);
player.getInventory().setItem(slot, null);
}
} }
} }
/**
* @return Center location of an entity using its bounding box
*/
public static Location getCenterLocation(Entity entity) {
return entity.getBoundingBox().getCenter().toLocation(entity.getWorld());
}
} }

View File

@ -1,144 +0,0 @@
package net.Indyuce.mmocore.api.util.item;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.logging.Level;
import org.apache.commons.lang.Validate;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import net.Indyuce.mmocore.MMOCore;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.version.VersionMaterial;
public class ConfigItem {
private final String name, id, texture;
private final ItemStack item;
private final List<String> lore;
private final int damage, modeldata;
private boolean unbreakable;
private final Map<String, String> placeholders = new HashMap<>();
public ConfigItem(ConfigurationSection config) {
id = config.getName();
name = config.getString("name");
lore = config.getStringList("lore");
item = new ItemStack(Material.valueOf(config.getString("item")));
Validate.notNull(name, "Name cannot be null");
Validate.notNull(lore, "Lore can be empty but not null");
/*
* extra options
*/
damage = config.getInt("damage");
texture = config.getString("texture");
modeldata = config.getInt("custom-model-data");
}
public ConfigItem(String id) {
this(MMOCore.plugin.configItems.get(id));
}
public ConfigItem(ConfigItem cache) {
this.id = cache.id;
name = cache.name;
lore = cache.lore;
item = cache.item;
damage = cache.damage;
texture = cache.texture;
modeldata = cache.modeldata;
unbreakable = cache.unbreakable;
}
public ItemStack getItem(int amount) {
ItemStack item = this.item.clone();
item.setAmount(amount);
return item;
}
public List<String> getLore() {
return lore;
}
public String getName() {
return name;
}
public int getModelData() {
return modeldata;
}
public String getId() {
return id;
}
public ConfigItem setUnbreakable() {
unbreakable = true;
return this;
}
public ConfigItem addPlaceholders(String... placeholders) {
for (int j = 0; j < placeholders.length - 1; j += 2)
this.placeholders.put(placeholders[j], placeholders[j + 1]);
return this;
}
public ItemStack build() {
return build(1);
}
public ItemStack build(int amount) {
ItemStack item = getItem(amount);
ItemMeta meta = item.getItemMeta();
if (meta instanceof Damageable)
((Damageable) meta).setDamage(damage);
if (MythicLib.plugin.getVersion().isStrictlyHigher(1, 13))
meta.setCustomModelData(modeldata);
if (item.getType() == VersionMaterial.PLAYER_HEAD.toMaterial() && texture != null)
try {
Field profileField = meta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
profile.getProperties().put("textures", new Property("textures", texture));
profileField.set(meta, profile);
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException exception) {
MMOCore.log(Level.WARNING, "Could not load config item texture of " + id);
}
meta.addItemFlags(ItemFlag.values());
meta.setDisplayName(format(name));
List<String> lore = new ArrayList<>();
getLore().forEach(line -> lore.add(format(line)));
meta.setLore(lore);
item.setItemMeta(meta);
return unbreakable ? NBTItem.get(item).addTag(new ItemTag("Unbreakable", true)).toItem() : item;
}
protected String format(String string) {
for (String placeholder : placeholders.keySet())
if (string.contains("{" + placeholder + "}"))
string = string.replace("{" + placeholder + "}", "" + placeholders.get(placeholder));
return MythicLib.plugin.parseColors(string);
}
}

View File

@ -1,45 +0,0 @@
package net.Indyuce.mmocore.api.util.item;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.item.NBTItem;
public class CurrencyItem extends ConfigItem {
private final int worth, amount;
public CurrencyItem(String key, int worth) {
this(key, worth, 1);
}
public CurrencyItem(String key, int worth, int amount) {
super(key);
addPlaceholders("worth", "" + (this.worth = worth));
this.amount = amount;
}
@Override
public ItemStack build() {
ItemStack item = getItem(amount);
ItemMeta meta = item.getItemMeta();
meta.addItemFlags(ItemFlag.values());
meta.setDisplayName(format(getName()));
List<String> lore = new ArrayList<>();
getLore().forEach(line -> lore.add(format(line)));
meta.setLore(lore);
if(MythicLib.plugin.getVersion().isStrictlyHigher(1, 13))
meta.setCustomModelData(getModelData());
item.setItemMeta(meta);
return NBTItem.get(item).addTag(new ItemTag("RpgWorth", worth)).toItem();
}
}

View File

@ -1,17 +0,0 @@
package net.Indyuce.mmocore.api.util.item;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import io.lumine.mythic.lib.MythicLib;
public class NamedItemStack extends ItemStack {
public NamedItemStack(Material material, String name) {
super(material);
ItemMeta meta = getItemMeta();
meta.setDisplayName(MythicLib.plugin.parseColors(name));
setItemMeta(meta);
}
}

View File

@ -1,7 +1,7 @@
package net.Indyuce.mmocore.command; package net.Indyuce.mmocore.command;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeRoot; import io.lumine.mythic.lib.command.api.CommandTreeRoot;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.command.rpg.CoinsCommandTreeNode; import net.Indyuce.mmocore.command.rpg.CoinsCommandTreeNode;
import net.Indyuce.mmocore.command.rpg.NoteCommandTreeNode; import net.Indyuce.mmocore.command.rpg.NoteCommandTreeNode;

View File

@ -1,44 +1,47 @@
package net.Indyuce.mmocore.command.rpg; package net.Indyuce.mmocore.command.rpg;
import io.lumine.mythic.lib.api.util.SmartGive; import io.lumine.mythic.lib.api.util.SmartGive;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
import net.Indyuce.mmocore.api.util.item.CurrencyItem; import net.Indyuce.mmocore.util.item.CurrencyItemBuilder;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class CoinsCommandTreeNode extends CommandTreeNode { public class CoinsCommandTreeNode extends CommandTreeNode {
public CoinsCommandTreeNode(CommandTreeNode parent) { public CoinsCommandTreeNode(CommandTreeNode parent) {
super(parent, "coins"); super(parent, "coins");
addParameter(Parameter.PLAYER); addParameter(Parameter.PLAYER);
addParameter(Parameter.AMOUNT); addParameter(Parameter.AMOUNT);
} }
@Override @Override
public CommandResult execute(CommandSender sender, String[] args) { public CommandResult execute(CommandSender sender, String[] args) {
if (args.length < 3) if (args.length < 3)
return CommandResult.THROW_USAGE; return CommandResult.THROW_USAGE;
Player player = Bukkit.getPlayer(args[1]); Player player = Bukkit.getPlayer(args[1]);
if (player == null) { if (player == null) {
sender.sendMessage(ChatColor.RED + "Could not find the player called " + args[1] + "."); sender.sendMessage(ChatColor.RED + "Could not find the player called " + args[1] + ".");
return CommandResult.FAILURE; return CommandResult.FAILURE;
} }
int amount; int amount;
try { try {
amount = Integer.parseInt(args[2]); amount = Integer.parseInt(args[2]);
} catch (Exception e) { } catch (Exception e) {
sender.sendMessage(ChatColor.RED + args[2] + " is not a valid number."); sender.sendMessage(ChatColor.RED + args[2] + " is not a valid number.");
return CommandResult.FAILURE; return CommandResult.FAILURE;
} }
new SmartGive(player).give(new CurrencyItem("GOLD_COIN", 1, amount).build()); ItemStack coins = new CurrencyItemBuilder("GOLD_COIN", 1).build();
return CommandResult.SUCCESS; coins.setAmount(amount);
} new SmartGive(player).give(coins);
return CommandResult.SUCCESS;
}
} }

View File

@ -7,10 +7,10 @@ import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import net.Indyuce.mmocore.api.util.item.CurrencyItem; import net.Indyuce.mmocore.util.item.CurrencyItemBuilder;
import io.lumine.mythic.lib.api.util.SmartGive; import io.lumine.mythic.lib.api.util.SmartGive;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
public class NoteCommandTreeNode extends CommandTreeNode { public class NoteCommandTreeNode extends CommandTreeNode {
public NoteCommandTreeNode(CommandTreeNode parent) { public NoteCommandTreeNode(CommandTreeNode parent) {
@ -40,7 +40,7 @@ public class NoteCommandTreeNode extends CommandTreeNode {
return CommandResult.FAILURE; return CommandResult.FAILURE;
} }
new SmartGive(player).give(new CurrencyItem("NOTE", worth).build()); new SmartGive(player).give(new CurrencyItemBuilder("NOTE", worth).build());
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} }
} }

View File

@ -5,7 +5,7 @@ import org.bukkit.command.CommandSender;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
public class ReloadCommandTreeNode extends CommandTreeNode { public class ReloadCommandTreeNode extends CommandTreeNode {
public ReloadCommandTreeNode(CommandTreeNode parent) { public ReloadCommandTreeNode(CommandTreeNode parent) {
@ -18,15 +18,11 @@ public class ReloadCommandTreeNode extends CommandTreeNode {
sender.sendMessage(ChatColor.YELLOW + "Reloading " + MMOCore.plugin.getName() + " " + MMOCore.plugin.getDescription().getVersion() + "..."); sender.sendMessage(ChatColor.YELLOW + "Reloading " + MMOCore.plugin.getName() + " " + MMOCore.plugin.getDescription().getVersion() + "...");
long ms = System.currentTimeMillis(); long ms = System.currentTimeMillis();
MMOCore.plugin.reloadConfig();
MMOCore.plugin.initializePlugin(true); MMOCore.plugin.initializePlugin(true);
PlayerData.getAll().forEach(PlayerData::update);
ms = System.currentTimeMillis() - ms; ms = System.currentTimeMillis() - ms;
sender.sendMessage(ChatColor.YELLOW + MMOCore.plugin.getName() + " " + MMOCore.plugin.getDescription().getVersion() + " successfully reloaded."); sender.sendMessage(ChatColor.YELLOW + MMOCore.plugin.getName() + " " + MMOCore.plugin.getDescription().getVersion() + " successfully reloaded.");
sender.sendMessage(ChatColor.YELLOW + "Time Taken: " + ChatColor.GOLD + ms + ChatColor.YELLOW + "ms (" + ChatColor.GOLD + (double) ms / 50 + ChatColor.YELLOW + " ticks)"); sender.sendMessage(ChatColor.YELLOW + "Time Taken: " + ChatColor.GOLD + ms + ChatColor.YELLOW + "ms (" + ChatColor.GOLD + (double) ms / 50 + ChatColor.YELLOW + " ticks)");
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} }
} }

View File

@ -1,6 +1,6 @@
package net.Indyuce.mmocore.command.rpg.admin; package net.Indyuce.mmocore.command.rpg.admin;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource; import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -10,8 +10,8 @@ import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute; import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
import net.Indyuce.mmocore.api.player.attribute.PlayerAttributes.AttributeInstance; import net.Indyuce.mmocore.api.player.attribute.PlayerAttributes.AttributeInstance;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
public class AttributeCommandTreeNode extends CommandTreeNode { public class AttributeCommandTreeNode extends CommandTreeNode {
public AttributeCommandTreeNode(CommandTreeNode parent) { public AttributeCommandTreeNode(CommandTreeNode parent) {

View File

@ -12,8 +12,8 @@ import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.profess.PlayerClass; import net.Indyuce.mmocore.api.player.profess.PlayerClass;
import net.Indyuce.mmocore.api.player.profess.SavedClassInformation; import net.Indyuce.mmocore.api.player.profess.SavedClassInformation;
import net.Indyuce.mmocore.command.CommandVerbose; import net.Indyuce.mmocore.command.CommandVerbose;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
public class ClassCommandTreeNode extends CommandTreeNode { public class ClassCommandTreeNode extends CommandTreeNode {
public ClassCommandTreeNode(CommandTreeNode parent) { public ClassCommandTreeNode(CommandTreeNode parent) {

View File

@ -1,7 +1,7 @@
package net.Indyuce.mmocore.command.rpg.admin; package net.Indyuce.mmocore.command.rpg.admin;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.command.CommandVerbose; import net.Indyuce.mmocore.command.CommandVerbose;

View File

@ -9,8 +9,8 @@ import org.bukkit.entity.Player;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.profess.PlayerClass; import net.Indyuce.mmocore.api.player.profess.PlayerClass;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
public class ForceClassCommandTreeNode extends CommandTreeNode { public class ForceClassCommandTreeNode extends CommandTreeNode {
public ForceClassCommandTreeNode(CommandTreeNode parent) { public ForceClassCommandTreeNode(CommandTreeNode parent) {

View File

@ -1,7 +1,7 @@
package net.Indyuce.mmocore.command.rpg.admin; package net.Indyuce.mmocore.command.rpg.admin;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
import net.Indyuce.mmocore.api.player.PlayerActivity; import net.Indyuce.mmocore.api.player.PlayerActivity;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

View File

@ -8,8 +8,8 @@ import org.bukkit.entity.Player;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.experience.Profession; import net.Indyuce.mmocore.experience.Profession;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
public class InfoCommandTreeNode extends CommandTreeNode { public class InfoCommandTreeNode extends CommandTreeNode {
public InfoCommandTreeNode(CommandTreeNode parent) { public InfoCommandTreeNode(CommandTreeNode parent) {

View File

@ -14,8 +14,8 @@ import net.Indyuce.mmocore.experience.PlayerProfessions;
import net.Indyuce.mmocore.experience.Profession; import net.Indyuce.mmocore.experience.Profession;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.command.MMOCoreCommandTreeRoot; import net.Indyuce.mmocore.command.MMOCoreCommandTreeRoot;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
public class LevelCommandTreeNode extends CommandTreeNode { public class LevelCommandTreeNode extends CommandTreeNode {
public LevelCommandTreeNode(CommandTreeNode parent) { public LevelCommandTreeNode(CommandTreeNode parent) {

View File

@ -7,8 +7,8 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
public class NoCooldownCommandTreeNode extends CommandTreeNode { public class NoCooldownCommandTreeNode extends CommandTreeNode {
public NoCooldownCommandTreeNode(CommandTreeNode parent) { public NoCooldownCommandTreeNode(CommandTreeNode parent) {

View File

@ -10,8 +10,8 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
public class PointsCommandTreeNode extends CommandTreeNode { public class PointsCommandTreeNode extends CommandTreeNode {
private final String type; private final String type;

View File

@ -10,8 +10,8 @@ import net.Indyuce.mmocore.experience.Profession;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.attribute.PlayerAttributes.AttributeInstance; import net.Indyuce.mmocore.api.player.attribute.PlayerAttributes.AttributeInstance;
import net.Indyuce.mmocore.command.CommandVerbose; import net.Indyuce.mmocore.command.CommandVerbose;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
public class ResetCommandTreeNode extends CommandTreeNode { public class ResetCommandTreeNode extends CommandTreeNode {
public ResetCommandTreeNode(CommandTreeNode parent) { public ResetCommandTreeNode(CommandTreeNode parent) {

View File

@ -1,7 +1,7 @@
package net.Indyuce.mmocore.command.rpg.admin; package net.Indyuce.mmocore.command.rpg.admin;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource; import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
import net.Indyuce.mmocore.api.quest.trigger.ManaTrigger; import net.Indyuce.mmocore.api.quest.trigger.ManaTrigger;

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmocore.command.rpg.booster;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
public class BoosterCommandTreeNode extends CommandTreeNode { public class BoosterCommandTreeNode extends CommandTreeNode {
public BoosterCommandTreeNode(CommandTreeNode parent) { public BoosterCommandTreeNode(CommandTreeNode parent) {

View File

@ -12,8 +12,8 @@ import net.Indyuce.mmocore.api.ConfigMessage;
import net.Indyuce.mmocore.experience.Booster; import net.Indyuce.mmocore.experience.Booster;
import net.Indyuce.mmocore.experience.Profession; import net.Indyuce.mmocore.experience.Profession;
import net.Indyuce.mmocore.command.MMOCoreCommandTreeRoot; import net.Indyuce.mmocore.command.MMOCoreCommandTreeRoot;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
public class CreateCommandTreeNode extends CommandTreeNode { public class CreateCommandTreeNode extends CommandTreeNode {
public CreateCommandTreeNode(CommandTreeNode parent) { public CreateCommandTreeNode(CommandTreeNode parent) {

View File

@ -8,7 +8,7 @@ import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.experience.Booster; import net.Indyuce.mmocore.experience.Booster;
import net.Indyuce.mmocore.api.util.math.format.DelayFormat; import net.Indyuce.mmocore.api.util.math.format.DelayFormat;
import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
public class ListCommandTreeNode extends CommandTreeNode { public class ListCommandTreeNode extends CommandTreeNode {
public ListCommandTreeNode(CommandTreeNode parent) { public ListCommandTreeNode(CommandTreeNode parent) {

View File

@ -8,8 +8,8 @@ import org.bukkit.command.CommandSender;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.experience.Booster; import net.Indyuce.mmocore.experience.Booster;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
public class RemoveCommandTreeNode extends CommandTreeNode { public class RemoveCommandTreeNode extends CommandTreeNode {
public RemoveCommandTreeNode(CommandTreeNode parent) { public RemoveCommandTreeNode(CommandTreeNode parent) {

View File

@ -3,7 +3,7 @@ package net.Indyuce.mmocore.command.rpg.debug;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
public class DebugCommandTreeNode extends CommandTreeNode { public class DebugCommandTreeNode extends CommandTreeNode {
public static final String commandPrefix = ChatColor.YELLOW + "[" + ChatColor.RED + "DEBUG" + ChatColor.GOLD + "] " + ChatColor.RESET; public static final String commandPrefix = ChatColor.YELLOW + "[" + ChatColor.RED + "DEBUG" + ChatColor.GOLD + "] " + ChatColor.RESET;

View File

@ -2,8 +2,8 @@ package net.Indyuce.mmocore.command.rpg.debug;
import io.lumine.mythic.lib.api.stat.StatInstance; import io.lumine.mythic.lib.api.stat.StatInstance;
import io.lumine.mythic.lib.api.stat.modifier.StatModifier; import io.lumine.mythic.lib.api.stat.modifier.StatModifier;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.stats.StatType; import net.Indyuce.mmocore.api.player.stats.StatType;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -6,8 +6,8 @@ import org.bukkit.entity.Player;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.stats.StatType; import net.Indyuce.mmocore.api.player.stats.StatType;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
public class StatValueCommandTreeNode extends CommandTreeNode { public class StatValueCommandTreeNode extends CommandTreeNode {
public StatValueCommandTreeNode(CommandTreeNode parent) { public StatValueCommandTreeNode(CommandTreeNode parent) {

View File

@ -7,8 +7,8 @@ import org.bukkit.entity.Player;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.quest.PlayerQuests; import net.Indyuce.mmocore.api.quest.PlayerQuests;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
public class CancelCommandTreeNode extends CommandTreeNode { public class CancelCommandTreeNode extends CommandTreeNode {
public CancelCommandTreeNode(CommandTreeNode parent) { public CancelCommandTreeNode(CommandTreeNode parent) {

View File

@ -1,7 +1,7 @@
package net.Indyuce.mmocore.command.rpg.quest; package net.Indyuce.mmocore.command.rpg.quest;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.quest.PlayerQuests; import net.Indyuce.mmocore.api.quest.PlayerQuests;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmocore.command.rpg.quest;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
public class QuestCommandTreeNode extends CommandTreeNode { public class QuestCommandTreeNode extends CommandTreeNode {

View File

@ -10,8 +10,8 @@ import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.quest.PlayerQuests; import net.Indyuce.mmocore.api.quest.PlayerQuests;
import net.Indyuce.mmocore.api.quest.Quest; import net.Indyuce.mmocore.api.quest.Quest;
import net.Indyuce.mmocore.command.MMOCoreCommandTreeRoot; import net.Indyuce.mmocore.command.MMOCoreCommandTreeRoot;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
public class StartCommandTreeNode extends CommandTreeNode { public class StartCommandTreeNode extends CommandTreeNode {
public StartCommandTreeNode(CommandTreeNode parent) { public StartCommandTreeNode(CommandTreeNode parent) {

View File

@ -6,8 +6,8 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import net.Indyuce.mmocore.manager.InventoryManager; import net.Indyuce.mmocore.manager.InventoryManager;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
public class OpenCommandTreeNode extends CommandTreeNode { public class OpenCommandTreeNode extends CommandTreeNode {
public OpenCommandTreeNode(CommandTreeNode parent) { public OpenCommandTreeNode(CommandTreeNode parent) {

View File

@ -1,9 +1,9 @@
package net.Indyuce.mmocore.command.rpg.waypoint; package net.Indyuce.mmocore.command.rpg.waypoint;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.Waypoint; import net.Indyuce.mmocore.waypoint.Waypoint;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -6,10 +6,10 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.Waypoint; import net.Indyuce.mmocore.waypoint.Waypoint;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
public class UnlockCommandTreeNode extends CommandTreeNode { public class UnlockCommandTreeNode extends CommandTreeNode {
public UnlockCommandTreeNode(CommandTreeNode parent) { public UnlockCommandTreeNode(CommandTreeNode parent) {

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmocore.command.rpg.waypoint;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode; import io.lumine.mythic.lib.command.api.CommandTreeNode;
public class WaypointsCommandTreeNode extends CommandTreeNode { public class WaypointsCommandTreeNode extends CommandTreeNode {
public WaypointsCommandTreeNode(CommandTreeNode parent) { public WaypointsCommandTreeNode(CommandTreeNode parent) {

View File

@ -1,24 +1,19 @@
package net.Indyuce.mmocore.comp.mythicmobs; package net.Indyuce.mmocore.comp.mythicmobs;
import io.lumine.xikage.mythicmobs.MythicMobs; import io.lumine.mythic.bukkit.MythicBukkit;
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicDropLoadEvent; import io.lumine.mythic.bukkit.events.MythicDropLoadEvent;
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicReloadedEvent; import io.lumine.mythic.bukkit.events.MythicReloadedEvent;
import io.lumine.xikage.mythicmobs.skills.placeholders.Placeholder; import io.lumine.mythic.core.skills.placeholders.Placeholder;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute; import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
import net.Indyuce.mmocore.api.player.attribute.PlayerAttributes; import net.Indyuce.mmocore.api.player.attribute.PlayerAttributes;
import net.Indyuce.mmocore.comp.mythicmobs.load.CurrencyItemDrop; import net.Indyuce.mmocore.comp.mythicmobs.load.CurrencyItemDrop;
import net.Indyuce.mmocore.comp.mythicmobs.load.GoldPouchDrop; import net.Indyuce.mmocore.comp.mythicmobs.load.GoldPouchDrop;
import net.Indyuce.mmocore.skill.RegisteredSkill;
import org.apache.commons.lang.Validate;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import java.util.Optional;
import java.util.logging.Level;
public class MythicHook implements Listener { public class MythicHook implements Listener {
public MythicHook() { public MythicHook() {
registerPlaceholders(); registerPlaceholders();
@ -46,25 +41,25 @@ public class MythicHook implements Listener {
// When MM is reloaded, reload placeholders because they are no longer registered // When MM is reloaded, reload placeholders because they are no longer registered
registerPlaceholders(); registerPlaceholders();
// Reload skills // Reload every god damn thing
MMOCore.plugin.skillManager.initialize(true); MMOCore.plugin.initializePlugin(true);
} }
private void registerPlaceholders() { private void registerPlaceholders() {
// Resource // Resource
MythicMobs.inst().getPlaceholderManager().register("mana", Placeholder.meta((metadata, arg) -> { MythicBukkit.inst().getPlaceholderManager().register("mana", Placeholder.meta((metadata, arg) -> {
return String.valueOf((int) PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getMana()); return String.valueOf((int) PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getMana());
})); }));
MythicMobs.inst().getPlaceholderManager().register("stamina", Placeholder.meta((metadata, arg) -> { MythicBukkit.inst().getPlaceholderManager().register("stamina", Placeholder.meta((metadata, arg) -> {
return String.valueOf((int) PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getStamina()); return String.valueOf((int) PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getStamina());
})); }));
MythicMobs.inst().getPlaceholderManager().register("stellium", Placeholder.meta((metadata, arg) -> { MythicBukkit.inst().getPlaceholderManager().register("stellium", Placeholder.meta((metadata, arg) -> {
return String.valueOf((int) PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getStellium()); return String.valueOf((int) PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getStellium());
})); }));
// Attributes // Attributes
MythicMobs.inst().getPlaceholderManager().register("attribute", Placeholder.meta((metadata, arg) -> { MythicBukkit.inst().getPlaceholderManager().register("attribute", Placeholder.meta((metadata, arg) -> {
PlayerAttributes attributes = PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getAttributes(); PlayerAttributes attributes = PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getAttributes();
PlayerAttribute attribute = MMOCore.plugin.attributeManager.get(arg); PlayerAttribute attribute = MMOCore.plugin.attributeManager.get(arg);
return String.valueOf(attributes.getAttribute(attribute)); return String.valueOf(attributes.getAttribute(attribute));

View File

@ -1,49 +1,54 @@
package net.Indyuce.mmocore.comp.mythicmobs; package net.Indyuce.mmocore.comp.mythicmobs;
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser; import io.lumine.mythic.lib.api.MMOLineConfig;
import org.bukkit.configuration.ConfigurationSection;
import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
import net.Indyuce.mmocore.api.load.MMOLoader; import net.Indyuce.mmocore.api.load.MMOLoader;
import net.Indyuce.mmocore.api.quest.objective.Objective; import net.Indyuce.mmocore.api.quest.objective.Objective;
import net.Indyuce.mmocore.api.quest.trigger.Trigger; import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicFactionExperienceSource; import net.Indyuce.mmocore.comp.mythicmobs.load.*;
import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicFactionObjective; import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicMobExperienceSource; import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicMobObjective; import net.Indyuce.mmocore.loot.droptable.dropitem.DropItem;
import net.Indyuce.mmocore.comp.mythicmobs.load.MythicSkillTrigger; import org.bukkit.configuration.ConfigurationSection;
import io.lumine.mythic.lib.api.MMOLineConfig;
public class MythicMobsMMOLoader extends MMOLoader { public class MythicMobsMMOLoader extends MMOLoader {
@Override @Override
public Trigger loadTrigger(MMOLineConfig config) { public Trigger loadTrigger(MMOLineConfig config) {
if (config.getKey().equalsIgnoreCase("mmskill") || config.getKey().equalsIgnoreCase("mythicmobskill")) if (config.getKey().equalsIgnoreCase("mmskill") || config.getKey().equalsIgnoreCase("mythicmobskill"))
return new MythicSkillTrigger(config); return new MythicSkillTrigger(config);
return null; return null;
} }
@Override @Override
public Objective loadObjective(MMOLineConfig config, ConfigurationSection section) { public DropItem loadDropItem(MMOLineConfig config) {
if (config.getKey().equalsIgnoreCase("killmythicmob")) if (config.getKey().equals("mmdroptable"))
return new KillMythicMobObjective(section, config); return new MMDropTableDropItem(config);
if (config.getKey().equalsIgnoreCase("killmythicfaction"))
return new KillMythicFactionObjective(section, config);
return null; return null;
} }
@Override @Override
public ExperienceSource<?> loadExperienceSource(MMOLineConfig config, ExperienceDispenser dispenser) { public Objective loadObjective(MMOLineConfig config, ConfigurationSection section) {
if (config.getKey().equalsIgnoreCase("killmythicmob")) if (config.getKey().equalsIgnoreCase("killmythicmob"))
return new KillMythicMobExperienceSource(dispenser, config); return new KillMythicMobObjective(section, config);
if (config.getKey().equalsIgnoreCase("killmythicfaction")) if (config.getKey().equalsIgnoreCase("killmythicfaction"))
return new KillMythicFactionExperienceSource(dispenser, config); return new KillMythicFactionObjective(section, config);
return null; return null;
} }
@Override
public ExperienceSource<?> loadExperienceSource(MMOLineConfig config, ExperienceDispenser dispenser) {
if (config.getKey().equalsIgnoreCase("killmythicmob"))
return new KillMythicMobExperienceSource(dispenser, config);
if (config.getKey().equalsIgnoreCase("killmythicfaction"))
return new KillMythicFactionExperienceSource(dispenser, config);
return null;
}
} }

View File

@ -1,40 +1,40 @@
package net.Indyuce.mmocore.comp.mythicmobs.load; package net.Indyuce.mmocore.comp.mythicmobs.load;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.drops.DropMetadata;
import io.lumine.mythic.api.drops.IMultiDrop;
import io.lumine.mythic.bukkit.adapters.BukkitItemStack;
import io.lumine.mythic.core.drops.Drop;
import io.lumine.mythic.core.drops.LootBag;
import io.lumine.mythic.core.drops.droppables.ItemDrop;
import net.Indyuce.mmocore.util.item.CurrencyItemBuilder;
import java.util.Random; import java.util.Random;
import io.lumine.xikage.mythicmobs.adapters.bukkit.BukkitItemStack;
import io.lumine.xikage.mythicmobs.drops.Drop;
import io.lumine.xikage.mythicmobs.drops.DropMetadata;
import io.lumine.xikage.mythicmobs.drops.IMultiDrop;
import io.lumine.xikage.mythicmobs.drops.LootBag;
import io.lumine.xikage.mythicmobs.drops.droppables.ItemDrop;
import io.lumine.xikage.mythicmobs.io.MythicLineConfig;
import net.Indyuce.mmocore.api.util.item.CurrencyItem;
public class CurrencyItemDrop extends Drop implements IMultiDrop { public class CurrencyItemDrop extends Drop implements IMultiDrop {
private final String key; private final String key;
private final int minw; private final int minw;
private final int maxw; private final int maxw;
private static final Random random = new Random(); private static final Random random = new Random();
public CurrencyItemDrop(String key, MythicLineConfig config) { public CurrencyItemDrop(String key, MythicLineConfig config) {
super(config.getLine(), config); super(config.getLine(), config);
this.key = key;
minw = config.getInteger("minw", 1);
maxw = config.getInteger("maxw", 1);
}
@SuppressWarnings("deprecation") this.key = key;
@Override minw = config.getInteger("minw", 1);
public LootBag get(DropMetadata metadata) { maxw = config.getInteger("maxw", 1);
LootBag loot = new LootBag(metadata); }
loot.add(new ItemDrop(this.getLine(), (MythicLineConfig) this.getConfig(), new BukkitItemStack(new CurrencyItem(key, random(minw, maxw)).build())));
return loot;
}
private int random(int a, int b) { @SuppressWarnings("deprecation")
return random.nextInt(b - a + 1) + a; @Override
} public LootBag get(DropMetadata metadata) {
LootBag loot = new LootBag(metadata);
loot.add(new ItemDrop(this.getLine(), this.getConfig(), new BukkitItemStack(new CurrencyItemBuilder(key, random(minw, maxw)).build())));
return loot;
}
private int random(int a, int b) {
return random.nextInt(b - a + 1) + a;
}
} }

View File

@ -1,66 +1,70 @@
package net.Indyuce.mmocore.comp.mythicmobs.load; package net.Indyuce.mmocore.comp.mythicmobs.load;
import java.util.Random; import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.drops.DropMetadata;
import io.lumine.mythic.api.drops.IMultiDrop;
import io.lumine.mythic.bukkit.adapters.BukkitItemStack;
import io.lumine.mythic.core.drops.Drop;
import io.lumine.mythic.core.drops.LootBag;
import io.lumine.mythic.core.drops.droppables.ItemDrop;
import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import net.Indyuce.mmocore.util.item.CurrencyItemBuilder;
import net.Indyuce.mmocore.util.item.SimpleItemBuilder;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import io.lumine.xikage.mythicmobs.adapters.bukkit.BukkitItemStack; import java.util.Random;
import io.lumine.xikage.mythicmobs.drops.Drop;
import io.lumine.xikage.mythicmobs.drops.DropMetadata;
import io.lumine.xikage.mythicmobs.drops.IMultiDrop;
import io.lumine.xikage.mythicmobs.drops.LootBag;
import io.lumine.xikage.mythicmobs.drops.droppables.ItemDrop;
import io.lumine.xikage.mythicmobs.io.MythicLineConfig;
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import net.Indyuce.mmocore.api.util.item.ConfigItem;
import net.Indyuce.mmocore.api.util.item.CurrencyItem;
import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.item.NBTItem;
public class GoldPouchDrop extends Drop implements IMultiDrop { public class GoldPouchDrop extends Drop implements IMultiDrop {
private final int min; private final int min;
private final int max; private final int max;
private static final Random random = new Random(); private static final Random random = new Random();
public GoldPouchDrop(MythicLineConfig config) { public GoldPouchDrop(MythicLineConfig config) {
super(config.getLine(), config); super(config.getLine(), config);
min = config.getInteger("min", 1); min = config.getInteger("min", 1);
max = config.getInteger("max", 10); max = config.getInteger("max", 10);
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public LootBag get(DropMetadata metadata) { public LootBag get(DropMetadata metadata) {
LootBag loot = new LootBag(metadata); LootBag loot = new LootBag(metadata);
NBTItem nbt = NBTItem.get(new ConfigItem("MOB_GOLD_POUCH").build()); NBTItem nbt = NBTItem.get(new SimpleItemBuilder("MOB_GOLD_POUCH").build());
ItemStack[] content = new ItemStack[18]; ItemStack[] content = new ItemStack[18];
int money = random.nextInt(max - min + 1) + min; int money = random.nextInt(max - min + 1) + min;
for (int j = 0; j < 7 && money > 0; j++) { for (int j = 0; j < 7 && money > 0; j++) {
int a = j == 6 ? money : Math.max(1, (int) ((.12 + random.nextDouble() * .4) * (double) money)); int a = j == 6 ? money : Math.max(1, (int) ((.12 + random.nextDouble() * .4) * (double) money));
money -= a; money -= a;
if (a < 30 && random.nextDouble() < .3) { if (a < 30 && random.nextDouble() < .3) {
content[getAvailableSlot(content)] = new CurrencyItem("GOLD_COIN", 1, a).build(); content[getAvailableSlot(content)] = setAmount(new CurrencyItemBuilder("GOLD_COIN", 1).build(), a);
continue; continue;
} }
content[getAvailableSlot(content)] = new CurrencyItem("NOTE", a, 1).build(); content[getAvailableSlot(content)] = new CurrencyItemBuilder("NOTE", a).build();
} }
nbt.addTag(new ItemTag("RpgPouchSize", 18), new ItemTag("RpgPouchMob", true), new ItemTag("RpgPouchInventory", MMOCoreUtils.toBase64(content))); nbt.addTag(new ItemTag("RpgPouchSize", 18), new ItemTag("RpgPouchMob", true), new ItemTag("RpgPouchInventory", MMOCoreUtils.toBase64(content)));
loot.add(new ItemDrop(this.getLine(), (MythicLineConfig) this.getConfig(), new BukkitItemStack(nbt.toItem()))); loot.add(new ItemDrop(this.getLine(), this.getConfig(), new BukkitItemStack(nbt.toItem())));
return loot; return loot;
} }
private int getAvailableSlot(ItemStack[] content) { private ItemStack setAmount(ItemStack item, int amount) {
int slot; item.setAmount(amount);
while (content[slot = random.nextInt(content.length)] != null) return item;
if(content[slot].getType() == Material.AIR) break; }
return slot;
} private int getAvailableSlot(ItemStack[] content) {
int slot;
while (content[slot = random.nextInt(content.length)] != null)
if (content[slot].getType() == Material.AIR) break;
return slot;
}
} }

View File

@ -1,10 +1,10 @@
package net.Indyuce.mmocore.comp.mythicmobs.load; package net.Indyuce.mmocore.comp.mythicmobs.load;
import io.lumine.mythic.bukkit.events.MythicMobDeathEvent;
import io.lumine.mythic.lib.api.MMOLineConfig; import io.lumine.mythic.lib.api.MMOLineConfig;
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser; import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource; import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager; import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

View File

@ -1,57 +1,56 @@
package net.Indyuce.mmocore.comp.mythicmobs.load; package net.Indyuce.mmocore.comp.mythicmobs.load;
import io.lumine.mythic.bukkit.events.MythicMobDeathEvent;
import io.lumine.mythic.lib.api.MMOLineConfig;
import net.Indyuce.mmocore.api.quest.ObjectiveProgress;
import net.Indyuce.mmocore.api.quest.QuestProgress;
import net.Indyuce.mmocore.api.quest.objective.Objective;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent;
import net.Indyuce.mmocore.api.quest.ObjectiveProgress;
import net.Indyuce.mmocore.api.quest.QuestProgress;
import net.Indyuce.mmocore.api.quest.objective.Objective;
import io.lumine.mythic.lib.api.MMOLineConfig;
public class KillMythicFactionObjective extends Objective { public class KillMythicFactionObjective extends Objective {
private final String factionName; private final String factionName;
private final int required; private final int required;
public KillMythicFactionObjective(ConfigurationSection section, MMOLineConfig config) { public KillMythicFactionObjective(ConfigurationSection section, MMOLineConfig config) {
super(section); super(section);
config.validate("amount", "name"); config.validate("amount", "name");
factionName = config.getString("name"); factionName = config.getString("name");
required = config.getInt("amount"); required = config.getInt("amount");
} }
@Override @Override
public ObjectiveProgress newProgress(QuestProgress questProgress) { public ObjectiveProgress newProgress(QuestProgress questProgress) {
return new KillFactionProgress(questProgress, this); return new KillFactionProgress(questProgress, this);
} }
public class KillFactionProgress extends ObjectiveProgress implements Listener { public class KillFactionProgress extends ObjectiveProgress implements Listener {
private int count; private int count;
public KillFactionProgress(QuestProgress questProgress, Objective objective) { public KillFactionProgress(QuestProgress questProgress, Objective objective) {
super(questProgress, objective); super(questProgress, objective);
} }
@EventHandler @EventHandler
public void a(MythicMobDeathEvent event) { public void a(MythicMobDeathEvent event) {
if(!getQuestProgress().getPlayer().isOnline()) return; if (!getQuestProgress().getPlayer().isOnline()) return;
if (event.getKiller() instanceof Player if (event.getKiller() instanceof Player
&& event.getKiller().equals(getQuestProgress().getPlayer().getPlayer()) && event.getKiller().equals(getQuestProgress().getPlayer().getPlayer())
&& event.getMob().hasFaction() && event.getMob().getFaction().equals(factionName)) { && event.getMob().hasFaction() && event.getMob().getFaction().equals(factionName)) {
count++; count++;
getQuestProgress().getPlayer().getQuestData().updateBossBar(); getQuestProgress().getPlayer().getQuestData().updateBossBar();
if (count >= required) if (count >= required)
getQuestProgress().completeObjective(); getQuestProgress().completeObjective();
} }
} }
@Override @Override
public String formatLore(String lore) { public String formatLore(String lore) {
return lore.replace("{left}", "" + (required - count)); return lore.replace("{left}", "" + (required - count));
} }
} }
} }

View File

@ -1,10 +1,10 @@
package net.Indyuce.mmocore.comp.mythicmobs.load; package net.Indyuce.mmocore.comp.mythicmobs.load;
import io.lumine.mythic.bukkit.events.MythicMobDeathEvent;
import io.lumine.mythic.lib.api.MMOLineConfig; import io.lumine.mythic.lib.api.MMOLineConfig;
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser; import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource; import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager; import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

View File

@ -1,55 +1,54 @@
package net.Indyuce.mmocore.comp.mythicmobs.load; package net.Indyuce.mmocore.comp.mythicmobs.load;
import io.lumine.mythic.bukkit.events.MythicMobDeathEvent;
import io.lumine.mythic.lib.api.MMOLineConfig;
import net.Indyuce.mmocore.api.quest.ObjectiveProgress;
import net.Indyuce.mmocore.api.quest.QuestProgress;
import net.Indyuce.mmocore.api.quest.objective.Objective;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent;
import net.Indyuce.mmocore.api.quest.ObjectiveProgress;
import net.Indyuce.mmocore.api.quest.QuestProgress;
import net.Indyuce.mmocore.api.quest.objective.Objective;
import io.lumine.mythic.lib.api.MMOLineConfig;
public class KillMythicMobObjective extends Objective { public class KillMythicMobObjective extends Objective {
private final String internalName; private final String internalName;
private final int required; private final int required;
public KillMythicMobObjective(ConfigurationSection section, MMOLineConfig config) { public KillMythicMobObjective(ConfigurationSection section, MMOLineConfig config) {
super(section); super(section);
config.validate("amount", "name"); config.validate("amount", "name");
internalName = config.getString("name"); internalName = config.getString("name");
required = config.getInt("amount"); required = config.getInt("amount");
} }
@Override @Override
public ObjectiveProgress newProgress(QuestProgress questProgress) { public ObjectiveProgress newProgress(QuestProgress questProgress) {
return new KillMobProgress(questProgress, this); return new KillMobProgress(questProgress, this);
} }
public class KillMobProgress extends ObjectiveProgress implements Listener { public class KillMobProgress extends ObjectiveProgress implements Listener {
private int count; private int count;
public KillMobProgress(QuestProgress questProgress, Objective objective) { public KillMobProgress(QuestProgress questProgress, Objective objective) {
super(questProgress, objective); super(questProgress, objective);
} }
@EventHandler @EventHandler
public void a(MythicMobDeathEvent event) { public void a(MythicMobDeathEvent event) {
if(!getQuestProgress().getPlayer().isOnline()) return; if (!getQuestProgress().getPlayer().isOnline()) return;
if (event.getKiller() instanceof Player && event.getKiller().equals(getQuestProgress().getPlayer().getPlayer()) && event.getMob().getType().getInternalName().equals(internalName)) { if (event.getKiller() instanceof Player && event.getKiller().equals(getQuestProgress().getPlayer().getPlayer()) && event.getMob().getType().getInternalName().equals(internalName)) {
count++; count++;
getQuestProgress().getPlayer().getQuestData().updateBossBar(); getQuestProgress().getPlayer().getQuestData().updateBossBar();
if (count >= required) if (count >= required)
getQuestProgress().completeObjective(); getQuestProgress().completeObjective();
} }
} }
@Override @Override
public String formatLore(String lore) { public String formatLore(String lore) {
return lore.replace("{left}", "" + (required - count)); return lore.replace("{left}", "" + (required - count));
} }
} }
} }

View File

@ -0,0 +1,42 @@
package net.Indyuce.mmocore.comp.mythicmobs.load;
import io.lumine.mythic.api.drops.DropMetadata;
import io.lumine.mythic.api.drops.IItemDrop;
import io.lumine.mythic.bukkit.BukkitAdapter;
import io.lumine.mythic.bukkit.MythicBukkit;
import io.lumine.mythic.core.drops.Drop;
import io.lumine.mythic.core.drops.DropMetadataImpl;
import io.lumine.mythic.core.drops.DropTable;
import io.lumine.mythic.core.drops.LootBag;
import io.lumine.mythic.lib.api.MMOLineConfig;
import net.Indyuce.mmocore.loot.LootBuilder;
import net.Indyuce.mmocore.loot.droptable.dropitem.DropItem;
import java.util.NoSuchElementException;
public class MMDropTableDropItem extends DropItem {
private final DropTable dropTable;
private static final DropMetadata DROP_METADATA = new DropMetadataImpl(null, null);
public MMDropTableDropItem(MMOLineConfig config) {
super(config);
config.validate("id");
String id = config.getString("id");
try {
dropTable = MythicBukkit.inst().getDropManager().getDropTable(id).orElse(null);
} catch (NoSuchElementException exception) {
throw new IllegalArgumentException("Could not find MM drop table with ID '" + id + "'");
}
}
@Override
public void collect(LootBuilder builder) {
LootBag lootBag = dropTable.generate(DROP_METADATA);
for (Drop type : lootBag.getDrops())
if (type instanceof IItemDrop)
builder.addLoot(BukkitAdapter.adapt(((IItemDrop) type).getDrop(DROP_METADATA, 1)));
}
}

View File

@ -1,18 +1,21 @@
package net.Indyuce.mmocore.comp.mythicmobs.load; package net.Indyuce.mmocore.comp.mythicmobs.load;
import io.lumine.mythic.api.adapters.AbstractPlayer;
import io.lumine.mythic.api.mobs.GenericCaster;
import io.lumine.mythic.api.skills.Skill;
import io.lumine.mythic.api.skills.SkillCaster;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillTrigger;
import io.lumine.mythic.bukkit.BukkitAdapter;
import io.lumine.mythic.bukkit.MythicBukkit;
import io.lumine.mythic.core.skills.SkillMetadataImpl;
import io.lumine.mythic.core.skills.SkillTriggers;
import io.lumine.mythic.lib.api.MMOLineConfig; import io.lumine.mythic.lib.api.MMOLineConfig;
import io.lumine.xikage.mythicmobs.MythicMobs;
import io.lumine.xikage.mythicmobs.adapters.AbstractPlayer;
import io.lumine.xikage.mythicmobs.adapters.bukkit.BukkitAdapter;
import io.lumine.xikage.mythicmobs.mobs.GenericCaster;
import io.lumine.xikage.mythicmobs.skills.Skill;
import io.lumine.xikage.mythicmobs.skills.SkillCaster;
import io.lumine.xikage.mythicmobs.skills.SkillMetadata;
import io.lumine.xikage.mythicmobs.skills.SkillTrigger;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.quest.trigger.Trigger; import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Optional; import java.util.Optional;
@ -24,7 +27,7 @@ public class MythicSkillTrigger extends Trigger {
config.validate("id"); config.validate("id");
String id = config.getString("id"); String id = config.getString("id");
Optional<io.lumine.xikage.mythicmobs.skills.Skill> opt = MythicMobs.inst().getSkillManager().getSkill(id); Optional<io.lumine.mythic.api.skills.Skill> opt = MythicBukkit.inst().getSkillManager().getSkill(id);
Validate.isTrue(opt.isPresent(), "Could not find MM skill " + id); Validate.isTrue(opt.isPresent(), "Could not find MM skill " + id);
skill = opt.get(); skill = opt.get();
} }
@ -35,8 +38,8 @@ public class MythicSkillTrigger extends Trigger {
AbstractPlayer trigger = BukkitAdapter.adapt(player.getPlayer()); AbstractPlayer trigger = BukkitAdapter.adapt(player.getPlayer());
SkillCaster caster = new GenericCaster(trigger); SkillCaster caster = new GenericCaster(trigger);
SkillMetadata skillMeta = new SkillMetadata(SkillTrigger.API, caster, trigger, BukkitAdapter.adapt(player.getPlayer().getLocation()), new HashSet<>(), null, 1); SkillMetadata skillMeta = new SkillMetadataImpl(SkillTriggers.API, caster, trigger, BukkitAdapter.adapt(player.getPlayer().getLocation()), new HashSet<>(), null, 1);
if (skill.usable(skillMeta, SkillTrigger.API)) if (skill.isUsable(skillMeta))
skill.execute(skillMeta); skill.execute(skillMeta);
} }
} }

View File

@ -1,19 +0,0 @@
package net.Indyuce.mmocore.experience;
public class ExperienceInfo {
private final Profession profess;
private final int value;
public ExperienceInfo(int value, Profession profess) {
this.value = value;
this.profess = profess;
}
public Profession getProfession() {
return profess;
}
public int getValue() {
return value;
}
}

View File

@ -12,7 +12,7 @@ import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.stats.StatType; import net.Indyuce.mmocore.api.player.stats.StatType;
import net.Indyuce.mmocore.api.util.MMOCoreUtils; import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import net.Indyuce.mmocore.api.util.math.particle.SmallParticleEffect; import net.Indyuce.mmocore.loot.chest.particle.SmallParticleEffect;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -5,8 +5,8 @@ import io.lumine.mythic.lib.api.util.PostLoadObject;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.util.math.formula.LinearValue; import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
import net.Indyuce.mmocore.experience.droptable.ExperienceTable; import net.Indyuce.mmocore.experience.droptable.ExperienceTable;
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser; import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
import net.Indyuce.mmocore.experience.provider.ProfessionExperienceDispenser; import net.Indyuce.mmocore.experience.dispenser.ProfessionExperienceDispenser;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;

View File

@ -1,4 +1,4 @@
package net.Indyuce.mmocore.experience.provider; package net.Indyuce.mmocore.experience.dispenser;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
@ -7,18 +7,18 @@ import net.Indyuce.mmocore.experience.EXPSource;
import org.bukkit.Location; import org.bukkit.Location;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class MainExperienceDispenser implements ExperienceDispenser { public class ClassExperienceDispenser implements ExperienceDispenser {
private final PlayerClass profess; private final PlayerClass profess;
public MainExperienceDispenser(PlayerClass profess) { public ClassExperienceDispenser(PlayerClass profess) {
this.profess = profess; this.profess = profess;
} }
@Override @Override
public void giveExperience(PlayerData playerData, double experience, @Nullable Location hologramLocation) { public void giveExperience(PlayerData playerData, double experience, @Nullable Location hologramLocation, EXPSource source) {
hologramLocation = !MMOCore.plugin.getConfig().getBoolean("display-main-class-exp-holograms") ? null hologramLocation = !MMOCore.plugin.getConfig().getBoolean("display-main-class-exp-holograms") ? null
: hologramLocation == null ? getPlayerLocation(playerData) : hologramLocation; : hologramLocation == null ? getPlayerLocation(playerData) : hologramLocation;
playerData.giveExperience(experience, EXPSource.SOURCE, hologramLocation, true); playerData.giveExperience(experience, source, hologramLocation, true);
} }
@Override @Override

View File

@ -1,12 +1,16 @@
package net.Indyuce.mmocore.experience.provider; package net.Indyuce.mmocore.experience.dispenser;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import net.Indyuce.mmocore.experience.EXPSource;
import org.bukkit.Location; import org.bukkit.Location;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
/** /**
* Used to differenciate between the main class experience * Used to differenciate between the main class experience and
* and experience given in a specific profession * experience given in a specific profession. Also being used to
* monitor EXP holograms.
*/ */
public interface ExperienceDispenser { public interface ExperienceDispenser {
@ -17,10 +21,12 @@ public interface ExperienceDispenser {
* @param experience Experience gained. Note that it is a double * @param experience Experience gained. Note that it is a double
* because it gets converted to an integer at * because it gets converted to an integer at
* the very last moment in MMOCore * the very last moment in MMOCore
* @param hologramLocation Location of displayed hologram, nothing * @param hologramLocation Location of displayed hologram. When set to null
* is displayed if it's null * and if exp holograms are enabled it will take the
* player's location instead.
* @param source Why the EXP was gained
*/ */
void giveExperience(PlayerData playerData, double experience, @Nullable Location hologramLocation); void giveExperience(PlayerData playerData, double experience, @Nullable Location hologramLocation, @NotNull EXPSource source);
/** /**
* Experience sources handle both CLASS experience sources and PROFESSION * Experience sources handle both CLASS experience sources and PROFESSION
@ -32,7 +38,8 @@ public interface ExperienceDispenser {
*/ */
boolean shouldHandle(PlayerData playerData); boolean shouldHandle(PlayerData playerData);
@Nullable
default Location getPlayerLocation(PlayerData player) { default Location getPlayerLocation(PlayerData player) {
return player.isOnline() ? player.getPlayer().getLocation() : null; return player.isOnline() ? MMOCoreUtils.getCenterLocation(player.getPlayer()) : null;
} }
} }

View File

@ -1,4 +1,4 @@
package net.Indyuce.mmocore.experience.provider; package net.Indyuce.mmocore.experience.dispenser;
import net.Indyuce.mmocore.experience.EXPSource; import net.Indyuce.mmocore.experience.EXPSource;
import net.Indyuce.mmocore.experience.Profession; import net.Indyuce.mmocore.experience.Profession;
@ -14,7 +14,7 @@ public class ProfessionExperienceDispenser implements ExperienceDispenser {
} }
@Override @Override
public void giveExperience(PlayerData playerData, double experience, @Nullable Location hologramLocation) { public void giveExperience(PlayerData playerData, double experience, @Nullable Location hologramLocation, EXPSource source) {
hologramLocation = !profession.getOption(Profession.ProfessionOption.EXP_HOLOGRAMS) ? null hologramLocation = !profession.getOption(Profession.ProfessionOption.EXP_HOLOGRAMS) ? null
: hologramLocation == null ? getPlayerLocation(playerData) : hologramLocation; : hologramLocation == null ? getPlayerLocation(playerData) : hologramLocation;
playerData.getCollectionSkills().giveExperience(profession, experience, EXPSource.SOURCE, hologramLocation); playerData.getCollectionSkills().giveExperience(profession, experience, EXPSource.SOURCE, hologramLocation);

View File

@ -0,0 +1,22 @@
package net.Indyuce.mmocore.experience.dispenser;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.experience.EXPSource;
import org.bukkit.Location;
import org.jetbrains.annotations.Nullable;
public class SimpleExperienceDispenser 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;
playerData.giveExperience(experience, source, hologramLocation, true);
}
@Override
public boolean shouldHandle(PlayerData playerData) {
return true;
}
}

View File

@ -2,7 +2,8 @@ package net.Indyuce.mmocore.experience.source;
import io.lumine.mythic.lib.api.MMOLineConfig; import io.lumine.mythic.lib.api.MMOLineConfig;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser; import net.Indyuce.mmocore.experience.EXPSource;
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
import net.Indyuce.mmocore.experience.source.type.ExperienceSource; import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager; import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
@ -167,7 +168,7 @@ public class BrewPotionExperienceSource extends ExperienceSource<PotionMeta> {
*/ */
// exp += getTotal(mapEffectDurations()); // exp += getTotal(mapEffectDurations());
getDispenser().giveExperience(PlayerData.get(player), (int) exp * multiplier, null); getDispenser().giveExperience(PlayerData.get(player), (int) exp * multiplier, null, EXPSource.SOURCE);
} }
} }
} }

View File

@ -3,7 +3,7 @@ package net.Indyuce.mmocore.experience.source;
import io.lumine.mythic.lib.api.MMOLineConfig; import io.lumine.mythic.lib.api.MMOLineConfig;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser; import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource; import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager; import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;

View File

@ -4,7 +4,8 @@ import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.MMOLineConfig; import io.lumine.mythic.lib.api.MMOLineConfig;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser; import net.Indyuce.mmocore.experience.EXPSource;
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
import net.Indyuce.mmocore.experience.source.type.ExperienceSource; import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager; import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
@ -59,7 +60,7 @@ public class EnchantItemExperienceSource extends ExperienceSource<Void> {
double exp = 0; double exp = 0;
for (Entry<Enchantment, Integer> entry : applicableEnchants.entrySet()) for (Entry<Enchantment, Integer> entry : applicableEnchants.entrySet())
exp += MMOCore.plugin.enchantManager.getBaseExperience(entry.getKey()) * entry.getValue(); exp += MMOCore.plugin.enchantManager.getBaseExperience(entry.getKey()) * entry.getValue();
getDispenser().giveExperience(player, (int) exp, event.getEnchantBlock().getLocation()); getDispenser().giveExperience(player, (int) exp, event.getEnchantBlock().getLocation(), EXPSource.SOURCE);
} }
} }
}; };

View File

@ -1,7 +1,7 @@
package net.Indyuce.mmocore.experience.source; package net.Indyuce.mmocore.experience.source;
import io.lumine.mythic.lib.api.MMOLineConfig; import io.lumine.mythic.lib.api.MMOLineConfig;
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser; import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource; import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager; import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;

View File

@ -4,7 +4,8 @@ import io.lumine.mythic.lib.api.MMOLineConfig;
import io.lumine.mythic.lib.api.event.PlayerKillEntityEvent; import io.lumine.mythic.lib.api.event.PlayerKillEntityEvent;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser; import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource; import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager; import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -34,7 +35,7 @@ public class KillMobExperienceSource extends SpecificExperienceSource<Entity> {
for (KillMobExperienceSource source : getSources()) for (KillMobExperienceSource source : getSources())
if (source.matches(data, event.getTarget())) if (source.matches(data, event.getTarget()))
source.giveExperience(data, 1, event.getTarget().getLocation()); source.giveExperience(data, 1, MMOCoreUtils.getCenterLocation(event.getTarget()));
} }
}, 2); }, 2);
} }

View File

@ -3,7 +3,7 @@ package net.Indyuce.mmocore.experience.source;
import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.MMOLineConfig; import io.lumine.mythic.lib.api.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser; import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource; import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager; import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
import org.bukkit.GameMode; import org.bukkit.GameMode;

View File

@ -1,7 +1,7 @@
package net.Indyuce.mmocore.experience.source; package net.Indyuce.mmocore.experience.source;
import io.lumine.mythic.lib.api.MMOLineConfig; import io.lumine.mythic.lib.api.MMOLineConfig;
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser; import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource; import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager; import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;

View File

@ -2,7 +2,8 @@ package net.Indyuce.mmocore.experience.source;
import io.lumine.mythic.lib.api.MMOLineConfig; import io.lumine.mythic.lib.api.MMOLineConfig;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser; import net.Indyuce.mmocore.experience.EXPSource;
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
import net.Indyuce.mmocore.experience.source.type.ExperienceSource; import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager; import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
@ -74,7 +75,7 @@ public class RepairItemExperienceSource extends ExperienceSource<ItemStack> {
*/ */
double exp = MMOCore.plugin.smithingManager.getBaseExperience(item.getType()) double exp = MMOCore.plugin.smithingManager.getBaseExperience(item.getType())
* Math.max(0, ((Damageable) old.getItemMeta()).getDamage() - ((Damageable) item.getItemMeta()).getDamage()) / 100; * Math.max(0, ((Damageable) old.getItemMeta()).getDamage() - ((Damageable) item.getItemMeta()).getDamage()) / 100;
getDispenser().giveExperience(data, (int) exp, null); getDispenser().giveExperience(data, (int) exp, null, EXPSource.SOURCE);
} }
} }
} }

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmocore.experience.source;
import io.lumine.mythic.lib.api.MMOLineConfig; import io.lumine.mythic.lib.api.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser; import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource; import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager; import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
import org.bukkit.Location; import org.bukkit.Location;

View File

@ -1,7 +1,7 @@
package net.Indyuce.mmocore.experience.source.type; package net.Indyuce.mmocore.experience.source.type;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser; import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager; import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
public abstract class ExperienceSource<T> { public abstract class ExperienceSource<T> {

View File

@ -1,7 +1,8 @@
package net.Indyuce.mmocore.experience.source.type; package net.Indyuce.mmocore.experience.source.type;
import io.lumine.mythic.lib.api.MMOLineConfig; import io.lumine.mythic.lib.api.MMOLineConfig;
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser; import net.Indyuce.mmocore.experience.EXPSource;
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.util.math.formula.RandomAmount; import net.Indyuce.mmocore.api.util.math.formula.RandomAmount;
import org.bukkit.Location; import org.bukkit.Location;
@ -41,6 +42,6 @@ public abstract class SpecificExperienceSource<T> extends ExperienceSource<T> {
* @param hologramLocation Location used to display the exp hologram * @param hologramLocation Location used to display the exp hologram
*/ */
public void giveExperience(PlayerData player, double multiplier, @Nullable Location hologramLocation) { public void giveExperience(PlayerData player, double multiplier, @Nullable Location hologramLocation) {
getDispenser().giveExperience(player, rollAmount() * multiplier, hologramLocation); getDispenser().giveExperience(player, rollAmount() * multiplier, hologramLocation, EXPSource.SOURCE);
} }
} }

View File

@ -200,13 +200,15 @@ public class PlayerStats extends EditableInventory {
@Override @Override
public ItemStack display(GeneratedInventory inv, int n) { public ItemStack display(GeneratedInventory inv, int n) {
ItemStack item = super.display(inv, n); ItemStack disp = super.display(inv, n);
if (item.getType() == VersionMaterial.PLAYER_HEAD.toMaterial()) { if (disp.getType() == VersionMaterial.PLAYER_HEAD.toMaterial()) {
SkullMeta meta = (SkullMeta) item.getItemMeta(); SkullMeta meta = (SkullMeta) disp.getItemMeta();
meta.setOwningPlayer(inv.getPlayer()); inv.dynamicallyUpdateItem(this, n, disp, current -> {
item.setItemMeta(meta); meta.setOwningPlayer(inv.getPlayer());
current.setItemMeta(meta);
});
} }
return item; return disp;
} }
@Override @Override

View File

@ -3,7 +3,6 @@ package net.Indyuce.mmocore.gui;
import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.Waypoint;
import net.Indyuce.mmocore.api.player.PlayerActivity; import net.Indyuce.mmocore.api.player.PlayerActivity;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.gui.api.EditableInventory; import net.Indyuce.mmocore.gui.api.EditableInventory;
@ -11,6 +10,9 @@ import net.Indyuce.mmocore.gui.api.GeneratedInventory;
import net.Indyuce.mmocore.gui.api.item.InventoryItem; import net.Indyuce.mmocore.gui.api.item.InventoryItem;
import net.Indyuce.mmocore.gui.api.item.Placeholders; import net.Indyuce.mmocore.gui.api.item.Placeholders;
import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem; import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem;
import net.Indyuce.mmocore.waypoint.CostType;
import net.Indyuce.mmocore.waypoint.Waypoint;
import net.Indyuce.mmocore.waypoint.WaypointOption;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -19,177 +21,208 @@ import org.bukkit.inventory.ItemStack;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
public class WaypointViewer extends EditableInventory { public class WaypointViewer extends EditableInventory {
public WaypointViewer() { public WaypointViewer() {
super("waypoints"); super("waypoints");
} }
@Override @Override
public InventoryItem load(String function, ConfigurationSection config) { public InventoryItem load(String function, ConfigurationSection config) {
if (function.equals("waypoint")) if (function.equals("waypoint"))
return new WaypointItem(config); return new WaypointItem(config);
if (function.equals("previous")) if (function.equals("previous"))
return new SimplePlaceholderItem<WaypointViewerInventory>(config) { return new SimplePlaceholderItem<WaypointViewerInventory>(config) {
@Override @Override
public boolean canDisplay(WaypointViewerInventory inv) { public boolean canDisplay(WaypointViewerInventory inv) {
return inv.page > 0; return inv.page > 0;
} }
}; };
if (function.equals("next")) if (function.equals("next"))
return new SimplePlaceholderItem<WaypointViewerInventory>(config) { return new SimplePlaceholderItem<WaypointViewerInventory>(config) {
@Override @Override
public boolean canDisplay(WaypointViewerInventory inv) { public boolean canDisplay(WaypointViewerInventory inv) {
return inv.getEditable().getByFunction("waypoint").getSlots().size() * (inv.page + 1) < inv.waypoints.size(); return inv.getEditable().getByFunction("waypoint").getSlots().size() * (inv.page + 1) < inv.waypoints.size();
} }
}; };
return new SimplePlaceholderItem(config); return new SimplePlaceholderItem(config);
} }
public GeneratedInventory newInventory(PlayerData data) { public GeneratedInventory newInventory(PlayerData data) {
return newInventory(data, null); return newInventory(data, null);
} }
public GeneratedInventory newInventory(PlayerData data, Waypoint waypoint) { public GeneratedInventory newInventory(PlayerData data, Waypoint waypoint) {
return new WaypointViewerInventory(data, this, waypoint); return new WaypointViewerInventory(data, this, waypoint);
} }
public class WaypointDisplayItem extends InventoryItem<WaypointViewerInventory> { public class WaypointItem extends SimplePlaceholderItem<WaypointViewerInventory> {
private final Material notReady; private final SimplePlaceholderItem noWaypoint, locked;
private final WaypointItemHandler availWaypoint, notLinked, notDynamic, noStellium;
public WaypointDisplayItem(ConfigurationSection config) { public WaypointItem(ConfigurationSection config) {
super(config); super(Material.BARRIER, config);
Validate.isTrue(config.contains("not-ready"), "Could not read 'not-ready' material"); Validate.notNull(config.getConfigurationSection("no-waypoint"), "Could not load 'no-waypoint' config");
notReady = Material.valueOf(config.getString("not-ready")); Validate.notNull(config.getConfigurationSection("locked"), "Could not load 'locked' config");
} Validate.notNull(config.getConfigurationSection("not-a-destination"), "Could not load 'not-a-destination' config");
Validate.notNull(config.getConfigurationSection("not-dynamic"), "Could not load 'not-dynamic' config");
Validate.notNull(config.getConfigurationSection("not-enough-stellium"), "Could not load 'not-enough-stellium' config");
Validate.notNull(config.getConfigurationSection("display"), "Could not load 'display' config");
@Override noWaypoint = new SimplePlaceholderItem(config.getConfigurationSection("no-waypoint"));
public ItemStack display(WaypointViewerInventory inv, int n) { locked = new SimplePlaceholderItem(config.getConfigurationSection("locked"));
ItemStack disp = super.display(inv, n); notLinked = new WaypointItemHandler(config.getConfigurationSection("not-a-destination"));
notDynamic = new WaypointItemHandler(config.getConfigurationSection("not-dynamic"));
noStellium = new WaypointItemHandler(config.getConfigurationSection("not-enough-stellium"));
availWaypoint = new WaypointItemHandler(config.getConfigurationSection("display"));
}
Waypoint waypoint = inv.waypoints.get(inv.page * inv.getEditable().getByFunction("waypoint").getSlots().size() + n); @Override
if (inv.getPlayerData().getStellium() < waypoint.getStelliumCost() || (inv.current == null && !waypoint.isDynamic())) public boolean hasDifferentDisplay() {
disp.setType(notReady); return true;
}
return NBTItem.get(disp).addTag(new ItemTag("waypointId", waypoint.getId())).toItem(); @Override
} public ItemStack display(WaypointViewerInventory inv, int n) {
@Override int index = inv.page * inv.getEditable().getByFunction("waypoint").getSlots().size() + n;
public Placeholders getPlaceholders(WaypointViewerInventory inv, int n) { if (index >= inv.waypoints.size())
Placeholders holders = new Placeholders(); return noWaypoint.display(inv, n);
Waypoint waypoint = inv.waypoints.get(inv.page * inv.getByFunction("waypoint").getSlots().size() + n); // Locked waypoint?
holders.register("name", waypoint.getName()); Waypoint waypoint = inv.waypoints.get(index);
holders.register("stellium", decimal.format(waypoint.getStelliumCost())); if (!inv.getPlayerData().hasWaypoint(waypoint))
return locked.display(inv, n);
return holders; // Waypoints are not linked
} if (inv.current != null && !inv.current.hasDestination(waypoint))
} return notLinked.display(inv, n);
public class WaypointItem extends SimplePlaceholderItem<WaypointViewerInventory> { // Not dynamic waypoint
private final SimplePlaceholderItem noWaypoint, locked; if (inv.current == null && !waypoint.hasOption(WaypointOption.DYNAMIC))
private final WaypointDisplayItem availWaypoint; return notDynamic.display(inv, n);
public WaypointItem(ConfigurationSection config) { // Stellium cost
super(Material.BARRIER, config); if (waypoint.getCost(inv.current == null ? CostType.DYNAMIC_USE : CostType.NORMAL_USE) > inv.getPlayerData().getStellium())
return noStellium.display(inv, n);
Validate.notNull(config.getConfigurationSection("no-waypoint"), "Could not load 'no-waypoint' config"); return availWaypoint.display(inv, n);
Validate.notNull(config.getConfigurationSection("locked"), "Could not load 'locked' config"); }
Validate.notNull(config.getConfigurationSection("display"), "Could not load 'display' config"); }
noWaypoint = new SimplePlaceholderItem(config.getConfigurationSection("no-waypoint")); public class WaypointItemHandler extends InventoryItem<WaypointViewerInventory> {
locked = new SimplePlaceholderItem(config.getConfigurationSection("locked")); public WaypointItemHandler(ConfigurationSection config) {
availWaypoint = new WaypointDisplayItem(config.getConfigurationSection("display")); super(config);
} }
@Override @Override
public boolean hasDifferentDisplay() { public ItemStack display(WaypointViewerInventory inv, int n) {
return true; ItemStack disp = super.display(inv, n);
}
@Override // If a player can teleport to another waypoint given his location
public ItemStack display(WaypointViewerInventory inv, int n) { Waypoint waypoint = inv.waypoints.get(inv.page * inv.getEditable().getByFunction("waypoint").getSlots().size() + n);
return NBTItem.get(disp).addTag(new ItemTag("waypointId", waypoint.getId())).toItem();
}
int index = inv.page * inv.getEditable().getByFunction("waypoint").getSlots().size() + n; @Override
if (index >= inv.waypoints.size()) public Placeholders getPlaceholders(WaypointViewerInventory inv, int n) {
return noWaypoint.display(inv, n); Placeholders holders = new Placeholders();
Waypoint waypoint = inv.waypoints.get(index); Waypoint waypoint = inv.waypoints.get(inv.page * inv.getByFunction("waypoint").getSlots().size() + n);
return inv.getPlayerData().hasWaypoint(waypoint) ? availWaypoint.display(inv, n) : locked.display(inv); holders.register("name", waypoint.getName());
} holders.register("current_cost", decimal.format(waypoint.getCost(inv.waypointCostType)));
} holders.register("normal_cost", decimal.format(waypoint.getCost(CostType.NORMAL_USE)));
holders.register("dynamic_cost", decimal.format(waypoint.getCost(CostType.DYNAMIC_USE)));
public class WaypointViewerInventory extends GeneratedInventory { return holders;
private final List<Waypoint> waypoints = new ArrayList<>(MMOCore.plugin.waypointManager.getAll()); }
private final Waypoint current; }
private int page; public class WaypointViewerInventory extends GeneratedInventory {
private final List<Waypoint> waypoints = new ArrayList<>(MMOCore.plugin.waypointManager.getAll());
private final Waypoint current;
private final CostType waypointCostType;
public WaypointViewerInventory(PlayerData playerData, EditableInventory editable, Waypoint current) { private int page;
super(playerData, editable);
this.current = current; public WaypointViewerInventory(PlayerData playerData, EditableInventory editable, Waypoint current) {
} super(playerData, editable);
@Override this.current = current;
public String calculateName() { this.waypointCostType = current == null ? CostType.DYNAMIC_USE : CostType.NORMAL_USE;
return getName(); }
}
@Override @Override
public void whenClicked(InventoryClickEvent event, InventoryItem item) { public String calculateName() {
if (item.getFunction().equals("next")) { return getName();
page++; }
open();
return;
}
if (item.getFunction().equals("previous")) { @Override
page--; public void whenClicked(InventoryClickEvent event, InventoryItem item) {
open(); if (item.getFunction().equals("next")) {
return; page++;
} open();
return;
}
if (item.getFunction().equals("waypoint")) { if (item.getFunction().equals("previous")) {
String tag = NBTItem.get(event.getCurrentItem()).getString("waypointId"); page--;
if (tag.equals("")) open();
return; return;
}
Waypoint waypoint = MMOCore.plugin.waypointManager.get(tag); if (item.getFunction().equals("waypoint")) {
if (!playerData.hasWaypoint(waypoint)) { String tag = NBTItem.get(event.getCurrentItem()).getString("waypointId");
MMOCore.plugin.configManager.getSimpleMessage("not-unlocked-waypoint").send(player); if (tag.equals(""))
return; return;
}
if (waypoint.equals(current)) { // Locked waypoint?
MMOCore.plugin.configManager.getSimpleMessage("standing-on-waypoint").send(player); Waypoint waypoint = MMOCore.plugin.waypointManager.get(tag);
return; if (!playerData.hasWaypoint(waypoint)) {
} MMOCore.plugin.configManager.getSimpleMessage("not-unlocked-waypoint").send(player);
return;
}
if (current == null && !waypoint.isDynamic()) { // Cannot teleport to current waypoint
MMOCore.plugin.configManager.getSimpleMessage("not-dynamic-waypoint").send(player); if (waypoint.equals(current)) {
return; MMOCore.plugin.configManager.getSimpleMessage("standing-on-waypoint").send(player);
} return;
}
double left = waypoint.getStelliumCost() - playerData.getStellium(); // Waypoint does not have target as destination
if (left > 0) { if (current != null && !current.hasDestination(waypoint)) {
MMOCore.plugin.configManager.getSimpleMessage("not-enough-stellium", "more", decimal.format(left)).send(player); MMOCore.plugin.configManager.getSimpleMessage("cannot-teleport-to").send(player);
return; return;
} }
if (playerData.getActivityTimeOut(PlayerActivity.USE_WAYPOINT) > 0) // Not dynamic waypoint
return; if (current == null && !waypoint.hasOption(WaypointOption.DYNAMIC)) {
MMOCore.plugin.configManager.getSimpleMessage("not-dynamic-waypoint").send(player);
return;
}
player.closeInventory(); // Stellium cost
playerData.warp(waypoint); CostType costType = current == null ? CostType.DYNAMIC_USE : CostType.NORMAL_USE;
} double left = waypoint.getCost(costType) - playerData.getStellium();
} if (left > 0) {
} MMOCore.plugin.configManager.getSimpleMessage("not-enough-stellium", "more", decimal.format(left)).send(player);
return;
}
if (playerData.getActivityTimeOut(PlayerActivity.USE_WAYPOINT) > 0)
return;
player.closeInventory();
playerData.warp(waypoint, costType);
}
}
}
} }

View File

@ -1,95 +1,112 @@
package net.Indyuce.mmocore.gui.api; package net.Indyuce.mmocore.gui.api;
import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.MythicLib;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.gui.api.item.InventoryItem; import net.Indyuce.mmocore.gui.api.item.InventoryItem;
import net.Indyuce.mmocore.gui.api.item.TriggerItem; import net.Indyuce.mmocore.gui.api.item.TriggerItem;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.Consumer;
public abstract class GeneratedInventory extends PluginInventory { public abstract class GeneratedInventory extends PluginInventory {
private final EditableInventory editable; private final EditableInventory editable;
private final List<InventoryItem> loaded = new ArrayList<>(); private final List<InventoryItem> loaded = new ArrayList<>();
public GeneratedInventory(PlayerData playerData, EditableInventory editable) { private Inventory open;
super(playerData);
this.editable = editable; public GeneratedInventory(PlayerData playerData, EditableInventory editable) {
} super(playerData);
public List<InventoryItem> getLoaded() { this.editable = editable;
return loaded; }
}
public EditableInventory getEditable() { public List<InventoryItem> getLoaded() {
return editable; return loaded;
} }
public InventoryItem getByFunction(String function) { public EditableInventory getEditable() {
for (InventoryItem item : loaded) return editable;
if (item.getFunction().equals(function)) }
return item;
return null;
}
public InventoryItem getBySlot(int slot) { public InventoryItem getByFunction(String function) {
for (InventoryItem item : loaded) for (InventoryItem item : loaded)
if (item.getSlots().contains(slot)) if (item.getFunction().equals(function))
return item; return item;
return null; return null;
} }
/** public InventoryItem getBySlot(int slot) {
* This method must use an ordered collection because for (InventoryItem item : loaded)
* of GUI items overriding possibilities. Hence the use if (item.getSlots().contains(slot))
* of an array list instead of a set return item;
*/ return null;
public void addLoaded(InventoryItem item) { }
loaded.add(0, item);
}
@Override /**
public Inventory getInventory() { * This method must use an ordered collection because
Inventory inv = Bukkit.createInventory(this, editable.getSlots(), MythicLib.plugin.parseColors(calculateName())); * of GUI items overriding possibilities. Hence the use
* of an array list instead of a set
*/
public void addLoaded(InventoryItem item) {
loaded.add(0, item);
}
for (InventoryItem item : editable.getItems()) @Override
if (item.canDisplay(this)) public Inventory getInventory() {
item.setDisplayed(inv, this); Inventory inv = Bukkit.createInventory(this, editable.getSlots(), MythicLib.plugin.parseColors(calculateName()));
return inv; for (InventoryItem item : editable.getItems())
} if (item.canDisplay(this))
item.setDisplayed(inv, this);
public void open() { return inv;
}
/* public void open() {
* Very important, in order to prevent ghost items, the loaded items map
* must be cleared when the inventory is updated or open at least twice
*/
loaded.clear();
getPlayer().openInventory(getInventory()); /*
} * Very important, in order to prevent ghost items, the loaded items map
* must be cleared when the inventory is updated or open at least twice
*/
loaded.clear();
public void whenClicked(InventoryClickEvent event) { getPlayer().openInventory(open = getInventory());
event.setCancelled(true); }
if (event.getClickedInventory() != null && event.getClickedInventory().equals(event.getInventory())) { /**
InventoryItem item = getBySlot(event.getSlot()); * @deprecated Not a fan of that implementation.
if (item == null) * Better work with {@link InventoryItem#setDisplayed(Inventory, GeneratedInventory)}
return; */
@Deprecated
public void dynamicallyUpdateItem(InventoryItem<?> item, int n, ItemStack placed, Consumer<ItemStack> update) {
Bukkit.getScheduler().runTaskAsynchronously(MMOCore.plugin, () -> {
update.accept(placed);
open.setItem(item.getSlots().get(n), placed);
});
}
if (item instanceof TriggerItem) public void whenClicked(InventoryClickEvent event) {
((TriggerItem) item).getTrigger().apply(getPlayerData()); event.setCancelled(true);
else
whenClicked(event, item);
}
}
public abstract String calculateName(); if (event.getClickedInventory() != null && event.getClickedInventory().equals(event.getInventory())) {
InventoryItem item = getBySlot(event.getSlot());
if (item == null)
return;
public abstract void whenClicked(InventoryClickEvent event, InventoryItem item); if (item instanceof TriggerItem)
((TriggerItem) item).getTrigger().apply(getPlayerData());
else
whenClicked(event, item);
}
}
public abstract String calculateName();
public abstract void whenClicked(InventoryClickEvent event, InventoryItem item);
} }

View File

@ -13,6 +13,8 @@ import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
@ -21,147 +23,160 @@ import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;
public abstract class InventoryItem<T extends GeneratedInventory> { public abstract class InventoryItem<T extends GeneratedInventory> {
private final String id, function; private final String id, function;
private final List<Integer> slots = new ArrayList<>(); private final List<Integer> slots = new ArrayList<>();
private final Material material; @Nullable
private final String name, texture; private final InventoryItem<?> parent;
private final List<String> lore;
private final int modelData;
private final boolean placeholders, hideFlags;
public InventoryItem(ConfigurationSection config) { private final Material material;
this(Material.valueOf(config.getString("item", "").toUpperCase().replace(" ", "_").replace("-", "_")), config); private final String name, texture;
} private final List<String> lore;
private final int modelData;
private final boolean hideFlags;
public InventoryItem(Material material, ConfigurationSection config) { public InventoryItem(ConfigurationSection config) {
this.id = config.getName(); this((InventoryItem) null, config);
this.function = config.getString("function", ""); }
this.material = material; public InventoryItem(@Nullable InventoryItem<?> parent, ConfigurationSection config) {
this.name = config.getString("name"); this(parent, Material.valueOf(config.getString("item", "").toUpperCase().replace(" ", "_").replace("-", "_")), config);
this.lore = config.getStringList("lore"); }
this.hideFlags = config.getBoolean("hide-flags");
this.texture = config.getString("texture");
this.placeholders = config.getBoolean("placeholders");
this.modelData = config.getInt("custom-model-data");
config.getStringList("slots").forEach(str -> slots.add(Integer.parseInt(str))); public InventoryItem(@NotNull Material material, ConfigurationSection config) {
} this(null, material, config);
}
public String getId() { public InventoryItem(InventoryItem parent, Material material, ConfigurationSection config) {
return id; this.id = config.getName();
} this.function = config.getString("function", "");
this.parent = parent;
public String getFunction() { this.material = material;
return function; this.name = config.getString("name");
} this.lore = config.getStringList("lore");
this.hideFlags = config.getBoolean("hide-flags");
this.texture = config.getString("texture");
this.modelData = config.getInt("custom-model-data");
public boolean hasFunction() { config.getStringList("slots").forEach(str -> slots.add(Integer.parseInt(str)));
return !function.isEmpty(); }
}
public List<Integer> getSlots() { public String getId() {
return slots; return id;
} }
public Material getMaterial() { @NotNull
return material; public String getFunction() {
} return parent == null ? function : parent.function;
}
public boolean hideFlags() { public boolean hasFunction() {
return hideFlags; return !getFunction().isEmpty();
} }
public boolean hasName() { @NotNull
return name != null; public List<Integer> getSlots() {
} return parent == null ? slots : parent.slots;
}
public String getName() { public Material getMaterial() {
return name; return material;
} }
public boolean hasLore() { public boolean hideFlags() {
return lore != null && !lore.isEmpty(); return hideFlags;
} }
public List<String> getLore() { public boolean hasName() {
return lore; return name != null;
} }
public int getModelData() { public String getName() {
return modelData; return name;
} }
public void setDisplayed(Inventory inv, T generated) { public boolean hasLore() {
generated.addLoaded(this); return lore != null && !lore.isEmpty();
}
if (!hasDifferentDisplay()) { public List<String> getLore() {
ItemStack display = display(generated); return lore;
for (int slot : getSlots()) }
inv.setItem(slot, display);
} else
for (int j = 0; j < slots.size(); j++)
inv.setItem(slots.get(j), display(generated, j));
} public int getModelData() {
return modelData;
}
public boolean hasDifferentDisplay() { public void setDisplayed(Inventory inv, T generated) {
return false; generated.addLoaded(this);
}
public boolean canDisplay(T inv) { if (!hasDifferentDisplay()) {
return true; ItemStack display = display(generated);
} for (int slot : getSlots())
inv.setItem(slot, display);
} else
for (int j = 0; j < slots.size(); j++)
inv.setItem(slots.get(j), display(generated, j));
public ItemStack display(T inv) { }
return display(inv, 0);
}
public ItemStack display(T inv, int n) { public boolean hasDifferentDisplay() {
return false;
}
Placeholders placeholders = getPlaceholders(inv, n); public boolean canDisplay(T inv) {
ItemStack item = new ItemStack(material); return true;
ItemMeta meta = item.getItemMeta(); }
if (texture != null && meta instanceof SkullMeta) public ItemStack display(T inv) {
applyTexture(texture, (SkullMeta) meta); return display(inv, 0);
}
if (hasName()) public ItemStack display(T inv, int n) {
meta.setDisplayName(placeholders.apply(inv.getPlayer(), getName()));
if (hideFlags()) Placeholders placeholders = getPlaceholders(inv, n);
meta.addItemFlags(ItemFlag.values()); ItemStack item = new ItemStack(material);
ItemMeta meta = item.getItemMeta();
if (hasLore()) { if (texture != null && meta instanceof SkullMeta)
List<String> lore = new ArrayList<>(); applyTexture(texture, (SkullMeta) meta);
getLore().forEach(line -> lore.add(ChatColor.GRAY + placeholders.apply(inv.getPlayer(), line)));
meta.setLore(lore);
}
if (MythicLib.plugin.getVersion().isStrictlyHigher(1, 13)) if (hasName())
meta.setCustomModelData(getModelData()); meta.setDisplayName(placeholders.apply(inv.getPlayer(), getName()));
item.setItemMeta(meta); if (hideFlags())
return item; meta.addItemFlags(ItemFlag.values());
}
private void applyTexture(String value, SkullMeta meta) { if (hasLore()) {
try { List<String> lore = new ArrayList<>();
GameProfile profile = new GameProfile(UUID.randomUUID(), null); getLore().forEach(line -> lore.add(ChatColor.GRAY + placeholders.apply(inv.getPlayer(), line)));
profile.getProperties().put("textures", new Property("textures", value)); meta.setLore(lore);
}
Field profileField = meta.getClass().getDeclaredField("profile"); if (MythicLib.plugin.getVersion().isStrictlyHigher(1, 13))
profileField.setAccessible(true); meta.setCustomModelData(getModelData());
profileField.set(meta, profile);
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException exception) {
MMOCore.log(Level.WARNING, "Could not apply item texture value of " + getId());
}
}
public Placeholders getPlaceholders(T inv) { item.setItemMeta(meta);
return getPlaceholders(inv, 0); return item;
} }
public abstract Placeholders getPlaceholders(T inv, int n); private void applyTexture(String value, SkullMeta meta) {
try {
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
profile.getProperties().put("textures", new Property("textures", value));
Field profileField = meta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(meta, profile);
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException exception) {
MMOCore.log(Level.WARNING, "Could not apply item texture value of " + getId());
}
}
public Placeholders getPlaceholders(T inv) {
return getPlaceholders(inv, 0);
}
public abstract Placeholders getPlaceholders(T inv, int n);
} }

View File

@ -7,28 +7,25 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class Placeholders { public class Placeholders {
private final Map<String, String> placeholders = new HashMap<>(); private final Map<String, String> placeholders = new HashMap<>();
public void register(String path, Object obj) { public void register(String path, Object obj) {
placeholders.put(path, obj.toString()); placeholders.put(path, obj.toString());
} }
public String apply(Player player, String str) { public String apply(Player player, String str) {
/* // Internal placeholders
* Remove potential conditions, apply color codes while (str.contains("{") && str.substring(str.indexOf("{")).contains("}")) {
* and external placeholders if needed.
*/
str = MMOCore.plugin.placeholderParser.parse(player, removeCondition(str));
while (str.contains("{") && str.substring(str.indexOf("{")).contains("}")) {
String holder = str.substring(str.indexOf("{") + 1, str.indexOf("}")); String holder = str.substring(str.indexOf("{") + 1, str.indexOf("}"));
str = str.replace("{" + holder + "}", placeholders.getOrDefault(holder, "Error")); str = str.replace("{" + holder + "}", placeholders.getOrDefault(holder, "Error"));
} }
return str;
}
private String removeCondition(String str) { // External placeholders
return str.startsWith("{") && str.contains("}") ? str.substring(str.indexOf("}") + 1) : str; return MMOCore.plugin.placeholderParser.parse(player, removeCondition(str));
} }
private String removeCondition(String str) {
return str.startsWith("{") && str.contains("}") ? str.substring(str.indexOf("}") + 1) : str;
}
} }

View File

@ -5,6 +5,10 @@ import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
public class SimplePlaceholderItem<T extends GeneratedInventory> extends InventoryItem<T> { public class SimplePlaceholderItem<T extends GeneratedInventory> extends InventoryItem<T> {
public SimplePlaceholderItem(InventoryItem<?> parent, ConfigurationSection config) {
super(parent, config);
}
public SimplePlaceholderItem(ConfigurationSection config) { public SimplePlaceholderItem(ConfigurationSection config) {
super(config); super(config);
} }

View File

@ -1,5 +1,6 @@
package net.Indyuce.mmocore.gui.eco; package net.Indyuce.mmocore.gui.eco;
import net.Indyuce.mmocore.util.item.SimpleItemBuilder;
import net.milkbowl.vault.economy.EconomyResponse; import net.milkbowl.vault.economy.EconomyResponse;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
@ -13,7 +14,6 @@ import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.util.MMOCoreUtils; import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import net.Indyuce.mmocore.api.util.item.ConfigItem;
import net.Indyuce.mmocore.gui.api.PluginInventory; import net.Indyuce.mmocore.gui.api.PluginInventory;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.util.SmartGive; import io.lumine.mythic.lib.api.util.SmartGive;
@ -30,7 +30,7 @@ public class DepositMenu extends PluginInventory {
public Inventory getInventory() { public Inventory getInventory() {
Inventory inv = Bukkit.createInventory(this, 27, "Deposit"); Inventory inv = Bukkit.createInventory(this, 27, "Deposit");
inv.setItem(26, depositItem = new ConfigItem("DEPOSIT_ITEM").addPlaceholders("worth", "0").build()); inv.setItem(26, depositItem = new SimpleItemBuilder("DEPOSIT_ITEM").addPlaceholders("worth", "0").build());
new BukkitRunnable() { new BukkitRunnable() {
@ -115,6 +115,6 @@ public class DepositMenu extends PluginInventory {
private void updateDeposit(Inventory inv) { private void updateDeposit(Inventory inv) {
deposit = MMOCoreUtils.getWorth(inv.getContents()); deposit = MMOCoreUtils.getWorth(inv.getContents());
inv.setItem(26, depositItem = new ConfigItem("DEPOSIT_ITEM").addPlaceholders("worth", "" + deposit).build()); inv.setItem(26, depositItem = new SimpleItemBuilder("DEPOSIT_ITEM").addPlaceholders("worth", "" + deposit).build());
} }
} }

View File

@ -1,7 +1,5 @@
package net.Indyuce.mmocore.gui.social.friend; package net.Indyuce.mmocore.gui.social.friend;
import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerActivity; import net.Indyuce.mmocore.api.player.PlayerActivity;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
@ -15,6 +13,7 @@ import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem;
import net.Indyuce.mmocore.manager.InventoryManager; import net.Indyuce.mmocore.manager.InventoryManager;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -24,10 +23,13 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.persistence.PersistentDataType;
import java.util.UUID; import java.util.UUID;
public class EditableFriendList extends EditableInventory { public class EditableFriendList extends EditableInventory {
private static final NamespacedKey UUID_NAMESPACEDKEY = new NamespacedKey(MMOCore.plugin, "Uuid");
public EditableFriendList() { public EditableFriendList() {
super("friend-list"); super("friend-list");
} }
@ -64,8 +66,8 @@ public class EditableFriendList extends EditableInventory {
} }
public static class OfflineFriendItem extends InventoryItem { public static class OfflineFriendItem extends InventoryItem {
public OfflineFriendItem(ConfigurationSection config) { public OfflineFriendItem(FriendItem parent, ConfigurationSection config) {
super(config); super(parent, config);
} }
@Override @Override
@ -82,27 +84,11 @@ public class EditableFriendList extends EditableInventory {
holders.register("last_seen", new DelayFormat(2).format(System.currentTimeMillis() - friend.getLastPlayed())); holders.register("last_seen", new DelayFormat(2).format(System.currentTimeMillis() - friend.getLastPlayed()));
return holders; return holders;
} }
@Override
public ItemStack display(GeneratedInventory inv, int n) {
OfflinePlayer friend = Bukkit.getOfflinePlayer(inv.getPlayerData().getFriends().get(n));
ItemStack disp = super.display(inv, n);
ItemMeta meta = disp.getItemMeta();
if (meta instanceof SkullMeta)
Bukkit.getScheduler().runTaskAsynchronously(MMOCore.plugin, () -> {
((SkullMeta) meta).setOwningPlayer(friend);
disp.setItemMeta(meta);
});
return NBTItem.get(disp).addTag(new ItemTag("uuid", friend.getUniqueId().toString())).toItem();
}
} }
public static class OnlineFriendItem extends SimplePlaceholderItem { public static class OnlineFriendItem extends SimplePlaceholderItem {
public OnlineFriendItem(ConfigurationSection config) { public OnlineFriendItem(FriendItem parent, ConfigurationSection config) {
super(config); super(parent, config);
} }
@Override @Override
@ -123,22 +109,6 @@ public class EditableFriendList extends EditableInventory {
holders.register("online_since", new DelayFormat(2).format(System.currentTimeMillis() - data.getLastLogin())); holders.register("online_since", new DelayFormat(2).format(System.currentTimeMillis() - data.getLastLogin()));
return holders; return holders;
} }
@Override
public ItemStack display(GeneratedInventory inv, int n) {
Player friend = Bukkit.getPlayer(inv.getPlayerData().getFriends().get(n));
ItemStack disp = super.display(inv, n);
ItemMeta meta = disp.getItemMeta();
if (meta instanceof SkullMeta)
Bukkit.getScheduler().runTaskAsynchronously(MMOCore.plugin, () -> {
((SkullMeta) meta).setOwningPlayer(friend);
disp.setItemMeta(meta);
});
return NBTItem.get(disp).addTag(new ItemTag("uuid", friend.getUniqueId().toString())).toItem();
}
} }
public static class FriendItem extends SimplePlaceholderItem { public static class FriendItem extends SimplePlaceholderItem {
@ -151,14 +121,28 @@ public class EditableFriendList extends EditableInventory {
Validate.notNull(config.contains("online"), "Could not load online config"); Validate.notNull(config.contains("online"), "Could not load online config");
Validate.notNull(config.contains("offline"), "Could not load offline config"); Validate.notNull(config.contains("offline"), "Could not load offline config");
online = new OnlineFriendItem(config.getConfigurationSection("online")); online = new OnlineFriendItem(this, config.getConfigurationSection("online"));
offline = new OfflineFriendItem(config.getConfigurationSection("offline")); offline = new OfflineFriendItem(this, config.getConfigurationSection("offline"));
} }
@Override @Override
public ItemStack display(GeneratedInventory inv, int n) { public ItemStack display(GeneratedInventory inv, int n) {
return inv.getPlayerData().getFriends().size() <= n ? super.display(inv, n) if (inv.getPlayerData().getFriends().size() <= n)
: Bukkit.getOfflinePlayer(inv.getPlayerData().getFriends().get(n)).isOnline() ? online.display(inv, n) : offline.display(inv, n); return super.display(inv, n);
ItemStack disp = Bukkit.getOfflinePlayer(inv.getPlayerData().getFriends().get(n)).isOnline() ? online.display(inv, n) : offline.display(inv, n);
Player friend = Bukkit.getPlayer(inv.getPlayerData().getFriends().get(n));
ItemMeta meta = disp.getItemMeta();
meta.getPersistentDataContainer().set(UUID_NAMESPACEDKEY, PersistentDataType.STRING, friend.getUniqueId().toString());
if (meta instanceof SkullMeta)
inv.dynamicallyUpdateItem(this, n, disp, current -> {
((SkullMeta) meta).setOwningPlayer(friend);
current.setItemMeta(meta);
});
disp.setItemMeta(meta);
return disp;
} }
@Override @Override
@ -238,7 +222,7 @@ public class EditableFriendList extends EditableInventory {
} }
if (item.getFunction().equals("friend") && event.getAction() == InventoryAction.PICKUP_HALF) { if (item.getFunction().equals("friend") && event.getAction() == InventoryAction.PICKUP_HALF) {
String tag = NBTItem.get(event.getCurrentItem()).getString("uuid"); String tag = event.getCurrentItem().getItemMeta().getPersistentDataContainer().get(UUID_NAMESPACEDKEY, PersistentDataType.STRING);
if (tag == null || tag.isEmpty()) if (tag == null || tag.isEmpty())
return; return;

View File

@ -13,6 +13,7 @@ import net.Indyuce.mmocore.gui.api.item.Placeholders;
import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem; import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -22,10 +23,13 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.persistence.PersistentDataType;
import java.util.UUID; import java.util.UUID;
public class EditableGuildAdmin extends EditableInventory { public class EditableGuildAdmin extends EditableInventory {
private static final NamespacedKey UUID_NAMESPACEDKEY = new NamespacedKey(MMOCore.plugin, "Uuid");
public EditableGuildAdmin() { public EditableGuildAdmin() {
super("guild-admin"); super("guild-admin");
} }
@ -40,8 +44,8 @@ public class EditableGuildAdmin extends EditableInventory {
} }
public static class MemberDisplayItem extends InventoryItem { public static class MemberDisplayItem extends InventoryItem {
public MemberDisplayItem(ConfigurationSection config) { public MemberDisplayItem(MemberItem memberItem, ConfigurationSection config) {
super(config); super(memberItem, config);
} }
@Override @Override
@ -65,19 +69,21 @@ public class EditableGuildAdmin extends EditableInventory {
@Override @Override
public ItemStack display(GeneratedInventory inv, int n) { public ItemStack display(GeneratedInventory inv, int n) {
PlayerData member = PlayerData.get(inv.getPlayerData().getGuild().getMembers().get(n)); UUID uuid = inv.getPlayerData().getGuild().getMembers().get(n);
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid);
ItemStack disp = super.display(inv, n); ItemStack disp = super.display(inv, n);
ItemMeta meta = disp.getItemMeta(); ItemMeta meta = disp.getItemMeta();
meta.getPersistentDataContainer().set(UUID_NAMESPACEDKEY, PersistentDataType.STRING, uuid.toString());
if (meta instanceof SkullMeta) if (meta instanceof SkullMeta && offlinePlayer != null)
Bukkit.getScheduler().runTaskAsynchronously(MMOCore.plugin, () -> { inv.dynamicallyUpdateItem(this, n, disp, current -> {
if (!member.isOnline()) return; ((SkullMeta) meta).setOwningPlayer(offlinePlayer);
((SkullMeta) meta).setOwningPlayer(member.getPlayer()); current.setItemMeta(meta);
disp.setItemMeta(meta);
}); });
return NBTItem.get(disp).addTag(new ItemTag("uuid", member.getUniqueId().toString())).toItem(); disp.setItemMeta(meta);
return disp;
} }
} }
@ -92,7 +98,7 @@ public class EditableGuildAdmin extends EditableInventory {
Validate.notNull(config.contains("member"), "Could not load member config"); Validate.notNull(config.contains("member"), "Could not load member config");
empty = new SimplePlaceholderItem(config.getConfigurationSection("empty")); empty = new SimplePlaceholderItem(config.getConfigurationSection("empty"));
member = new MemberDisplayItem(config.getConfigurationSection("member")); member = new MemberDisplayItem(this, config.getConfigurationSection("member"));
} }
@Override @Override
@ -174,7 +180,7 @@ public class EditableGuildAdmin extends EditableInventory {
if (!playerData.getGuild().getOwner().equals(playerData.getUniqueId())) if (!playerData.getGuild().getOwner().equals(playerData.getUniqueId()))
return; return;
OfflinePlayer target = Bukkit.getOfflinePlayer(UUID.fromString(NBTItem.get(event.getCurrentItem()).getString("uuid"))); OfflinePlayer target = Bukkit.getOfflinePlayer(UUID.fromString(event.getCurrentItem().getItemMeta().getPersistentDataContainer().get(UUID_NAMESPACEDKEY, PersistentDataType.STRING)));
if (target.equals(player)) if (target.equals(player))
return; return;

View File

@ -1,7 +1,5 @@
package net.Indyuce.mmocore.gui.social.guild; package net.Indyuce.mmocore.gui.social.guild;
import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.OfflinePlayerData; import net.Indyuce.mmocore.api.player.OfflinePlayerData;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
@ -13,10 +11,7 @@ import net.Indyuce.mmocore.gui.api.item.InventoryItem;
import net.Indyuce.mmocore.gui.api.item.Placeholders; import net.Indyuce.mmocore.gui.api.item.Placeholders;
import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem; import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit; import org.bukkit.*;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.Sound;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryAction;
@ -24,10 +19,13 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.persistence.PersistentDataType;
import java.util.UUID; import java.util.UUID;
public class EditableGuildView extends EditableInventory { public class EditableGuildView extends EditableInventory {
private static final NamespacedKey UUID_NAMESPACEDKEY = new NamespacedKey(MMOCore.plugin, "Uuid");
public EditableGuildView() { public EditableGuildView() {
super("guild-view"); super("guild-view");
} }
@ -38,8 +36,8 @@ public class EditableGuildView extends EditableInventory {
} }
public static class MemberDisplayItem extends InventoryItem { public static class MemberDisplayItem extends InventoryItem {
public MemberDisplayItem(ConfigurationSection config) { public MemberDisplayItem(MemberItem memberItem, ConfigurationSection config) {
super(config); super(memberItem, config);
} }
@Override @Override
@ -71,14 +69,16 @@ public class EditableGuildView extends EditableInventory {
ItemStack disp = super.display(inv, n); ItemStack disp = super.display(inv, n);
ItemMeta meta = disp.getItemMeta(); ItemMeta meta = disp.getItemMeta();
meta.getPersistentDataContainer().set(UUID_NAMESPACEDKEY, PersistentDataType.STRING, uuid.toString());
if (meta instanceof SkullMeta) if (meta instanceof SkullMeta)
Bukkit.getScheduler().runTaskAsynchronously(MMOCore.plugin, () -> { inv.dynamicallyUpdateItem(this, n, disp, current -> {
((SkullMeta) meta).setOwningPlayer(Bukkit.getOfflinePlayer(uuid)); ((SkullMeta) meta).setOwningPlayer(Bukkit.getOfflinePlayer(uuid));
disp.setItemMeta(meta); current.setItemMeta(meta);
}); });
return NBTItem.get(disp).addTag(new ItemTag("uuid", uuid.toString())).toItem(); disp.setItemMeta(meta);
return disp;
} }
} }
@ -93,7 +93,7 @@ public class EditableGuildView extends EditableInventory {
Validate.notNull(config.contains("member"), "Could not load member config"); Validate.notNull(config.contains("member"), "Could not load member config");
empty = new SimplePlaceholderItem(config.getConfigurationSection("empty")); empty = new SimplePlaceholderItem(config.getConfigurationSection("empty"));
member = new MemberDisplayItem(config.getConfigurationSection("member")); member = new MemberDisplayItem(this, config.getConfigurationSection("member"));
} }
@Override @Override
@ -223,11 +223,15 @@ public class EditableGuildView extends EditableInventory {
}); });
} }
if (item.getFunction().equals("member") && event.getAction() == InventoryAction.PICKUP_HALF && !NBTItem.get(event.getCurrentItem()).getString("uuid").isEmpty()) { if (item.getFunction().equals("member") && event.getAction() == InventoryAction.PICKUP_HALF) {
if (!playerData.getGuild().getOwner().equals(playerData.getUniqueId())) if (!playerData.getGuild().getOwner().equals(playerData.getUniqueId()))
return; return;
OfflinePlayer target = Bukkit.getOfflinePlayer(UUID.fromString(NBTItem.get(event.getCurrentItem()).getString("uuid"))); String tag = event.getCurrentItem().getItemMeta().getPersistentDataContainer().get(UUID_NAMESPACEDKEY, PersistentDataType.STRING);
if (tag == null || tag.isEmpty())
return;
OfflinePlayer target = Bukkit.getOfflinePlayer(UUID.fromString(tag));
if (target.equals(player)) if (target.equals(player))
return; return;

View File

@ -1,7 +1,5 @@
package net.Indyuce.mmocore.gui.social.party; package net.Indyuce.mmocore.gui.social.party;
import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.util.input.PlayerInput.InputType; import net.Indyuce.mmocore.api.util.input.PlayerInput.InputType;
@ -13,10 +11,7 @@ import net.Indyuce.mmocore.gui.api.item.Placeholders;
import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem; import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem;
import net.Indyuce.mmocore.party.provided.Party; import net.Indyuce.mmocore.party.provided.Party;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit; import org.bukkit.*;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.Sound;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryAction;
@ -24,178 +19,178 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.persistence.PersistentDataType;
import java.util.UUID; import java.util.UUID;
public class EditablePartyView extends EditableInventory { public class EditablePartyView extends EditableInventory {
public EditablePartyView() { private static final NamespacedKey UUID_NAMESPACEDKEY = new NamespacedKey(MMOCore.plugin, "Uuid");
super("party-view");
}
@Override public EditablePartyView() {
public InventoryItem load(String function, ConfigurationSection config) { super("party-view");
return function.equals("member") ? new MemberItem(config) : new SimplePlaceholderItem(config); }
}
public static class MemberDisplayItem extends InventoryItem { @Override
public MemberDisplayItem(ConfigurationSection config) { public InventoryItem load(String function, ConfigurationSection config) {
super(config); return function.equals("member") ? new MemberItem(config) : new SimplePlaceholderItem(config);
} }
@Override public static class MemberDisplayItem extends InventoryItem {
public boolean hasDifferentDisplay() { public MemberDisplayItem(MemberItem memberItem, ConfigurationSection config) {
return true; super(memberItem, config);
} }
@Override @Override
public Placeholders getPlaceholders(GeneratedInventory inv, int n) { public boolean hasDifferentDisplay() {
Party party = (Party) inv.getPlayerData().getParty(); return true;
PlayerData member = party.getMembers().get(n); }
Placeholders holders = new Placeholders(); @Override
if (member.isOnline()) public Placeholders getPlaceholders(GeneratedInventory inv, int n) {
holders.register("name", member.getPlayer().getName()); Party party = (Party) inv.getPlayerData().getParty();
holders.register("class", member.getProfess().getName()); PlayerData member = party.getMembers().get(n);
holders.register("level", "" + member.getLevel());
holders.register("since", new DelayFormat(2).format(System.currentTimeMillis() - member.getLastLogin()));
return holders;
}
@Override Placeholders holders = new Placeholders();
public ItemStack display(GeneratedInventory inv, int n) { if (member.isOnline())
Party party = (Party) inv.getPlayerData().getParty(); holders.register("name", member.getPlayer().getName());
PlayerData member = party.getMembers().get(n); holders.register("class", member.getProfess().getName());
holders.register("level", "" + member.getLevel());
holders.register("since", new DelayFormat(2).format(System.currentTimeMillis() - member.getLastLogin()));
return holders;
}
ItemStack disp = super.display(inv, n); @Override
ItemMeta meta = disp.getItemMeta(); public ItemStack display(GeneratedInventory inv, int n) {
Party party = (Party) inv.getPlayerData().getParty();
PlayerData member = party.getMembers().get(n);
/* ItemStack disp = super.display(inv, n);
* run async to save performance ItemMeta meta = disp.getItemMeta();
*/ meta.getPersistentDataContainer().set(UUID_NAMESPACEDKEY, PersistentDataType.STRING, member.getUniqueId().toString());
if (meta instanceof SkullMeta)
Bukkit.getScheduler().runTaskAsynchronously(MMOCore.plugin, () -> {
if (!member.isOnline()) return;
((SkullMeta) meta).setOwningPlayer(member.getPlayer());
disp.setItemMeta(meta);
});
return NBTItem.get(disp).addTag(new ItemTag("uuid", member.getUniqueId().toString())).toItem(); if (meta instanceof SkullMeta)
} inv.dynamicallyUpdateItem(this, n, disp, current -> {
} ((SkullMeta) meta).setOwningPlayer(member.getPlayer());
current.setItemMeta(meta);
});
public static class MemberItem extends SimplePlaceholderItem { disp.setItemMeta(meta);
private final InventoryItem empty; return disp;
private final MemberDisplayItem member; }
}
public MemberItem(ConfigurationSection config) { public static class MemberItem extends SimplePlaceholderItem {
super(Material.BARRIER, config); private final InventoryItem empty;
private final MemberDisplayItem member;
Validate.notNull(config.contains("empty"), "Could not load empty config"); public MemberItem(ConfigurationSection config) {
Validate.notNull(config.contains("member"), "Could not load member config"); super(Material.BARRIER, config);
empty = new SimplePlaceholderItem(config.getConfigurationSection("empty")); Validate.notNull(config.contains("empty"), "Could not load empty config");
member = new MemberDisplayItem(config.getConfigurationSection("member")); Validate.notNull(config.contains("member"), "Could not load member config");
}
@Override empty = new SimplePlaceholderItem(config.getConfigurationSection("empty"));
public ItemStack display(GeneratedInventory inv, int n) { member = new MemberDisplayItem(this, config.getConfigurationSection("member"));
Party party = (Party) inv.getPlayerData().getParty(); }
return party.getMembers().size() > n ? member.display(inv, n) : empty.display(inv, n);
}
@Override @Override
public boolean hasDifferentDisplay() { public ItemStack display(GeneratedInventory inv, int n) {
return true; Party party = (Party) inv.getPlayerData().getParty();
} return party.getMembers().size() > n ? member.display(inv, n) : empty.display(inv, n);
}
@Override @Override
public boolean canDisplay(GeneratedInventory inv) { public boolean hasDifferentDisplay() {
return true; return true;
} }
}
public GeneratedInventory newInventory(PlayerData data) { @Override
return new PartyViewInventory(data, this); public boolean canDisplay(GeneratedInventory inv) {
} return true;
}
}
public class PartyViewInventory extends GeneratedInventory { public GeneratedInventory newInventory(PlayerData data) {
private final int max; return new PartyViewInventory(data, this);
}
public PartyViewInventory(PlayerData playerData, EditableInventory editable) { public class PartyViewInventory extends GeneratedInventory {
super(playerData, editable); private final int max;
max = editable.getByFunction("member").getSlots().size(); public PartyViewInventory(PlayerData playerData, EditableInventory editable) {
} super(playerData, editable);
@Override max = editable.getByFunction("member").getSlots().size();
public String calculateName() { }
Party party = (Party) getPlayerData().getParty();
return getName().replace("{max}", "" + max).replace("{players}", "" + party.getMembers().size());
}
@Override @Override
public void whenClicked(InventoryClickEvent event, InventoryItem item) { public String calculateName() {
Party party = (Party) playerData.getParty(); Party party = (Party) getPlayerData().getParty();
return getName().replace("{max}", "" + max).replace("{players}", "" + party.getMembers().size());
}
if (item.getFunction().equals("leave")) { @Override
party.removeMember(playerData); public void whenClicked(InventoryClickEvent event, InventoryItem item) {
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); Party party = (Party) playerData.getParty();
player.closeInventory();
return;
}
if (item.getFunction().equals("invite")) { if (item.getFunction().equals("leave")) {
party.removeMember(playerData);
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
player.closeInventory();
return;
}
if (party.getMembers().size() >= max) { if (item.getFunction().equals("invite")) {
MMOCore.plugin.configManager.getSimpleMessage("party-is-full").send(player);
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
return;
}
MMOCore.plugin.configManager.newPlayerInput(player, InputType.PARTY_INVITE, (input) -> { if (party.getMembers().size() >= max) {
Player target = Bukkit.getPlayer(input); MMOCore.plugin.configManager.getSimpleMessage("party-is-full").send(player);
if (target == null) { player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
MMOCore.plugin.configManager.getSimpleMessage("not-online-player", "player", input).send(player); return;
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1); }
open();
return;
}
long remaining = party.getLastInvite(target) + 60 * 2 * 1000 - System.currentTimeMillis(); MMOCore.plugin.configManager.newPlayerInput(player, InputType.PARTY_INVITE, (input) -> {
if (remaining > 0) { Player target = Bukkit.getPlayer(input);
MMOCore.plugin.configManager.getSimpleMessage("party-invite-cooldown", "player", target.getName(), "cooldown", new DelayFormat().format(remaining)).send(player); if (target == null) {
open(); MMOCore.plugin.configManager.getSimpleMessage("not-online-player", "player", input).send(player);
return; player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
} open();
return;
}
PlayerData targetData = PlayerData.get(target); long remaining = party.getLastInvite(target) + 60 * 2 * 1000 - System.currentTimeMillis();
if (party.hasMember(target)) { if (remaining > 0) {
MMOCore.plugin.configManager.getSimpleMessage("already-in-party", "player", target.getName()).send(player); MMOCore.plugin.configManager.getSimpleMessage("party-invite-cooldown", "player", target.getName(), "cooldown", new DelayFormat().format(remaining)).send(player);
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1); open();
open(); return;
return; }
}
party.sendInvite(playerData, targetData); PlayerData targetData = PlayerData.get(target);
MMOCore.plugin.configManager.getSimpleMessage("sent-party-invite", "player", target.getName()).send(player); if (party.hasMember(target)) {
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); MMOCore.plugin.configManager.getSimpleMessage("already-in-party", "player", target.getName()).send(player);
open(); player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
}); open();
} return;
}
if (item.getFunction().equals("member") && event.getAction() == InventoryAction.PICKUP_HALF) { party.sendInvite(playerData, targetData);
if (!party.getOwner().equals(playerData)) MMOCore.plugin.configManager.getSimpleMessage("sent-party-invite", "player", target.getName()).send(player);
return; player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
open();
});
}
OfflinePlayer target = Bukkit.getOfflinePlayer(UUID.fromString(NBTItem.get(event.getCurrentItem()).getString("uuid"))); if (item.getFunction().equals("member") && event.getAction() == InventoryAction.PICKUP_HALF) {
if (target.equals(player)) if (!party.getOwner().equals(playerData))
return; return;
party.removeMember(PlayerData.get(target)); OfflinePlayer target = Bukkit.getOfflinePlayer(UUID.fromString(event.getCurrentItem().getItemMeta().getPersistentDataContainer().get(UUID_NAMESPACEDKEY, PersistentDataType.STRING)));
MMOCore.plugin.configManager.getSimpleMessage("kick-from-party", "player", target.getName()).send(player); if (target.equals(player))
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); return;
}
} party.removeMember(PlayerData.get(target));
} MMOCore.plugin.configManager.getSimpleMessage("kick-from-party", "player", target.getName()).send(player);
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
}
}
}
} }

View File

@ -1,40 +1,58 @@
package net.Indyuce.mmocore.listener; package net.Indyuce.mmocore.listener;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.SoundEvent; import net.Indyuce.mmocore.api.SoundEvent;
import net.Indyuce.mmocore.manager.SoundManager; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.loot.chest.particle.SmallParticleEffect;
import net.Indyuce.mmocore.manager.InventoryManager;
import net.Indyuce.mmocore.waypoint.Waypoint;
import net.Indyuce.mmocore.waypoint.WaypointOption;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.event.player.PlayerToggleSneakEvent;
import net.Indyuce.mmocore.MMOCore; import java.util.Objects;
import net.Indyuce.mmocore.api.Waypoint;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.util.math.particle.SmallParticleEffect;
import net.Indyuce.mmocore.manager.InventoryManager;
public class WaypointsListener implements Listener { public class WaypointsListener implements Listener {
@EventHandler
public void a(PlayerToggleSneakEvent event) {
Player player = event.getPlayer();
if (!event.isSneaking())
return;
Waypoint waypoint = MMOCore.plugin.waypointManager.getCurrentWaypoint(player); @EventHandler
if (waypoint == null || !waypoint.hasSneakEnabled()) public void interactWithWaypoint(PlayerToggleSneakEvent event) {
return; Player player = event.getPlayer();
if (!event.isSneaking())
return;
PlayerData data = PlayerData.get(player); Waypoint waypoint = MMOCore.plugin.waypointManager.getCurrentWaypoint(player);
if (!data.hasWaypoint(waypoint)) { if (waypoint == null)
data.unlockWaypoint(waypoint); return;
new SmallParticleEffect(player, Particle.SPELL_WITCH);
MMOCore.plugin.configManager.getSimpleMessage("new-waypoint", "waypoint", waypoint.getName()).send(player);
MMOCore.plugin.soundManager.getSound(SoundEvent.WARP_UNLOCK).playTo(player);
return;
}
player.setSneaking(false); PlayerData data = PlayerData.get(player);
InventoryManager.WAYPOINTS.newInventory(data, waypoint).open(); if (waypoint.hasOption(WaypointOption.UNLOCKABLE) && !data.hasWaypoint(waypoint)) {
} data.unlockWaypoint(waypoint);
new SmallParticleEffect(player, Particle.SPELL_WITCH);
MMOCore.plugin.configManager.getSimpleMessage("new-waypoint", "waypoint", waypoint.getName()).send(player);
MMOCore.plugin.soundManager.getSound(SoundEvent.WARP_UNLOCK).playTo(player);
return;
}
if (waypoint.hasOption(WaypointOption.ENABLE_MENU)) {
player.setSneaking(false);
InventoryManager.WAYPOINTS.newInventory(data, waypoint).open();
}
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void waypointBook(PlayerInteractEvent event) {
if (!event.hasItem() || (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK))
return;
NBTItem nbtItem = NBTItem.get(event.getItem());
if (Objects.equals(nbtItem.getString("MMOCoreItemId"), "WAYPOINT_BOOK"))
InventoryManager.WAYPOINTS.newInventory(PlayerData.get(event.getPlayer())).open();
}
} }

View File

@ -36,7 +36,7 @@ import java.util.UUID;
public class FishingListener implements Listener { public class FishingListener implements Listener {
private final Set<UUID> fishing = new HashSet<>(); private final Set<UUID> fishing = new HashSet<>();
private static final Random random = new Random(); private static final Random RANDOM = new Random();
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW)
public void a(PlayerFishEvent event) { public void a(PlayerFishEvent event) {
@ -65,9 +65,9 @@ public class FishingListener implements Listener {
private final Player player; private final Player player;
private final FishHook hook; private final FishHook hook;
private final int total, exp; private final int fishStrength, experienceDropped;
private int pulls; private int currentPulls;
/** /**
* Used to track the last time the player swung the fishing rod. * Used to track the last time the player swung the fishing rod.
@ -84,16 +84,20 @@ public class FishingListener implements Listener {
this.playerData = PlayerData.get(this.player = player); this.playerData = PlayerData.get(this.player = player);
this.hook = hook; this.hook = hook;
this.total = (int) (caught.rollTugs() * (1 - PlayerData.get(player).getStats().getStat(StatType.FISHING_STRENGTH) / 100)); this.fishStrength = (int) Math.floor(caught.rollTugs() * (1 - PlayerData.get(player).getStats().getStat(StatType.FISHING_STRENGTH) / 100));
this.exp = caught.rollExperience(); this.experienceDropped = caught.rollExperience();
fishing.add(player.getUniqueId()); fishing.add(player.getUniqueId());
runTaskTimer(MMOCore.plugin, 0, 2); runTaskTimer(MMOCore.plugin, 0, 2);
Bukkit.getPluginManager().registerEvents(this, MMOCore.plugin); Bukkit.getPluginManager().registerEvents(this, MMOCore.plugin);
// Check for instant loot
if (fishStrength == 0)
lootFish();
} }
public void criticalFish() { public void setCriticalFish() {
pulls = total + 2; currentPulls = fishStrength + 2;
} }
public boolean isTimedOut() { public boolean isTimedOut() {
@ -103,16 +107,17 @@ public class FishingListener implements Listener {
/** /**
* @return If the fish is weak enough to be looted by the player. * @return If the fish is weak enough to be looted by the player.
*/ */
public boolean pull() { public boolean pullOnce() {
last = System.currentTimeMillis(); last = System.currentTimeMillis();
return pulls++ > total; currentPulls++;
return currentPulls >= fishStrength;
} }
/** /**
* Critical fish's means you catch the fish on the very first try * Critical fish's means you catch the fish on the very first try
*/ */
public boolean isCrit() { public boolean isCriticalFish() {
return pulls > total + 1; return currentPulls > fishStrength + 1;
} }
private void close() { private void close() {
@ -128,7 +133,7 @@ public class FishingListener implements Listener {
if (isTimedOut()) if (isTimedOut())
close(); close();
location.getWorld().spawnParticle(Particle.CRIT, location, 0, 2 * (random.nextDouble() - .5), 3, 2 * (random.nextDouble() - .5), .6); location.getWorld().spawnParticle(Particle.CRIT, location, 0, 2 * (RANDOM.nextDouble() - .5), 3, 2 * (RANDOM.nextDouble() - .5), .6);
} }
@EventHandler @EventHandler
@ -143,54 +148,57 @@ public class FishingListener implements Listener {
return; return;
} }
if (pulls == 0 && random.nextDouble() < PlayerData.get(player).getStats().getStat(StatType.CRITICAL_FISHING_CHANCE) / 100) if (currentPulls == 0 && RANDOM.nextDouble() < PlayerData.get(player).getStats().getStat(StatType.CRITICAL_FISHING_CHANCE) / 100)
criticalFish(); setCriticalFish();
// Check if enough pulls; if not, wait till the next fish event // Check if enough pulls; if not, wait till the next fish event
if (!pull()) if (pullOnce())
return; lootFish();
// The fish is successfully looted from here
close();
ItemStack mainhand = player.getInventory().getItem(EquipmentSlot.HAND);
MMOCoreUtils.decreaseDurability(player,
(mainhand != null && mainhand.getType() == Material.FISHING_ROD) ? EquipmentSlot.HAND : EquipmentSlot.OFF_HAND, 1);
if (!isCrit() && random.nextDouble() < PlayerData.get(player).getStats().getStat(StatType.CRITICAL_FISHING_FAILURE_CHANCE) / 100) {
player.setVelocity(hook.getLocation().subtract(player.getLocation()).toVector().setY(0).multiply(3).setY(.5));
hook.getWorld().spawnParticle(Particle.SMOKE_NORMAL, location, 24, 0, 0, 0, .08);
return;
}
ItemStack collect = caught.collect(new LootBuilder(playerData, 0));
if (collect == null) {
hook.getWorld().spawnParticle(Particle.SMOKE_NORMAL, location, 24, 0, 0, 0, .08);
return;
}
CustomPlayerFishEvent called = new CustomPlayerFishEvent(playerData, collect);
Bukkit.getPluginManager().callEvent(called);
if (called.isCancelled())
return;
// Calculate yeet velocity
Item item = hook.getWorld().dropItemNaturally(hook.getLocation(), collect);
MMOCoreUtils.displayIndicator(location.add(0, 1.25, 0),
MMOCore.plugin.configManager.getSimpleMessage("fish-out-water" + (isCrit() ? "-crit" : "")).message());
Vector vec = player.getLocation().subtract(hook.getLocation()).toVector();
vec.setY(vec.getY() * .031 + vec.length() * .05);
vec.setX(vec.getX() * .08);
vec.setZ(vec.getZ() * .08);
item.setVelocity(vec);
player.getWorld().playSound(player.getLocation(), VersionSound.BLOCK_NOTE_BLOCK_HAT.toSound(), 1, 0);
for (int j = 0; j < 16; j++)
location.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, location, 0, 4 * (random.nextDouble() - .5), 2,
4 * (random.nextDouble() - .5), .05);
if (MMOCore.plugin.fishingManager.hasLinkedProfession())
playerData.getCollectionSkills().giveExperience(MMOCore.plugin.fishingManager.getLinkedProfession(), exp, EXPSource.FISHING, location);
} }
} }
public void lootFish() {
close();
ItemStack mainhand = player.getInventory().getItem(EquipmentSlot.HAND);
MMOCoreUtils.decreaseDurability(player,
(mainhand != null && mainhand.getType() == Material.FISHING_ROD) ? EquipmentSlot.HAND : EquipmentSlot.OFF_HAND, 1);
// Critical fishing failure
if (!isCriticalFish() && RANDOM.nextDouble() < PlayerData.get(player).getStats().getStat(StatType.CRITICAL_FISHING_FAILURE_CHANCE) / 100) {
player.setVelocity(hook.getLocation().subtract(player.getLocation()).toVector().setY(0).multiply(3).setY(.5));
hook.getWorld().spawnParticle(Particle.SMOKE_NORMAL, location, 24, 0, 0, 0, .08);
return;
}
// Find looted item
ItemStack collect = caught.collect(new LootBuilder(playerData, 0));
if (collect == null) {
hook.getWorld().spawnParticle(Particle.SMOKE_NORMAL, location, 24, 0, 0, 0, .08);
return;
}
// Call Bukkit event
CustomPlayerFishEvent called = new CustomPlayerFishEvent(playerData, collect);
Bukkit.getPluginManager().callEvent(called);
if (called.isCancelled())
return;
// Calculate yeet velocity
Item item = hook.getWorld().dropItemNaturally(hook.getLocation(), collect);
MMOCoreUtils.displayIndicator(location.add(0, 1.25, 0),
MMOCore.plugin.configManager.getSimpleMessage("fish-out-water" + (isCriticalFish() ? "-crit" : "")).message());
Vector vec = player.getLocation().subtract(hook.getLocation()).toVector();
vec.setY(vec.getY() * .031 + vec.length() * .05);
vec.setX(vec.getX() * .08);
vec.setZ(vec.getZ() * .08);
item.setVelocity(vec);
player.getWorld().playSound(player.getLocation(), VersionSound.BLOCK_NOTE_BLOCK_HAT.toSound(), 1, 0);
for (int j = 0; j < 8; j++)
location.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, location, 0, 4 * (RANDOM.nextDouble() - .5), RANDOM.nextDouble() + 1, 4 * (RANDOM.nextDouble() - .5), .08);
if (MMOCore.plugin.fishingManager.hasLinkedProfession())
playerData.getCollectionSkills().giveExperience(MMOCore.plugin.fishingManager.getLinkedProfession(), experienceDropped, EXPSource.FISHING, location);
}
} }
} }

View File

@ -13,7 +13,7 @@ import org.bukkit.potion.PotionEffectType;
import net.Indyuce.mmocore.api.event.CustomBlockMineEvent; import net.Indyuce.mmocore.api.event.CustomBlockMineEvent;
import net.Indyuce.mmocore.api.player.stats.StatType; import net.Indyuce.mmocore.api.player.stats.StatType;
import net.Indyuce.mmocore.api.util.math.particle.SmallParticleEffect; import net.Indyuce.mmocore.loot.chest.particle.SmallParticleEffect;
import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.MythicLib;
public class PlayerCollectStats implements Listener { public class PlayerCollectStats implements Listener {

View File

@ -7,7 +7,7 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.util.math.particle.ChestParticleEffect; import net.Indyuce.mmocore.loot.chest.particle.ChestParticleEffect;
public class TierEffect { public class TierEffect {
private final ChestParticleEffect type; private final ChestParticleEffect type;

View File

@ -1,4 +1,4 @@
package net.Indyuce.mmocore.api.util.math.particle; package net.Indyuce.mmocore.loot.chest.particle;
import java.util.function.Consumer; import java.util.function.Consumer;

View File

@ -1,4 +1,4 @@
package net.Indyuce.mmocore.api.util.math.particle; package net.Indyuce.mmocore.loot.chest.particle;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;

View File

@ -1,4 +1,4 @@
package net.Indyuce.mmocore.api.util.math.particle; package net.Indyuce.mmocore.loot.chest.particle;
import java.util.function.Consumer; import java.util.function.Consumer;

View File

@ -1,4 +1,4 @@
package net.Indyuce.mmocore.api.util.math.particle; package net.Indyuce.mmocore.loot.chest.particle;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.Particle; import org.bukkit.Particle;

View File

@ -1,4 +1,4 @@
package net.Indyuce.mmocore.api.util.math.particle; package net.Indyuce.mmocore.loot.chest.particle;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Particle; import org.bukkit.Particle;

View File

@ -1,16 +1,19 @@
package net.Indyuce.mmocore.loot.droptable.dropitem; package net.Indyuce.mmocore.loot.droptable.dropitem;
import net.Indyuce.mmocore.loot.LootBuilder;
import net.Indyuce.mmocore.api.util.item.CurrencyItem;
import io.lumine.mythic.lib.api.MMOLineConfig; import io.lumine.mythic.lib.api.MMOLineConfig;
import net.Indyuce.mmocore.util.item.CurrencyItemBuilder;
import net.Indyuce.mmocore.loot.LootBuilder;
import org.bukkit.inventory.ItemStack;
public class GoldDropItem extends DropItem { public class GoldDropItem extends DropItem {
public GoldDropItem(MMOLineConfig config) { public GoldDropItem(MMOLineConfig config) {
super(config); super(config);
} }
@Override @Override
public void collect(LootBuilder builder) { public void collect(LootBuilder builder) {
builder.addLoot(new CurrencyItem("GOLD_COIN", 1, rollAmount()).build()); ItemStack item = new CurrencyItemBuilder("GOLD_COIN", 1).build();
} item.setAmount(rollAmount());
builder.addLoot(item);
}
} }

View File

@ -1,40 +0,0 @@
package net.Indyuce.mmocore.loot.droptable.dropitem;
import java.util.NoSuchElementException;
import io.lumine.xikage.mythicmobs.MythicMobs;
import io.lumine.xikage.mythicmobs.adapters.bukkit.BukkitAdapter;
import io.lumine.xikage.mythicmobs.drops.Drop;
import io.lumine.xikage.mythicmobs.drops.DropMetadata;
import io.lumine.xikage.mythicmobs.drops.DropTable;
import io.lumine.xikage.mythicmobs.drops.IItemDrop;
import io.lumine.xikage.mythicmobs.drops.LootBag;
import net.Indyuce.mmocore.loot.LootBuilder;
import io.lumine.mythic.lib.api.MMOLineConfig;
public class MMDropTableDropItem extends DropItem {
private final DropTable dropTable;
private static final DropMetadata metadata = new DropMetadata(null, null);
public MMDropTableDropItem(MMOLineConfig config) {
super(config);
config.validate("id");
String id = config.getString("id");
try {
dropTable = MythicMobs.inst().getDropManager().getDropTable(id).orElse(null);
} catch (NoSuchElementException exception) {
throw new IllegalArgumentException("Could not find MM drop table with ID '" + id + "'");
}
}
@Override
public void collect(LootBuilder builder) {
LootBag lootBag = dropTable.generate(metadata);
for (Drop type : lootBag.getDrops())
if (type instanceof IItemDrop)
builder.addLoot(BukkitAdapter.adapt(((IItemDrop) type).getDrop(metadata)));
}
}

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