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,6 +383,7 @@ 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) {
if (clearBefore)
reloadConfig(); 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;
if (!nbt.getBoolean("Unbreakable") && item.getItemMeta() instanceof Damageable) {
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
((Damageable) meta).setDamage(((Damageable) meta).getDamage() + damage); if (event.getDamage() + ((Damageable) meta).getDamage() >= item.getType().getMaxDurability()) {
item.setItemMeta(meta);
if (((Damageable) meta).getDamage() >= item.getType().getMaxDurability()) {
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1F, 1F); player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1F, 1F);
player.getInventory().setItem(slot, null); player.getInventory().setItem(slot, null);
} else {
((Damageable) meta).setDamage(((Damageable) meta).getDamage() + event.getDamage());
item.setItemMeta(meta);
} }
} }
/**
* @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,13 +1,14 @@
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 {
@ -37,7 +38,9 @@ public class CoinsCommandTreeNode extends CommandTreeNode {
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();
coins.setAmount(amount);
new SmartGive(player).give(coins);
return CommandResult.SUCCESS; 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,18 +1,14 @@
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 {
@ -25,6 +21,15 @@ public class MythicMobsMMOLoader extends MMOLoader {
return null; return null;
} }
@Override
public DropItem loadDropItem(MMOLineConfig config) {
if (config.getKey().equals("mmdroptable"))
return new MMDropTableDropItem(config);
return null;
}
@Override @Override
public Objective loadObjective(MMOLineConfig config, ConfigurationSection section) { public Objective loadObjective(MMOLineConfig config, ConfigurationSection section) {

View File

@ -1,15 +1,15 @@
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 net.Indyuce.mmocore.util.item.CurrencyItemBuilder;
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.item.CurrencyItem;
public class CurrencyItemDrop extends Drop implements IMultiDrop { public class CurrencyItemDrop extends Drop implements IMultiDrop {
private final String key; private final String key;
@ -30,7 +30,7 @@ public class CurrencyItemDrop extends Drop implements IMultiDrop {
@Override @Override
public LootBag get(DropMetadata metadata) { public LootBag get(DropMetadata metadata) {
LootBag loot = new LootBag(metadata); LootBag loot = new LootBag(metadata);
loot.add(new ItemDrop(this.getLine(), (MythicLineConfig) this.getConfig(), new BukkitItemStack(new CurrencyItem(key, random(minw, maxw)).build()))); loot.add(new ItemDrop(this.getLine(), this.getConfig(), new BukkitItemStack(new CurrencyItemBuilder(key, random(minw, maxw)).build())));
return loot; return loot;
} }

View File

@ -1,22 +1,21 @@
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;
@ -35,7 +34,7 @@ public class GoldPouchDrop extends Drop implements IMultiDrop {
@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;
@ -45,18 +44,23 @@ public class GoldPouchDrop extends Drop implements IMultiDrop {
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 ItemStack setAmount(ItemStack item, int amount) {
item.setAmount(amount);
return item;
}
private int getAvailableSlot(ItemStack[] content) { private int getAvailableSlot(ItemStack[] content) {
int slot; int slot;
while (content[slot = random.nextInt(content.length)] != null) while (content[slot = random.nextInt(content.length)] != null)

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,16 +1,15 @@
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;

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,16 +1,15 @@
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;

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();
inv.dynamicallyUpdateItem(this, n, disp, current -> {
meta.setOwningPlayer(inv.getPlayer()); meta.setOwningPlayer(inv.getPlayer());
item.setItemMeta(meta); 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,6 +21,7 @@ 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() {
@ -60,53 +63,26 @@ public class WaypointViewer extends EditableInventory {
return new WaypointViewerInventory(data, this, waypoint); return new WaypointViewerInventory(data, this, waypoint);
} }
public class WaypointDisplayItem extends InventoryItem<WaypointViewerInventory> {
private final Material notReady;
public WaypointDisplayItem(ConfigurationSection config) {
super(config);
Validate.isTrue(config.contains("not-ready"), "Could not read 'not-ready' material");
notReady = Material.valueOf(config.getString("not-ready"));
}
@Override
public ItemStack display(WaypointViewerInventory inv, int n) {
ItemStack disp = super.display(inv, n);
Waypoint waypoint = inv.waypoints.get(inv.page * inv.getEditable().getByFunction("waypoint").getSlots().size() + n);
if (inv.getPlayerData().getStellium() < waypoint.getStelliumCost() || (inv.current == null && !waypoint.isDynamic()))
disp.setType(notReady);
return NBTItem.get(disp).addTag(new ItemTag("waypointId", waypoint.getId())).toItem();
}
@Override
public Placeholders getPlaceholders(WaypointViewerInventory inv, int n) {
Placeholders holders = new Placeholders();
Waypoint waypoint = inv.waypoints.get(inv.page * inv.getByFunction("waypoint").getSlots().size() + n);
holders.register("name", waypoint.getName());
holders.register("stellium", decimal.format(waypoint.getStelliumCost()));
return holders;
}
}
public class WaypointItem extends SimplePlaceholderItem<WaypointViewerInventory> { public class WaypointItem extends SimplePlaceholderItem<WaypointViewerInventory> {
private final SimplePlaceholderItem noWaypoint, locked; private final SimplePlaceholderItem noWaypoint, locked;
private final WaypointDisplayItem availWaypoint; private final WaypointItemHandler availWaypoint, notLinked, notDynamic, noStellium;
public WaypointItem(ConfigurationSection config) { public WaypointItem(ConfigurationSection config) {
super(Material.BARRIER, config); super(Material.BARRIER, config);
Validate.notNull(config.getConfigurationSection("no-waypoint"), "Could not load 'no-waypoint' config"); Validate.notNull(config.getConfigurationSection("no-waypoint"), "Could not load 'no-waypoint' config");
Validate.notNull(config.getConfigurationSection("locked"), "Could not load 'locked' config"); 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"); Validate.notNull(config.getConfigurationSection("display"), "Could not load 'display' config");
noWaypoint = new SimplePlaceholderItem(config.getConfigurationSection("no-waypoint")); noWaypoint = new SimplePlaceholderItem(config.getConfigurationSection("no-waypoint"));
locked = new SimplePlaceholderItem(config.getConfigurationSection("locked")); locked = new SimplePlaceholderItem(config.getConfigurationSection("locked"));
availWaypoint = new WaypointDisplayItem(config.getConfigurationSection("display")); 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"));
} }
@Override @Override
@ -121,14 +97,59 @@ public class WaypointViewer extends EditableInventory {
if (index >= inv.waypoints.size()) if (index >= inv.waypoints.size())
return noWaypoint.display(inv, n); return noWaypoint.display(inv, n);
// Locked waypoint?
Waypoint waypoint = inv.waypoints.get(index); Waypoint waypoint = inv.waypoints.get(index);
return inv.getPlayerData().hasWaypoint(waypoint) ? availWaypoint.display(inv, n) : locked.display(inv); if (!inv.getPlayerData().hasWaypoint(waypoint))
return locked.display(inv, n);
// Waypoints are not linked
if (inv.current != null && !inv.current.hasDestination(waypoint))
return notLinked.display(inv, n);
// Not dynamic waypoint
if (inv.current == null && !waypoint.hasOption(WaypointOption.DYNAMIC))
return notDynamic.display(inv, n);
// Stellium cost
if (waypoint.getCost(inv.current == null ? CostType.DYNAMIC_USE : CostType.NORMAL_USE) > inv.getPlayerData().getStellium())
return noStellium.display(inv, n);
return availWaypoint.display(inv, n);
}
}
public class WaypointItemHandler extends InventoryItem<WaypointViewerInventory> {
public WaypointItemHandler(ConfigurationSection config) {
super(config);
}
@Override
public ItemStack display(WaypointViewerInventory inv, int n) {
ItemStack disp = super.display(inv, n);
// If a player can teleport to another waypoint given his location
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();
}
@Override
public Placeholders getPlaceholders(WaypointViewerInventory inv, int n) {
Placeholders holders = new Placeholders();
Waypoint waypoint = inv.waypoints.get(inv.page * inv.getByFunction("waypoint").getSlots().size() + n);
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)));
return holders;
} }
} }
public class WaypointViewerInventory extends GeneratedInventory { public class WaypointViewerInventory extends GeneratedInventory {
private final List<Waypoint> waypoints = new ArrayList<>(MMOCore.plugin.waypointManager.getAll()); private final List<Waypoint> waypoints = new ArrayList<>(MMOCore.plugin.waypointManager.getAll());
private final Waypoint current; private final Waypoint current;
private final CostType waypointCostType;
private int page; private int page;
@ -136,6 +157,7 @@ public class WaypointViewer extends EditableInventory {
super(playerData, editable); super(playerData, editable);
this.current = current; this.current = current;
this.waypointCostType = current == null ? CostType.DYNAMIC_USE : CostType.NORMAL_USE;
} }
@Override @Override
@ -162,23 +184,34 @@ public class WaypointViewer extends EditableInventory {
if (tag.equals("")) if (tag.equals(""))
return; return;
// Locked waypoint?
Waypoint waypoint = MMOCore.plugin.waypointManager.get(tag); Waypoint waypoint = MMOCore.plugin.waypointManager.get(tag);
if (!playerData.hasWaypoint(waypoint)) { if (!playerData.hasWaypoint(waypoint)) {
MMOCore.plugin.configManager.getSimpleMessage("not-unlocked-waypoint").send(player); MMOCore.plugin.configManager.getSimpleMessage("not-unlocked-waypoint").send(player);
return; return;
} }
// Cannot teleport to current waypoint
if (waypoint.equals(current)) { if (waypoint.equals(current)) {
MMOCore.plugin.configManager.getSimpleMessage("standing-on-waypoint").send(player); MMOCore.plugin.configManager.getSimpleMessage("standing-on-waypoint").send(player);
return; return;
} }
if (current == null && !waypoint.isDynamic()) { // Waypoint does not have target as destination
if (current != null && !current.hasDestination(waypoint)) {
MMOCore.plugin.configManager.getSimpleMessage("cannot-teleport-to").send(player);
return;
}
// Not dynamic waypoint
if (current == null && !waypoint.hasOption(WaypointOption.DYNAMIC)) {
MMOCore.plugin.configManager.getSimpleMessage("not-dynamic-waypoint").send(player); MMOCore.plugin.configManager.getSimpleMessage("not-dynamic-waypoint").send(player);
return; return;
} }
double left = waypoint.getStelliumCost() - playerData.getStellium(); // Stellium cost
CostType costType = current == null ? CostType.DYNAMIC_USE : CostType.NORMAL_USE;
double left = waypoint.getCost(costType) - playerData.getStellium();
if (left > 0) { if (left > 0) {
MMOCore.plugin.configManager.getSimpleMessage("not-enough-stellium", "more", decimal.format(left)).send(player); MMOCore.plugin.configManager.getSimpleMessage("not-enough-stellium", "more", decimal.format(left)).send(player);
return; return;
@ -188,7 +221,7 @@ public class WaypointViewer extends EditableInventory {
return; return;
player.closeInventory(); player.closeInventory();
playerData.warp(waypoint); playerData.warp(waypoint, costType);
} }
} }
} }

View File

@ -1,20 +1,25 @@
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<>();
private Inventory open;
public GeneratedInventory(PlayerData playerData, EditableInventory editable) { public GeneratedInventory(PlayerData playerData, EditableInventory editable) {
super(playerData); super(playerData);
@ -71,7 +76,19 @@ public abstract class GeneratedInventory extends PluginInventory {
*/ */
loaded.clear(); loaded.clear();
getPlayer().openInventory(getInventory()); getPlayer().openInventory(open = getInventory());
}
/**
* @deprecated Not a fan of that implementation.
* Better work with {@link InventoryItem#setDisplayed(Inventory, GeneratedInventory)}
*/
@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);
});
} }
public void whenClicked(InventoryClickEvent event) { public void whenClicked(InventoryClickEvent event) {

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;
@ -24,26 +26,37 @@ 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<>();
@Nullable
private final InventoryItem<?> parent;
private final Material material; private final Material material;
private final String name, texture; private final String name, texture;
private final List<String> lore; private final List<String> lore;
private final int modelData; private final int modelData;
private final boolean placeholders, hideFlags; private final boolean hideFlags;
public InventoryItem(ConfigurationSection config) { public InventoryItem(ConfigurationSection config) {
this(Material.valueOf(config.getString("item", "").toUpperCase().replace(" ", "_").replace("-", "_")), config); this((InventoryItem) null, config);
} }
public InventoryItem(Material material, ConfigurationSection config) { public InventoryItem(@Nullable InventoryItem<?> parent, ConfigurationSection config) {
this(parent, Material.valueOf(config.getString("item", "").toUpperCase().replace(" ", "_").replace("-", "_")), config);
}
public InventoryItem(@NotNull Material material, ConfigurationSection config) {
this(null, material, config);
}
public InventoryItem(InventoryItem parent, Material material, ConfigurationSection config) {
this.id = config.getName(); this.id = config.getName();
this.function = config.getString("function", ""); this.function = config.getString("function", "");
this.parent = parent;
this.material = material; this.material = material;
this.name = config.getString("name"); this.name = config.getString("name");
this.lore = config.getStringList("lore"); this.lore = config.getStringList("lore");
this.hideFlags = config.getBoolean("hide-flags"); this.hideFlags = config.getBoolean("hide-flags");
this.texture = config.getString("texture"); this.texture = config.getString("texture");
this.placeholders = config.getBoolean("placeholders");
this.modelData = config.getInt("custom-model-data"); this.modelData = config.getInt("custom-model-data");
config.getStringList("slots").forEach(str -> slots.add(Integer.parseInt(str))); config.getStringList("slots").forEach(str -> slots.add(Integer.parseInt(str)));
@ -53,16 +66,18 @@ public abstract class InventoryItem<T extends GeneratedInventory> {
return id; return id;
} }
@NotNull
public String getFunction() { public String getFunction() {
return function; return parent == null ? function : parent.function;
} }
public boolean hasFunction() { public boolean hasFunction() {
return !function.isEmpty(); return !getFunction().isEmpty();
} }
@NotNull
public List<Integer> getSlots() { public List<Integer> getSlots() {
return slots; return parent == null ? slots : parent.slots;
} }
public Material getMaterial() { public Material getMaterial() {

View File

@ -15,17 +15,14 @@ public class Placeholders {
public String apply(Player player, String str) { public String apply(Player player, String str) {
/* // Internal placeholders
* Remove potential conditions, apply color codes
* and external placeholders if needed.
*/
str = MMOCore.plugin.placeholderParser.parse(player, removeCondition(str));
while (str.contains("{") && str.substring(str.indexOf("{")).contains("}")) { 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;
// External placeholders
return MMOCore.plugin.placeholderParser.parse(player, removeCondition(str));
} }
private String removeCondition(String str) { private String removeCondition(String 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,11 +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 EditablePartyView extends EditableInventory { public class EditablePartyView extends EditableInventory {
private static final NamespacedKey UUID_NAMESPACEDKEY = new NamespacedKey(MMOCore.plugin, "Uuid");
public EditablePartyView() { public EditablePartyView() {
super("party-view"); super("party-view");
} }
@ -39,8 +36,8 @@ public class EditablePartyView 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
@ -69,18 +66,16 @@ public class EditablePartyView 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, member.getUniqueId().toString());
/*
* run async to save performance
*/
if (meta instanceof SkullMeta) if (meta instanceof SkullMeta)
Bukkit.getScheduler().runTaskAsynchronously(MMOCore.plugin, () -> { inv.dynamicallyUpdateItem(this, n, disp, current -> {
if (!member.isOnline()) return;
((SkullMeta) meta).setOwningPlayer(member.getPlayer()); ((SkullMeta) meta).setOwningPlayer(member.getPlayer());
disp.setItemMeta(meta); current.setItemMeta(meta);
}); });
return NBTItem.get(disp).addTag(new ItemTag("uuid", member.getUniqueId().toString())).toItem(); disp.setItemMeta(meta);
return disp;
} }
} }
@ -95,7 +90,7 @@ public class EditablePartyView 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
@ -188,7 +183,7 @@ public class EditablePartyView extends EditableInventory {
if (!party.getOwner().equals(playerData)) if (!party.getOwner().equals(playerData))
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,32 +1,38 @@
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 @EventHandler
public void a(PlayerToggleSneakEvent event) { public void interactWithWaypoint(PlayerToggleSneakEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!event.isSneaking()) if (!event.isSneaking())
return; return;
Waypoint waypoint = MMOCore.plugin.waypointManager.getCurrentWaypoint(player); Waypoint waypoint = MMOCore.plugin.waypointManager.getCurrentWaypoint(player);
if (waypoint == null || !waypoint.hasSneakEnabled()) if (waypoint == null)
return; return;
PlayerData data = PlayerData.get(player); PlayerData data = PlayerData.get(player);
if (!data.hasWaypoint(waypoint)) { if (waypoint.hasOption(WaypointOption.UNLOCKABLE) && !data.hasWaypoint(waypoint)) {
data.unlockWaypoint(waypoint); data.unlockWaypoint(waypoint);
new SmallParticleEffect(player, Particle.SPELL_WITCH); new SmallParticleEffect(player, Particle.SPELL_WITCH);
MMOCore.plugin.configManager.getSimpleMessage("new-waypoint", "waypoint", waypoint.getName()).send(player); MMOCore.plugin.configManager.getSimpleMessage("new-waypoint", "waypoint", waypoint.getName()).send(player);
@ -34,7 +40,19 @@ public class WaypointsListener implements Listener {
return; return;
} }
if (waypoint.hasOption(WaypointOption.ENABLE_MENU)) {
player.setSneaking(false); player.setSneaking(false);
InventoryManager.WAYPOINTS.newInventory(data, waypoint).open(); 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,32 +148,37 @@ 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 public void lootFish() {
close(); close();
ItemStack mainhand = player.getInventory().getItem(EquipmentSlot.HAND); ItemStack mainhand = player.getInventory().getItem(EquipmentSlot.HAND);
MMOCoreUtils.decreaseDurability(player, MMOCoreUtils.decreaseDurability(player,
(mainhand != null && mainhand.getType() == Material.FISHING_ROD) ? EquipmentSlot.HAND : EquipmentSlot.OFF_HAND, 1); (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) { // 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)); 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); hook.getWorld().spawnParticle(Particle.SMOKE_NORMAL, location, 24, 0, 0, 0, .08);
return; return;
} }
// Find looted item
ItemStack collect = caught.collect(new LootBuilder(playerData, 0)); ItemStack collect = caught.collect(new LootBuilder(playerData, 0));
if (collect == null) { if (collect == null) {
hook.getWorld().spawnParticle(Particle.SMOKE_NORMAL, location, 24, 0, 0, 0, .08); hook.getWorld().spawnParticle(Particle.SMOKE_NORMAL, location, 24, 0, 0, 0, .08);
return; return;
} }
// Call Bukkit event
CustomPlayerFishEvent called = new CustomPlayerFishEvent(playerData, collect); CustomPlayerFishEvent called = new CustomPlayerFishEvent(playerData, collect);
Bukkit.getPluginManager().callEvent(called); Bukkit.getPluginManager().callEvent(called);
if (called.isCancelled()) if (called.isCancelled())
@ -177,20 +187,18 @@ public class FishingListener implements Listener {
// Calculate yeet velocity // Calculate yeet velocity
Item item = hook.getWorld().dropItemNaturally(hook.getLocation(), collect); Item item = hook.getWorld().dropItemNaturally(hook.getLocation(), collect);
MMOCoreUtils.displayIndicator(location.add(0, 1.25, 0), MMOCoreUtils.displayIndicator(location.add(0, 1.25, 0),
MMOCore.plugin.configManager.getSimpleMessage("fish-out-water" + (isCrit() ? "-crit" : "")).message()); MMOCore.plugin.configManager.getSimpleMessage("fish-out-water" + (isCriticalFish() ? "-crit" : "")).message());
Vector vec = player.getLocation().subtract(hook.getLocation()).toVector(); Vector vec = player.getLocation().subtract(hook.getLocation()).toVector();
vec.setY(vec.getY() * .031 + vec.length() * .05); vec.setY(vec.getY() * .031 + vec.length() * .05);
vec.setX(vec.getX() * .08); vec.setX(vec.getX() * .08);
vec.setZ(vec.getZ() * .08); vec.setZ(vec.getZ() * .08);
item.setVelocity(vec); item.setVelocity(vec);
player.getWorld().playSound(player.getLocation(), VersionSound.BLOCK_NOTE_BLOCK_HAT.toSound(), 1, 0); player.getWorld().playSound(player.getLocation(), VersionSound.BLOCK_NOTE_BLOCK_HAT.toSound(), 1, 0);
for (int j = 0; j < 16; j++) for (int j = 0; j < 8; j++)
location.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, location, 0, 4 * (random.nextDouble() - .5), 2, location.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, location, 0, 4 * (RANDOM.nextDouble() - .5), RANDOM.nextDouble() + 1, 4 * (RANDOM.nextDouble() - .5), .08);
4 * (random.nextDouble() - .5), .05);
if (MMOCore.plugin.fishingManager.hasLinkedProfession()) if (MMOCore.plugin.fishingManager.hasLinkedProfession())
playerData.getCollectionSkills().giveExperience(MMOCore.plugin.fishingManager.getLinkedProfession(), exp, EXPSource.FISHING, location); 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,8 +1,9 @@
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) {
@ -11,6 +12,8 @@ public class GoldDropItem extends DropItem {
@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