mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-24 00:15:16 +01:00
Merge branch 'master' of http://Indyuce@dev.lumine.io/bitbucket/scm/mmo/mmocore.git
This commit is contained in:
commit
b74f92296b
BIN
lib/MMOLib.jar
BIN
lib/MMOLib.jar
Binary file not shown.
Binary file not shown.
BIN
lib/spigot.jar
BIN
lib/spigot.jar
Binary file not shown.
287
pom.xml
287
pom.xml
@ -1,97 +1,100 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.Indyuce</groupId>
|
||||
<artifactId>MMOCore</artifactId>
|
||||
<version>1.3</version>
|
||||
<description>Offer your players a brand new RPG experience.</description>
|
||||
|
||||
<properties>
|
||||
<build.number>SNAPSHOT</build.number>
|
||||
<downloadSources>false</downloadSources>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.Indyuce</groupId>
|
||||
<artifactId>MMOCore</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<name>MMOCore</name>
|
||||
<description>Offer your players a brand new RPG experience.</description>
|
||||
|
||||
<properties>
|
||||
<build.number>SNAPSHOT</build.number>
|
||||
<downloadSources>false</downloadSources>
|
||||
<downloadJavadocs>false</downloadJavadocs>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
</properties>
|
||||
|
||||
<distributionManagement>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>nexus</id>
|
||||
<name>Lumine Releases</name>
|
||||
<url>http://mvn.lumine.io/repository/maven-releases/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>nexus</id>
|
||||
<name>Lumine Snapshots</name>
|
||||
<url>http://mvn.lumine.io/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
<build>
|
||||
<finalName>${project.name}-${project.version}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/main/resources/</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<junitArtifactName>junit:junit</junitArtifactName>
|
||||
<encoding>UTF-8</encoding>
|
||||
<inputEncoding>UTF-8</inputEncoding>
|
||||
<outputEncoding>UTF-8</outputEncoding>
|
||||
<argLine>-ea -Dfile.encoding=UTF-8</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
<id>nexus</id>
|
||||
<name>Lumine Releases</name>
|
||||
<url>http://mvn.lumine.io/repository/maven-releases/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>https://maven.enginehub.org/repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>placeholderapi</id>
|
||||
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.Indyuce</groupId>
|
||||
<artifactId>mmoitems</artifactId>
|
||||
<version>5.1.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/MMOItems.jar</systemPath>
|
||||
</dependency>
|
||||
<snapshotRepository>
|
||||
<id>nexus</id>
|
||||
<name>Lumine Snapshots</name>
|
||||
<url>http://mvn.lumine.io/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
<build>
|
||||
<finalName>${project.name}-${project.version}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/main/resources/</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<junitArtifactName>junit:junit</junitArtifactName>
|
||||
<encoding>UTF-8</encoding>
|
||||
<inputEncoding>UTF-8</inputEncoding>
|
||||
<outputEncoding>UTF-8</outputEncoding>
|
||||
<argLine>-ea -Dfile.encoding=UTF-8</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>https://maven.enginehub.org/repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>placeholderapi</id>
|
||||
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.Indyuce</groupId>
|
||||
<artifactId>mmoitems</artifactId>
|
||||
<version>5.1.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/MMOItems.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.Indyuce</groupId>
|
||||
<artifactId>MMOLib</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/MMOLib.jar</systemPath>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/MMOLib.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.14.4</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/spigot.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.14.4</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/spigot.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bekvon.bukkit</groupId>
|
||||
<artifactId>Residence</artifactId>
|
||||
@ -99,63 +102,63 @@
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/Residence.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.Zrips</groupId>
|
||||
<artifactId>CMI</artifactId>
|
||||
<version>8.6.5.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/CMI.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sainttx.holograms</groupId>
|
||||
<artifactId>holograms</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/Holograms.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.gmail.filoghost</groupId>
|
||||
<artifactId>HolographicDisplays</artifactId>
|
||||
<version>6.9.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/HolographicDisplays.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.lumine.xikage</groupId>
|
||||
<artifactId>MythicMobs</artifactId>
|
||||
<version>4.8.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/MythicMobs.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.MilkBowl</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-bukkit</artifactId>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.citizensnpcs</groupId>
|
||||
<artifactId>citizens</artifactId>
|
||||
<version>2.0.25-SNAPSHOT</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/Citizens.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.10.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.41</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependency>
|
||||
<groupId>com.Zrips</groupId>
|
||||
<artifactId>CMI</artifactId>
|
||||
<version>8.6.5.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/CMI.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sainttx.holograms</groupId>
|
||||
<artifactId>holograms</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/Holograms.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.gmail.filoghost</groupId>
|
||||
<artifactId>HolographicDisplays</artifactId>
|
||||
<version>6.9.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/HolographicDisplays.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.lumine.xikage</groupId>
|
||||
<artifactId>MythicMobs</artifactId>
|
||||
<version>4.8.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/MythicMobs.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.MilkBowl</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-bukkit</artifactId>
|
||||
<version>7.0.2-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.citizensnpcs</groupId>
|
||||
<artifactId>citizens</artifactId>
|
||||
<version>2.0.25-SNAPSHOT</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/Citizens.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.10.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.41</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -151,6 +151,13 @@ public class MMOCore extends JavaPlugin {
|
||||
|
||||
if (Bukkit.getPluginManager().getPlugin("MythicMobs") != null)
|
||||
loadManager.registerLoader(new MythicMobsMMOLoader());
|
||||
|
||||
/*
|
||||
* WorldGuard closes the flag registry after 'onLoad()',
|
||||
* so it must be registered here or it will throw an IllegalStateException
|
||||
*/
|
||||
if(Bukkit.getPluginManager().getPlugin("WorldGuard") != null)
|
||||
flagPlugin = new WorldGuardFlags();
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
@ -176,7 +183,6 @@ public class MMOCore extends JavaPlugin {
|
||||
|
||||
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null) {
|
||||
regionHandler = new WorldGuardRegionHandler();
|
||||
flagPlugin = new WorldGuardFlags();
|
||||
getLogger().log(Level.INFO, "Hooked onto WorldGuard");
|
||||
} else if (Bukkit.getPluginManager().getPlugin("Residence") != null) {
|
||||
flagPlugin = new ResidenceFlags();
|
||||
@ -256,8 +262,8 @@ public class MMOCore extends JavaPlugin {
|
||||
/*
|
||||
* enable debug mode for extra debug tools.
|
||||
*/
|
||||
if (getConfig().getBoolean("debug"))
|
||||
new DebugMode();
|
||||
if (getConfig().contains("debug"))
|
||||
new DebugMode(getConfig().getInt("debug", 0));
|
||||
|
||||
if (configManager.overrideVanillaExp = getConfig().getBoolean("override-vanilla-exp"))
|
||||
Bukkit.getPluginManager().registerEvents(new VanillaExperienceOverride(), this);
|
||||
@ -295,7 +301,9 @@ public class MMOCore extends JavaPlugin {
|
||||
*/
|
||||
dataProvider.getGuildManager().load();
|
||||
|
||||
// commands
|
||||
/*
|
||||
* commands
|
||||
*/
|
||||
try {
|
||||
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
|
||||
|
||||
@ -385,6 +393,10 @@ public class MMOCore extends JavaPlugin {
|
||||
|
||||
// experience must be loaded before professions and classes
|
||||
experience.reload();
|
||||
|
||||
// drop tables must be loaded before professions
|
||||
dropTableManager.clear();
|
||||
dropTableManager.reload();
|
||||
|
||||
professionManager.clear();
|
||||
professionManager.reload();
|
||||
@ -394,9 +406,6 @@ public class MMOCore extends JavaPlugin {
|
||||
|
||||
inventoryManager = new InventoryManager();
|
||||
|
||||
dropTableManager.clear();
|
||||
dropTableManager.reload();
|
||||
|
||||
questManager.clear();
|
||||
questManager.reload();
|
||||
|
||||
@ -414,10 +423,19 @@ public class MMOCore extends JavaPlugin {
|
||||
log(Level.INFO, message);
|
||||
}
|
||||
|
||||
public static void debug(int value, String message) {
|
||||
debug(value, Level.INFO, message);
|
||||
}
|
||||
|
||||
public static void log(Level level, String message) {
|
||||
plugin.getLogger().log(level, message);
|
||||
}
|
||||
|
||||
public static void debug(int value, Level level, String message) {
|
||||
if(DebugMode.level > (value - 1))
|
||||
plugin.getLogger().log(level, message);
|
||||
}
|
||||
|
||||
public File getJarFile() {
|
||||
return getFile();
|
||||
}
|
||||
|
@ -3,11 +3,11 @@ package net.Indyuce.mmocore.api;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
public class ConfigMessage {
|
||||
@ -31,14 +31,14 @@ public class ConfigMessage {
|
||||
}
|
||||
|
||||
public void send(CommandSender sender) {
|
||||
messages.forEach(line -> sender.sendMessage(ChatColor.translateAlternateColorCodes('&', line)));
|
||||
messages.forEach(line -> sender.sendMessage(new ColorParse('&', line).toChatColor()));
|
||||
}
|
||||
|
||||
public void send(Collection<? extends Player> players) {
|
||||
players.forEach(player -> messages.forEach(line -> player.sendMessage(ChatColor.translateAlternateColorCodes('&', MMOCore.plugin.placeholderParser.parse(player, line)))));
|
||||
players.forEach(player -> messages.forEach(line -> player.sendMessage(new ColorParse('&', MMOCore.plugin.placeholderParser.parse(player, line)).toChatColor())));
|
||||
}
|
||||
|
||||
public void sendAsJSon(Player player) {
|
||||
messages.forEach(line -> MMOLib.plugin.getNMS().sendJson(player, ChatColor.translateAlternateColorCodes('&', line)));
|
||||
messages.forEach(line -> MMOLib.plugin.getNMS().sendJson(player, new ColorParse('&', line).toChatColor()));
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package net.Indyuce.mmocore.api;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -10,6 +9,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.stats.StatType;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
@ -31,7 +31,7 @@ public class PlayerActionBar extends BukkitRunnable {
|
||||
for (PlayerData data : PlayerData.getAll())
|
||||
if (data.isOnline() && !data.getPlayer().isDead() && !data.isCasting() && data.canSeeActionBar()) {
|
||||
data.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(MMOCore.plugin.placeholderParser.parse(data.getPlayer(),
|
||||
ChatColor.translateAlternateColorCodes('&', new String(format)
|
||||
new ColorParse('&', new String(format)
|
||||
.replace("{health}", digit.format(data.getPlayer().getHealth()))
|
||||
.replace("{max_health}", "" + StatType.MAX_HEALTH.format(data.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()))
|
||||
.replace("{mana_icon}", data.getProfess().getManaDisplay().getIcon())
|
||||
@ -45,7 +45,7 @@ public class PlayerActionBar extends BukkitRunnable {
|
||||
.replace("{xp}", "" + data.getExperience())
|
||||
.replace("{armor}", "" + StatType.ARMOR.format(data.getPlayer().getAttribute(Attribute.GENERIC_ARMOR).getValue()))
|
||||
.replace("{level}", "" + data.getLevel())
|
||||
.replace("{name}", data.getPlayer().getDisplayName())))));
|
||||
.replace("{name}", data.getPlayer().getDisplayName())).toChatColor())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
package net.Indyuce.mmocore.api.event;
|
||||
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
|
||||
public class MMOCommandEvent extends PlayerDataEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
|
||||
private final String command;
|
||||
|
||||
public MMOCommandEvent(PlayerData player, String command) {
|
||||
super(player);
|
||||
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean b) {
|
||||
cancelled = b;
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ package net.Indyuce.mmocore.api.event;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import net.Indyuce.mmocore.api.experience.EXPSource;
|
||||
import net.Indyuce.mmocore.api.experience.Profession;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
|
||||
@ -11,19 +12,21 @@ public class PlayerExperienceGainEvent extends PlayerDataEvent implements Cancel
|
||||
|
||||
// if null, this is main experience
|
||||
private final Profession profession;
|
||||
private final EXPSource source;
|
||||
|
||||
private int experience;
|
||||
private boolean cancelled;
|
||||
|
||||
public PlayerExperienceGainEvent(PlayerData player, int experience) {
|
||||
this(player, null, experience);
|
||||
public PlayerExperienceGainEvent(PlayerData player, int experience, EXPSource source) {
|
||||
this(player, null, experience, source);
|
||||
}
|
||||
|
||||
public PlayerExperienceGainEvent(PlayerData player, Profession profession, int experience) {
|
||||
public PlayerExperienceGainEvent(PlayerData player, Profession profession, int experience, EXPSource source) {
|
||||
super(player);
|
||||
|
||||
this.profession = profession;
|
||||
this.experience = experience;
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public int getExperience() {
|
||||
@ -52,6 +55,10 @@ public class PlayerExperienceGainEvent extends PlayerDataEvent implements Cancel
|
||||
return profession;
|
||||
}
|
||||
|
||||
public EXPSource getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
|
@ -4,11 +4,15 @@ import java.util.UUID;
|
||||
|
||||
public class Booster {
|
||||
private final UUID uuid = UUID.randomUUID();
|
||||
private final long date = System.currentTimeMillis(), length;
|
||||
private final long date = System.currentTimeMillis();
|
||||
private final Profession profession;
|
||||
private final double extra;
|
||||
private final String author;
|
||||
|
||||
// length not final because boosters can stack, this allows to reduce the
|
||||
// amount of boosters
|
||||
private long length;
|
||||
|
||||
public Booster(double extra, long length) {
|
||||
this(null, null, extra, length);
|
||||
}
|
||||
@ -40,6 +44,10 @@ public class Booster {
|
||||
return length;
|
||||
}
|
||||
|
||||
public void addLength(long length) {
|
||||
this.length += length;
|
||||
}
|
||||
|
||||
public boolean hasProfession() {
|
||||
return profession != null;
|
||||
}
|
||||
@ -67,4 +75,8 @@ public class Booster {
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public boolean canStackWith(Booster booster) {
|
||||
return extra == booster.extra && (profession != null ? profession.equals(booster.getProfession()) : booster.getProfession() == null);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
package net.Indyuce.mmocore.api.experience;
|
||||
|
||||
public enum EXPSource {
|
||||
SOURCE,
|
||||
COMMAND,
|
||||
VANILLA,
|
||||
QUEST,
|
||||
FISHING,
|
||||
OTHER;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package net.Indyuce.mmocore.api.player;
|
||||
package net.Indyuce.mmocore.api.experience;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
@ -17,6 +17,7 @@ import com.google.gson.JsonObject;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.ConfigMessage;
|
||||
import net.Indyuce.mmocore.api.event.PlayerExperienceGainEvent;
|
||||
import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.util.math.particle.SmallParticleEffect;
|
||||
@ -102,29 +103,28 @@ public class PlayerProfessions {
|
||||
exp.put(profession.getId(), value);
|
||||
}
|
||||
|
||||
public void giveLevels(Profession profession, int value) {
|
||||
public void giveLevels(Profession profession, int value, EXPSource source) {
|
||||
int total = 0, level = getLevel(profession);
|
||||
while (value-- > 0)
|
||||
total += profession.getExpCurve().getExperience(level + value + 1);
|
||||
giveExperience(profession, total);
|
||||
giveExperience(profession, total, source);
|
||||
}
|
||||
|
||||
public void giveExperience(Profession profession, int value) {
|
||||
giveExperience(profession, value, null);
|
||||
public void giveExperience(Profession profession, int value, EXPSource source) {
|
||||
giveExperience(profession, value, null, source);
|
||||
}
|
||||
|
||||
public boolean hasReachedMaxLevel(Profession profession) {
|
||||
return profession.hasMaxLevel() && getLevel(profession) >= profession.getMaxLevel();
|
||||
}
|
||||
|
||||
public void giveExperience(Profession profession, int value, Location loc) {
|
||||
public void giveExperience(Profession profession, int value, Location loc, EXPSource source) {
|
||||
if(hasReachedMaxLevel(profession)) {
|
||||
setExperience(profession, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
value = MMOCore.plugin.boosterManager.calculateExp(profession, value);
|
||||
exp.put(profession.getId(), exp.containsKey(profession.getId()) ? exp.get(profession.getId()) + value : value);
|
||||
|
||||
// display hologram
|
||||
if (MMOCore.plugin.getConfig().getBoolean("display-exp-holograms"))
|
||||
@ -132,6 +132,12 @@ public class PlayerProfessions {
|
||||
MMOCore.plugin.hologramSupport.displayIndicator(loc.add(.5, 1.5, .5),
|
||||
MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + value).message(), playerData.getPlayer());
|
||||
|
||||
PlayerExperienceGainEvent event = new PlayerExperienceGainEvent(playerData, profession, value, source);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
exp.put(profession.getId(), exp.containsKey(profession.getId()) ? exp.get(profession.getId()) + value : value);
|
||||
int needed, exp, level, oldLevel = getLevel(profession);
|
||||
|
||||
/*
|
||||
@ -155,7 +161,7 @@ public class PlayerProfessions {
|
||||
if (check) {
|
||||
Bukkit.getPluginManager().callEvent(new PlayerLevelUpEvent(playerData, profession, oldLevel, level));
|
||||
new SmallParticleEffect(playerData.getPlayer(), Particle.SPELL_INSTANT);
|
||||
new ConfigMessage("profession-level-up").addPlaceholders("level", "" + (level), "profession", profession.getName())
|
||||
new ConfigMessage("profession-level-up").addPlaceholders("level", "" + level, "profession", profession.getName())
|
||||
.send(playerData.getPlayer());
|
||||
playerData.getPlayer().playSound(playerData.getPlayer().getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 2);
|
||||
playerData.getStats().updateStats();
|
||||
|
@ -11,7 +11,6 @@ import org.bukkit.potion.PotionType;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.load.PostLoadObject;
|
||||
import net.Indyuce.mmocore.api.player.ExpCurve;
|
||||
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.MMOLineConfig;
|
||||
|
@ -33,7 +33,7 @@ public class SmeltItemExperienceSource extends SpecificExperienceSource<ItemStac
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void a(BlockCookEvent event) {
|
||||
if (!event.isCancelled()) {
|
||||
Optional<Player> player = getNearbyPlayer(event.getBlock().getLocation(), 10);
|
||||
Optional<Player> player = getNearestPlayer(event.getBlock().getLocation(), 10);
|
||||
if (!player.isPresent())
|
||||
return;
|
||||
|
||||
@ -50,9 +50,20 @@ public class SmeltItemExperienceSource extends SpecificExperienceSource<ItemStac
|
||||
};
|
||||
}
|
||||
|
||||
private Optional<Player> getNearbyPlayer(Location loc, double d) {
|
||||
double d2 = d * d;
|
||||
return loc.getWorld().getPlayers().stream().filter(player -> player.getLocation().distanceSquared(loc) < d2).findAny();
|
||||
private Optional<Player> getNearestPlayer(Location loc, double d) {
|
||||
final double d2 = d * d;
|
||||
final Player[] nearby = loc.getWorld().getPlayers().stream()
|
||||
.filter(player -> player.getLocation().distanceSquared(loc) < d2).toArray(Player[]::new);
|
||||
Player selected = null;
|
||||
double lastDist = d2;
|
||||
for(Player p : nearby) {
|
||||
double currDist = p.getLocation().distance(loc);
|
||||
if(currDist < lastDist) {
|
||||
lastDist = currDist;
|
||||
selected = p;
|
||||
}
|
||||
}
|
||||
return Optional.ofNullable(selected);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,6 +2,7 @@ package net.Indyuce.mmocore.api.experience.source.type;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import net.Indyuce.mmocore.api.experience.EXPSource;
|
||||
import net.Indyuce.mmocore.api.experience.Profession;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||
@ -46,8 +47,8 @@ public abstract class ExperienceSource<T> {
|
||||
|
||||
public void giveExperience(PlayerData player, int amount, Location location) {
|
||||
if (hasProfession())
|
||||
player.getCollectionSkills().giveExperience(profession, amount, location == null ? player.getPlayer().getLocation() : location);
|
||||
player.getCollectionSkills().giveExperience(profession, amount, location == null ? player.getPlayer().getLocation() : location, EXPSource.SOURCE);
|
||||
else
|
||||
player.giveExperience(amount, location == null ? player.getPlayer().getLocation() : location);
|
||||
player.giveExperience(amount, location == null ? player.getPlayer().getLocation() : location, EXPSource.SOURCE);
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import net.Indyuce.mmocore.api.event.PlayerCastSkillEvent;
|
||||
import net.Indyuce.mmocore.api.event.PlayerExperienceGainEvent;
|
||||
import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent;
|
||||
import net.Indyuce.mmocore.api.event.PlayerRegenResourceEvent;
|
||||
import net.Indyuce.mmocore.api.experience.EXPSource;
|
||||
import net.Indyuce.mmocore.api.experience.PlayerProfessions;
|
||||
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
|
||||
import net.Indyuce.mmocore.api.player.attribute.PlayerAttributes;
|
||||
@ -245,11 +246,11 @@ public class PlayerData extends OfflinePlayerData {
|
||||
getStats().updateStats();
|
||||
}
|
||||
|
||||
public void giveLevels(int value) {
|
||||
public void giveLevels(int value, EXPSource source) {
|
||||
int total = 0;
|
||||
while (value-- > 0)
|
||||
total += getProfess().getExpCurve().getExperience(getLevel() + value + 1);
|
||||
giveExperience(total);
|
||||
giveExperience(total, source);
|
||||
}
|
||||
|
||||
public void setExperience(int value) {
|
||||
@ -422,11 +423,11 @@ public class PlayerData extends OfflinePlayerData {
|
||||
return getProfess().getMaxLevel() > 0 && getLevel() >= getProfess().getMaxLevel();
|
||||
}
|
||||
|
||||
public void giveExperience(int value) {
|
||||
giveExperience(value, null);
|
||||
public void giveExperience(int value, EXPSource source) {
|
||||
giveExperience(value, null, source);
|
||||
}
|
||||
|
||||
public void giveExperience(int value, Location loc) {
|
||||
public void giveExperience(int value, Location loc, EXPSource source) {
|
||||
if (hasReachedMaxLevel()) {
|
||||
setExperience(0);
|
||||
return;
|
||||
@ -441,7 +442,7 @@ public class PlayerData extends OfflinePlayerData {
|
||||
value = MMOCore.plugin.boosterManager.calculateExp(null, value);
|
||||
value *= 1 + getStats().getStat(StatType.ADDITIONAL_EXPERIENCE) / 100;
|
||||
|
||||
PlayerExperienceGainEvent event = new PlayerExperienceGainEvent(this, value);
|
||||
PlayerExperienceGainEvent event = new PlayerExperienceGainEvent(this, value, source);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
@ -2,15 +2,13 @@ package net.Indyuce.mmocore.api.player.attribute;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.api.stat.modifier.StatModifier;
|
||||
|
||||
public class PlayerAttribute {
|
||||
@ -18,8 +16,8 @@ public class PlayerAttribute {
|
||||
private final int max;
|
||||
|
||||
/*
|
||||
* used to store stats using StatType, but attributes also need to access non
|
||||
* basic MMOCore stats hence the string maps keys
|
||||
* used to store stats using StatType, but attributes also need to access
|
||||
* non basic MMOCore stats hence the string maps keys
|
||||
*/
|
||||
private final Map<String, StatModifier> buffs = new HashMap<>();
|
||||
|
||||
@ -38,8 +36,7 @@ public class PlayerAttribute {
|
||||
String stat = key.toUpperCase().replace("-", "_").replace(" ", "_");
|
||||
buffs.put(stat, new StatModifier(config.getString("buff." + key)));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.log(Level.WARNING,
|
||||
"Could not load buff '" + key + "' from attribute '" + id + "': " + exception.getMessage());
|
||||
MMOCore.log(Level.WARNING, "Could not load buff '" + key + "' from attribute '" + id + "': " + exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,7 +45,7 @@ public class PlayerAttribute {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return ChatColor.translateAlternateColorCodes('&', name);
|
||||
return new ColorParse('&', name).toChatColor();
|
||||
}
|
||||
|
||||
public boolean hasMax() {
|
||||
@ -59,7 +56,7 @@ public class PlayerAttribute {
|
||||
return max;
|
||||
}
|
||||
|
||||
public Set<Entry<String, StatModifier>> getBuffs() {
|
||||
return buffs.entrySet();
|
||||
public Map<String, StatModifier> getBuffs() {
|
||||
return buffs;
|
||||
}
|
||||
}
|
||||
|
@ -193,8 +193,8 @@ public class PlayerAttributes {
|
||||
public void update() {
|
||||
PlayerAttribute attribute = MMOCore.plugin.attributeManager.get(id);
|
||||
int total = getTotal();
|
||||
attribute.getBuffs().forEach(buff -> data.getStats().getInstance(buff.getKey()).addModifier("attribute." + attribute.getId(),
|
||||
buff.getValue().multiply(total)));
|
||||
attribute.getBuffs()
|
||||
.forEach((key, buff) -> data.getStats().getInstance(key).addModifier("attribute." + attribute.getId(), buff.multiply(total)));
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -13,7 +13,6 @@ import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -25,9 +24,9 @@ import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.experience.ExpCurve;
|
||||
import net.Indyuce.mmocore.api.experience.source.type.ExperienceSource;
|
||||
import net.Indyuce.mmocore.api.load.PostLoadObject;
|
||||
import net.Indyuce.mmocore.api.player.ExpCurve;
|
||||
import net.Indyuce.mmocore.api.player.profess.event.EventTrigger;
|
||||
import net.Indyuce.mmocore.api.player.profess.resource.ManaDisplayOptions;
|
||||
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
||||
@ -38,6 +37,8 @@ import net.Indyuce.mmocore.api.skill.Skill.SkillInfo;
|
||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
||||
import net.Indyuce.mmocore.api.util.math.particle.CastingParticle;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.mmogroup.mmolib.api.MMOLineConfig;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
|
||||
@ -64,7 +65,7 @@ public class PlayerClass extends PostLoadObject {
|
||||
|
||||
this.id = id.toUpperCase().replace("-", "_").replace(" ", "_");
|
||||
|
||||
name = ChatColor.translateAlternateColorCodes('&', config.getString("display.name"));
|
||||
name = new ColorParse('&', config.getString("display.name")).toChatColor();
|
||||
icon = MMOCoreUtils.readIcon(config.getString("display.item", "BARRIER"));
|
||||
|
||||
if (config.contains("display.texture") && icon.getType() == VersionMaterial.PLAYER_HEAD.toMaterial())
|
||||
@ -76,20 +77,23 @@ public class PlayerClass extends PostLoadObject {
|
||||
gp.getProperties().put("textures", new Property("textures", config.getString("display.texture")));
|
||||
profileField.set(meta, gp);
|
||||
icon.setItemMeta(meta);
|
||||
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException exception) {
|
||||
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException
|
||||
| SecurityException exception) {
|
||||
throw new IllegalArgumentException("Could not apply playerhead texture: " + exception.getMessage());
|
||||
}
|
||||
|
||||
for (String string : config.getStringList("display.lore"))
|
||||
description.add(ChatColor.GRAY + ChatColor.translateAlternateColorCodes('&', string));
|
||||
description.add(ChatColor.GRAY + new ColorParse('&', string).toChatColor());
|
||||
for (String string : config.getStringList("display.attribute-lore"))
|
||||
attrDescription.add(ChatColor.GRAY + ChatColor.translateAlternateColorCodes('&', string));
|
||||
manaDisplay = config.contains("mana") ? new ManaDisplayOptions(config.getConfigurationSection("mana")) : ManaDisplayOptions.DEFAULT;
|
||||
attrDescription.add(ChatColor.GRAY + new ColorParse('&', string).toChatColor());
|
||||
manaDisplay = config.contains("mana") ? new ManaDisplayOptions(config.getConfigurationSection("mana"))
|
||||
: ManaDisplayOptions.DEFAULT;
|
||||
maxLevel = config.getInt("max-level");
|
||||
displayOrder = config.getInt("display.order");
|
||||
|
||||
expCurve = config.contains("exp-curve")
|
||||
? MMOCore.plugin.experience.getOrThrow(config.get("exp-curve").toString().toLowerCase().replace("_", "-").replace(" ", "-"))
|
||||
? MMOCore.plugin.experience.getOrThrow(
|
||||
config.get("exp-curve").toString().toLowerCase().replace("_", "-").replace(" ", "-"))
|
||||
: ExpCurve.DEFAULT;
|
||||
|
||||
if (config.contains("attributes"))
|
||||
@ -98,27 +102,30 @@ public class PlayerClass extends PostLoadObject {
|
||||
stats.put(StatType.valueOf(key.toUpperCase().replace("-", "_")),
|
||||
new LinearValue(config.getConfigurationSection("attributes." + key)));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING,
|
||||
"Could not load stat info '" + key + "' from class '" + id + "': " + exception.getMessage());
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load stat info '" + key + "' from class '"
|
||||
+ id + "': " + exception.getMessage());
|
||||
}
|
||||
|
||||
if (config.contains("skills"))
|
||||
for (String key : config.getConfigurationSection("skills").getKeys(false))
|
||||
try {
|
||||
Validate.isTrue(MMOCore.plugin.skillManager.has(key), "Could not find skill " + key);
|
||||
skills.put(key.toUpperCase(), MMOCore.plugin.skillManager.get(key).newSkillInfo(config.getConfigurationSection("skills." + key)));
|
||||
skills.put(key.toUpperCase(), MMOCore.plugin.skillManager.get(key)
|
||||
.newSkillInfo(config.getConfigurationSection("skills." + key)));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING,
|
||||
"Could not load skill info '" + key + "' from class '" + id + "': " + exception.getMessage());
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load skill info '" + key + "' from class '"
|
||||
+ id + "': " + exception.getMessage());
|
||||
}
|
||||
|
||||
castParticle = config.contains("cast-particle") ? new CastingParticle(config.getConfigurationSection("cast-particle"))
|
||||
castParticle = config.contains("cast-particle")
|
||||
? new CastingParticle(config.getConfigurationSection("cast-particle"))
|
||||
: new CastingParticle(Particle.SPELL_INSTANT);
|
||||
|
||||
if (config.contains("options"))
|
||||
for (String key : config.getConfigurationSection("options").getKeys(false))
|
||||
try {
|
||||
setOption(ClassOption.valueOf(key.toUpperCase().replace("-", "_").replace(" ", "_")), config.getBoolean("options." + key));
|
||||
setOption(ClassOption.valueOf(key.toUpperCase().replace("-", "_").replace(" ", "_")),
|
||||
config.getBoolean("options." + key));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING,
|
||||
"Could not load option '" + key + "' from class '" + key + "': " + exception.getMessage());
|
||||
@ -127,12 +134,13 @@ public class PlayerClass extends PostLoadObject {
|
||||
if (config.contains("main-exp-sources"))
|
||||
for (String key : config.getStringList("main-exp-sources"))
|
||||
try {
|
||||
ExperienceSource<?> source = MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key), null);
|
||||
ExperienceSource<?> source = MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key),
|
||||
null);
|
||||
source.setClass(this);
|
||||
MMOCore.plugin.professionManager.registerExpSource(source);
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING,
|
||||
"Could not load exp source '" + key + "' from class '" + id + "': " + exception.getMessage());
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load exp source '" + key + "' from class '"
|
||||
+ id + "': " + exception.getMessage());
|
||||
}
|
||||
|
||||
if (config.contains("triggers"))
|
||||
@ -146,17 +154,17 @@ public class PlayerClass extends PostLoadObject {
|
||||
}
|
||||
|
||||
/*
|
||||
* must make sure all the resourceHandlers are registered when the
|
||||
* placer class is initialized.
|
||||
* must make sure all the resourceHandlers are registered when the placer class
|
||||
* is initialized.
|
||||
*/
|
||||
for (PlayerResource resource : PlayerResource.values()) {
|
||||
if (config.isConfigurationSection("resource." + resource.name().toLowerCase()))
|
||||
try {
|
||||
resourceHandlers.put(resource,
|
||||
new ResourceHandler(resource, config.getConfigurationSection("resource." + resource.name().toLowerCase())));
|
||||
resourceHandlers.put(resource, new ResourceHandler(resource,
|
||||
config.getConfigurationSection("resource." + resource.name().toLowerCase())));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.log(Level.WARNING, "[PlayerClasses:" + id + "] Could not load special resource regen for " + resource.name() + ": "
|
||||
+ exception.getMessage());
|
||||
MMOCore.log(Level.WARNING, "[PlayerClasses:" + id + "] Could not load special resource regen for "
|
||||
+ resource.name() + ": " + exception.getMessage());
|
||||
resourceHandlers.put(resource, new ResourceHandler(resource));
|
||||
}
|
||||
else
|
||||
@ -191,11 +199,13 @@ public class PlayerClass extends PostLoadObject {
|
||||
if (config.contains("subclasses"))
|
||||
for (String key : config.getConfigurationSection("subclasses").getKeys(false))
|
||||
try {
|
||||
subclasses.add(new Subclass(MMOCore.plugin.classManager.getOrThrow(key.toUpperCase().replace("-", "_").replace(" ", "_")),
|
||||
subclasses.add(new Subclass(
|
||||
MMOCore.plugin.classManager
|
||||
.getOrThrow(key.toUpperCase().replace("-", "_").replace(" ", "_")),
|
||||
config.getInt("subclasses." + key)));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING,
|
||||
"Could not load subclass '" + key + "' from class '" + getId() + "': " + exception.getMessage());
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load subclass '" + key + "' from class '"
|
||||
+ getId() + "': " + exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package net.Indyuce.mmocore.api.player.profess.event.trigger;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||
@ -22,9 +23,11 @@ public class LevelUpEventTrigger implements EventTriggerHandler {
|
||||
|
||||
if(event.hasProfession()) {
|
||||
String prof = event.getProfession().getId().toLowerCase();
|
||||
MMOCore.debug(2, "[DEBUG] Looking for triggers: level-up-" + prof);
|
||||
processTrigger(player, profess, "level-up-" + prof);
|
||||
processTrigger(player, profess, "level-up-" + prof + "-" + event.getNewLevel());
|
||||
} else {
|
||||
MMOCore.debug(2, "[DEBUG] Normal level up trigger.");
|
||||
processTrigger(player, profess, "level-up");
|
||||
processTrigger(player, profess, "level-up-" + event.getNewLevel());
|
||||
if(profess.getMaxLevel() == event.getNewLevel())
|
||||
|
@ -1,9 +1,10 @@
|
||||
package net.Indyuce.mmocore.api.player.profess.resource;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.mmogroup.mmolib.api.util.AltChar;
|
||||
|
||||
public class ManaDisplayOptions {
|
||||
@ -21,15 +22,15 @@ public class ManaDisplayOptions {
|
||||
Validate.notNull(name, "Could not load mana name");
|
||||
|
||||
Validate.notNull(config.getConfigurationSection("color"), "Could not find mana color config");
|
||||
full = ChatColor.valueOf(config.getString("color.full", "NO_INPUT").toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||
half = ChatColor.valueOf(config.getString("color.half", "NO_INPUT").toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||
empty = ChatColor.valueOf(config.getString("color.empty", "NO_INPUT").toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||
full = ColorParse.getColor(config.getString("color.full", "NO_INPUT"));
|
||||
half = ColorParse.getColor(config.getString("color.half", "NO_INPUT"));
|
||||
empty = ColorParse.getColor(config.getString("color.empty", "NO_INPUT"));
|
||||
|
||||
String format = config.getString("char", "");
|
||||
Validate.notEmpty(format, "Could not load mana bar character");
|
||||
barCharacter = format.charAt(0);
|
||||
|
||||
icon = ChatColor.translateAlternateColorCodes('&', config.getString("icon", ""));
|
||||
icon = new ColorParse('&', config.getString("icon", "")).toChatColor();
|
||||
Validate.notEmpty(format, "Could not load mana action bar icon");
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,10 @@ public class Party {
|
||||
}
|
||||
|
||||
public void removeMember(PlayerData data) {
|
||||
removeMember(data, true);
|
||||
}
|
||||
|
||||
public void removeMember(PlayerData data, boolean notify) {
|
||||
if (data.isOnline() && data.getPlayer().getOpenInventory() != null
|
||||
&& data.getPlayer().getOpenInventory().getTopInventory().getHolder() instanceof PartyViewInventory)
|
||||
InventoryManager.PARTY_CREATION.newInventory(data).open();
|
||||
@ -72,7 +76,7 @@ public class Party {
|
||||
// transfer ownership
|
||||
if (owner.equals(data)) {
|
||||
owner = members.get(0);
|
||||
MMOCore.plugin.configManager.getSimpleMessage("transfer-party-ownership").send(owner.getPlayer());
|
||||
if(notify) MMOCore.plugin.configManager.getSimpleMessage("transfer-party-ownership").send(owner.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,9 @@ public enum StatType {
|
||||
WEAPON_DAMAGE,
|
||||
SKILL_DAMAGE,
|
||||
|
||||
PVP_DAMAGE,
|
||||
PVE_DAMAGE,
|
||||
|
||||
DAMAGE_REDUCTION,
|
||||
PHYSICAL_DAMAGE_REDUCTION,
|
||||
PROJECTILE_DAMAGE_REDUCTION,
|
||||
|
@ -1,9 +1,8 @@
|
||||
package net.Indyuce.mmocore.api.quest;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.quest.objective.Objective;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
|
||||
public class QuestProgress {
|
||||
private final Quest quest;
|
||||
@ -65,6 +64,6 @@ public class QuestProgress {
|
||||
}
|
||||
|
||||
public String getFormattedLore() {
|
||||
return ChatColor.translateAlternateColorCodes('&', objectiveProgress.formatLore(objectiveProgress.getObjective().getDefaultLore()));
|
||||
return new ColorParse('&', objectiveProgress.formatLore(objectiveProgress.getObjective().getDefaultLore())).toChatColor();
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ package net.Indyuce.mmocore.api.quest.trigger;
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.experience.EXPSource;
|
||||
import net.Indyuce.mmocore.api.experience.ExperienceInfo;
|
||||
import net.Indyuce.mmocore.api.experience.Profession;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
@ -29,9 +30,9 @@ public class ExperienceTrigger extends Trigger {
|
||||
@Override
|
||||
public void apply(PlayerData player) {
|
||||
if (profession == null)
|
||||
player.giveExperience(amount.calculateInt());
|
||||
player.giveExperience(amount.calculateInt(), EXPSource.QUEST);
|
||||
else
|
||||
player.getCollectionSkills().giveExperience(profession, amount.calculateInt());
|
||||
player.getCollectionSkills().giveExperience(profession, amount.calculateInt(), EXPSource.QUEST);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3,8 +3,20 @@ package net.Indyuce.mmocore.api.util.debug;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
|
||||
public class DebugMode {
|
||||
public DebugMode() {
|
||||
if (MMOCore.plugin.getConfig().getBoolean("debug-action-bar.enabled"))
|
||||
/*
|
||||
* Debug Levels:
|
||||
* 1:
|
||||
* - Print WorldGuard Flag Registry
|
||||
* 2:
|
||||
* - Print Profession Trigger Things
|
||||
* 3:
|
||||
* - Debug Action Bar
|
||||
*/
|
||||
public static int level = 0;
|
||||
|
||||
public DebugMode(int i) {
|
||||
level = i;
|
||||
if (level > 2 && MMOCore.plugin.getConfig().getBoolean("debug-action-bar.enabled"))
|
||||
new ActionBarRunnable().runTaskTimer(MMOCore.plugin, 0, 10);
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
@ -20,6 +19,7 @@ import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.item.ItemTag;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
@ -138,6 +138,6 @@ public class ConfigItem {
|
||||
for (String placeholder : placeholders.keySet())
|
||||
if (string.contains("{" + placeholder + "}"))
|
||||
string = string.replace("{" + placeholder + "}", "" + placeholders.get(placeholder));
|
||||
return ChatColor.translateAlternateColorCodes('&', string);
|
||||
return new ColorParse('&', string).toChatColor();
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,17 @@
|
||||
package net.Indyuce.mmocore.api.util.item;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
|
||||
public class NamedItemStack extends ItemStack {
|
||||
public NamedItemStack(Material material, String name) {
|
||||
super(material);
|
||||
|
||||
ItemMeta meta = getItemMeta();
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
||||
meta.setDisplayName(new ColorParse('&', name).toChatColor());
|
||||
setItemMeta(meta);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
package net.Indyuce.mmocore.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.defaults.BukkitCommand;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmocore.api.event.MMOCommandEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.manager.InventoryManager;
|
||||
|
||||
@ -24,7 +26,10 @@ public class AttributesCommand extends BukkitCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
InventoryManager.ATTRIBUTE_VIEW.newInventory(PlayerData.get((Player) sender)).open();
|
||||
PlayerData data = PlayerData.get((Player) sender);
|
||||
MMOCommandEvent event = new MMOCommandEvent(data, "attributes");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if(!event.isCancelled()) InventoryManager.ATTRIBUTE_VIEW.newInventory(data).open();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.defaults.BukkitCommand;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmocore.api.event.MMOCommandEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.manager.InventoryManager;
|
||||
|
||||
@ -30,6 +31,9 @@ public class ClassCommand extends BukkitCommand {
|
||||
}
|
||||
|
||||
PlayerData data = PlayerData.get(player);
|
||||
MMOCommandEvent event = new MMOCommandEvent(data, "class");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if(event.isCancelled()) return true;
|
||||
if (data.getProfess().getSubclasses().stream().filter(sub -> sub.getLevel() <= data.getLevel()).count() > 0)
|
||||
InventoryManager.SUBCLASS_SELECT.newInventory(data).open();
|
||||
else
|
||||
|
@ -2,6 +2,7 @@ package net.Indyuce.mmocore.command;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.defaults.BukkitCommand;
|
||||
@ -9,6 +10,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.event.MMOCommandEvent;
|
||||
import net.Indyuce.mmocore.api.player.OfflinePlayerData;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.social.FriendRequest;
|
||||
@ -30,6 +32,11 @@ public class FriendsCommand extends BukkitCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerData data = PlayerData.get((Player) sender);
|
||||
MMOCommandEvent event = new MMOCommandEvent(data, "friends");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if(event.isCancelled()) return true;
|
||||
|
||||
if (args.length > 1) {
|
||||
UUID uuid;
|
||||
try {
|
||||
@ -59,7 +66,7 @@ public class FriendsCommand extends BukkitCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
InventoryManager.FRIEND_LIST.newInventory(PlayerData.get((Player) sender)).open();
|
||||
InventoryManager.FRIEND_LIST.newInventory(data).open();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package net.Indyuce.mmocore.command;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -10,6 +11,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.event.MMOCommandEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.social.Request;
|
||||
import net.Indyuce.mmocore.api.player.social.guilds.GuildInvite;
|
||||
@ -31,6 +33,11 @@ public class GuildCommand extends BukkitCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerData data = PlayerData.get((OfflinePlayer) sender);
|
||||
MMOCommandEvent event = new MMOCommandEvent(data, "guild");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if(event.isCancelled()) return true;
|
||||
|
||||
if (args.length > 1) {
|
||||
UUID uuid;
|
||||
try {
|
||||
@ -60,7 +67,6 @@ public class GuildCommand extends BukkitCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerData data = PlayerData.get((OfflinePlayer) sender);
|
||||
if (data.inGuild())
|
||||
InventoryManager.GUILD_VIEW.newInventory(data).open();
|
||||
else
|
||||
|
@ -54,6 +54,7 @@ public class MMOCoreCommand extends CommandRoot implements CommandExecutor, TabC
|
||||
|
||||
CommandParser reader = readCommand(args);
|
||||
List<String> list = reader.readTabCompletion();
|
||||
return args[args.length - 1].isEmpty() ? list : list.stream().filter(string -> string.toLowerCase().startsWith(args[args.length - 1].toLowerCase())).collect(Collectors.toList());
|
||||
return args[args.length - 1].isEmpty() ? list
|
||||
: list.stream().filter(string -> string.toLowerCase().startsWith(args[args.length - 1].toLowerCase())).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package net.Indyuce.mmocore.command;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -10,6 +11,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.event.MMOCommandEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.social.PartyInvite;
|
||||
import net.Indyuce.mmocore.api.player.social.Request;
|
||||
@ -31,6 +33,11 @@ public class PartyCommand extends BukkitCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerData data = PlayerData.get((OfflinePlayer) sender);
|
||||
MMOCommandEvent event = new MMOCommandEvent(data, "party");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if(event.isCancelled()) return true;
|
||||
|
||||
if (args.length > 1) {
|
||||
UUID uuid;
|
||||
try {
|
||||
@ -60,7 +67,6 @@ public class PartyCommand extends BukkitCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerData data = PlayerData.get((OfflinePlayer) sender);
|
||||
if (data.hasParty())
|
||||
InventoryManager.PARTY_VIEW.newInventory(data).open();
|
||||
else
|
||||
|
@ -1,11 +1,13 @@
|
||||
package net.Indyuce.mmocore.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.defaults.BukkitCommand;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmocore.api.event.MMOCommandEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.manager.InventoryManager;
|
||||
|
||||
@ -23,8 +25,11 @@ public class PlayerStatsCommand extends BukkitCommand {
|
||||
sender.sendMessage(ChatColor.RED + "This command is for players only.");
|
||||
return true;
|
||||
}
|
||||
|
||||
InventoryManager.PLAYER_STATS.newInventory(PlayerData.get((Player) sender)).open();
|
||||
|
||||
PlayerData data = PlayerData.get((Player) sender);
|
||||
MMOCommandEvent event = new MMOCommandEvent(data, "profile");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if(!event.isCancelled()) InventoryManager.PLAYER_STATS.newInventory(data).open();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
package net.Indyuce.mmocore.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.defaults.BukkitCommand;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmocore.api.event.MMOCommandEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.manager.InventoryManager;
|
||||
|
||||
@ -18,8 +20,12 @@ public class QuestsCommand extends BukkitCommand {
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
if (sender instanceof Player)
|
||||
InventoryManager.QUEST_LIST.newInventory(PlayerData.get((Player) sender)).open();
|
||||
if (sender instanceof Player) {
|
||||
PlayerData data = PlayerData.get((Player) sender);
|
||||
MMOCommandEvent event = new MMOCommandEvent(data, "quests");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if(!event.isCancelled()) InventoryManager.QUEST_LIST.newInventory(data).open();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
package net.Indyuce.mmocore.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.defaults.BukkitCommand;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.event.MMOCommandEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.manager.InventoryManager;
|
||||
|
||||
@ -21,6 +23,10 @@ public class SkillsCommand extends BukkitCommand {
|
||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
PlayerData data = PlayerData.get((Player) sender);
|
||||
MMOCommandEvent event = new MMOCommandEvent(data, "skills");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if(event.isCancelled()) return true;
|
||||
|
||||
if (data.getProfess().getSkills().size() < 1) {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("no-class-skill").send((Player) sender);
|
||||
return true;
|
||||
|
@ -1,10 +1,12 @@
|
||||
package net.Indyuce.mmocore.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.defaults.BukkitCommand;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmocore.api.event.MMOCommandEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.manager.InventoryManager;
|
||||
|
||||
@ -18,8 +20,12 @@ public class WaypointsCommand extends BukkitCommand {
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
if (sender instanceof Player && sender.hasPermission("mmocore.waypoints"))
|
||||
InventoryManager.WAYPOINTS.newInventory(PlayerData.get((Player) sender)).open();
|
||||
if (sender instanceof Player && sender.hasPermission("mmocore.waypoints")) {
|
||||
PlayerData data = PlayerData.get((Player) sender);
|
||||
MMOCommandEvent event = new MMOCommandEvent(data, "waypoints");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if(!event.isCancelled()) InventoryManager.WAYPOINTS.newInventory(data).open();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.experience.Profession;
|
||||
import net.Indyuce.mmocore.api.experience.EXPSource;
|
||||
import net.Indyuce.mmocore.api.experience.PlayerProfessions;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.command.api.CommandEnd;
|
||||
@ -20,7 +21,7 @@ public class ExperienceCommandMap extends CommandMap {
|
||||
super(parent, "exp");
|
||||
|
||||
addFloor(new ActionCommandMap(this, "set", (data, value) -> data.setExperience(value), (professions, profession, value) -> professions.setExperience(profession, value)));
|
||||
addFloor(new ActionCommandMap(this, "give", (data, value) -> data.giveExperience(value, data.getPlayer().getLocation()), (professions, profession, value) -> professions.giveExperience(profession, value, professions.getPlayerData().getPlayer().getLocation())));
|
||||
addFloor(new ActionCommandMap(this, "give", (data, value) -> data.giveExperience(value, data.getPlayer().getLocation(), EXPSource.COMMAND), (professions, profession, value) -> professions.giveExperience(profession, value, professions.getPlayerData().getPlayer().getLocation(), EXPSource.COMMAND)));
|
||||
}
|
||||
|
||||
public class ActionCommandMap extends CommandEnd {
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.experience.Profession;
|
||||
import net.Indyuce.mmocore.api.experience.EXPSource;
|
||||
import net.Indyuce.mmocore.api.experience.PlayerProfessions;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.command.api.CommandEnd;
|
||||
@ -20,7 +21,7 @@ public class LevelCommandMap extends CommandMap {
|
||||
super(parent, "level");
|
||||
|
||||
addFloor(new ActionCommandMap(this, "set", (data, value) -> data.setLevel(value), (professions, profession, value) -> professions.setLevel(profession, value)));
|
||||
addFloor(new ActionCommandMap(this, "give", (data, value) -> data.giveLevels(value), (professions, profession, value) -> professions.giveLevels(profession, value)));
|
||||
addFloor(new ActionCommandMap(this, "give", (data, value) -> data.giveLevels(value, EXPSource.COMMAND), (professions, profession, value) -> professions.giveLevels(profession, value, EXPSource.COMMAND)));
|
||||
}
|
||||
|
||||
public class ActionCommandMap extends CommandEnd {
|
||||
|
@ -44,7 +44,7 @@ public class StatModifiersCommandMap extends CommandEnd {
|
||||
StatInstance instance = data.getStats().getInstance(stat);
|
||||
sender.sendMessage("Stat Modifiers (" + instance.getKeys().size() + "):");
|
||||
for (String key : instance.getKeys()) {
|
||||
StatModifier mod = instance.getByKey(key);
|
||||
StatModifier mod = instance.getAttribute(key);
|
||||
sender.sendMessage("- " + key + ": " + mod.getValue() + " " + mod.getType().name());
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package net.Indyuce.mmocore.comp.flags;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -14,6 +15,8 @@ import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
|
||||
public class WorldGuardFlags implements FlagPlugin {
|
||||
private final WorldGuard worldguard;
|
||||
private final WorldGuardPlugin worldguardPlugin;
|
||||
@ -30,7 +33,11 @@ public class WorldGuardFlags implements FlagPlugin {
|
||||
try {
|
||||
registry.register(flag);
|
||||
flags.put(customFlag.getPath(), flag);
|
||||
MMOCore.debug(1, "[FLAGDEBUG] Registered WG Flag\n"
|
||||
+ " - Info{name=" + flag.getName() + ",path=" + customFlag.getPath() + "}");
|
||||
} catch (Exception exception) {
|
||||
MMOCore.debug(1, Level.SEVERE, "[FLAGDEBUG] FAILED to register WG Flag\n"
|
||||
+ " - Info{name=" + flag.getName() + ",path=" + customFlag.getPath() + "}");
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ import net.Indyuce.mmocore.api.experience.source.type.ExperienceSource;
|
||||
import net.Indyuce.mmocore.api.load.MMOLoader;
|
||||
import net.Indyuce.mmocore.api.quest.objective.Objective;
|
||||
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
|
||||
import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicFactionExperienceSource;
|
||||
import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicFactionObjective;
|
||||
import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicMobExperienceSource;
|
||||
import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicMobObjective;
|
||||
import net.Indyuce.mmocore.comp.mythicmobs.load.MythicMobSkillTrigger;
|
||||
@ -28,6 +30,8 @@ public class MythicMobsMMOLoader extends MMOLoader {
|
||||
|
||||
if (config.getKey().equalsIgnoreCase("killmythicmob"))
|
||||
return new KillMythicMobObjective(section, config);
|
||||
if (config.getKey().equalsIgnoreCase("killmythicfaction"))
|
||||
return new KillMythicFactionObjective(section, config);
|
||||
|
||||
return null;
|
||||
}
|
||||
@ -37,6 +41,8 @@ public class MythicMobsMMOLoader extends MMOLoader {
|
||||
|
||||
if (config.getKey().equalsIgnoreCase("killmythicmob"))
|
||||
return new KillMythicMobExperienceSource(profession, config);
|
||||
if (config.getKey().equalsIgnoreCase("killmythicfaction"))
|
||||
return new KillMythicFactionExperienceSource(profession, config);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -0,0 +1,51 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs.load;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.experience.Profession;
|
||||
import net.Indyuce.mmocore.api.experience.source.type.SpecificExperienceSource;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.manager.profession.ExperienceManager;
|
||||
import net.mmogroup.mmolib.api.MMOLineConfig;
|
||||
|
||||
public class KillMythicFactionExperienceSource extends SpecificExperienceSource<String> {
|
||||
private final String factionName;
|
||||
|
||||
public KillMythicFactionExperienceSource(Profession profession, MMOLineConfig config) {
|
||||
super(profession, config);
|
||||
|
||||
config.validate("name");
|
||||
factionName = config.getString("name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExperienceManager<KillMythicFactionExperienceSource> newManager() {
|
||||
return new ExperienceManager<KillMythicFactionExperienceSource>() {
|
||||
@EventHandler
|
||||
public void a(MythicMobDeathEvent event) {
|
||||
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!event.getEntity().isDead()) return;
|
||||
if (!event.getMob().hasFaction()) return;
|
||||
if (!(event.getKiller() instanceof Player) || event.getKiller().hasMetadata("NPC")) return;
|
||||
|
||||
PlayerData data = PlayerData.get((Player) event.getKiller());
|
||||
for (KillMythicFactionExperienceSource source : getSources())
|
||||
if (source.matches(data, event.getMob().getFaction()))
|
||||
source.giveExperience(data, event.getEntity().getLocation());
|
||||
}
|
||||
}, 2);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(PlayerData player, String name) {
|
||||
return hasRightClass(player) && name.equals(factionName);
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs.load;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
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 net.mmogroup.mmolib.api.MMOLineConfig;
|
||||
|
||||
public class KillMythicFactionObjective extends Objective {
|
||||
private final String factionName;
|
||||
private final int required;
|
||||
|
||||
public KillMythicFactionObjective(ConfigurationSection section, MMOLineConfig config) {
|
||||
super(section);
|
||||
|
||||
config.validate("amount", "name");
|
||||
|
||||
factionName = config.getString("name");
|
||||
required = config.getInt("amount");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectiveProgress newProgress(QuestProgress questProgress) {
|
||||
return new KillFactionProgress(questProgress, this);
|
||||
}
|
||||
|
||||
public class KillFactionProgress extends ObjectiveProgress implements Listener {
|
||||
private int count;
|
||||
|
||||
public KillFactionProgress(QuestProgress questProgress, Objective objective) {
|
||||
super(questProgress, objective);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(MythicMobDeathEvent event) {
|
||||
if (event.getKiller() instanceof Player
|
||||
&& event.getKiller().equals(getQuestProgress().getPlayer().getPlayer())
|
||||
&& event.getMob().hasFaction() && event.getMob().getFaction().equals(factionName)) {
|
||||
count++;
|
||||
getQuestProgress().getPlayer().getQuestData().updateBossBar();
|
||||
if (count >= required)
|
||||
getQuestProgress().completeObjective();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatLore(String lore) {
|
||||
return lore.replace("{left}", "" + (required - count));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
package net.Indyuce.mmocore.comp.placeholder;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
|
||||
public class DefaultParser implements PlaceholderParser {
|
||||
@Override
|
||||
public String parse(OfflinePlayer player, String string) {
|
||||
return ChatColor.translateAlternateColorCodes('&', string.replace("%player%", player.getName()));
|
||||
return new ColorParse('&', string.replace("%player%", player.getName())).toChatColor();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package net.Indyuce.mmocore.gui;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
@ -17,7 +15,6 @@ import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.InventoryPlaceholderItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
||||
import net.mmogroup.mmolib.api.stat.modifier.StatModifier;
|
||||
|
||||
public class AttributeView extends EditableInventory {
|
||||
public AttributeView() {
|
||||
@ -52,7 +49,8 @@ public class AttributeView extends EditableInventory {
|
||||
public AttributeItem(String function, ConfigurationSection config) {
|
||||
super(config);
|
||||
|
||||
attribute = MMOCore.plugin.attributeManager.get(function.substring("attribute_".length()).toLowerCase().replace(" ", "-").replace("_", "-"));
|
||||
attribute = MMOCore.plugin.attributeManager
|
||||
.get(function.substring("attribute_".length()).toLowerCase().replace(" ", "-").replace("_", "-"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -66,10 +64,10 @@ public class AttributeView extends EditableInventory {
|
||||
holders.register("max", attribute.getMax());
|
||||
holders.register("current", total);
|
||||
holders.register("attribute_points", inv.getPlayerData().getAttributePoints());
|
||||
for (Entry<String, StatModifier> entry : attribute.getBuffs()) {
|
||||
holders.register("buff_" + entry.getKey().toLowerCase(), entry.getValue());
|
||||
holders.register("total_" + entry.getKey().toLowerCase(), entry.getValue().multiply(total));
|
||||
}
|
||||
attribute.getBuffs().forEach((key, buff) -> {
|
||||
holders.register("buff_" + key.toLowerCase(), buff);
|
||||
holders.register("total_" + key.toLowerCase(), buff.multiply(total));
|
||||
});
|
||||
return holders;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -24,6 +23,7 @@ import net.Indyuce.mmocore.gui.api.GeneratedInventory;
|
||||
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
|
||||
import net.Indyuce.mmocore.manager.InventoryManager;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.api.item.ItemTag;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
|
||||
@ -68,7 +68,7 @@ public class ClassSelect extends EditableInventory {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (hideFlags())
|
||||
meta.addItemFlags(ItemFlag.values());
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name).replace("{name}", profess.getName()));
|
||||
meta.setDisplayName(new ColorParse('&', name).toChatColor().replace("{name}", profess.getName()));
|
||||
List<String> lore = new ArrayList<>(this.lore);
|
||||
|
||||
int index = lore.indexOf("{lore}");
|
||||
|
@ -27,6 +27,7 @@ import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.InventoryPlaceholderItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.api.item.ItemTag;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
|
||||
@ -70,7 +71,7 @@ public class SkillList extends EditableInventory {
|
||||
|
||||
if (function.equals("slot"))
|
||||
return new InventoryPlaceholderItem(config) {
|
||||
private final String none = ChatColor.translateAlternateColorCodes('&', config.getString("no-skill"));
|
||||
private final String none = new ColorParse('&', config.getString("no-skill")).toChatColor();
|
||||
private final Material emptyMaterial = Material
|
||||
.valueOf(config.getString("empty-item").toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||
|
||||
@ -169,12 +170,12 @@ public class SkillList extends EditableInventory {
|
||||
lore.add(index + j, skillLore.get(j));
|
||||
|
||||
for (int j = 0; j < lore.size(); j++)
|
||||
lore.set(j, ChatColor.GRAY + ChatColor.translateAlternateColorCodes('&', lore.get(j)));
|
||||
lore.set(j, ChatColor.GRAY + new ColorParse('&', lore.get(j)).toChatColor());
|
||||
|
||||
ItemStack item = cloneItem();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', getName().replace("{skill}", skill.getSkill().getName())
|
||||
.replace("{roman}", MMOCoreUtils.intToRoman(skillLevel)).replace("{level}", "" + skillLevel)));
|
||||
meta.setDisplayName(new ColorParse('&', getName().replace("{skill}", skill.getSkill().getName())
|
||||
.replace("{roman}", MMOCoreUtils.intToRoman(skillLevel)).replace("{level}", "" + skillLevel)).toChatColor());
|
||||
meta.addItemFlags(ItemFlag.values());
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
@ -21,6 +20,7 @@ import net.Indyuce.mmocore.gui.api.GeneratedInventory;
|
||||
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
|
||||
import net.Indyuce.mmocore.manager.InventoryManager;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
import net.mmogroup.mmolib.api.item.ItemTag;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
|
||||
@ -65,7 +65,7 @@ public class SubclassSelect extends EditableInventory {
|
||||
|
||||
ItemStack item = profess.getIcon();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name).replace("{name}", profess.getName()));
|
||||
meta.setDisplayName(new ColorParse('&', name).toChatColor().replace("{name}", profess.getName()));
|
||||
List<String> lore = new ArrayList<>(this.lore);
|
||||
|
||||
int index = lore.indexOf("{lore}");
|
||||
|
@ -4,13 +4,13 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.TriggerItem;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
|
||||
public abstract class GeneratedInventory extends PluginInventory {
|
||||
private final EditableInventory editable;
|
||||
@ -54,7 +54,7 @@ public abstract class GeneratedInventory extends PluginInventory {
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
Inventory inv = Bukkit.createInventory(this, editable.getSlots(), ChatColor.translateAlternateColorCodes('&', calculateName()));
|
||||
Inventory inv = Bukkit.createInventory(this, editable.getSlots(), new ColorParse('&', calculateName()).toChatColor());
|
||||
|
||||
for (InventoryItem item : editable.getItems())
|
||||
if (item.canDisplay(this))
|
||||
|
@ -65,10 +65,11 @@ public class EditablePartyView extends EditableInventory {
|
||||
/*
|
||||
* run async to save performance
|
||||
*/
|
||||
if (meta instanceof SkullMeta) {
|
||||
((SkullMeta) meta).setOwningPlayer(member.getPlayer());
|
||||
disp.setItemMeta(meta);
|
||||
}
|
||||
if (meta instanceof SkullMeta)
|
||||
Bukkit.getScheduler().runTaskAsynchronously(MMOCore.plugin, () -> {
|
||||
((SkullMeta) meta).setOwningPlayer(member.getPlayer());
|
||||
disp.setItemMeta(meta);
|
||||
});
|
||||
|
||||
return NBTItem.get(disp).addTag(new ItemTag("uuid", member.getUniqueId().toString())).toItem();
|
||||
}
|
||||
|
@ -70,6 +70,8 @@ public class PlayerListener implements Listener {
|
||||
PlayerData playerData = PlayerData.get(event.getPlayer());
|
||||
if (playerData.hasParty())
|
||||
playerData.getParty().removeMember(playerData);
|
||||
|
||||
MMOCore.plugin.dataProvider.getDataManager().remove(playerData);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -33,6 +33,7 @@ public class WaypointsListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
player.setSneaking(false);
|
||||
InventoryManager.WAYPOINTS.newInventory(data, waypoint).open();
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerExpChangeEvent;
|
||||
|
||||
import net.Indyuce.mmocore.api.experience.EXPSource;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
|
||||
public class RedirectVanillaExp implements Listener {
|
||||
@ -17,6 +18,6 @@ public class RedirectVanillaExp implements Listener {
|
||||
public void a(PlayerExpChangeEvent event) {
|
||||
int a = (int) (event.getAmount() * ratio);
|
||||
if (a > 0)
|
||||
PlayerData.get(event.getPlayer()).giveExperience(a);
|
||||
PlayerData.get(event.getPlayer()).giveExperience(a, EXPSource.VANILLA);
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import org.bukkit.util.Vector;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.droptable.dropitem.fishing.FishingDropItem;
|
||||
import net.Indyuce.mmocore.api.event.CustomPlayerFishEvent;
|
||||
import net.Indyuce.mmocore.api.experience.EXPSource;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.stats.StatType;
|
||||
import net.Indyuce.mmocore.manager.profession.FishingManager.FishingDropTable;
|
||||
@ -176,7 +177,7 @@ public class FishingListener implements Listener {
|
||||
location.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, location, 0, 4 * (random.nextDouble() - .5), 2, 4 * (random.nextDouble() - .5), .05);
|
||||
|
||||
if (MMOCore.plugin.professionManager.has("fishing"))
|
||||
playerData.getCollectionSkills().giveExperience(MMOCore.plugin.professionManager.get("fishing"), exp, location);
|
||||
playerData.getCollectionSkills().giveExperience(MMOCore.plugin.professionManager.get("fishing"), exp, location, EXPSource.FISHING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import net.Indyuce.mmocore.api.util.input.AnvilGUI;
|
||||
import net.Indyuce.mmocore.api.util.input.ChatInput;
|
||||
import net.Indyuce.mmocore.api.util.input.PlayerInput;
|
||||
import net.Indyuce.mmocore.api.util.input.PlayerInput.InputType;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
|
||||
public class ConfigManager {
|
||||
|
||||
@ -155,28 +156,32 @@ public class ConfigManager {
|
||||
String format = messages.getString(key, "");
|
||||
for (int j = 0; j < placeholders.length - 1; j += 2)
|
||||
format = format.replace("{" + placeholders[j] + "}", placeholders[j + 1]);
|
||||
return new SimpleMessage(ChatColor.translateAlternateColorCodes('&', format));
|
||||
return new SimpleMessage(new ColorParse('&', format).toChatColor());
|
||||
}
|
||||
|
||||
public class SimpleMessage {
|
||||
private final String message;
|
||||
private final boolean actionbar;
|
||||
private final boolean hasPlaceholders;
|
||||
|
||||
public SimpleMessage(String message) {
|
||||
this.message = message;
|
||||
this.actionbar = message.startsWith("%");
|
||||
this.message = actionbar ? message.substring(1) : message;
|
||||
this.hasPlaceholders = this.message.contains("%");
|
||||
}
|
||||
|
||||
public String message() {
|
||||
return message.startsWith("%") ? message.substring(1) : message;
|
||||
return message;
|
||||
}
|
||||
|
||||
public boolean send(Player player) {
|
||||
if (!message.isEmpty()) {
|
||||
if (message.startsWith("%"))
|
||||
PlayerData.get(player.getUniqueId()).displayActionBar(message.substring(1));
|
||||
else
|
||||
player.sendMessage(message);
|
||||
String msg = hasPlaceholders ? MMOCore.plugin.placeholderParser.parse(player, message) : message;
|
||||
|
||||
if (!msg.isEmpty()) {
|
||||
if (actionbar) PlayerData.get(player.getUniqueId()).displayActionBar(msg);
|
||||
else player.sendMessage(msg);
|
||||
}
|
||||
return !message.isEmpty();
|
||||
return !msg.isEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import java.util.logging.Level;
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.ExpCurve;
|
||||
import net.Indyuce.mmocore.api.experience.ExpCurve;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
|
||||
public class ExperienceManager {
|
||||
|
@ -25,6 +25,10 @@ public abstract class PlayerDataManager {
|
||||
return map.getOrDefault(uuid, PlayerData.NOT_LOADED);
|
||||
}
|
||||
|
||||
public void remove(UUID uuid) {
|
||||
map.remove(uuid);
|
||||
}
|
||||
|
||||
public abstract OfflinePlayerData getOffline(UUID uuid);
|
||||
|
||||
public void setup(Player player) {
|
||||
@ -54,7 +58,7 @@ public abstract class PlayerDataManager {
|
||||
public boolean isLoaded(UUID uuid) {
|
||||
return map.containsKey(uuid);
|
||||
}
|
||||
|
||||
|
||||
public Collection<PlayerData> getLoaded() {
|
||||
return map.values();
|
||||
}
|
||||
@ -62,4 +66,6 @@ public abstract class PlayerDataManager {
|
||||
public abstract void loadData(PlayerData data);
|
||||
|
||||
public abstract void saveData(PlayerData data);
|
||||
|
||||
public abstract void remove(PlayerData data);
|
||||
}
|
||||
|
@ -231,4 +231,10 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
||||
return lastLogin;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(PlayerData data) {
|
||||
saveData(data);
|
||||
remove(data.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
@ -127,4 +127,7 @@ public class YAMLPlayerDataManager extends PlayerDataManager {
|
||||
public OfflinePlayerData getOffline(UUID uuid) {
|
||||
return isLoaded(uuid) ? get(uuid) : new YAMLOfflinePlayerData(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(PlayerData data) {}
|
||||
}
|
||||
|
@ -11,7 +11,16 @@ public class BoosterManager {
|
||||
private List<Booster> map = new ArrayList<>();
|
||||
|
||||
public void register(Booster booster) {
|
||||
|
||||
// always flush booster list to reduce future calculations
|
||||
flush();
|
||||
|
||||
for (Booster active : map)
|
||||
if (active.canStackWith(booster)) {
|
||||
active.addLength(booster.getLength());
|
||||
return;
|
||||
}
|
||||
|
||||
map.add(booster);
|
||||
}
|
||||
|
||||
@ -25,17 +34,20 @@ public class BoosterManager {
|
||||
|
||||
public int calculateExp(Profession profession, double exp) {
|
||||
flush();
|
||||
|
||||
for (Booster booster : map)
|
||||
if (booster.getProfession() == profession)
|
||||
exp = booster.calculateExp(exp);
|
||||
|
||||
return (int) exp;
|
||||
}
|
||||
|
||||
public List<Booster> getBoosters() {
|
||||
flush();
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
public Booster get(int index) {
|
||||
return map.get(index);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user