diff --git a/.project b/.project index 62e272d..231375f 100644 --- a/.project +++ b/.project @@ -1,23 +1,23 @@ - - - PluginLibrary - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.m2e.core.maven2Nature - org.eclipse.jdt.core.javanature - - + + + PluginLibrary + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index f4217b0..6249222 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,12 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.7 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/pom.xml b/pom.xml index 99ac83a..c9471e8 100644 --- a/pom.xml +++ b/pom.xml @@ -1,47 +1,50 @@ - - 4.0.0 - PluginLibrary - PluginLibrary - 1.0 - PluginLibrary - - src - - - src - - **/*.java - - - - - true - ${basedir} - - *.yml - - - - - - maven-compiler-plugin - 3.1 - - 1.7 - 1.7 - - - - - - - - - git-Staartvin - Staartvin's Git based repo - https://github.com/Staartvin/maven-repo/raw/master/ - - - + + 4.0.0 + PluginLibrary + PluginLibrary + 1.0 + PluginLibrary + + src + + + src + + **/*.java + + + + + true + ${basedir} + + *.yml + + + + + + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + + + + + + Staartvin-Bitbucket-repo + https://bitbucket.org/Staartvin/maven-repo/raw/master/ + + + + stats-repo-snapshots + http://nexus.lolmewn.nl/content/repositories/snapshots/ + + + \ No newline at end of file diff --git a/src/me/staartvin/plugins/pluginlibrary/Library.java b/src/me/staartvin/plugins/pluginlibrary/Library.java index bac7480..e16e894 100644 --- a/src/me/staartvin/plugins/pluginlibrary/Library.java +++ b/src/me/staartvin/plugins/pluginlibrary/Library.java @@ -1,61 +1,61 @@ -package me.staartvin.plugins.pluginlibrary; - -import me.staartvin.plugins.pluginlibrary.hooks.AFKTerminatorHook; -import me.staartvin.plugins.pluginlibrary.hooks.AutorankHook; -import me.staartvin.plugins.pluginlibrary.hooks.FactionsHook; -import me.staartvin.plugins.pluginlibrary.hooks.LibraryHook; -import me.staartvin.plugins.pluginlibrary.hooks.McMMOHook; -import me.staartvin.plugins.pluginlibrary.hooks.OnTimeHook; -import me.staartvin.plugins.pluginlibrary.hooks.RoyalCommandsHook; -import me.staartvin.plugins.pluginlibrary.hooks.StatsHook; -import me.staartvin.plugins.pluginlibrary.hooks.UltimateCoreHook; - -/** - * This class holds all libraries PluginLibrary has. - *

- * Date created: 14:12:35 12 aug. 2015 - * - * @author Staartvin - * - */ -public enum Library { - - AUTORANK("Autorank", new AutorankHook()), - STATS("Stats", new StatsHook()), - MCMMO("mcMMO", new McMMOHook()), - FACTIONS("Factions", new FactionsHook()), - ONTIME("OnTime", new OnTimeHook()), - AFKTERMINATOR("afkTerminator", new AFKTerminatorHook()), - ROYALCOMMANDS("RoyalCommands", new RoyalCommandsHook()), - ULTIMATECORE("UltimateCore", new UltimateCoreHook()); - - private String pluginName; - private LibraryHook hook; - - Library(String pluginName, LibraryHook hook) { - this.pluginName = pluginName; - this.hook = hook; - } - - public String getPluginName() { - return pluginName; - } - - public LibraryHook getHook() { - return hook; - } - - /** - * Get a library programmaticaly. This method is the same as valueOf(), but is case-insensitive. - * @param value name of the library - * @return the Library object or null if not found. - */ - public static Library getEnum(String value) { - for (Library e : Library.values()) { - if (e.getPluginName().equalsIgnoreCase(value)) - return e; - } - - throw new IllegalArgumentException("There is no library called '" + value + "'!"); - } -} +package me.staartvin.plugins.pluginlibrary; + +import me.staartvin.plugins.pluginlibrary.hooks.AFKTerminatorHook; +import me.staartvin.plugins.pluginlibrary.hooks.AutorankHook; +import me.staartvin.plugins.pluginlibrary.hooks.FactionsHook; +import me.staartvin.plugins.pluginlibrary.hooks.LibraryHook; +import me.staartvin.plugins.pluginlibrary.hooks.McMMOHook; +import me.staartvin.plugins.pluginlibrary.hooks.OnTimeHook; +import me.staartvin.plugins.pluginlibrary.hooks.RoyalCommandsHook; +import me.staartvin.plugins.pluginlibrary.hooks.StatsHook; +import me.staartvin.plugins.pluginlibrary.hooks.UltimateCoreHook; + +/** + * This class holds all libraries PluginLibrary has. + *

+ * Date created: 14:12:35 12 aug. 2015 + * + * @author Staartvin + * + */ +public enum Library { + + AUTORANK("Autorank", new AutorankHook()), + STATS("Stats", new StatsHook()), + MCMMO("mcMMO", new McMMOHook()), + FACTIONS("Factions", new FactionsHook()), + ONTIME("OnTime", new OnTimeHook()), + AFKTERMINATOR("afkTerminator", new AFKTerminatorHook()), + ROYALCOMMANDS("RoyalCommands", new RoyalCommandsHook()), + ULTIMATECORE("UltimateCore", new UltimateCoreHook()); + + private String pluginName; + private LibraryHook hook; + + Library(String pluginName, LibraryHook hook) { + this.pluginName = pluginName; + this.hook = hook; + } + + public String getPluginName() { + return pluginName; + } + + public LibraryHook getHook() { + return hook; + } + + /** + * Get a library programmaticaly. This method is the same as valueOf(), but is case-insensitive. + * @param value name of the library + * @return the Library object or null if not found. + */ + public static Library getEnum(String value) { + for (Library e : Library.values()) { + if (e.getPluginName().equalsIgnoreCase(value)) + return e; + } + + throw new IllegalArgumentException("There is no library called '" + value + "'!"); + } +} diff --git a/src/me/staartvin/plugins/pluginlibrary/PluginLibrary.java b/src/me/staartvin/plugins/pluginlibrary/PluginLibrary.java index 3331c43..c45d866 100644 --- a/src/me/staartvin/plugins/pluginlibrary/PluginLibrary.java +++ b/src/me/staartvin/plugins/pluginlibrary/PluginLibrary.java @@ -29,7 +29,6 @@ public void onEnable() { loadedLibraries.clear(); //this is a test - // I'm just one below yours logMessage(ChatColor.GOLD + "***== Loading libraries ==***"); logMessage(ChatColor.GOLD + "***== Loaded " + ChatColor.WHITE + loadLibraries() + ChatColor.GOLD + " libraries! ==***"); diff --git a/src/me/staartvin/plugins/pluginlibrary/hooks/AFKTerminatorHook.java b/src/me/staartvin/plugins/pluginlibrary/hooks/AFKTerminatorHook.java index 71a319f..2c70508 100644 --- a/src/me/staartvin/plugins/pluginlibrary/hooks/AFKTerminatorHook.java +++ b/src/me/staartvin/plugins/pluginlibrary/hooks/AFKTerminatorHook.java @@ -1,88 +1,88 @@ -package me.staartvin.plugins.pluginlibrary.hooks; - -import java.util.UUID; - -import me.edge209.afkTerminator.AfkDetect; -import me.edge209.afkTerminator.AfkDetect.AFKMACHINES; -import me.staartvin.plugins.pluginlibrary.Library; - -/** - * afkTerminator library, link. - *

- * Date created: 16:26:41 14 aug. 2015 - * - * @author Staartvin - * - */ -public class AFKTerminatorHook extends LibraryHook { - - /* (non-Javadoc) - * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#isAvailable() - */ - @Override - public boolean isAvailable() { - return this.getPlugin().getServer().getPluginManager() - .isPluginEnabled(Library.AFKTERMINATOR.getPluginName()); - } - - /* (non-Javadoc) - * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#hook() - */ - @Override - public boolean hook() { - // All api calls are done static, so there is no need to get the plugin class. - // We only check if the plugin is available. - return isAvailable(); - } - - /**See if a player is suspected of using an AFK Machine. - *
This will return 'true' if the player's activity is indicative of an AFK Machine, but not all conditions of an AFK machine are confirmed. - * @param uuid UUID of the player to check. - * @return true if afkTerminator suspects that the player is using an AFK machine; false otherwise. - */ - public boolean isAFKMachineSuspected(UUID uuid) { - return AfkDetect.isAFKMachineSuspected(uuid); - } - - /** - * See if use of an AFK machine has been confirmed for a user. - *
This will return 'true' if the player's activity is confirmed to be an AFK Machine by the plugin. - *
If the machine is a big one, it can take a while before afkTerminator detects it. - * @param uuid UUID of the player to check. - * @return true if afkTerminator detected that the player is using an AFK machine; false otherwise. - */ - public boolean isAFKMachineDetected(UUID uuid) { - return AfkDetect.isAFKMachineDetected(uuid); - } - - /** - * If a machine is suspected or later detected, find out the timestamp of when the player is thought to have started using the machine. - *
This is expressed in milliseconds, as measured from the java epoch of Jan 1, 1970. - - * @param uuid UUID of the player to check. - * @return Time in milliseconds since the player started using the machine, UNIX time; otherwise 0. - */ - public long getAFKMachineStartTime(UUID uuid) { - return AfkDetect.getAFKMachineStartTime(uuid); - - } - - /** - * When a player is using an AFK machine, you can get the type of the AFK machine. - *
Types possible: - *
VEHICLE, TETHERED_PIG, HORSE, WATER, JUMP, PISTON, FISHING, PROJECTILE or INTERACTION. - * @param uuid UUID of the player to check. - * @return Type of the AFK machine or null if the player is not using any. - */ - public String getAFKMachineType(UUID uuid) { - AFKMACHINES type = AfkDetect.getAFKMachineType(uuid); - - if (type == null) return null; - - return type.toString(); - } - - - -} +package me.staartvin.plugins.pluginlibrary.hooks; + +import java.util.UUID; + +import me.edge209.afkTerminator.AfkDetect; +import me.edge209.afkTerminator.AfkDetect.AFKMACHINES; +import me.staartvin.plugins.pluginlibrary.Library; + +/** + * afkTerminator library, link. + *

+ * Date created: 16:26:41 14 aug. 2015 + * + * @author Staartvin + * + */ +public class AFKTerminatorHook extends LibraryHook { + + /* (non-Javadoc) + * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#isAvailable() + */ + @Override + public boolean isAvailable() { + return this.getPlugin().getServer().getPluginManager() + .isPluginEnabled(Library.AFKTERMINATOR.getPluginName()); + } + + /* (non-Javadoc) + * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#hook() + */ + @Override + public boolean hook() { + // All api calls are done static, so there is no need to get the plugin class. + // We only check if the plugin is available. + return isAvailable(); + } + + /**See if a player is suspected of using an AFK Machine. + *
This will return 'true' if the player's activity is indicative of an AFK Machine, but not all conditions of an AFK machine are confirmed. + * @param uuid UUID of the player to check. + * @return true if afkTerminator suspects that the player is using an AFK machine; false otherwise. + */ + public boolean isAFKMachineSuspected(UUID uuid) { + return AfkDetect.isAFKMachineSuspected(uuid); + } + + /** + * See if use of an AFK machine has been confirmed for a user. + *
This will return 'true' if the player's activity is confirmed to be an AFK Machine by the plugin. + *
If the machine is a big one, it can take a while before afkTerminator detects it. + * @param uuid UUID of the player to check. + * @return true if afkTerminator detected that the player is using an AFK machine; false otherwise. + */ + public boolean isAFKMachineDetected(UUID uuid) { + return AfkDetect.isAFKMachineDetected(uuid); + } + + /** + * If a machine is suspected or later detected, find out the timestamp of when the player is thought to have started using the machine. + *
This is expressed in milliseconds, as measured from the java epoch of Jan 1, 1970. + + * @param uuid UUID of the player to check. + * @return Time in milliseconds since the player started using the machine, UNIX time; otherwise 0. + */ + public long getAFKMachineStartTime(UUID uuid) { + return AfkDetect.getAFKMachineStartTime(uuid); + + } + + /** + * When a player is using an AFK machine, you can get the type of the AFK machine. + *
Types possible: + *
VEHICLE, TETHERED_PIG, HORSE, WATER, JUMP, PISTON, FISHING, PROJECTILE or INTERACTION. + * @param uuid UUID of the player to check. + * @return Type of the AFK machine or null if the player is not using any. + */ + public String getAFKMachineType(UUID uuid) { + AFKMACHINES type = AfkDetect.getAFKMachineType(uuid); + + if (type == null) return null; + + return type.toString(); + } + + + +} diff --git a/src/me/staartvin/plugins/pluginlibrary/hooks/FactionsHook.java b/src/me/staartvin/plugins/pluginlibrary/hooks/FactionsHook.java index ce80d85..0b1d005 100644 --- a/src/me/staartvin/plugins/pluginlibrary/hooks/FactionsHook.java +++ b/src/me/staartvin/plugins/pluginlibrary/hooks/FactionsHook.java @@ -1,235 +1,235 @@ -package me.staartvin.plugins.pluginlibrary.hooks; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -import me.staartvin.plugins.pluginlibrary.Library; -import me.staartvin.plugins.pluginlibrary.hooks.factions.Faction; - -import org.bukkit.Location; - -import com.massivecraft.factions.Factions; -import com.massivecraft.factions.entity.BoardColl; -import com.massivecraft.factions.entity.FactionColl; -import com.massivecraft.factions.entity.MPlayer; -import com.massivecraft.massivecore.ps.PS; - -/** - * Factions, link. - *

- * Date created: 20:22:17 12 aug. 2015 - * - * @author Staartvin - * - */ -public class FactionsHook extends LibraryHook { - - private Factions factions; - - /* (non-Javadoc) - * @see me.staartvin.plugins.pluginlibrary.LibraryHook#isAvailable() - */ - @Override - public boolean isAvailable() { - // TODO Auto-generated method stub - - return this.getPlugin().getServer().getPluginManager() - .isPluginEnabled(Library.FACTIONS.getPluginName()); - } - - /* (non-Javadoc) - * @see me.staartvin.plugins.pluginlibrary.LibraryHook#hook() - */ - @Override - public boolean hook() { - // TODO Auto-generated method stub - - if (!isAvailable()) - return false; - - factions = (Factions) this.getPlugin().getServer().getPluginManager() - .getPlugin(Library.FACTIONS.getPluginName()); - - return factions != null; - } - - /* Util methods */ - - private MPlayer getMPlayer(UUID uuid) { - return MPlayer.get(uuid); - } - - /* Faction vars */ - - /** - * Gets the faction by its name. Use the comparison name, see - * {@link me.staartvin.plugins.pluginlibrary.hooks.factions.Faction#getComparisonName()} - * . - * - * @param factionName Name of the faction. Without colour codes! - * @return {@link Faction} or null if no faction found. - */ - public Faction getFactionByName(String factionName) { - if (factionName == null) - return null; - - com.massivecraft.factions.entity.Faction fac = FactionColl.get() - .getByName(factionName); - - if (fac == null) - return null; - - return new Faction(fac); - } - - /** - * Gets the faction a player is in. - * - * @param uuid UUID of the player. - * @return {@link Faction}, null if the player doesn't exist or is not in a - * faction. - */ - public Faction getFactionByUUID(UUID uuid) { - if (uuid == null) - return null; - - MPlayer mPlayer = getMPlayer(uuid); - - if (mPlayer == null) - return null; - - com.massivecraft.factions.entity.Faction fac = mPlayer.getFaction(); - - if (fac == null) - return null; - - return new Faction(fac); - } - - /** - * Gets a faction by its internal Factions id. - * - * @param factionId Id of the faction - * @return {@link Faction} or null if id is invalid. - */ - public Faction getFactionById(String factionId) { - if (factionId == null) - return null; - - if (FactionColl.get().containsId(factionId)) { - com.massivecraft.factions.entity.Faction fac = FactionColl.get() - .get(factionId); - - if (fac == null) - return null; - - return new Faction(fac); - } - - return null; - } - - /** - * Gets a list of all factions that currently exist. - * - * @return a list of all factions. - */ - public List getAllFactions() { - List factions = new ArrayList(); - - for (com.massivecraft.factions.entity.Faction fac : FactionColl.get() - .getAll()) { - factions.add(new Faction(fac)); - } - - return factions; - } - - /** - * Gets the Wilderness 'faction'. - * - * @return the Wilderness faction. - */ - public Faction getWilderness() { - com.massivecraft.factions.entity.Faction fac = FactionColl.get() - .getNone(); - - if (fac == null) - return null; - - return new Faction(fac); - } - - /** - * Gets the Safezone 'faction'. - * - * @return the Safezone faction. - */ - public Faction getSafezone() { - - com.massivecraft.factions.entity.Faction fac = FactionColl.get() - .getSafezone(); - - if (fac == null) - return null; - - return new Faction(fac); - } - - /** - * Gets the Warzone 'faction'. - * - * @return the Warzone faction. - */ - public Faction getWarzone() { - com.massivecraft.factions.entity.Faction fac = FactionColl.get() - .getWarzone(); - - if (fac == null) - return null; - - return new Faction(fac); - } - - /** - * Gets the faction at a specific {@link Location}. - * - * @param location Location for the faction to be at. - * @return A {@link Faction} or null if the location does not contain a - * faction. - */ - public Faction getFactionAt(Location location) { - if (location == null) - return null; - - com.massivecraft.factions.entity.Faction fac = BoardColl.get() - .getFactionAt(PS.valueOf(location)); - - if (fac == null) - return null; - - return new Faction(fac); - } - - /** - * Gets the - * {@link me.staartvin.plugins.pluginlibrary.hooks.factions.MPlayer} for a - * player, which represents the player object Factions internally uses. - * - * @param uuid UUID of the player. - * @return {@link me.staartvin.plugins.pluginlibrary.hooks.factions.MPlayer} - * or null if player does not exist/is not stored by Factions. - */ - public me.staartvin.plugins.pluginlibrary.hooks.factions.MPlayer getFactionsPlayer( - UUID uuid) { - MPlayer mPlayer = MPlayer.get(uuid); - - if (mPlayer == null) - return null; - - return new me.staartvin.plugins.pluginlibrary.hooks.factions.MPlayer( - mPlayer); - } +package me.staartvin.plugins.pluginlibrary.hooks; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import me.staartvin.plugins.pluginlibrary.Library; +import me.staartvin.plugins.pluginlibrary.hooks.factions.Faction; + +import org.bukkit.Location; + +import com.massivecraft.factions.Factions; +import com.massivecraft.factions.entity.BoardColl; +import com.massivecraft.factions.entity.FactionColl; +import com.massivecraft.factions.entity.MPlayer; +import com.massivecraft.massivecore.ps.PS; + +/** + * Factions, link. + *

+ * Date created: 20:22:17 12 aug. 2015 + * + * @author Staartvin + * + */ +public class FactionsHook extends LibraryHook { + + private Factions factions; + + /* (non-Javadoc) + * @see me.staartvin.plugins.pluginlibrary.LibraryHook#isAvailable() + */ + @Override + public boolean isAvailable() { + // TODO Auto-generated method stub + + return this.getPlugin().getServer().getPluginManager() + .isPluginEnabled(Library.FACTIONS.getPluginName()); + } + + /* (non-Javadoc) + * @see me.staartvin.plugins.pluginlibrary.LibraryHook#hook() + */ + @Override + public boolean hook() { + // TODO Auto-generated method stub + + if (!isAvailable()) + return false; + + factions = (Factions) this.getPlugin().getServer().getPluginManager() + .getPlugin(Library.FACTIONS.getPluginName()); + + return factions != null; + } + + /* Util methods */ + + private MPlayer getMPlayer(UUID uuid) { + return MPlayer.get(uuid); + } + + /* Faction vars */ + + /** + * Gets the faction by its name. Use the comparison name, see + * {@link me.staartvin.plugins.pluginlibrary.hooks.factions.Faction#getComparisonName()} + * . + * + * @param factionName Name of the faction. Without colour codes! + * @return {@link Faction} or null if no faction found. + */ + public Faction getFactionByName(String factionName) { + if (factionName == null) + return null; + + com.massivecraft.factions.entity.Faction fac = FactionColl.get() + .getByName(factionName); + + if (fac == null) + return null; + + return new Faction(fac); + } + + /** + * Gets the faction a player is in. + * + * @param uuid UUID of the player. + * @return {@link Faction}, null if the player doesn't exist or is not in a + * faction. + */ + public Faction getFactionByUUID(UUID uuid) { + if (uuid == null) + return null; + + MPlayer mPlayer = getMPlayer(uuid); + + if (mPlayer == null) + return null; + + com.massivecraft.factions.entity.Faction fac = mPlayer.getFaction(); + + if (fac == null) + return null; + + return new Faction(fac); + } + + /** + * Gets a faction by its internal Factions id. + * + * @param factionId Id of the faction + * @return {@link Faction} or null if id is invalid. + */ + public Faction getFactionById(String factionId) { + if (factionId == null) + return null; + + if (FactionColl.get().containsId(factionId)) { + com.massivecraft.factions.entity.Faction fac = FactionColl.get() + .get(factionId); + + if (fac == null) + return null; + + return new Faction(fac); + } + + return null; + } + + /** + * Gets a list of all factions that currently exist. + * + * @return a list of all factions. + */ + public List getAllFactions() { + List factions = new ArrayList(); + + for (com.massivecraft.factions.entity.Faction fac : FactionColl.get() + .getAll()) { + factions.add(new Faction(fac)); + } + + return factions; + } + + /** + * Gets the Wilderness 'faction'. + * + * @return the Wilderness faction. + */ + public Faction getWilderness() { + com.massivecraft.factions.entity.Faction fac = FactionColl.get() + .getNone(); + + if (fac == null) + return null; + + return new Faction(fac); + } + + /** + * Gets the Safezone 'faction'. + * + * @return the Safezone faction. + */ + public Faction getSafezone() { + + com.massivecraft.factions.entity.Faction fac = FactionColl.get() + .getSafezone(); + + if (fac == null) + return null; + + return new Faction(fac); + } + + /** + * Gets the Warzone 'faction'. + * + * @return the Warzone faction. + */ + public Faction getWarzone() { + com.massivecraft.factions.entity.Faction fac = FactionColl.get() + .getWarzone(); + + if (fac == null) + return null; + + return new Faction(fac); + } + + /** + * Gets the faction at a specific {@link Location}. + * + * @param location Location for the faction to be at. + * @return A {@link Faction} or null if the location does not contain a + * faction. + */ + public Faction getFactionAt(Location location) { + if (location == null) + return null; + + com.massivecraft.factions.entity.Faction fac = BoardColl.get() + .getFactionAt(PS.valueOf(location)); + + if (fac == null) + return null; + + return new Faction(fac); + } + + /** + * Gets the + * {@link me.staartvin.plugins.pluginlibrary.hooks.factions.MPlayer} for a + * player, which represents the player object Factions internally uses. + * + * @param uuid UUID of the player. + * @return {@link me.staartvin.plugins.pluginlibrary.hooks.factions.MPlayer} + * or null if player does not exist/is not stored by Factions. + */ + public me.staartvin.plugins.pluginlibrary.hooks.factions.MPlayer getFactionsPlayer( + UUID uuid) { + MPlayer mPlayer = MPlayer.get(uuid); + + if (mPlayer == null) + return null; + + return new me.staartvin.plugins.pluginlibrary.hooks.factions.MPlayer( + mPlayer); + } } \ No newline at end of file diff --git a/src/me/staartvin/plugins/pluginlibrary/hooks/LibraryHook.java b/src/me/staartvin/plugins/pluginlibrary/hooks/LibraryHook.java index 44ab29c..b8bdb94 100644 --- a/src/me/staartvin/plugins/pluginlibrary/hooks/LibraryHook.java +++ b/src/me/staartvin/plugins/pluginlibrary/hooks/LibraryHook.java @@ -1,32 +1,32 @@ -package me.staartvin.plugins.pluginlibrary.hooks; - -import me.staartvin.plugins.pluginlibrary.PluginLibrary; - -import org.bukkit.Bukkit; - -/** - * Represents a hook to another plugin - *

- * Date created: 14:13:45 - * 12 aug. 2015 - * @author Staartvin - * - */ -public abstract class LibraryHook { - - protected PluginLibrary getPlugin() { - return (PluginLibrary) Bukkit.getServer().getPluginManager().getPlugin("PluginLibrary"); - } - - /** - * Whether or not the plugin is available. - * @return true when plugin is available to use; false otherwise. - */ - public abstract boolean isAvailable(); - - /** - * Hook the plugin to make sure data can be retrieved. - * @return true if PluginLibrary could successfully hook; false otherwise. - */ - public abstract boolean hook(); -} +package me.staartvin.plugins.pluginlibrary.hooks; + +import me.staartvin.plugins.pluginlibrary.PluginLibrary; + +import org.bukkit.Bukkit; + +/** + * Represents a hook to another plugin + *

+ * Date created: 14:13:45 + * 12 aug. 2015 + * @author Staartvin + * + */ +public abstract class LibraryHook { + + protected PluginLibrary getPlugin() { + return (PluginLibrary) Bukkit.getServer().getPluginManager().getPlugin("PluginLibrary"); + } + + /** + * Whether or not the plugin is available. + * @return true when plugin is available to use; false otherwise. + */ + public abstract boolean isAvailable(); + + /** + * Hook the plugin to make sure data can be retrieved. + * @return true if PluginLibrary could successfully hook; false otherwise. + */ + public abstract boolean hook(); +} diff --git a/src/me/staartvin/plugins/pluginlibrary/hooks/McMMOHook.java b/src/me/staartvin/plugins/pluginlibrary/hooks/McMMOHook.java index 5ee4718..10c0d6d 100644 --- a/src/me/staartvin/plugins/pluginlibrary/hooks/McMMOHook.java +++ b/src/me/staartvin/plugins/pluginlibrary/hooks/McMMOHook.java @@ -1,1184 +1,1184 @@ -package me.staartvin.plugins.pluginlibrary.hooks; - -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.UUID; - -import me.staartvin.plugins.pluginlibrary.Library; - -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.api.AbilityAPI; -import com.gmail.nossr50.api.ChatAPI; -import com.gmail.nossr50.api.ExperienceAPI; -import com.gmail.nossr50.api.PartyAPI; -import com.gmail.nossr50.api.SkillAPI; -import com.gmail.nossr50.api.exceptions.InvalidFormulaTypeException; -import com.gmail.nossr50.api.exceptions.InvalidPlayerException; -import com.gmail.nossr50.api.exceptions.InvalidSkillException; -import com.gmail.nossr50.api.exceptions.InvalidXPGainReasonException; -import com.gmail.nossr50.datatypes.party.Party; - -/** - * mcMMO library, link. - *

- * Date created: 18:25:13 12 aug. 2015 - * - * @author Staartvin - * - */ -public class McMMOHook extends LibraryHook { - - private mcMMO api; - - /* (non-Javadoc) - * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#isAvailable() - */ - @Override - public boolean isAvailable() { - // TODO Auto-generated method stub - - return this.getPlugin().getServer().getPluginManager() - .isPluginEnabled(Library.MCMMO.getPluginName()); - } - - /* (non-Javadoc) - * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#hook() - */ - @Override - public boolean hook() { - // TODO Auto-generated method stub - - if (!isAvailable()) - return false; - - api = (mcMMO) this.getPlugin().getServer().getPluginManager() - .getPlugin(Library.MCMMO.getPluginName()); - - return api != null; - } - - /* ExperienceAPI below */ - - /** - * Checks whether given string is a valid type of skill suitable for the - * other API calls in mcMMO. - *
- * - * @param skillType String to check. - * @return true if this is a valid mcMMO skill. - */ - public boolean isValidSkillType(String skillType) { - return ExperienceAPI.isValidSkillType(skillType); - } - - /** - * Checks whether the given skill type string is both valid and not a - * child skill. (Child skills have no XP of their own, and their level is - * derived from the parent(s).) - *
- * - * @param skillType the skill to check - * @return true if this is a valid, non-child mcMMO skill - */ - public boolean isNonChildSkill(String skillType) { - return ExperienceAPI.isNonChildSkill(skillType); - } - - /** - * Adds raw XP to the player. - *
- * - * @param player The player to add XP to - * @param skillType The skill to add XP to - * @param XP The amount of XP to add - * @param xpGainReason The reason to gain XP, choose from PVP, PVE, - * VAMPIRISM, SHARED_PVP, SHARED_PVE, COMMAND or UNKNOWN. - * @param isUnshared true if the XP cannot be shared with party members - * - * @throws InvalidSkillException if the given skill is not valid - * @throws InvalidXPGainReasonException if the given xpGainReason is not - * valid - */ - public void addRawXP(Player player, String skillType, float XP, - String xpGainReason, boolean isUnshared) { - ExperienceAPI.addRawXP(player, skillType, XP, xpGainReason, isUnshared); - } - - /** - * Adds raw XP to an offline player. - *
- * - * @param uuid The UUID of player to add XP to - * @param skillType The skill to add XP to - * @param XP The amount of XP to add - * - * @throws InvalidSkillException if the given skill is not valid - * @throws InvalidPlayerException if the given player does not exist in the - * database - */ - - public void addRawXPOffline(UUID uuid, String skillType, float XP) { - ExperienceAPI.addRawXPOffline(uuid, skillType, XP); - } - - /** - * Adds XP to the player, calculates for XP Rate and skill modifier. - *
- * - * @param player The player to add XP to - * @param skillType The skill to add XP to - * @param XP The amount of XP to add - * @param xpGainReason The reason to gain XP, choose from PVP, PVE, - * VAMPIRISM, SHARED_PVP, SHARED_PVE, COMMAND or UNKNOWN. - * @param isUnshared true if the XP cannot be shared with party members - * - * @throws InvalidSkillException if the given skill is not valid - * @throws InvalidXPGainReasonException if the given xpGainReason is not - * valid - */ - public void addModifiedXP(Player player, String skillType, int XP, - String xpGainReason, boolean isUnshared) { - ExperienceAPI.addModifiedXP(player, skillType, XP, xpGainReason, - isUnshared); - } - - /** - * Adds XP to the player, calculates for XP Rate only. - *
- * - * @param player The player to add XP to - * @param skillType The skill to add XP to - * @param XP The amount of XP to add - * @param xpGainReason The reason to gain XP, choose from PVP, PVE, - * VAMPIRISM, SHARED_PVP, SHARED_PVE, COMMAND or UNKNOWN. - * - * @throws InvalidSkillException if the given skill is not valid - * @throws InvalidXPGainReasonException if the given xpGainReason is not - * valid - */ - public void addMultipliedXP(Player player, String skillType, int XP, - String xpGainReason) { - ExperienceAPI.addMultipliedXP(player, skillType, XP, xpGainReason); - } - - /** - * Adds XP to an offline player, calculates for XP Rate only. - *
- * - * @deprecated Unknown reason - * - * @param playerName The player to add XP to - * @param skillType The skill to add XP to - * @param XP The amount of XP to add - * - * @throws InvalidSkillException if the given skill is not valid - * @throws InvalidPlayerException if the given player does not exist in the - * database - */ - @Deprecated - public void addMultipliedXPOffline(String playerName, String skillType, - int XP) { - ExperienceAPI.addMultipliedXPOffline(playerName, skillType, XP); - } - - /** - * Adds XP to an offline player, calculates for XP Rate and skill modifier. - *
- * - * @deprecated Unknown reason - * - * @param playerName The player to add XP to - * @param skillType The skill to add XP to - * @param XP The amount of XP to add - * - * @throws InvalidSkillException if the given skill is not valid - * @throws InvalidPlayerException if the given player does not exist in the - * database - */ - @Deprecated - public void addModifiedXPOffline(String playerName, String skillType, int XP) { - ExperienceAPI.addModifiedXPOffline(playerName, skillType, XP); - } - - /** - * Adds XP to the player, calculates for XP Rate, skill modifiers, perks, - * child skills, - * and party sharing. - *
- * - * @param player The player to add XP to - * @param skillType The skill to add XP to - * @param XP The amount of XP to add - * @param xpGainReason The reason to gain XP, choose from PVP, PVE, - * VAMPIRISM, SHARED_PVP, SHARED_PVE, COMMAND or UNKNOWN. - * @param isUnshared true if the XP cannot be shared with party members - * - * @throws InvalidSkillException if the given skill is not valid - * @throws InvalidXPGainReasonException if the given xpGainReason is not - * valid - */ - public void addXP(Player player, String skillType, int XP, - String xpGainReason, boolean isUnshared) { - ExperienceAPI.addXP(player, skillType, XP, xpGainReason, isUnshared); - } - - /** - * Get the amount of XP a player has in a specific skill. - *
- * - * @param player The player to get XP for - * @param skillType The skill to get XP for - * @return the amount of XP in a given skill - * - * @throws InvalidSkillException if the given skill is not valid - * @throws UnsupportedOperationException if the given skill is a child skill - */ - public int getXP(Player player, String skillType) { - return ExperienceAPI.getXP(player, skillType); - } - - /** - * Get the amount of XP an offline player has in a specific skill. - *
- * - * @param uuid The player to get XP for - * @param skillType The skill to get XP for - * @return the amount of XP in a given skill - * - * @throws InvalidSkillException if the given skill is not valid - * @throws InvalidPlayerException if the given player does not exist in the - * database - * @throws UnsupportedOperationException if the given skill is a child skill - */ - public int getOfflineXP(UUID uuid, String skillType) { - return ExperienceAPI.getOfflineXP(uuid, skillType); - } - - /** - * Get the raw amount of XP a player has in a specific skill. - *
- * - * @param player The player to get XP for - * @param skillType The skill to get XP for - * @return the amount of XP in a given skill - * - * @throws InvalidSkillException if the given skill is not valid - * @throws UnsupportedOperationException if the given skill is a child skill - */ - public float getXPRaw(Player player, String skillType) { - return ExperienceAPI.getXPRaw(player, skillType); - } - - /** - * Get the raw amount of XP an offline player has in a specific skill. - *
- * - * @param uuid The player to get XP for - * @param skillType The skill to get XP for - * @return the amount of XP in a given skill - * - * @throws InvalidSkillException if the given skill is not valid - * @throws InvalidPlayerException if the given player does not exist in the - * database - * @throws UnsupportedOperationException if the given skill is a child skill - */ - public float getOfflineXPRaw(UUID uuid, String skillType) { - return ExperienceAPI.getOfflineXPRaw(uuid, skillType); - } - - /** - * Get the total amount of XP needed to reach the next level. - *
- * - * @param player The player to get the XP amount for - * @param skillType The skill to get the XP amount for - * @return the total amount of XP needed to reach the next level - * - * @throws InvalidSkillException if the given skill is not valid - * @throws UnsupportedOperationException if the given skill is a child skill - */ - public int getXPToNextLevel(Player player, String skillType) { - return ExperienceAPI.getXPToNextLevel(player, skillType); - } - - /** - * Get the total amount of XP an offline player needs to reach the next - * level. - *
- * - * @param uuid The player to get XP for - * @param skillType The skill to get XP for - * @return the total amount of XP needed to reach the next level - * - * @throws InvalidSkillException if the given skill is not valid - * @throws InvalidPlayerException if the given player does not exist in the - * database - * @throws UnsupportedOperationException if the given skill is a child skill - */ - public int getOfflineXPToNextLevel(UUID uuid, String skillType) { - return ExperienceAPI.getOfflineXPToNextLevel(uuid, skillType); - } - - /** - * Get the amount of XP remaining until the next level. - *
- * - * @param player The player to get the XP amount for - * @param skillType The skill to get the XP amount for - * @return the amount of XP remaining until the next level - * - * @throws InvalidSkillException if the given skill is not valid - * @throws UnsupportedOperationException if the given skill is a child skill - */ - public int getXPRemaining(Player player, String skillType) { - return ExperienceAPI.getXPRemaining(player, skillType); - } - - /** - * Get the amount of XP an offline player has left before leveling up. - *
- * - * @param uuid The player to get XP for - * @param skillType The skill to get XP for - * @return the amount of XP needed to reach the next level - * - * @throws InvalidSkillException if the given skill is not valid - * @throws InvalidPlayerException if the given player does not exist in the - * database - * @throws UnsupportedOperationException if the given skill is a child skill - */ - public float getOfflineXPRemaining(UUID uuid, String skillType) { - return ExperienceAPI.getOfflineXPRemaining(uuid, skillType); - } - - /** - * Add levels to a skill. - *
- * - * @param player The player to add levels to - * @param skillType Type of skill to add levels to - * @param levels Number of levels to add - * - * @throws InvalidSkillException if the given skill is not valid - */ - public void addLevel(Player player, String skillType, int levels) { - ExperienceAPI.addLevel(player, skillType, levels); - } - - /** - * Add levels to a skill for an offline player. - *
. - * - * @param uuid The player to add levels to - * @param skillType Type of skill to add levels to - * @param levels Number of levels to add - * - * @throws InvalidSkillException if the given skill is not valid - * @throws InvalidPlayerException if the given player does not exist in the - * database - */ - public void addLevelOffline(UUID uuid, String skillType, int levels) { - ExperienceAPI.addLevelOffline(uuid, skillType, levels); - } - - /** - * Get the level a player has in a specific skill. - *
- * - * @param player The player to get the level for - * @param skillType The skill to get the level for - * @return the level of a given skill - * - * @throws InvalidSkillException if the given skill is not valid - */ - public int getLevel(Player player, String skillType) { - return ExperienceAPI.getLevel(player, skillType); - } - - /** - * Get the level an offline player has in a specific skill. - *
- * - * @param uuid The player to get the level for - * @param skillType The skill to get the level for - * @return the level of a given skill - * - * @throws InvalidSkillException if the given skill is not valid - * @throws InvalidPlayerException if the given player does not exist in the - * database - */ - public int getLevelOffline(UUID uuid, String skillType) { - return ExperienceAPI.getLevelOffline(uuid, skillType); - } - - /** - * Gets the power level of a player. - *
- * - * @param player The player to get the power level for - * @return the power level of the player - */ - public int getPowerLevel(Player player) { - return ExperienceAPI.getPowerLevel(player); - } - - /** - * Gets the power level of an offline player. - *
- * - * @param uuid The player to get the power level for - * @return the power level of the player - * - * @throws InvalidPlayerException if the given player does not exist in the - * database - */ - public int getPowerLevelOffline(UUID uuid) { - return ExperienceAPI.getPowerLevelOffline(uuid); - } - - /** - * Get the level cap of a specific skill. - *
- * - * @param skillType The skill to get the level cap for - * @return the level cap of a given skill - * - * @throws InvalidSkillException if the given skill is not valid - */ - public int getLevelCap(String skillType) { - return ExperienceAPI.getLevelCap(skillType); - } - - /** - * Get the power level cap. - *
- * - * @return the overall power level cap - */ - public int getPowerLevelCap() { - return ExperienceAPI.getPowerLevelCap(); - } - - /** - * Get the position on the leaderboard of a player. - *
- * - * @param uuid The name of the player to check - * @param skillType The skill to check - * - * @throws InvalidSkillException if the given skill is not valid - * @throws InvalidPlayerException if the given player does not exist in the - * database - * @throws UnsupportedOperationException if the given skill is a child skill - * - * @return the position on the leaderboard - */ - public int getPlayerRankSkill(UUID uuid, String skillType) { - return ExperienceAPI.getPlayerRankSkill(uuid, skillType); - } - - /** - * Get the position on the power level leaderboard of a player. - *
- * - * @param uuid The name of the player to check - * - * @throws InvalidPlayerException if the given player does not exist in the - * database - * - * @return the position on the power level leaderboard - */ - public int getPlayerRankOverall(UUID uuid) { - return ExperienceAPI.getPlayerRankOverall(uuid); - } - - /** - * Sets the level of a player in a specific skill type. - *
- * - * @param player The player to set the level of - * @param skillType The skill to set the level for - * @param skillLevel The value to set the level to - * - * @throws InvalidSkillException if the given skill is not valid - */ - public void setLevel(Player player, String skillType, int skillLevel) { - ExperienceAPI.setLevel(player, skillType, skillLevel); - } - - /** - * Sets the level of an offline player in a specific skill type. - *
- * - * @param uuid The player to set the level of - * @param skillType The skill to set the level for - * @param skillLevel The value to set the level to - * - * @throws InvalidSkillException if the given skill is not valid - * @throws InvalidPlayerException if the given player does not exist in the - * database - */ - public void setLevelOffline(UUID uuid, String skillType, int skillLevel) { - ExperienceAPI.setLevelOffline(uuid, skillType, skillLevel); - } - - /** - * Sets the XP of a player in a specific skill type. - *
- * - * @param player The player to set the XP of - * @param skillType The skill to set the XP for - * @param newValue The value to set the XP to - * - * @throws InvalidSkillException if the given skill is not valid - * @throws UnsupportedOperationException if the given skill is a child skill - */ - public void setXP(Player player, String skillType, int newValue) { - ExperienceAPI.setXP(player, skillType, newValue); - } - - /** - * Sets the XP of an offline player in a specific skill type. - *
- * - * @param uuid The player to set the XP of - * @param skillType The skill to set the XP for - * @param newValue The value to set the XP to - * - * @throws InvalidSkillException if the given skill is not valid - * @throws InvalidPlayerException if the given player does not exist in the - * database - * @throws UnsupportedOperationException if the given skill is a child skill - */ - public void setXPOffline(UUID uuid, String skillType, int newValue) { - ExperienceAPI.setXPOffline(uuid, skillType, newValue); - } - - /** - * Removes XP from a player in a specific skill type. - *
- * - * @param player The player to change the XP of - * @param skillType The skill to change the XP for - * @param xp The amount of XP to remove - * - * @throws InvalidSkillException if the given skill is not valid - * @throws UnsupportedOperationException if the given skill is a child skill - */ - public void removeXP(Player player, String skillType, int xp) { - ExperienceAPI.removeXP(player, skillType, xp); - } - - /** - * Removes XP from an offline player in a specific skill type. - *
- * - * @param uuid The player to change the XP of - * @param skillType The skill to change the XP for - * @param xp The amount of XP to remove - * - * @throws InvalidSkillException if the given skill is not valid - * @throws InvalidPlayerException if the given player does not exist in the - * database - * @throws UnsupportedOperationException if the given skill is a child skill - */ - public void removeXPOffline(UUID uuid, String skillType, int xp) { - ExperienceAPI.removeXPOffline(uuid, skillType, xp); - } - - /** - * Check how much XP is needed for a specific level with the selected level - * curve. - *
- * - * @param level The level to get the amount of XP for - * - * @throws InvalidFormulaTypeException if the given formulaType is not valid - */ - public int getXpNeededToLevel(int level) { - return ExperienceAPI.getXpNeededToLevel(level); - } - - /** - * Check how much XP is needed for a specific level with the provided level - * curve. - *
- * - * @param level The level to get the amount of XP for - * @param formulaType The formula type to get the amount of XP for - * - * @throws InvalidFormulaTypeException if the given formulaType is not valid - */ - public int getXpNeededToLevel(int level, String formulaType) { - return ExperienceAPI.getXpNeededToLevel(level, formulaType); - } - - /* AbilityAPI below */ - - /** - * Checks whether Berserk is enabled for a specific player. - * - * @param player Player to check for - * @return true if enabled; false otherwise. - */ - public boolean berserkEnabled(Player player) { - return AbilityAPI.berserkEnabled(player); - } - - /** - * Checks whether GigaDrill Breaker is enabled for a specific player. - * - * @param player Player to check for - * @return true if enabled; false otherwise. - */ - public boolean gigaDrillBreakerEnabled(Player player) { - return AbilityAPI.gigaDrillBreakerEnabled(player); - } - - /** - * Checks whether Green Terra is enabled for a specific player. - * - * @param player Player to check for - * @return true if enabled; false otherwise. - */ - public boolean greenTerraEnabled(Player player) { - return AbilityAPI.greenTerraEnabled(player); - } - - /** - * Checks whether Serrated Strikes is enabled for a specific player. - * - * @param player Player to check for - * @return true if enabled; false otherwise. - */ - public boolean serratedStrikesEnabled(Player player) { - return AbilityAPI.serratedStrikesEnabled(player); - } - - /** - * Checks whether Skull Splitter is enabled for a specific player. - * - * @param player Player to check for - * @return true if enabled; false otherwise. - */ - public boolean skullSplitterEnabled(Player player) { - return AbilityAPI.skullSplitterEnabled(player); - } - - /** - * Checks whether Super Breaker is enabled for a specific player. - * - * @param player Player to check for - * @return true if enabled; false otherwise. - */ - public boolean superBreakerEnabled(Player player) { - return AbilityAPI.superBreakerEnabled(player); - } - - /** - * Checks whether Tree Feller is enabled for a specific player. - * - * @param player Player to check for - * @return true if enabled; false otherwise. - */ - public boolean treeFellerEnabled(Player player) { - return AbilityAPI.treeFellerEnabled(player); - } - - /** - * Checks whether any special ability is enabled for a specific player. - * - * @param player Player to check for - * @return true if enabled; false otherwise. - */ - public boolean isAnyAbilityEnabled(Player player) { - return AbilityAPI.isAnyAbilityEnabled(player); - } - - /** - * Resets all ability cooldowns for a player so he/she can use it again - * immediately. - * - * @param player Player to reset cooldowns for. - */ - public void resetCooldowns(Player player) { - AbilityAPI.resetCooldowns(player); - } - - /** - * Set the cooldown of Berserk of a specific player. - * - * @param player Player to set the cooldown for. - * @param cooldown Cooldown (in seconds) for the ability. - */ - public void setBerserkCooldown(Player player, long cooldown) { - AbilityAPI.setBerserkCooldown(player, cooldown); - } - - /** - * Set the cooldown of GigaDrill Breaker of a specific player. - * - * @param player Player to set the cooldown for. - * @param cooldown Cooldown (in seconds) for the ability. - */ - public void setGigaDrillBreakerCooldown(Player player, long cooldown) { - AbilityAPI.setGigaDrillBreakerCooldown(player, cooldown); - } - - /** - * Set the cooldown of Green Terra of a specific player. - * - * @param player Player to set the cooldown for. - * @param cooldown Cooldown (in seconds) for the ability. - */ - public void setGreenTerraCooldown(Player player, long cooldown) { - AbilityAPI.setGreenTerraCooldown(player, cooldown); - } - - /** - * Set the cooldown of Serrated Strikes of a specific player. - * - * @param player Player to set the cooldown for. - * @param cooldown Cooldown (in seconds) for the ability. - */ - public void setSerratedStrikesCooldown(Player player, long cooldown) { - AbilityAPI.setSerratedStrikesCooldown(player, cooldown); - } - - /** - * Set the cooldown of Skull Splitter of a specific player. - * - * @param player Player to set the cooldown for. - * @param cooldown Cooldown (in seconds) for the ability. - */ - public void setSkullSplitterCooldown(Player player, long cooldown) { - AbilityAPI.setSkullSplitterCooldown(player, cooldown); - } - - /** - * Set the cooldown of Super Breaker of a specific player. - * - * @param player Player to set the cooldown for. - * @param cooldown Cooldown (in seconds) for the ability. - */ - public void setSuperBreakerCooldown(Player player, long cooldown) { - AbilityAPI.setSuperBreakerCooldown(player, cooldown); - } - - /** - * Set the cooldown of Tree Feller of a specific player. - * - * @param player Player to set the cooldown for. - * @param cooldown Cooldown (in seconds) for the ability. - */ - public void setTreeFellerCooldown(Player player, long cooldown) { - AbilityAPI.setTreeFellerCooldown(player, cooldown); - } - - /** - * Checks whether the given entity is bleeding. - * - * @param entity Entity to check. - * @return true if bleeding; false otherwise. - */ - public boolean isBleeding(LivingEntity entity) { - return AbilityAPI.isBleeding(entity); - } - - /* ChatAPI below */ - - /** - * Send a message to all members of a party - *
- * - * - * @param plugin The plugin sending the message - * @param sender The name of the sender - * @param displayName The display name of the sender - * @param party The name of the party to send to - * @param message The message to send - */ - public void sendPartyChat(Plugin plugin, String sender, String displayName, - String party, String message) { - ChatAPI.sendPartyChat(plugin, sender, displayName, party, message); - } - - /** - * Send a message to all members of a party - *
- * - * - * @param plugin The plugin sending the message - * @param sender The name of the sender to display in the chat - * @param party The name of the party to send to - * @param message The message to send - */ - public void sendPartyChat(Plugin plugin, String sender, String party, - String message) { - ChatAPI.sendPartyChat(plugin, sender, party, message); - } - - /** - * Send a message to administrators - *
- * - * - * @param plugin The plugin sending the message - * @param sender The name of the sender - * @param displayName The display name of the sender - * @param message The message to send - */ - public void sendAdminChat(Plugin plugin, String sender, String displayName, - String message) { - ChatAPI.sendAdminChat(plugin, sender, displayName, message); - } - - /** - * Send a message to administrators - *
- * - * - * @param plugin The plugin sending the message - * @param sender The name of the sender to display in the chat - * @param message The message to send - */ - public void sendAdminChat(Plugin plugin, String sender, String message) { - ChatAPI.sendAdminChat(plugin, sender, message); - } - - /** - * Check if a player is currently talking in party chat. - * - * @param player The player to check - * @return true if the player is using party chat, false otherwise - */ - public boolean isUsingPartyChat(Player player) { - return ChatAPI.isUsingPartyChat(player); - } - - /** - * Check if a player is currently talking in party chat. - * - * @param playerName The name of the player to check - * @return true if the player is using party chat, false otherwise - */ - public boolean isUsingPartyChat(String playerName) { - return ChatAPI.isUsingPartyChat(playerName); - } - - /** - * Check if a player is currently talking in admin chat. - * - * @param player The player to check - * @return true if the player is using admin chat, false otherwise - */ - public boolean isUsingAdminChat(Player player) { - return ChatAPI.isUsingAdminChat(player); - } - - /** - * Check if a player is currently talking in admin chat. - * - * @param playerName The name of the player to check - * @return true if the player is using admin chat, false otherwise - */ - public boolean isUsingAdminChat(String playerName) { - return ChatAPI.isUsingAdminChat(playerName); - } - - /** - * Toggle the party chat mode of a player. - * - * @param player The player to toggle party chat on. - */ - public void togglePartyChat(Player player) { - ChatAPI.togglePartyChat(player); - } - - /** - * Toggle the party chat mode of a player. - * - * @param playerName The name of the player to toggle party chat on. - */ - public void togglePartyChat(String playerName) { - ChatAPI.togglePartyChat(playerName); - } - - /** - * Toggle the admin chat mode of a player. - * - * @param player The player to toggle admin chat on. - */ - public void toggleAdminChat(Player player) { - ChatAPI.toggleAdminChat(player); - } - - /** - * Toggle the admin chat mode of a player. - * - * @param playerName The name of the player to toggle party chat on. - */ - public void toggleAdminChat(String playerName) { - ChatAPI.toggleAdminChat(playerName); - } - - /* PartyAPI below */ - - /** - * Get the name of the party a player is in. - *
- - * - * @param player The player to check the party name of - * @return the name of the player's party, or null if not in a party - */ - public String getPartyName(Player player) { - return PartyAPI.getPartyName(player); - } - - /** - * Checks if a player is in a party. - *
- - * - * @param player The player to check - * @return true if the player is in a party, false otherwise - */ - public boolean inParty(Player player) { - return PartyAPI.inParty(player); - } - - /** - * Check if two players are in the same party. - *
- - * - * @param playera The first player to check - * @param playerb The second player to check - * @return true if the two players are in the same party, false otherwise - */ - public boolean inSameParty(Player playera, Player playerb) { - return PartyAPI.inSameParty(playera, playerb); - } - - /** - * Get a list of all current parties. - *
- - * - * @return the list of parties. - */ - public List getParties() { - return PartyAPI.getParties(); - } - - /** - * Add a player to a party. - *
- - * - * @param player The player to add to the party - * @param partyName The party to add the player to - */ - public void addToParty(Player player, String partyName) { - PartyAPI.addToParty(player, partyName); - } - - /** - * Remove a player from a party. - *
- - * - * @param player The player to remove - */ - public void removeFromParty(Player player) { - PartyAPI.removeFromParty(player); - } - - /** - * Get the leader of a party. - *
- - * - * @param partyName The party name - * @return the leader of the party - */ - public String getPartyLeader(String partyName) { - return PartyAPI.getPartyLeader(partyName); - } - - /** - * Set the leader of a party. - *
- * @deprecated Unknown reason. - * - * @param partyName The name of the party to set the leader of - * @param playerName The playerName to set as leader - */ - @Deprecated - public void setPartyLeader(String partyName, String playerName) { - PartyAPI.setPartyLeader(partyName, playerName); - } - - /** - * Get a list of all players in this player's party. - *
- @deprecated Unknown reason. - * - * @param player The player to check - * @return all the players in the player's party - */ - @Deprecated - public List getOnlineAndOfflineMembers(Player player) { - return PartyAPI.getOnlineAndOfflineMembers(player); - } - - /** - * Get a list of all player names in this player's party. - *
- @deprecated Unknown reason. - * - * @param player The player to check - * @return all the player names in the player's party - */ - @Deprecated - public LinkedHashSet getMembers(Player player) { - return PartyAPI.getMembers(player); - } - - /** - * Get a list of all player names and uuids in this player's party. - *
- - * - * @param player The player to check - * @return all the player names and uuids in the player's party - */ - public LinkedHashMap getMembersMap(Player player) { - return PartyAPI.getMembersMap(player); - } - - /** - * Get a list of all online players in this party. - *
- - * - * @param partyName The party to check - * @return all online players in this party - */ - public List getOnlineMembers(String partyName) { - return PartyAPI.getOnlineMembers(partyName); - } - - /** - * Get a list of all online players in this player's party. - *
- - * - * @param player The player to check - * @return all online players in the player's party - */ - public List getOnlineMembers(Player player) { - return PartyAPI.getOnlineMembers(player); - } - - /** - * Whether the given party has an ally. - * @param partyName Party to check. - * @return true if the party has an ally; false otherwise. - */ - public boolean hasAlly(String partyName) { - return PartyAPI.hasAlly(partyName); - } - - /** - * Get the ally of a party. - * @param partyName Party to get the ally from. - * @return Name of the ally or null if not found. - */ - public String getAllyName(String partyName) { - return PartyAPI.getAllyName(partyName); - } - - /* SkillAPI below */ - - /** - * Returns a list of strings with mcMMO's skills - * This includes parent and child skills - *
- - * - * @return a list of strings with valid skill names - */ - public List getSkills() { - return SkillAPI.getSkills(); - } - - /** - * Returns a list of strings with mcMMO's skills - * This only includes parent skills - *
- - * - * @return a list of strings with valid skill names - */ - public List getNonChildSkills() { - return SkillAPI.getNonChildSkills(); - } - - /** - * Returns a list of strings with mcMMO's skills - * This only includes child skills - *
- - * - * @return a list of strings with valid skill names - */ - public List getChildSkills() { - return SkillAPI.getChildSkills(); - } - - /** - * Returns a list of strings with mcMMO's skills - * This only includes combat skills - *
- - * - * @return a list of strings with valid skill names - */ - public List getCombatSkills() { - return SkillAPI.getCombatSkills(); - } - - /** - * Returns a list of strings with mcMMO's skills - * This only includes gathering skills - *
- - * - * @return a list of strings with valid skill names - */ - public List getGatheringSkills() { - return SkillAPI.getGatheringSkills(); - } - - /** - * Returns a list of strings with mcMMO's skills - * This only includes misc skills - *
- - * - * @return a list of strings with valid skill names - */ - public List getMiscSkills() { - return SkillAPI.getMiscSkills(); - } - -} +package me.staartvin.plugins.pluginlibrary.hooks; + +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.UUID; + +import me.staartvin.plugins.pluginlibrary.Library; + +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.api.AbilityAPI; +import com.gmail.nossr50.api.ChatAPI; +import com.gmail.nossr50.api.ExperienceAPI; +import com.gmail.nossr50.api.PartyAPI; +import com.gmail.nossr50.api.SkillAPI; +import com.gmail.nossr50.api.exceptions.InvalidFormulaTypeException; +import com.gmail.nossr50.api.exceptions.InvalidPlayerException; +import com.gmail.nossr50.api.exceptions.InvalidSkillException; +import com.gmail.nossr50.api.exceptions.InvalidXPGainReasonException; +import com.gmail.nossr50.datatypes.party.Party; + +/** + * mcMMO library, link. + *

+ * Date created: 18:25:13 12 aug. 2015 + * + * @author Staartvin + * + */ +public class McMMOHook extends LibraryHook { + + private mcMMO api; + + /* (non-Javadoc) + * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#isAvailable() + */ + @Override + public boolean isAvailable() { + // TODO Auto-generated method stub + + return this.getPlugin().getServer().getPluginManager() + .isPluginEnabled(Library.MCMMO.getPluginName()); + } + + /* (non-Javadoc) + * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#hook() + */ + @Override + public boolean hook() { + // TODO Auto-generated method stub + + if (!isAvailable()) + return false; + + api = (mcMMO) this.getPlugin().getServer().getPluginManager() + .getPlugin(Library.MCMMO.getPluginName()); + + return api != null; + } + + /* ExperienceAPI below */ + + /** + * Checks whether given string is a valid type of skill suitable for the + * other API calls in mcMMO. + *
+ * + * @param skillType String to check. + * @return true if this is a valid mcMMO skill. + */ + public boolean isValidSkillType(String skillType) { + return ExperienceAPI.isValidSkillType(skillType); + } + + /** + * Checks whether the given skill type string is both valid and not a + * child skill. (Child skills have no XP of their own, and their level is + * derived from the parent(s).) + *
+ * + * @param skillType the skill to check + * @return true if this is a valid, non-child mcMMO skill + */ + public boolean isNonChildSkill(String skillType) { + return ExperienceAPI.isNonChildSkill(skillType); + } + + /** + * Adds raw XP to the player. + *
+ * + * @param player The player to add XP to + * @param skillType The skill to add XP to + * @param XP The amount of XP to add + * @param xpGainReason The reason to gain XP, choose from PVP, PVE, + * VAMPIRISM, SHARED_PVP, SHARED_PVE, COMMAND or UNKNOWN. + * @param isUnshared true if the XP cannot be shared with party members + * + * @throws InvalidSkillException if the given skill is not valid + * @throws InvalidXPGainReasonException if the given xpGainReason is not + * valid + */ + public void addRawXP(Player player, String skillType, float XP, + String xpGainReason, boolean isUnshared) { + ExperienceAPI.addRawXP(player, skillType, XP, xpGainReason, isUnshared); + } + + /** + * Adds raw XP to an offline player. + *
+ * + * @param uuid The UUID of player to add XP to + * @param skillType The skill to add XP to + * @param XP The amount of XP to add + * + * @throws InvalidSkillException if the given skill is not valid + * @throws InvalidPlayerException if the given player does not exist in the + * database + */ + + public void addRawXPOffline(UUID uuid, String skillType, float XP) { + ExperienceAPI.addRawXPOffline(uuid, skillType, XP); + } + + /** + * Adds XP to the player, calculates for XP Rate and skill modifier. + *
+ * + * @param player The player to add XP to + * @param skillType The skill to add XP to + * @param XP The amount of XP to add + * @param xpGainReason The reason to gain XP, choose from PVP, PVE, + * VAMPIRISM, SHARED_PVP, SHARED_PVE, COMMAND or UNKNOWN. + * @param isUnshared true if the XP cannot be shared with party members + * + * @throws InvalidSkillException if the given skill is not valid + * @throws InvalidXPGainReasonException if the given xpGainReason is not + * valid + */ + public void addModifiedXP(Player player, String skillType, int XP, + String xpGainReason, boolean isUnshared) { + ExperienceAPI.addModifiedXP(player, skillType, XP, xpGainReason, + isUnshared); + } + + /** + * Adds XP to the player, calculates for XP Rate only. + *
+ * + * @param player The player to add XP to + * @param skillType The skill to add XP to + * @param XP The amount of XP to add + * @param xpGainReason The reason to gain XP, choose from PVP, PVE, + * VAMPIRISM, SHARED_PVP, SHARED_PVE, COMMAND or UNKNOWN. + * + * @throws InvalidSkillException if the given skill is not valid + * @throws InvalidXPGainReasonException if the given xpGainReason is not + * valid + */ + public void addMultipliedXP(Player player, String skillType, int XP, + String xpGainReason) { + ExperienceAPI.addMultipliedXP(player, skillType, XP, xpGainReason); + } + + /** + * Adds XP to an offline player, calculates for XP Rate only. + *
+ * + * @deprecated Unknown reason + * + * @param playerName The player to add XP to + * @param skillType The skill to add XP to + * @param XP The amount of XP to add + * + * @throws InvalidSkillException if the given skill is not valid + * @throws InvalidPlayerException if the given player does not exist in the + * database + */ + @Deprecated + public void addMultipliedXPOffline(String playerName, String skillType, + int XP) { + ExperienceAPI.addMultipliedXPOffline(playerName, skillType, XP); + } + + /** + * Adds XP to an offline player, calculates for XP Rate and skill modifier. + *
+ * + * @deprecated Unknown reason + * + * @param playerName The player to add XP to + * @param skillType The skill to add XP to + * @param XP The amount of XP to add + * + * @throws InvalidSkillException if the given skill is not valid + * @throws InvalidPlayerException if the given player does not exist in the + * database + */ + @Deprecated + public void addModifiedXPOffline(String playerName, String skillType, int XP) { + ExperienceAPI.addModifiedXPOffline(playerName, skillType, XP); + } + + /** + * Adds XP to the player, calculates for XP Rate, skill modifiers, perks, + * child skills, + * and party sharing. + *
+ * + * @param player The player to add XP to + * @param skillType The skill to add XP to + * @param XP The amount of XP to add + * @param xpGainReason The reason to gain XP, choose from PVP, PVE, + * VAMPIRISM, SHARED_PVP, SHARED_PVE, COMMAND or UNKNOWN. + * @param isUnshared true if the XP cannot be shared with party members + * + * @throws InvalidSkillException if the given skill is not valid + * @throws InvalidXPGainReasonException if the given xpGainReason is not + * valid + */ + public void addXP(Player player, String skillType, int XP, + String xpGainReason, boolean isUnshared) { + ExperienceAPI.addXP(player, skillType, XP, xpGainReason, isUnshared); + } + + /** + * Get the amount of XP a player has in a specific skill. + *
+ * + * @param player The player to get XP for + * @param skillType The skill to get XP for + * @return the amount of XP in a given skill + * + * @throws InvalidSkillException if the given skill is not valid + * @throws UnsupportedOperationException if the given skill is a child skill + */ + public int getXP(Player player, String skillType) { + return ExperienceAPI.getXP(player, skillType); + } + + /** + * Get the amount of XP an offline player has in a specific skill. + *
+ * + * @param uuid The player to get XP for + * @param skillType The skill to get XP for + * @return the amount of XP in a given skill + * + * @throws InvalidSkillException if the given skill is not valid + * @throws InvalidPlayerException if the given player does not exist in the + * database + * @throws UnsupportedOperationException if the given skill is a child skill + */ + public int getOfflineXP(UUID uuid, String skillType) { + return ExperienceAPI.getOfflineXP(uuid, skillType); + } + + /** + * Get the raw amount of XP a player has in a specific skill. + *
+ * + * @param player The player to get XP for + * @param skillType The skill to get XP for + * @return the amount of XP in a given skill + * + * @throws InvalidSkillException if the given skill is not valid + * @throws UnsupportedOperationException if the given skill is a child skill + */ + public float getXPRaw(Player player, String skillType) { + return ExperienceAPI.getXPRaw(player, skillType); + } + + /** + * Get the raw amount of XP an offline player has in a specific skill. + *
+ * + * @param uuid The player to get XP for + * @param skillType The skill to get XP for + * @return the amount of XP in a given skill + * + * @throws InvalidSkillException if the given skill is not valid + * @throws InvalidPlayerException if the given player does not exist in the + * database + * @throws UnsupportedOperationException if the given skill is a child skill + */ + public float getOfflineXPRaw(UUID uuid, String skillType) { + return ExperienceAPI.getOfflineXPRaw(uuid, skillType); + } + + /** + * Get the total amount of XP needed to reach the next level. + *
+ * + * @param player The player to get the XP amount for + * @param skillType The skill to get the XP amount for + * @return the total amount of XP needed to reach the next level + * + * @throws InvalidSkillException if the given skill is not valid + * @throws UnsupportedOperationException if the given skill is a child skill + */ + public int getXPToNextLevel(Player player, String skillType) { + return ExperienceAPI.getXPToNextLevel(player, skillType); + } + + /** + * Get the total amount of XP an offline player needs to reach the next + * level. + *
+ * + * @param uuid The player to get XP for + * @param skillType The skill to get XP for + * @return the total amount of XP needed to reach the next level + * + * @throws InvalidSkillException if the given skill is not valid + * @throws InvalidPlayerException if the given player does not exist in the + * database + * @throws UnsupportedOperationException if the given skill is a child skill + */ + public int getOfflineXPToNextLevel(UUID uuid, String skillType) { + return ExperienceAPI.getOfflineXPToNextLevel(uuid, skillType); + } + + /** + * Get the amount of XP remaining until the next level. + *
+ * + * @param player The player to get the XP amount for + * @param skillType The skill to get the XP amount for + * @return the amount of XP remaining until the next level + * + * @throws InvalidSkillException if the given skill is not valid + * @throws UnsupportedOperationException if the given skill is a child skill + */ + public int getXPRemaining(Player player, String skillType) { + return ExperienceAPI.getXPRemaining(player, skillType); + } + + /** + * Get the amount of XP an offline player has left before leveling up. + *
+ * + * @param uuid The player to get XP for + * @param skillType The skill to get XP for + * @return the amount of XP needed to reach the next level + * + * @throws InvalidSkillException if the given skill is not valid + * @throws InvalidPlayerException if the given player does not exist in the + * database + * @throws UnsupportedOperationException if the given skill is a child skill + */ + public float getOfflineXPRemaining(UUID uuid, String skillType) { + return ExperienceAPI.getOfflineXPRemaining(uuid, skillType); + } + + /** + * Add levels to a skill. + *
+ * + * @param player The player to add levels to + * @param skillType Type of skill to add levels to + * @param levels Number of levels to add + * + * @throws InvalidSkillException if the given skill is not valid + */ + public void addLevel(Player player, String skillType, int levels) { + ExperienceAPI.addLevel(player, skillType, levels); + } + + /** + * Add levels to a skill for an offline player. + *
. + * + * @param uuid The player to add levels to + * @param skillType Type of skill to add levels to + * @param levels Number of levels to add + * + * @throws InvalidSkillException if the given skill is not valid + * @throws InvalidPlayerException if the given player does not exist in the + * database + */ + public void addLevelOffline(UUID uuid, String skillType, int levels) { + ExperienceAPI.addLevelOffline(uuid, skillType, levels); + } + + /** + * Get the level a player has in a specific skill. + *
+ * + * @param player The player to get the level for + * @param skillType The skill to get the level for + * @return the level of a given skill + * + * @throws InvalidSkillException if the given skill is not valid + */ + public int getLevel(Player player, String skillType) { + return ExperienceAPI.getLevel(player, skillType); + } + + /** + * Get the level an offline player has in a specific skill. + *
+ * + * @param uuid The player to get the level for + * @param skillType The skill to get the level for + * @return the level of a given skill + * + * @throws InvalidSkillException if the given skill is not valid + * @throws InvalidPlayerException if the given player does not exist in the + * database + */ + public int getLevelOffline(UUID uuid, String skillType) { + return ExperienceAPI.getLevelOffline(uuid, skillType); + } + + /** + * Gets the power level of a player. + *
+ * + * @param player The player to get the power level for + * @return the power level of the player + */ + public int getPowerLevel(Player player) { + return ExperienceAPI.getPowerLevel(player); + } + + /** + * Gets the power level of an offline player. + *
+ * + * @param uuid The player to get the power level for + * @return the power level of the player + * + * @throws InvalidPlayerException if the given player does not exist in the + * database + */ + public int getPowerLevelOffline(UUID uuid) { + return ExperienceAPI.getPowerLevelOffline(uuid); + } + + /** + * Get the level cap of a specific skill. + *
+ * + * @param skillType The skill to get the level cap for + * @return the level cap of a given skill + * + * @throws InvalidSkillException if the given skill is not valid + */ + public int getLevelCap(String skillType) { + return ExperienceAPI.getLevelCap(skillType); + } + + /** + * Get the power level cap. + *
+ * + * @return the overall power level cap + */ + public int getPowerLevelCap() { + return ExperienceAPI.getPowerLevelCap(); + } + + /** + * Get the position on the leaderboard of a player. + *
+ * + * @param uuid The name of the player to check + * @param skillType The skill to check + * + * @throws InvalidSkillException if the given skill is not valid + * @throws InvalidPlayerException if the given player does not exist in the + * database + * @throws UnsupportedOperationException if the given skill is a child skill + * + * @return the position on the leaderboard + */ + public int getPlayerRankSkill(UUID uuid, String skillType) { + return ExperienceAPI.getPlayerRankSkill(uuid, skillType); + } + + /** + * Get the position on the power level leaderboard of a player. + *
+ * + * @param uuid The name of the player to check + * + * @throws InvalidPlayerException if the given player does not exist in the + * database + * + * @return the position on the power level leaderboard + */ + public int getPlayerRankOverall(UUID uuid) { + return ExperienceAPI.getPlayerRankOverall(uuid); + } + + /** + * Sets the level of a player in a specific skill type. + *
+ * + * @param player The player to set the level of + * @param skillType The skill to set the level for + * @param skillLevel The value to set the level to + * + * @throws InvalidSkillException if the given skill is not valid + */ + public void setLevel(Player player, String skillType, int skillLevel) { + ExperienceAPI.setLevel(player, skillType, skillLevel); + } + + /** + * Sets the level of an offline player in a specific skill type. + *
+ * + * @param uuid The player to set the level of + * @param skillType The skill to set the level for + * @param skillLevel The value to set the level to + * + * @throws InvalidSkillException if the given skill is not valid + * @throws InvalidPlayerException if the given player does not exist in the + * database + */ + public void setLevelOffline(UUID uuid, String skillType, int skillLevel) { + ExperienceAPI.setLevelOffline(uuid, skillType, skillLevel); + } + + /** + * Sets the XP of a player in a specific skill type. + *
+ * + * @param player The player to set the XP of + * @param skillType The skill to set the XP for + * @param newValue The value to set the XP to + * + * @throws InvalidSkillException if the given skill is not valid + * @throws UnsupportedOperationException if the given skill is a child skill + */ + public void setXP(Player player, String skillType, int newValue) { + ExperienceAPI.setXP(player, skillType, newValue); + } + + /** + * Sets the XP of an offline player in a specific skill type. + *
+ * + * @param uuid The player to set the XP of + * @param skillType The skill to set the XP for + * @param newValue The value to set the XP to + * + * @throws InvalidSkillException if the given skill is not valid + * @throws InvalidPlayerException if the given player does not exist in the + * database + * @throws UnsupportedOperationException if the given skill is a child skill + */ + public void setXPOffline(UUID uuid, String skillType, int newValue) { + ExperienceAPI.setXPOffline(uuid, skillType, newValue); + } + + /** + * Removes XP from a player in a specific skill type. + *
+ * + * @param player The player to change the XP of + * @param skillType The skill to change the XP for + * @param xp The amount of XP to remove + * + * @throws InvalidSkillException if the given skill is not valid + * @throws UnsupportedOperationException if the given skill is a child skill + */ + public void removeXP(Player player, String skillType, int xp) { + ExperienceAPI.removeXP(player, skillType, xp); + } + + /** + * Removes XP from an offline player in a specific skill type. + *
+ * + * @param uuid The player to change the XP of + * @param skillType The skill to change the XP for + * @param xp The amount of XP to remove + * + * @throws InvalidSkillException if the given skill is not valid + * @throws InvalidPlayerException if the given player does not exist in the + * database + * @throws UnsupportedOperationException if the given skill is a child skill + */ + public void removeXPOffline(UUID uuid, String skillType, int xp) { + ExperienceAPI.removeXPOffline(uuid, skillType, xp); + } + + /** + * Check how much XP is needed for a specific level with the selected level + * curve. + *
+ * + * @param level The level to get the amount of XP for + * + * @throws InvalidFormulaTypeException if the given formulaType is not valid + */ + public int getXpNeededToLevel(int level) { + return ExperienceAPI.getXpNeededToLevel(level); + } + + /** + * Check how much XP is needed for a specific level with the provided level + * curve. + *
+ * + * @param level The level to get the amount of XP for + * @param formulaType The formula type to get the amount of XP for + * + * @throws InvalidFormulaTypeException if the given formulaType is not valid + */ + public int getXpNeededToLevel(int level, String formulaType) { + return ExperienceAPI.getXpNeededToLevel(level, formulaType); + } + + /* AbilityAPI below */ + + /** + * Checks whether Berserk is enabled for a specific player. + * + * @param player Player to check for + * @return true if enabled; false otherwise. + */ + public boolean berserkEnabled(Player player) { + return AbilityAPI.berserkEnabled(player); + } + + /** + * Checks whether GigaDrill Breaker is enabled for a specific player. + * + * @param player Player to check for + * @return true if enabled; false otherwise. + */ + public boolean gigaDrillBreakerEnabled(Player player) { + return AbilityAPI.gigaDrillBreakerEnabled(player); + } + + /** + * Checks whether Green Terra is enabled for a specific player. + * + * @param player Player to check for + * @return true if enabled; false otherwise. + */ + public boolean greenTerraEnabled(Player player) { + return AbilityAPI.greenTerraEnabled(player); + } + + /** + * Checks whether Serrated Strikes is enabled for a specific player. + * + * @param player Player to check for + * @return true if enabled; false otherwise. + */ + public boolean serratedStrikesEnabled(Player player) { + return AbilityAPI.serratedStrikesEnabled(player); + } + + /** + * Checks whether Skull Splitter is enabled for a specific player. + * + * @param player Player to check for + * @return true if enabled; false otherwise. + */ + public boolean skullSplitterEnabled(Player player) { + return AbilityAPI.skullSplitterEnabled(player); + } + + /** + * Checks whether Super Breaker is enabled for a specific player. + * + * @param player Player to check for + * @return true if enabled; false otherwise. + */ + public boolean superBreakerEnabled(Player player) { + return AbilityAPI.superBreakerEnabled(player); + } + + /** + * Checks whether Tree Feller is enabled for a specific player. + * + * @param player Player to check for + * @return true if enabled; false otherwise. + */ + public boolean treeFellerEnabled(Player player) { + return AbilityAPI.treeFellerEnabled(player); + } + + /** + * Checks whether any special ability is enabled for a specific player. + * + * @param player Player to check for + * @return true if enabled; false otherwise. + */ + public boolean isAnyAbilityEnabled(Player player) { + return AbilityAPI.isAnyAbilityEnabled(player); + } + + /** + * Resets all ability cooldowns for a player so he/she can use it again + * immediately. + * + * @param player Player to reset cooldowns for. + */ + public void resetCooldowns(Player player) { + AbilityAPI.resetCooldowns(player); + } + + /** + * Set the cooldown of Berserk of a specific player. + * + * @param player Player to set the cooldown for. + * @param cooldown Cooldown (in seconds) for the ability. + */ + public void setBerserkCooldown(Player player, long cooldown) { + AbilityAPI.setBerserkCooldown(player, cooldown); + } + + /** + * Set the cooldown of GigaDrill Breaker of a specific player. + * + * @param player Player to set the cooldown for. + * @param cooldown Cooldown (in seconds) for the ability. + */ + public void setGigaDrillBreakerCooldown(Player player, long cooldown) { + AbilityAPI.setGigaDrillBreakerCooldown(player, cooldown); + } + + /** + * Set the cooldown of Green Terra of a specific player. + * + * @param player Player to set the cooldown for. + * @param cooldown Cooldown (in seconds) for the ability. + */ + public void setGreenTerraCooldown(Player player, long cooldown) { + AbilityAPI.setGreenTerraCooldown(player, cooldown); + } + + /** + * Set the cooldown of Serrated Strikes of a specific player. + * + * @param player Player to set the cooldown for. + * @param cooldown Cooldown (in seconds) for the ability. + */ + public void setSerratedStrikesCooldown(Player player, long cooldown) { + AbilityAPI.setSerratedStrikesCooldown(player, cooldown); + } + + /** + * Set the cooldown of Skull Splitter of a specific player. + * + * @param player Player to set the cooldown for. + * @param cooldown Cooldown (in seconds) for the ability. + */ + public void setSkullSplitterCooldown(Player player, long cooldown) { + AbilityAPI.setSkullSplitterCooldown(player, cooldown); + } + + /** + * Set the cooldown of Super Breaker of a specific player. + * + * @param player Player to set the cooldown for. + * @param cooldown Cooldown (in seconds) for the ability. + */ + public void setSuperBreakerCooldown(Player player, long cooldown) { + AbilityAPI.setSuperBreakerCooldown(player, cooldown); + } + + /** + * Set the cooldown of Tree Feller of a specific player. + * + * @param player Player to set the cooldown for. + * @param cooldown Cooldown (in seconds) for the ability. + */ + public void setTreeFellerCooldown(Player player, long cooldown) { + AbilityAPI.setTreeFellerCooldown(player, cooldown); + } + + /** + * Checks whether the given entity is bleeding. + * + * @param entity Entity to check. + * @return true if bleeding; false otherwise. + */ + public boolean isBleeding(LivingEntity entity) { + return AbilityAPI.isBleeding(entity); + } + + /* ChatAPI below */ + + /** + * Send a message to all members of a party + *
+ * + * + * @param plugin The plugin sending the message + * @param sender The name of the sender + * @param displayName The display name of the sender + * @param party The name of the party to send to + * @param message The message to send + */ + public void sendPartyChat(Plugin plugin, String sender, String displayName, + String party, String message) { + ChatAPI.sendPartyChat(plugin, sender, displayName, party, message); + } + + /** + * Send a message to all members of a party + *
+ * + * + * @param plugin The plugin sending the message + * @param sender The name of the sender to display in the chat + * @param party The name of the party to send to + * @param message The message to send + */ + public void sendPartyChat(Plugin plugin, String sender, String party, + String message) { + ChatAPI.sendPartyChat(plugin, sender, party, message); + } + + /** + * Send a message to administrators + *
+ * + * + * @param plugin The plugin sending the message + * @param sender The name of the sender + * @param displayName The display name of the sender + * @param message The message to send + */ + public void sendAdminChat(Plugin plugin, String sender, String displayName, + String message) { + ChatAPI.sendAdminChat(plugin, sender, displayName, message); + } + + /** + * Send a message to administrators + *
+ * + * + * @param plugin The plugin sending the message + * @param sender The name of the sender to display in the chat + * @param message The message to send + */ + public void sendAdminChat(Plugin plugin, String sender, String message) { + ChatAPI.sendAdminChat(plugin, sender, message); + } + + /** + * Check if a player is currently talking in party chat. + * + * @param player The player to check + * @return true if the player is using party chat, false otherwise + */ + public boolean isUsingPartyChat(Player player) { + return ChatAPI.isUsingPartyChat(player); + } + + /** + * Check if a player is currently talking in party chat. + * + * @param playerName The name of the player to check + * @return true if the player is using party chat, false otherwise + */ + public boolean isUsingPartyChat(String playerName) { + return ChatAPI.isUsingPartyChat(playerName); + } + + /** + * Check if a player is currently talking in admin chat. + * + * @param player The player to check + * @return true if the player is using admin chat, false otherwise + */ + public boolean isUsingAdminChat(Player player) { + return ChatAPI.isUsingAdminChat(player); + } + + /** + * Check if a player is currently talking in admin chat. + * + * @param playerName The name of the player to check + * @return true if the player is using admin chat, false otherwise + */ + public boolean isUsingAdminChat(String playerName) { + return ChatAPI.isUsingAdminChat(playerName); + } + + /** + * Toggle the party chat mode of a player. + * + * @param player The player to toggle party chat on. + */ + public void togglePartyChat(Player player) { + ChatAPI.togglePartyChat(player); + } + + /** + * Toggle the party chat mode of a player. + * + * @param playerName The name of the player to toggle party chat on. + */ + public void togglePartyChat(String playerName) { + ChatAPI.togglePartyChat(playerName); + } + + /** + * Toggle the admin chat mode of a player. + * + * @param player The player to toggle admin chat on. + */ + public void toggleAdminChat(Player player) { + ChatAPI.toggleAdminChat(player); + } + + /** + * Toggle the admin chat mode of a player. + * + * @param playerName The name of the player to toggle party chat on. + */ + public void toggleAdminChat(String playerName) { + ChatAPI.toggleAdminChat(playerName); + } + + /* PartyAPI below */ + + /** + * Get the name of the party a player is in. + *
+ + * + * @param player The player to check the party name of + * @return the name of the player's party, or null if not in a party + */ + public String getPartyName(Player player) { + return PartyAPI.getPartyName(player); + } + + /** + * Checks if a player is in a party. + *
+ + * + * @param player The player to check + * @return true if the player is in a party, false otherwise + */ + public boolean inParty(Player player) { + return PartyAPI.inParty(player); + } + + /** + * Check if two players are in the same party. + *
+ + * + * @param playera The first player to check + * @param playerb The second player to check + * @return true if the two players are in the same party, false otherwise + */ + public boolean inSameParty(Player playera, Player playerb) { + return PartyAPI.inSameParty(playera, playerb); + } + + /** + * Get a list of all current parties. + *
+ + * + * @return the list of parties. + */ + public List getParties() { + return PartyAPI.getParties(); + } + + /** + * Add a player to a party. + *
+ + * + * @param player The player to add to the party + * @param partyName The party to add the player to + */ + public void addToParty(Player player, String partyName) { + PartyAPI.addToParty(player, partyName); + } + + /** + * Remove a player from a party. + *
+ + * + * @param player The player to remove + */ + public void removeFromParty(Player player) { + PartyAPI.removeFromParty(player); + } + + /** + * Get the leader of a party. + *
+ + * + * @param partyName The party name + * @return the leader of the party + */ + public String getPartyLeader(String partyName) { + return PartyAPI.getPartyLeader(partyName); + } + + /** + * Set the leader of a party. + *
+ * @deprecated Unknown reason. + * + * @param partyName The name of the party to set the leader of + * @param playerName The playerName to set as leader + */ + @Deprecated + public void setPartyLeader(String partyName, String playerName) { + PartyAPI.setPartyLeader(partyName, playerName); + } + + /** + * Get a list of all players in this player's party. + *
+ @deprecated Unknown reason. + * + * @param player The player to check + * @return all the players in the player's party + */ + @Deprecated + public List getOnlineAndOfflineMembers(Player player) { + return PartyAPI.getOnlineAndOfflineMembers(player); + } + + /** + * Get a list of all player names in this player's party. + *
+ @deprecated Unknown reason. + * + * @param player The player to check + * @return all the player names in the player's party + */ + @Deprecated + public LinkedHashSet getMembers(Player player) { + return PartyAPI.getMembers(player); + } + + /** + * Get a list of all player names and uuids in this player's party. + *
+ + * + * @param player The player to check + * @return all the player names and uuids in the player's party + */ + public LinkedHashMap getMembersMap(Player player) { + return PartyAPI.getMembersMap(player); + } + + /** + * Get a list of all online players in this party. + *
+ + * + * @param partyName The party to check + * @return all online players in this party + */ + public List getOnlineMembers(String partyName) { + return PartyAPI.getOnlineMembers(partyName); + } + + /** + * Get a list of all online players in this player's party. + *
+ + * + * @param player The player to check + * @return all online players in the player's party + */ + public List getOnlineMembers(Player player) { + return PartyAPI.getOnlineMembers(player); + } + + /** + * Whether the given party has an ally. + * @param partyName Party to check. + * @return true if the party has an ally; false otherwise. + */ + public boolean hasAlly(String partyName) { + return PartyAPI.hasAlly(partyName); + } + + /** + * Get the ally of a party. + * @param partyName Party to get the ally from. + * @return Name of the ally or null if not found. + */ + public String getAllyName(String partyName) { + return PartyAPI.getAllyName(partyName); + } + + /* SkillAPI below */ + + /** + * Returns a list of strings with mcMMO's skills + * This includes parent and child skills + *
+ + * + * @return a list of strings with valid skill names + */ + public List getSkills() { + return SkillAPI.getSkills(); + } + + /** + * Returns a list of strings with mcMMO's skills + * This only includes parent skills + *
+ + * + * @return a list of strings with valid skill names + */ + public List getNonChildSkills() { + return SkillAPI.getNonChildSkills(); + } + + /** + * Returns a list of strings with mcMMO's skills + * This only includes child skills + *
+ + * + * @return a list of strings with valid skill names + */ + public List getChildSkills() { + return SkillAPI.getChildSkills(); + } + + /** + * Returns a list of strings with mcMMO's skills + * This only includes combat skills + *
+ + * + * @return a list of strings with valid skill names + */ + public List getCombatSkills() { + return SkillAPI.getCombatSkills(); + } + + /** + * Returns a list of strings with mcMMO's skills + * This only includes gathering skills + *
+ + * + * @return a list of strings with valid skill names + */ + public List getGatheringSkills() { + return SkillAPI.getGatheringSkills(); + } + + /** + * Returns a list of strings with mcMMO's skills + * This only includes misc skills + *
+ + * + * @return a list of strings with valid skill names + */ + public List getMiscSkills() { + return SkillAPI.getMiscSkills(); + } + +} diff --git a/src/me/staartvin/plugins/pluginlibrary/hooks/OnTimeHook.java b/src/me/staartvin/plugins/pluginlibrary/hooks/OnTimeHook.java index 20db5a4..16f042e 100644 --- a/src/me/staartvin/plugins/pluginlibrary/hooks/OnTimeHook.java +++ b/src/me/staartvin/plugins/pluginlibrary/hooks/OnTimeHook.java @@ -1,145 +1,145 @@ -package me.staartvin.plugins.pluginlibrary.hooks; - -import java.util.HashMap; -import java.util.Map; - -import me.edge209.OnTime.DataIO; -import me.edge209.OnTime.OnTimeAPI; -import me.edge209.OnTime.OnTimeAPI.topData; -import me.edge209.OnTime.PlayingTime; -import me.staartvin.plugins.pluginlibrary.Library; - -/** - * OnTime library, link. - *

- * Date created: 15:35:44 14 aug. 2015 - * - * @author Staartvin - * - */ -public class OnTimeHook extends LibraryHook { - - /* (non-Javadoc) - * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#isAvailable() - */ - @Override - public boolean isAvailable() { - // TODO Auto-generated method stub - - return this.getPlugin().getServer().getPluginManager() - .isPluginEnabled(Library.ONTIME.getPluginName()); - } - - /* (non-Javadoc) - * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#hook() - */ - @Override - public boolean hook() { - // All api calls are done static, so there is no need to get the plugin class. - // We only check if the plugin is available. - return isAvailable(); - } - - /** - * Whether or not the given player is stored by OnTime. - * - * @param playerName Name of the player to check. - * @return true if the player is stored; false otherwise. - */ - public boolean isPlayerStored(String playerName) { - return PlayingTime.playerHasOnTimeRecord(playerName); - } - - /** - * Gets a specific data piece of the given player.
- * There a few data types that can be used: - *

- * TOTALPLAY: Total play time (OnTime) a player has spent on your - * server. The returned value is in milliseconds. - *

- * TODAYPLAY: The time a player has spent on your server since - * midnight of the current day. The returned value is in milliseconds. - *

- * WEEKPLAY: The time a player has spent on your server since - * midnight of the first day of the current week. The first day of the week - * is set in the OnTime/config.yml. The returned value is in milliseconds. - *

- * MONTHPLAY: The time a player has spent on your server since - * midnight of the first day of the current month. The first day of the - * month is set in the OnTime/config.yml. The returned value is in - * milliseconds. - *

- * LASTLOGIN: The time stamp (date and time) of the player's last - * login (join) event. The returned value is in milliseconds, and is the - * number of milliseconds that have passed since the JAVA epoch date of - * January 1, 1970. - *

- * LASTVOTE: The time stamp (date and time) of the player's last - * received vote for the server. The returned value is in milliseconds, and - * is the number of milliseconds that have passed since the JAVA epoch date - * of January 1, 1970. - *

- * TOTALVOTE: Number of votes coast by the player for all time. - *

- * TODAYVOTE: Number of votes cast by the player in the current day. - *

- * WEEKVOTE: Number of votes cast by the player in the current week. - *

- * MONTHVOTE: Number of votes cast by the player in the current - * month. - *

- * TOTALREFER: Number of referrals made by the player for all time. - *

- * TODAYREFER: Number of referrals made by the player in the current - * day. - *

- * WEEKREFER: Number of referrals made by the player in the current - * week. - *

- * MONTHREFER: Number of referrals made by the player in the current - * month. - * - * @param playerName Name of the player to get data for. - * @param dataType Type of data, see above. - * @return long value corresponding to the data type, -1 if no data was - * found or the player was invalid. - */ - public long getPlayerData(String playerName, String dataType) { - if (playerName == null || dataType == null) - return -1; - - OnTimeAPI.data data = OnTimeAPI.data.valueOf(dataType.toUpperCase()); - - if (data == null) { - return -1; - } - - return DataIO.getPlayerTimeData(playerName, data); - } - - /** - * Gets a leaderboard-like map containing all top scores of players for the given data type. - *
All data types that are specified at {@link #getPlayerData(String, String)} can be used, except LASTLOGIN and LASTVOTE. - * - * @param dataType Data type to get the leaderboard for. - * @return a map containing the names of the players and their values; null when data type was invalid. - */ - public Map getTopData(String dataType) { - HashMap leaderboard = new HashMap(); - - OnTimeAPI.data data = OnTimeAPI.data.valueOf(dataType.toUpperCase()); - - if (data == null) { - return null; - } - - topData[] topData = DataIO.getTopData(data); - - for (topData td: topData) { - leaderboard.put(td.getPlayerName(), td.getValue()); - } - - return leaderboard; - } -} +package me.staartvin.plugins.pluginlibrary.hooks; + +import java.util.HashMap; +import java.util.Map; + +import me.edge209.OnTime.DataIO; +import me.edge209.OnTime.OnTimeAPI; +import me.edge209.OnTime.OnTimeAPI.topData; +import me.edge209.OnTime.PlayingTime; +import me.staartvin.plugins.pluginlibrary.Library; + +/** + * OnTime library, link. + *

+ * Date created: 15:35:44 14 aug. 2015 + * + * @author Staartvin + * + */ +public class OnTimeHook extends LibraryHook { + + /* (non-Javadoc) + * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#isAvailable() + */ + @Override + public boolean isAvailable() { + // TODO Auto-generated method stub + + return this.getPlugin().getServer().getPluginManager() + .isPluginEnabled(Library.ONTIME.getPluginName()); + } + + /* (non-Javadoc) + * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#hook() + */ + @Override + public boolean hook() { + // All api calls are done static, so there is no need to get the plugin class. + // We only check if the plugin is available. + return isAvailable(); + } + + /** + * Whether or not the given player is stored by OnTime. + * + * @param playerName Name of the player to check. + * @return true if the player is stored; false otherwise. + */ + public boolean isPlayerStored(String playerName) { + return PlayingTime.playerHasOnTimeRecord(playerName); + } + + /** + * Gets a specific data piece of the given player.
+ * There a few data types that can be used: + *

+ * TOTALPLAY: Total play time (OnTime) a player has spent on your + * server. The returned value is in milliseconds. + *

+ * TODAYPLAY: The time a player has spent on your server since + * midnight of the current day. The returned value is in milliseconds. + *

+ * WEEKPLAY: The time a player has spent on your server since + * midnight of the first day of the current week. The first day of the week + * is set in the OnTime/config.yml. The returned value is in milliseconds. + *

+ * MONTHPLAY: The time a player has spent on your server since + * midnight of the first day of the current month. The first day of the + * month is set in the OnTime/config.yml. The returned value is in + * milliseconds. + *

+ * LASTLOGIN: The time stamp (date and time) of the player's last + * login (join) event. The returned value is in milliseconds, and is the + * number of milliseconds that have passed since the JAVA epoch date of + * January 1, 1970. + *

+ * LASTVOTE: The time stamp (date and time) of the player's last + * received vote for the server. The returned value is in milliseconds, and + * is the number of milliseconds that have passed since the JAVA epoch date + * of January 1, 1970. + *

+ * TOTALVOTE: Number of votes coast by the player for all time. + *

+ * TODAYVOTE: Number of votes cast by the player in the current day. + *

+ * WEEKVOTE: Number of votes cast by the player in the current week. + *

+ * MONTHVOTE: Number of votes cast by the player in the current + * month. + *

+ * TOTALREFER: Number of referrals made by the player for all time. + *

+ * TODAYREFER: Number of referrals made by the player in the current + * day. + *

+ * WEEKREFER: Number of referrals made by the player in the current + * week. + *

+ * MONTHREFER: Number of referrals made by the player in the current + * month. + * + * @param playerName Name of the player to get data for. + * @param dataType Type of data, see above. + * @return long value corresponding to the data type, -1 if no data was + * found or the player was invalid. + */ + public long getPlayerData(String playerName, String dataType) { + if (playerName == null || dataType == null) + return -1; + + OnTimeAPI.data data = OnTimeAPI.data.valueOf(dataType.toUpperCase()); + + if (data == null) { + return -1; + } + + return DataIO.getPlayerTimeData(playerName, data); + } + + /** + * Gets a leaderboard-like map containing all top scores of players for the given data type. + *
All data types that are specified at {@link #getPlayerData(String, String)} can be used, except LASTLOGIN and LASTVOTE. + * + * @param dataType Data type to get the leaderboard for. + * @return a map containing the names of the players and their values; null when data type was invalid. + */ + public Map getTopData(String dataType) { + HashMap leaderboard = new HashMap(); + + OnTimeAPI.data data = OnTimeAPI.data.valueOf(dataType.toUpperCase()); + + if (data == null) { + return null; + } + + topData[] topData = DataIO.getTopData(data); + + for (topData td: topData) { + leaderboard.put(td.getPlayerName(), td.getValue()); + } + + return leaderboard; + } +} diff --git a/src/me/staartvin/plugins/pluginlibrary/hooks/RoyalCommandsHook.java b/src/me/staartvin/plugins/pluginlibrary/hooks/RoyalCommandsHook.java index b82b42c..eda8789 100644 --- a/src/me/staartvin/plugins/pluginlibrary/hooks/RoyalCommandsHook.java +++ b/src/me/staartvin/plugins/pluginlibrary/hooks/RoyalCommandsHook.java @@ -1,89 +1,89 @@ -package me.staartvin.plugins.pluginlibrary.hooks; - -import me.staartvin.plugins.pluginlibrary.Library; - -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; -import org.bukkit.inventory.Inventory; -import org.royaldev.royalcommands.RoyalCommands; -import org.royaldev.royalcommands.WorldManager; - -/** - * RoyalCommands library, link. - *

- * Date created: 16:46:20 14 aug. 2015 - * - * @author Staartvin - * - */ -public class RoyalCommandsHook extends LibraryHook { - - private RoyalCommands api; - - /* (non-Javadoc) - * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#isAvailable() - */ - @Override - public boolean isAvailable() { - return this.getPlugin().getServer().getPluginManager() - .isPluginEnabled(Library.ROYALCOMMANDS.getPluginName()); - } - - /* (non-Javadoc) - * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#hook() - */ - @Override - public boolean hook() { - if (!isAvailable()) - return false; - - api = (RoyalCommands) this.getPlugin().getServer().getPluginManager() - .getPlugin(Library.ROYALCOMMANDS.getPluginName()); - - return api != null; - } - - public void doSOmething() { - - } - - /** - * Whether or not the given player is afk according to RoyalCommands. - * @param player Player to check. - * @return true if the player is afk; false otherwise. - */ - public boolean isAFK(Player player) { - return api.getAPI().getPlayerAPI().isAfk(player); - } - - /** - * Gets the display name of the given player. - * @param player Player to get the display name of. - * @return The display name of the player; when no display name was found, the default name of the player. - */ - public String getDisplayName(Player player) { - return api.getAPI().getPlayerAPI().getDisplayName(player); - } - - /** - * Gets the offline inventory of a player on a given world. - * @param player Offline player to get the inventory of. - * @param worldName Name of the world to get the inventory on. - * @return A {@link Inventory} representing the inventory of the offline player on that world; null if any errors occured. - */ - public Inventory getOfflineInventory(OfflinePlayer player, String worldName) { - return WorldManager.il.getOfflinePlayerInventory(player, worldName); - } - - /** - * Gets the offline inventory (enderchest) of a player on a given world. - * @param player Offline player to get the inventory of. - * @param worldName Name of the world to get the inventory on. - * @return A {@link Inventory} representing the enderchest inventory of the offline player on that world; null if any errors occured. - */ - public Inventory getOfflineEnderInventory(OfflinePlayer player, String worldName) { - return WorldManager.il.getOfflinePlayerEnderInventory(player, worldName); - } - -} +package me.staartvin.plugins.pluginlibrary.hooks; + +import me.staartvin.plugins.pluginlibrary.Library; + +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.royaldev.royalcommands.RoyalCommands; +import org.royaldev.royalcommands.WorldManager; + +/** + * RoyalCommands library, link. + *

+ * Date created: 16:46:20 14 aug. 2015 + * + * @author Staartvin + * + */ +public class RoyalCommandsHook extends LibraryHook { + + private RoyalCommands api; + + /* (non-Javadoc) + * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#isAvailable() + */ + @Override + public boolean isAvailable() { + return this.getPlugin().getServer().getPluginManager() + .isPluginEnabled(Library.ROYALCOMMANDS.getPluginName()); + } + + /* (non-Javadoc) + * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#hook() + */ + @Override + public boolean hook() { + if (!isAvailable()) + return false; + + api = (RoyalCommands) this.getPlugin().getServer().getPluginManager() + .getPlugin(Library.ROYALCOMMANDS.getPluginName()); + + return api != null; + } + + public void doSOmething() { + + } + + /** + * Whether or not the given player is afk according to RoyalCommands. + * @param player Player to check. + * @return true if the player is afk; false otherwise. + */ + public boolean isAFK(Player player) { + return api.getAPI().getPlayerAPI().isAfk(player); + } + + /** + * Gets the display name of the given player. + * @param player Player to get the display name of. + * @return The display name of the player; when no display name was found, the default name of the player. + */ + public String getDisplayName(Player player) { + return api.getAPI().getPlayerAPI().getDisplayName(player); + } + + /** + * Gets the offline inventory of a player on a given world. + * @param player Offline player to get the inventory of. + * @param worldName Name of the world to get the inventory on. + * @return A {@link Inventory} representing the inventory of the offline player on that world; null if any errors occured. + */ + public Inventory getOfflineInventory(OfflinePlayer player, String worldName) { + return WorldManager.il.getOfflinePlayerInventory(player, worldName); + } + + /** + * Gets the offline inventory (enderchest) of a player on a given world. + * @param player Offline player to get the inventory of. + * @param worldName Name of the world to get the inventory on. + * @return A {@link Inventory} representing the enderchest inventory of the offline player on that world; null if any errors occured. + */ + public Inventory getOfflineEnderInventory(OfflinePlayer player, String worldName) { + return WorldManager.il.getOfflinePlayerEnderInventory(player, worldName); + } + +} diff --git a/src/me/staartvin/plugins/pluginlibrary/hooks/StatsHook.java b/src/me/staartvin/plugins/pluginlibrary/hooks/StatsHook.java index 20e4dfa..af38202 100644 --- a/src/me/staartvin/plugins/pluginlibrary/hooks/StatsHook.java +++ b/src/me/staartvin/plugins/pluginlibrary/hooks/StatsHook.java @@ -1,516 +1,516 @@ -package me.staartvin.plugins.pluginlibrary.hooks; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; -import java.util.UUID; - -import me.staartvin.plugins.pluginlibrary.Library; -import me.staartvin.plugins.pluginlibrary.hooks.customstats.FoodEatenStat; -import me.staartvin.plugins.pluginlibrary.hooks.customstats.MobKilledStat; -import nl.lolmewn.stats.api.stat.Stat; -import nl.lolmewn.stats.api.stat.StatEntry; -import nl.lolmewn.stats.api.user.StatsHolder; -import nl.lolmewn.stats.bukkit.BukkitMain; - -import org.bukkit.Material; -import org.bukkit.entity.EntityType; - -/** - * Stats library, link. - *

- * Date created: 16:30:26 12 aug. 2015 - * - * @author Staartvin - * - */ -public class StatsHook extends LibraryHook { - - private BukkitMain stats; - - /* (non-Javadoc) - * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#isAvailable() - */ - @Override - public boolean isAvailable() { - // TODO Auto-generated method stub - return this.getPlugin().getServer().getPluginManager() - .isPluginEnabled(Library.STATS.getPluginName()); - } - - /* (non-Javadoc) - * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#hook() - */ - @Override - public boolean hook() { - if (!isAvailable()) - return false; - - stats = (BukkitMain) this.getPlugin().getServer().getPluginManager() - .getPlugin(Library.STATS.getPluginName()); - - return stats != null; - } - - /** - * Gets the total amount of blocks that are broken by a player with a - * certain item id and damage value. - *

- * You must specify the UUID of the player and the item id of the block.
- * Damage value and worldName are optional. If you don't want to check for a - * block with a damage value, just use -1.
- * If you want to check on all worlds, use null as worldName. - * - * @param uuid UUID of player. - * @param id Item ID to check for. - * @param damageValue Damage value to check for. (-1 for no damage value) - * @param worldName World to check in. Null for global. - * @return The amount of blocks a player has broken. - */ - - @SuppressWarnings("deprecation") - public int getBlocksBroken(final UUID uuid, final int id, - final int damageValue, final String worldName) { - if (!isAvailable()) - return 0; - - final Collection stat = getStatType("Blocks broken", uuid); - boolean checkDamageValue = false; - - if (damageValue > 0) { - checkDamageValue = true; - } - - int value = 0; - - for (StatEntry s : stat) { - Map metadata = s.getMetadata(); - - // Check world - if (worldName != null && metadata.containsKey("world")) { - // Not in the world we look for - if (!metadata.get("world").equals(worldName)) - continue; - } - - // Check damage value - if (checkDamageValue) { - if (metadata.containsKey("data")) { - if (!metadata.get("data").equals(damageValue)) - continue; - } - } - - // Check correct id - if (metadata.containsKey("name")) { - Material material = Material.matchMaterial(metadata.get("name") - .toString()); - - if (material.getId() != id) - continue; - } - - value += s.getValue(); - } - - return value; - } - - /** - * Gets the total amount of blocks that are placed by a player with a - * certain item id and damage value. - *

- * You must specify the UUID of the player and the item id of the block.
- * Damage value and worldName are optional. If you don't want to check for a - * block with a damage value, just use -1.
- * If you want to check on all worlds, use null as worldName. - * - * @param uuid UUID of player. - * @param id Item ID to check for. - * @param damageValue Damage value to check for. (-1 for no damage value) - * @param worldName World to check in. Null for global. - * @return The amount of blocks a player has placed. - */ - - @SuppressWarnings("deprecation") - public int getBlocksPlaced(final UUID uuid, final int id, - final int damageValue, final String worldName) { - if (!isAvailable()) - return 0; - - final Collection stat = getStatType("Blocks placed", uuid); - boolean checkDamageValue = false; - - if (damageValue > 0) { - checkDamageValue = true; - } - - int value = 0; - - for (StatEntry s : stat) { - Map metadata = s.getMetadata(); - - // Check world - if (worldName != null && metadata.containsKey("world")) { - // Not in the world we look for - if (!metadata.get("world").equals(worldName)) - continue; - } - - // Check damage value - if (checkDamageValue) { - if (metadata.containsKey("data")) { - if (!metadata.get("data").equals(damageValue)) - continue; - } - } - - // Check correct id - if (metadata.containsKey("name")) { - Material material = Material.matchMaterial(metadata.get("name") - .toString()); - - if (material.getId() != id) - continue; - } - - value += s.getValue(); - } - - return value; - } - - public EntityType getEntityType(final String entityName) { - try { - return EntityType.valueOf(entityName.toUpperCase()); - } catch (final Exception e) { - return null; - } - } - - /** - * If there is no method for getting specific data, you can use this one. - *
This is just for generic stats. - *
Most stats can be retrieved with this method: - *
Arrows, Beds entered, Buckets emptied, Buckets filled, Commands done, Damage taken, Eggs thrown, Fish caught, Joins, - * Last join, Last seen, Money, Omnomnom (amount of food eaten), PVP streak, PVP top streak, Playtime, Shears, Teleports, - * Times kicked, Trades, Votes, Words said, Times changed world, XP gained - * - * @param uuid UUID of the player. - * @param statName Name of the stat. - * @param worldName Name of the world, or null for global. - * @return - */ - public int getNormalStat(final UUID uuid, final String statName, - final String worldName) { - if (!isAvailable()) - return 0; - - final Collection stat = getStatType(statName, uuid); - - int value = 0; - - for (StatEntry s : stat) { - Map metadata = s.getMetadata(); - - if (worldName != null && metadata.containsKey("world")) { - // Not in the world we look for - if (!metadata.get("world").equals(worldName)) - continue; - } - - value += s.getValue(); - } - - return value; - } - - /** - * Get the stats of a player, a new stat will be created if it didn't exist - * yet. - * - * @param statName Name of the stat to get - * @param uuid UUID to get the stats of. - * @return Requested stat of the player - */ - public Collection getStatType(final String statName, - final UUID uuid) { - - if (uuid == null) { - return new ArrayList(); - } - - StatsHolder holder = stats.getUserManager().getUser(uuid); - - if (holder == null) { - this.getPlugin().logMessage( - "UUID '" + uuid.toString() - + "' was not found in Stats database!"); - - return new ArrayList(); - } - - Stat stat = stats.getStatManager().getStat(statName); - - if (stat == null) - throw new IllegalArgumentException("Unknown stat '" + statName - + "'!"); - - return holder.getStats(stat); - } - - /** - * Gets the total amount of all broken blocks. It ignores item id or damage value. - *
If you want to check the amount of broken blocks for a certain type of block or with a damage value, - *
use {@link #getBlocksBroken(UUID, int, int, String)}. - * @param uuid UUID of the player. - * @param worldName Name of the world, or null for global. - * @return The amount of total blocks broken. - */ - public int getTotalBlocksBroken(final UUID uuid, final String worldName) { - if (!isAvailable()) - return 0; - - return this.getNormalStat(uuid, "Blocks broken", worldName); - } - - /** - * Gets the total amount of blocks a player has moved.
- * You need specify a type of movement: - *
0: By foot - *
1: By boat - *
2: By cart - *
3: By pig - *
4: By pig in cart - *
5: By horse - * - *

If you want to check on all worlds, use null as worldName. - * @param uuid UUID of the player to check - * @param type Type of movement - * @param worldName Name of world, null for global - * @return The amount of blocks moved by a player - */ - public int getTotalBlocksMoved(final UUID uuid, final int type, - final String worldName) { - if (!isAvailable()) - return 0; - - final String statName = "Move"; - - final Collection stat = getStatType(statName, uuid); - - int value = 0; - - for (StatEntry s : stat) { - - Map metadata = s.getMetadata(); - - if (worldName != null && metadata.containsKey("world")) { - // Not in the world we look for - if (!metadata.get("world").equals(worldName)) - continue; - } - - if (metadata.containsKey("type") - && (Integer) metadata.get("type") != type) - continue; - - value += s.getValue(); - - } - - return value; - } - - /** - * Gets the total amount of all placed blocks. It ignores item id or damage value. - *
If you want to check the amount of placed blocks for a certain type of block or with a damage value, - *
use {@link #getBlocksPlaced(UUID, int, int, String)}. - * @param uuid UUID of the player. - * @param worldName Name of the world, or null for global. - * @return The amount of total blocks placed. - */ - public int getTotalBlocksPlaced(final UUID uuid, final String worldName) { - if (!isAvailable()) - return 0; - - return this.getNormalStat(uuid, "Blocks placed", worldName); - } - - /** - * Gets the amount of mobs a player has killed. - *
You can specify a mob name. If you don't, it will return the total amount of mob kills. - *
A few special mobs are the 'wither_skeleton', 'charged_creeper', 'spider_jockey', 'chicken_jockey' and 'elder_guardian'. - * @param uuid UUID of the player. - * @param mobName Name of the mob, or null for all mobs. - * @param worldName Name of the world, or null for global. - * @return The amount of mobs killed a player has killed. - */ - public int getMobsKilled(final UUID uuid, final String mobName, - final String worldName) { - if (!isAvailable()) - return 0; - - final String statName = "Kill"; - - // Mob type - String type = null; - - if (mobName != null && !mobName.equals("")) { - - if (mobName.equalsIgnoreCase("wither_skeleton")) { - return this.getSpecialMobsKilled(uuid, "WITHER SKELETON", - worldName); - } else if (mobName.equalsIgnoreCase("charged_creeper")) { - return this.getSpecialMobsKilled(uuid, "POWERED CREEPER", - worldName); - } else if (mobName.equalsIgnoreCase("spider_jockey")) { - return this.getSpecialMobsKilled(uuid, "SPIDER JOCKEY", - worldName); - } else if (mobName.equalsIgnoreCase("chicken_jockey")) { - return this.getSpecialMobsKilled(uuid, "CHICKEN JOCKEY", - worldName); - } else if (mobName.equalsIgnoreCase("killer_rabbit")) { - return this.getSpecialMobsKilled(uuid, "KILLER RABBIT", - worldName); - } else if (mobName.equalsIgnoreCase("elder_guardian")) { - return this.getSpecialMobsKilled(uuid, "ELDER GUARDIAN", - worldName); - } - - type = EntityType.valueOf( - mobName.toUpperCase().replaceAll(" ", "_")).toString(); - } - - final Collection stat = getStatType(statName, uuid); - - int value = 0; - - for (StatEntry s : stat) { - - Map metadata = s.getMetadata(); - - if (worldName != null && metadata.containsKey("world")) { - // Not in the world we look for - if (!metadata.get("world").equals(worldName)) - continue; - } - - if (type != null && metadata.containsKey("entityType") - && !metadata.get("entityType").equals(type)) - continue; - - // If no type was given (so any mob can be killed, exclude 'player' kills, as most admins don't see players as a real mob). - if (type == null && metadata.containsKey("entityType") - && metadata.get("entityType").equals("PLAYER")) - continue; - - value += s.getValue(); - - } - - return value; - } - - private int getSpecialMobsKilled(UUID uuid, String mobName, String worldName) { - if (!isAvailable()) - return 0; - - final String statName = MobKilledStat.statName; - - final Collection stat = getStatType(statName, uuid); - - int value = 0; - - String extraType = mobName.split(" ")[0].trim(); - String entityType = mobName.split(" ")[1].trim(); - - for (StatEntry s : stat) { - - Map metadata = s.getMetadata(); - - if (worldName != null && metadata.containsKey("world")) { - // Not in the world we look for - if (!metadata.get("world").equals(worldName)) - continue; - } - - if (metadata.containsKey("entityType") - && !metadata.get("entityType").equals(entityType)) - continue; - - if (metadata.containsKey("extraType") - && !metadata.get("extraType").equals(extraType)) - continue; - - value += s.getValue(); - - } - - return value; - } - - /** - * Gets the amount of players a player has killed. - * @param uuid UUID of the player. - * @param worldName Name of the world, or null for global. - * @return The amount of players a player has killed. - */ - public int getPlayersKilled(UUID uuid, String worldName) { - return this.getMobsKilled(uuid, "player", worldName); - } - - /** - * Gets the amount of specific food a player has eaten. - *
If you only want to know about the total amount of food eaten, use {@link #getNormalStat(UUID, String, String)} with statName as 'Omnomnom' instead. - *

A list of usable food types can be found here. - * @param uuid UUID of the player. - * @param worldName Name of the world, or null for global. - * @param foodType Type of food. - * @return The amount of specific food eaten by a player. - */ - public int getFoodEaten(final UUID uuid, final String worldName, - String foodType) { - if (!isAvailable()) - return 0; - - String statName = FoodEatenStat.statName; - - final Collection stat = getStatType(statName, uuid); - - int value = 0; - - for (StatEntry s : stat) { - Map metadata = s.getMetadata(); - - if (worldName != null && metadata.containsKey("world")) { - // Not in the world we look for - if (!metadata.get("world").equals(worldName)) - continue; - } - - if (foodType != null && metadata.containsKey("foodType")) { - if (!metadata.get("foodType").equals(foodType)) - continue; - } - - value += s.getValue(); - } - - return value; - } - - public void addStat(Stat stat) { - stats.getStatManager().addStat(stat); - } - - public Stat getStat(String statName) { - return stats.getStatManager().getStat(statName); - } - - public StatsHolder getStatsHolder(UUID uuid) { - return stats.getUserManager().getUser(uuid); - } - -} +package me.staartvin.plugins.pluginlibrary.hooks; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; +import java.util.UUID; + +import me.staartvin.plugins.pluginlibrary.Library; +import me.staartvin.plugins.pluginlibrary.hooks.customstats.FoodEatenStat; +import me.staartvin.plugins.pluginlibrary.hooks.customstats.MobKilledStat; +import nl.lolmewn.stats.api.stat.Stat; +import nl.lolmewn.stats.api.stat.StatEntry; +import nl.lolmewn.stats.api.user.StatsHolder; +import nl.lolmewn.stats.bukkit.BukkitMain; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; + +/** + * Stats library, link. + *

+ * Date created: 16:30:26 12 aug. 2015 + * + * @author Staartvin + * + */ +public class StatsHook extends LibraryHook { + + private BukkitMain stats; + + /* (non-Javadoc) + * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#isAvailable() + */ + @Override + public boolean isAvailable() { + // TODO Auto-generated method stub + return this.getPlugin().getServer().getPluginManager() + .isPluginEnabled(Library.STATS.getPluginName()); + } + + /* (non-Javadoc) + * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#hook() + */ + @Override + public boolean hook() { + if (!isAvailable()) + return false; + + stats = (BukkitMain) this.getPlugin().getServer().getPluginManager() + .getPlugin(Library.STATS.getPluginName()); + + return stats != null; + } + + /** + * Gets the total amount of blocks that are broken by a player with a + * certain item id and damage value. + *

+ * You must specify the UUID of the player and the item id of the block.
+ * Damage value and worldName are optional. If you don't want to check for a + * block with a damage value, just use -1.
+ * If you want to check on all worlds, use null as worldName. + * + * @param uuid UUID of player. + * @param id Item ID to check for. + * @param damageValue Damage value to check for. (-1 for no damage value) + * @param worldName World to check in. Null for global. + * @return The amount of blocks a player has broken. + */ + + @SuppressWarnings("deprecation") + public int getBlocksBroken(final UUID uuid, final int id, + final int damageValue, final String worldName) { + if (!isAvailable()) + return 0; + + final Collection stat = getStatType("Blocks broken", uuid); + boolean checkDamageValue = false; + + if (damageValue > 0) { + checkDamageValue = true; + } + + int value = 0; + + for (StatEntry s : stat) { + Map metadata = s.getMetadata(); + + // Check world + if (worldName != null && metadata.containsKey("world")) { + // Not in the world we look for + if (!metadata.get("world").equals(worldName)) + continue; + } + + // Check damage value + if (checkDamageValue) { + if (metadata.containsKey("data")) { + if (!metadata.get("data").equals(damageValue)) + continue; + } + } + + // Check correct id + if (metadata.containsKey("name")) { + Material material = Material.matchMaterial(metadata.get("name") + .toString()); + + if (material.getId() != id) + continue; + } + + value += s.getValue(); + } + + return value; + } + + /** + * Gets the total amount of blocks that are placed by a player with a + * certain item id and damage value. + *

+ * You must specify the UUID of the player and the item id of the block.
+ * Damage value and worldName are optional. If you don't want to check for a + * block with a damage value, just use -1.
+ * If you want to check on all worlds, use null as worldName. + * + * @param uuid UUID of player. + * @param id Item ID to check for. + * @param damageValue Damage value to check for. (-1 for no damage value) + * @param worldName World to check in. Null for global. + * @return The amount of blocks a player has placed. + */ + + @SuppressWarnings("deprecation") + public int getBlocksPlaced(final UUID uuid, final int id, + final int damageValue, final String worldName) { + if (!isAvailable()) + return 0; + + final Collection stat = getStatType("Blocks placed", uuid); + boolean checkDamageValue = false; + + if (damageValue > 0) { + checkDamageValue = true; + } + + int value = 0; + + for (StatEntry s : stat) { + Map metadata = s.getMetadata(); + + // Check world + if (worldName != null && metadata.containsKey("world")) { + // Not in the world we look for + if (!metadata.get("world").equals(worldName)) + continue; + } + + // Check damage value + if (checkDamageValue) { + if (metadata.containsKey("data")) { + if (!metadata.get("data").equals(damageValue)) + continue; + } + } + + // Check correct id + if (metadata.containsKey("name")) { + Material material = Material.matchMaterial(metadata.get("name") + .toString()); + + if (material.getId() != id) + continue; + } + + value += s.getValue(); + } + + return value; + } + + public EntityType getEntityType(final String entityName) { + try { + return EntityType.valueOf(entityName.toUpperCase()); + } catch (final Exception e) { + return null; + } + } + + /** + * If there is no method for getting specific data, you can use this one. + *
This is just for generic stats. + *
Most stats can be retrieved with this method: + *
Arrows, Beds entered, Buckets emptied, Buckets filled, Commands done, Damage taken, Eggs thrown, Fish caught, Joins, + * Last join, Last seen, Money, Omnomnom (amount of food eaten), PVP streak, PVP top streak, Playtime, Shears, Teleports, + * Times kicked, Trades, Votes, Words said, Times changed world, XP gained + * + * @param uuid UUID of the player. + * @param statName Name of the stat. + * @param worldName Name of the world, or null for global. + * @return + */ + public int getNormalStat(final UUID uuid, final String statName, + final String worldName) { + if (!isAvailable()) + return 0; + + final Collection stat = getStatType(statName, uuid); + + int value = 0; + + for (StatEntry s : stat) { + Map metadata = s.getMetadata(); + + if (worldName != null && metadata.containsKey("world")) { + // Not in the world we look for + if (!metadata.get("world").equals(worldName)) + continue; + } + + value += s.getValue(); + } + + return value; + } + + /** + * Get the stats of a player, a new stat will be created if it didn't exist + * yet. + * + * @param statName Name of the stat to get + * @param uuid UUID to get the stats of. + * @return Requested stat of the player + */ + public Collection getStatType(final String statName, + final UUID uuid) { + + if (uuid == null) { + return new ArrayList(); + } + + StatsHolder holder = stats.getUserManager().getUser(uuid); + + if (holder == null) { + this.getPlugin().logMessage( + "UUID '" + uuid.toString() + + "' was not found in Stats database!"); + + return new ArrayList(); + } + + Stat stat = stats.getStatManager().getStat(statName); + + if (stat == null) + throw new IllegalArgumentException("Unknown stat '" + statName + + "'!"); + + return holder.getStats(stat); + } + + /** + * Gets the total amount of all broken blocks. It ignores item id or damage value. + *
If you want to check the amount of broken blocks for a certain type of block or with a damage value, + *
use {@link #getBlocksBroken(UUID, int, int, String)}. + * @param uuid UUID of the player. + * @param worldName Name of the world, or null for global. + * @return The amount of total blocks broken. + */ + public int getTotalBlocksBroken(final UUID uuid, final String worldName) { + if (!isAvailable()) + return 0; + + return this.getNormalStat(uuid, "Blocks broken", worldName); + } + + /** + * Gets the total amount of blocks a player has moved.
+ * You need specify a type of movement: + *
0: By foot + *
1: By boat + *
2: By cart + *
3: By pig + *
4: By pig in cart + *
5: By horse + * + *

If you want to check on all worlds, use null as worldName. + * @param uuid UUID of the player to check + * @param type Type of movement + * @param worldName Name of world, null for global + * @return The amount of blocks moved by a player + */ + public int getTotalBlocksMoved(final UUID uuid, final int type, + final String worldName) { + if (!isAvailable()) + return 0; + + final String statName = "Move"; + + final Collection stat = getStatType(statName, uuid); + + int value = 0; + + for (StatEntry s : stat) { + + Map metadata = s.getMetadata(); + + if (worldName != null && metadata.containsKey("world")) { + // Not in the world we look for + if (!metadata.get("world").equals(worldName)) + continue; + } + + if (metadata.containsKey("type") + && (Integer) metadata.get("type") != type) + continue; + + value += s.getValue(); + + } + + return value; + } + + /** + * Gets the total amount of all placed blocks. It ignores item id or damage value. + *
If you want to check the amount of placed blocks for a certain type of block or with a damage value, + *
use {@link #getBlocksPlaced(UUID, int, int, String)}. + * @param uuid UUID of the player. + * @param worldName Name of the world, or null for global. + * @return The amount of total blocks placed. + */ + public int getTotalBlocksPlaced(final UUID uuid, final String worldName) { + if (!isAvailable()) + return 0; + + return this.getNormalStat(uuid, "Blocks placed", worldName); + } + + /** + * Gets the amount of mobs a player has killed. + *
You can specify a mob name. If you don't, it will return the total amount of mob kills. + *
A few special mobs are the 'wither_skeleton', 'charged_creeper', 'spider_jockey', 'chicken_jockey' and 'elder_guardian'. + * @param uuid UUID of the player. + * @param mobName Name of the mob, or null for all mobs. + * @param worldName Name of the world, or null for global. + * @return The amount of mobs killed a player has killed. + */ + public int getMobsKilled(final UUID uuid, final String mobName, + final String worldName) { + if (!isAvailable()) + return 0; + + final String statName = "Kill"; + + // Mob type + String type = null; + + if (mobName != null && !mobName.equals("")) { + + if (mobName.equalsIgnoreCase("wither_skeleton")) { + return this.getSpecialMobsKilled(uuid, "WITHER SKELETON", + worldName); + } else if (mobName.equalsIgnoreCase("charged_creeper")) { + return this.getSpecialMobsKilled(uuid, "POWERED CREEPER", + worldName); + } else if (mobName.equalsIgnoreCase("spider_jockey")) { + return this.getSpecialMobsKilled(uuid, "SPIDER JOCKEY", + worldName); + } else if (mobName.equalsIgnoreCase("chicken_jockey")) { + return this.getSpecialMobsKilled(uuid, "CHICKEN JOCKEY", + worldName); + } else if (mobName.equalsIgnoreCase("killer_rabbit")) { + return this.getSpecialMobsKilled(uuid, "KILLER RABBIT", + worldName); + } else if (mobName.equalsIgnoreCase("elder_guardian")) { + return this.getSpecialMobsKilled(uuid, "ELDER GUARDIAN", + worldName); + } + + type = EntityType.valueOf( + mobName.toUpperCase().replaceAll(" ", "_")).toString(); + } + + final Collection stat = getStatType(statName, uuid); + + int value = 0; + + for (StatEntry s : stat) { + + Map metadata = s.getMetadata(); + + if (worldName != null && metadata.containsKey("world")) { + // Not in the world we look for + if (!metadata.get("world").equals(worldName)) + continue; + } + + if (type != null && metadata.containsKey("entityType") + && !metadata.get("entityType").equals(type)) + continue; + + // If no type was given (so any mob can be killed, exclude 'player' kills, as most admins don't see players as a real mob). + if (type == null && metadata.containsKey("entityType") + && metadata.get("entityType").equals("PLAYER")) + continue; + + value += s.getValue(); + + } + + return value; + } + + private int getSpecialMobsKilled(UUID uuid, String mobName, String worldName) { + if (!isAvailable()) + return 0; + + final String statName = MobKilledStat.statName; + + final Collection stat = getStatType(statName, uuid); + + int value = 0; + + String extraType = mobName.split(" ")[0].trim(); + String entityType = mobName.split(" ")[1].trim(); + + for (StatEntry s : stat) { + + Map metadata = s.getMetadata(); + + if (worldName != null && metadata.containsKey("world")) { + // Not in the world we look for + if (!metadata.get("world").equals(worldName)) + continue; + } + + if (metadata.containsKey("entityType") + && !metadata.get("entityType").equals(entityType)) + continue; + + if (metadata.containsKey("extraType") + && !metadata.get("extraType").equals(extraType)) + continue; + + value += s.getValue(); + + } + + return value; + } + + /** + * Gets the amount of players a player has killed. + * @param uuid UUID of the player. + * @param worldName Name of the world, or null for global. + * @return The amount of players a player has killed. + */ + public int getPlayersKilled(UUID uuid, String worldName) { + return this.getMobsKilled(uuid, "player", worldName); + } + + /** + * Gets the amount of specific food a player has eaten. + *
If you only want to know about the total amount of food eaten, use {@link #getNormalStat(UUID, String, String)} with statName as 'Omnomnom' instead. + *

A list of usable food types can be found here. + * @param uuid UUID of the player. + * @param worldName Name of the world, or null for global. + * @param foodType Type of food. + * @return The amount of specific food eaten by a player. + */ + public int getFoodEaten(final UUID uuid, final String worldName, + String foodType) { + if (!isAvailable()) + return 0; + + String statName = FoodEatenStat.statName; + + final Collection stat = getStatType(statName, uuid); + + int value = 0; + + for (StatEntry s : stat) { + Map metadata = s.getMetadata(); + + if (worldName != null && metadata.containsKey("world")) { + // Not in the world we look for + if (!metadata.get("world").equals(worldName)) + continue; + } + + if (foodType != null && metadata.containsKey("foodType")) { + if (!metadata.get("foodType").equals(foodType)) + continue; + } + + value += s.getValue(); + } + + return value; + } + + public void addStat(Stat stat) { + stats.getStatManager().addStat(stat); + } + + public Stat getStat(String statName) { + return stats.getStatManager().getStat(statName); + } + + public StatsHolder getStatsHolder(UUID uuid) { + return stats.getUserManager().getUser(uuid); + } + +} diff --git a/src/me/staartvin/plugins/pluginlibrary/hooks/customstats/CustomStatsManager.java b/src/me/staartvin/plugins/pluginlibrary/hooks/customstats/CustomStatsManager.java index b48a2d3..cf2bd7a 100644 --- a/src/me/staartvin/plugins/pluginlibrary/hooks/customstats/CustomStatsManager.java +++ b/src/me/staartvin/plugins/pluginlibrary/hooks/customstats/CustomStatsManager.java @@ -1,47 +1,47 @@ -package me.staartvin.plugins.pluginlibrary.hooks.customstats; - -import me.staartvin.plugins.pluginlibrary.Library; -import me.staartvin.plugins.pluginlibrary.PluginLibrary; -import me.staartvin.plugins.pluginlibrary.hooks.StatsHook; -import me.staartvin.plugins.pluginlibrary.listeners.PlayerEatsFoodListener; -import me.staartvin.plugins.pluginlibrary.listeners.PlayerKillsMobListener; - -/** - * Manages all custom stats that Autorank creates with Stats. - *

- * Date created: 15:00:27 15 jul. 2015 - * - * @author Staartvin - * - */ -public class CustomStatsManager { - - private final PluginLibrary plugin; - - public CustomStatsManager(PluginLibrary instance) { - this.plugin = instance; - } - - public void registerCustomStats() { - - // Stats is not available - if (!plugin.isLibraryLoaded(Library.STATS)) - return; - - StatsHook hook = (StatsHook) PluginLibrary.getLibrary(Library.STATS); - - hook.addStat(new MobKilledStat()); - /*plugin.debugMessage("Registered '" + MobKilledStat.statName - + "' to Stats.");*/ - - hook.addStat(new FoodEatenStat()); - /*plugin.debugMessage("Registered '" + FoodEatenStat.statName - + "' to Stats.");*/ - - // Register listeners - plugin.getServer().getPluginManager() - .registerEvents(new PlayerEatsFoodListener(plugin), plugin); - plugin.getServer().getPluginManager() - .registerEvents(new PlayerKillsMobListener(plugin), plugin); - } -} +package me.staartvin.plugins.pluginlibrary.hooks.customstats; + +import me.staartvin.plugins.pluginlibrary.Library; +import me.staartvin.plugins.pluginlibrary.PluginLibrary; +import me.staartvin.plugins.pluginlibrary.hooks.StatsHook; +import me.staartvin.plugins.pluginlibrary.listeners.PlayerEatsFoodListener; +import me.staartvin.plugins.pluginlibrary.listeners.PlayerKillsMobListener; + +/** + * Manages all custom stats that Autorank creates with Stats. + *

+ * Date created: 15:00:27 15 jul. 2015 + * + * @author Staartvin + * + */ +public class CustomStatsManager { + + private final PluginLibrary plugin; + + public CustomStatsManager(PluginLibrary instance) { + this.plugin = instance; + } + + public void registerCustomStats() { + + // Stats is not available + if (!plugin.isLibraryLoaded(Library.STATS)) + return; + + StatsHook hook = (StatsHook) PluginLibrary.getLibrary(Library.STATS); + + hook.addStat(new MobKilledStat()); + /*plugin.debugMessage("Registered '" + MobKilledStat.statName + + "' to Stats.");*/ + + hook.addStat(new FoodEatenStat()); + /*plugin.debugMessage("Registered '" + FoodEatenStat.statName + + "' to Stats.");*/ + + // Register listeners + plugin.getServer().getPluginManager() + .registerEvents(new PlayerEatsFoodListener(plugin), plugin); + plugin.getServer().getPluginManager() + .registerEvents(new PlayerKillsMobListener(plugin), plugin); + } +} diff --git a/src/me/staartvin/plugins/pluginlibrary/hooks/customstats/FoodEatenStat.java b/src/me/staartvin/plugins/pluginlibrary/hooks/customstats/FoodEatenStat.java index 2e6ce67..7c14727 100644 --- a/src/me/staartvin/plugins/pluginlibrary/hooks/customstats/FoodEatenStat.java +++ b/src/me/staartvin/plugins/pluginlibrary/hooks/customstats/FoodEatenStat.java @@ -1,84 +1,84 @@ -package me.staartvin.plugins.pluginlibrary.hooks.customstats; - -import java.util.HashMap; -import java.util.Map; - -import nl.lolmewn.stats.api.stat.Stat; -import nl.lolmewn.stats.api.stat.StatEntry; -import nl.lolmewn.stats.api.storage.DataType; - -/** - * Stat that tracks what kind of food is eaten by a player - *

- * Date created: 15:59:38 27 jun. 2015 - * - * @author Staartvin - * - */ -public class FoodEatenStat implements Stat { - - private final HashMap data = new HashMap(); - - public static String statName = "PL food eaten"; - - public FoodEatenStat() { - // init - data.put("foodType", DataType.STRING); - data.put("world", DataType.STRING); - } - - /* (non-Javadoc) - * @see nl.lolmewn.stats.api.stat.Stat#format(nl.lolmewn.stats.api.stat.StatEntry) - */ - @Override - public String format(StatEntry arg0) { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see nl.lolmewn.stats.api.stat.Stat#getDataTypes() - */ - @Override - public Map getDataTypes() { - // TODO Auto-generated method stub - return data; - } - - /* (non-Javadoc) - * @see nl.lolmewn.stats.api.stat.Stat#getDescription() - */ - @Override - public String getDescription() { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see nl.lolmewn.stats.api.stat.Stat#getName() - */ - @Override - public String getName() { - // TODO Auto-generated method stub - return statName; - } - - /* (non-Javadoc) - * @see nl.lolmewn.stats.api.stat.Stat#isEnabled() - */ - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return true; - } - - /* (non-Javadoc) - * @see nl.lolmewn.stats.api.stat.Stat#setEnabled(boolean) - */ - @Override - public void setEnabled(boolean arg0) { - // TODO Auto-generated method stub - - } - -} +package me.staartvin.plugins.pluginlibrary.hooks.customstats; + +import java.util.HashMap; +import java.util.Map; + +import nl.lolmewn.stats.api.stat.Stat; +import nl.lolmewn.stats.api.stat.StatEntry; +import nl.lolmewn.stats.api.storage.DataType; + +/** + * Stat that tracks what kind of food is eaten by a player + *

+ * Date created: 15:59:38 27 jun. 2015 + * + * @author Staartvin + * + */ +public class FoodEatenStat implements Stat { + + private final HashMap data = new HashMap(); + + public static String statName = "PL food eaten"; + + public FoodEatenStat() { + // init + data.put("foodType", DataType.STRING); + data.put("world", DataType.STRING); + } + + /* (non-Javadoc) + * @see nl.lolmewn.stats.api.stat.Stat#format(nl.lolmewn.stats.api.stat.StatEntry) + */ + @Override + public String format(StatEntry arg0) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see nl.lolmewn.stats.api.stat.Stat#getDataTypes() + */ + @Override + public Map getDataTypes() { + // TODO Auto-generated method stub + return data; + } + + /* (non-Javadoc) + * @see nl.lolmewn.stats.api.stat.Stat#getDescription() + */ + @Override + public String getDescription() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see nl.lolmewn.stats.api.stat.Stat#getName() + */ + @Override + public String getName() { + // TODO Auto-generated method stub + return statName; + } + + /* (non-Javadoc) + * @see nl.lolmewn.stats.api.stat.Stat#isEnabled() + */ + @Override + public boolean isEnabled() { + // TODO Auto-generated method stub + return true; + } + + /* (non-Javadoc) + * @see nl.lolmewn.stats.api.stat.Stat#setEnabled(boolean) + */ + @Override + public void setEnabled(boolean arg0) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/me/staartvin/plugins/pluginlibrary/hooks/customstats/MobKilledStat.java b/src/me/staartvin/plugins/pluginlibrary/hooks/customstats/MobKilledStat.java index de44829..8364eae 100644 --- a/src/me/staartvin/plugins/pluginlibrary/hooks/customstats/MobKilledStat.java +++ b/src/me/staartvin/plugins/pluginlibrary/hooks/customstats/MobKilledStat.java @@ -1,86 +1,86 @@ -package me.staartvin.plugins.pluginlibrary.hooks.customstats; - -import java.util.HashMap; -import java.util.Map; - -import nl.lolmewn.stats.api.stat.Stat; -import nl.lolmewn.stats.api.stat.StatEntry; -import nl.lolmewn.stats.api.storage.DataType; - -/** - * Stat that tracks special mobs killed, such as 'charged creeper' or 'elder - * guardian' - *

- * Date created: 15:59:38 27 jun. 2015 - * - * @author Staartvin - * - */ -public class MobKilledStat implements Stat { - - private final HashMap data = new HashMap(); - - public static String statName = "PL special mobs killed"; - - public MobKilledStat() { - // init - data.put("entityType", DataType.STRING); - data.put("extraType", DataType.STRING); - data.put("world", DataType.STRING); - } - - /* (non-Javadoc) - * @see nl.lolmewn.stats.api.stat.Stat#format(nl.lolmewn.stats.api.stat.StatEntry) - */ - @Override - public String format(StatEntry arg0) { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see nl.lolmewn.stats.api.stat.Stat#getDataTypes() - */ - @Override - public Map getDataTypes() { - // TODO Auto-generated method stub - return data; - } - - /* (non-Javadoc) - * @see nl.lolmewn.stats.api.stat.Stat#getDescription() - */ - @Override - public String getDescription() { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see nl.lolmewn.stats.api.stat.Stat#getName() - */ - @Override - public String getName() { - // TODO Auto-generated method stub - return statName; - } - - /* (non-Javadoc) - * @see nl.lolmewn.stats.api.stat.Stat#isEnabled() - */ - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return true; - } - - /* (non-Javadoc) - * @see nl.lolmewn.stats.api.stat.Stat#setEnabled(boolean) - */ - @Override - public void setEnabled(boolean arg0) { - // TODO Auto-generated method stub - - } - -} +package me.staartvin.plugins.pluginlibrary.hooks.customstats; + +import java.util.HashMap; +import java.util.Map; + +import nl.lolmewn.stats.api.stat.Stat; +import nl.lolmewn.stats.api.stat.StatEntry; +import nl.lolmewn.stats.api.storage.DataType; + +/** + * Stat that tracks special mobs killed, such as 'charged creeper' or 'elder + * guardian' + *

+ * Date created: 15:59:38 27 jun. 2015 + * + * @author Staartvin + * + */ +public class MobKilledStat implements Stat { + + private final HashMap data = new HashMap(); + + public static String statName = "PL special mobs killed"; + + public MobKilledStat() { + // init + data.put("entityType", DataType.STRING); + data.put("extraType", DataType.STRING); + data.put("world", DataType.STRING); + } + + /* (non-Javadoc) + * @see nl.lolmewn.stats.api.stat.Stat#format(nl.lolmewn.stats.api.stat.StatEntry) + */ + @Override + public String format(StatEntry arg0) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see nl.lolmewn.stats.api.stat.Stat#getDataTypes() + */ + @Override + public Map getDataTypes() { + // TODO Auto-generated method stub + return data; + } + + /* (non-Javadoc) + * @see nl.lolmewn.stats.api.stat.Stat#getDescription() + */ + @Override + public String getDescription() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see nl.lolmewn.stats.api.stat.Stat#getName() + */ + @Override + public String getName() { + // TODO Auto-generated method stub + return statName; + } + + /* (non-Javadoc) + * @see nl.lolmewn.stats.api.stat.Stat#isEnabled() + */ + @Override + public boolean isEnabled() { + // TODO Auto-generated method stub + return true; + } + + /* (non-Javadoc) + * @see nl.lolmewn.stats.api.stat.Stat#setEnabled(boolean) + */ + @Override + public void setEnabled(boolean arg0) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/me/staartvin/plugins/pluginlibrary/hooks/factions/Faction.java b/src/me/staartvin/plugins/pluginlibrary/hooks/factions/Faction.java index c028354..da25e71 100644 --- a/src/me/staartvin/plugins/pluginlibrary/hooks/factions/Faction.java +++ b/src/me/staartvin/plugins/pluginlibrary/hooks/factions/Faction.java @@ -1,394 +1,394 @@ -package me.staartvin.plugins.pluginlibrary.hooks.factions; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.UUID; - -import org.bukkit.Chunk; -import org.bukkit.Location; -import org.bukkit.entity.Player; - -import com.massivecraft.factions.Rel; -import com.massivecraft.factions.entity.BoardColl; -import com.massivecraft.factions.entity.FactionColl; -import com.massivecraft.factions.entity.MFlag; -import com.massivecraft.massivecore.ps.PS; - -/** - * Represents the {@link com.massivecraft.factions.entity.Faction} class. - *
This class mirroring is used so developers don't have to import the API of Factions. - *

- * Date created: 23:56:42 - * 13 aug. 2015 - * @author Staartvin - * - */ -public class Faction { - private final com.massivecraft.factions.entity.Faction faction; - - public Faction(com.massivecraft.factions.entity.Faction fac) { - if (fac == null) { - throw new NullPointerException("Faction is null!"); - } - faction = fac; - } - - /** - * Gets the name of the faction. - *
When using other API calls, always use {@link #getId()} (where applicable) or {@link #getComparisonName()}. - *
Only use this method when you want to show the name of the faction to a player! - * - * @return Name of the faction. - */ - public String getName() { - return faction.getName(); - } - - /** - * Gets the description of the faction. - * - * @return description including colour codes or null if non-existent. - */ - public String getDescription() { - return faction.getDescription(); - } - - /** - * Gets the MOTD of the faction. - * - * @return String containting the MOTD, null if faction doesn't exist or has - * no MOTD. - */ - public String getMotd() { - return faction.getMotd(); - } - - /** - * Gets the time (from UNIX timestamp) when the faction was created. - * - * @return time in milliseconds of creation (UNIX) - */ - public long getCreatedAt() { - return faction.getCreatedAtMillis(); - } - - /** - * Gets the location of the home of a faction. - * - * @return A {@link Location} or null if faction is non-existent or the home - * is not set. - */ - public Location getHomeLocation() { - if (faction.getHome() == null) - return null; - - return faction.getHome().asBukkitLocation(); - } - - /** - * Gets the powerboost of the faction. - * - * @return the powerboost of the faction or null if 0. - */ - public Double getPowerBoost() { - return faction.getPowerBoost(); - } - - /** - * Sets the name of the faction. - * - * @param name New name for the faction. - */ - public void setName(String name) { - faction.setName(name); - } - - /** - * Sets the description of the faction. - * - * @param description Description to set. - */ - public void setDescription(String description) { - faction.setDescription(getDescription()); - } - - /** - * Sets the MOTD of a faction. - * - * @param motd MOTD to set to. - */ - public void setMotd(String motd) { - faction.setMotd(motd); - } - - /** - * Sets the time the faction was created at. - * - * @param time Time (in milliseconds) in UNIX timestamp. - */ - public void setCreatedAt(long time) { - faction.setCreatedAtMillis(time); - } - - /** - * Sets the location of the home of a faction. - * - * @param location Location to set the home to. - */ - public void setHomeLocation(Location location) { - faction.setHome(PS.valueOf(location)); - } - - /** - * Sets the powerboost of the faction. - * - * @param powerBoost Powerboost to set it to. - */ - public void setPowerBoost(Double powerBoost) { - faction.setPowerBoost(powerBoost); - } - - /** - * Gets the boolean value of the flag specified for this faction. - * - * @param flagId Name of the flag. You can use: open, monsters, powerloss, - * pvp, friendlyfire, explosions, offlineexplosions, firespread, - * endergrief, permanent, peaceful or infpower. - * @return true if flag is true; false if faction does not exist or flag is - * false. - * @throws NullPointerException If faction does not exist or flagId is - * invalid. - */ - public boolean getFlagValue(String flagId) { - // throw new NullPointerException("flagId"); - return faction.getFlag(flagId); - } - - /** - * Sets the value of the given flag for a faction. - * - * @param flagId Name of the flag. For a list of flags, see - * {@link #getFactionFlag(String, String)}. - * @param value Value to set the flag to. - */ - public void setFlagValue(String flagId, boolean value) { - // throw new NullPointerException("flagId"); - faction.setFlag(flagId, value); - } - - /** - * Gets a list of UUIDs that are invited to this faction. - * - * @return a list of UUIDs corresponding to players. - */ - public Set getInvitedPlayerIds() { - HashSet uuids = new HashSet(); - - for (String uuid : faction.getInvitedPlayerIds()) { - uuids.add(UUID.fromString(uuid)); - } - - return uuids; - } - - /** - * Checks whether a player is invited or not. - * - * @param uuid UUID to check. - * @return true if invited; false otherwise. - */ - public boolean isInvited(UUID uuid) { - return this.getInvitedPlayerIds().contains(uuid); - } - - /** - * Gets the current power of the faction. - * - * @return power of the faction. - */ - public double getPower() { - return faction.getPower(); - } - - /** - * Gets the leader of the faction. - * - * @return {@link MPlayer} that is the leader of this faction or null if not - * found. - */ - public MPlayer getLeader() { - - if (faction.getLeader() == null) return null; - - return new MPlayer(faction.getLeader()); - } - - /** - * Gets the chunks the faction has claimed. - * - * @return a list of claimed chunks. - */ - public List getChunks() { - Set chunks = BoardColl.get().getChunks(faction); - List realChunks = new ArrayList(); - - for (PS chunk : chunks) { - if (chunk == null) - continue; - - realChunks.add(chunk.asBukkitChunk()); - } - - return realChunks; - } - - /** - * Gets the relation wish of this faction to another faction.
- * Will return a relationship type. This can be ALLY, TRUCE, NEUTRAL and - * ENEMY. - * - * @param otherFaction Other faction. - * @return A relationship type or null if the other faction was not found. - */ - public String getRelationWish(Faction otherFaction) { - com.massivecraft.factions.entity.Faction otherFac = FactionColl.get() - .get(otherFaction.getId()); - - if (otherFac == null) - return null; - - Rel rel = faction.getRelationWish(otherFac); - - if (rel == null) - return null; - - return rel.toString(); - } - - /** - * Sets the relation wish of this faction to another faction.
- * For a list of relation types, see {@link #getRelationWish(Faction)} - *
NOTE: You can only try to set the relation as a wish, as the other faction has to accept it. - *
There is no setRelation(). - * - * @param otherFaction The other faction to set the relation to. - * @param relation Relation type. - */ - public void setRelationWish(Faction otherFaction, String relation) { - com.massivecraft.factions.entity.Faction otherFac = FactionColl.get() - .get(otherFaction.getId()); - - if (otherFac == null) - return; - - Rel rel = Rel.valueOf(relation.toUpperCase()); - - if (rel == null) - return; - - faction.setRelationWish(otherFac, rel); - } - - /** - * Gets the relation of this faction to another faction.
- * Will return a relationship type. This can be ALLY, TRUCE, NEUTRAL and - * ENEMY. - * - * @param otherFaction Other faction. - * @return A relationship type or null if the other faction was not found. - */ - public String getRelationTo(Faction otherFaction) { - com.massivecraft.factions.entity.Faction otherFac = FactionColl.get() - .get(otherFaction.getId()); - - if (otherFac == null) - return null; - - Rel rel = faction.getRelationTo(otherFac); - - if (rel == null) - return null; - - return rel.toString(); - } - - /** - * Gets a list of online players that are member of this faction. - * - * @return a list containing all online-member players. - */ - public List getOnlinePlayers() { - return faction.getOnlinePlayers(); - } - - /** - * Gets the amount of chunks owned by this faction. - * - * @return amount of chunks owned. - */ - public int getLandCount() { - return this.getChunks().size(); - } - - /** - * Sends a message to all online players of this faction. - * @param message Message to send. - */ - public void sendMessage(String message) { - faction.sendMessage(message); - } - - /** - * Gets the maximum amount of power this faction may have. - * @return maximum power amount or null if it doesn't exist. Can also return 999999 if max power is infinite (due to flag). - */ - public Double getPowerMax() { - return faction.getPowerMax(); - } - - /** - * Whether or not this faction is the Wilderness. - * @return true if the Wilderness; false otherwise. - */ - public boolean isWilderness() { - return faction.isNone(); - } - - /** - * Whether or not this faction is the Safezone. - * @return true if the Safezone; false otherwise. - */ - public boolean isSafezone() { - return !faction.getFlag(MFlag.ID_PVP); - } - - /** - * Whether or not this faction is the Warzone. - * @return true if the Warzone; false otherwise. - */ - public boolean isWarzone() { - // Faction allows pvp and is not normal - return faction.getFlag(MFlag.ID_PVP) && !faction.isNormal(); - } - - /** - * Gets the id of this faction. - *
Internally used to reference unique factions. - * @return id of the faction. - */ - public String getId() { - return faction.getId(); - } - - /** - * Gets the 'comparison name' of the faction. - *
When retrieving the name of the faction via {@link #getName()}, it will also include colour codes. - *
This method will remove those colour codes and is internally used by Factions to reference each seperate Faction. - * @return Unique name of Faction without colour codes. - */ - public String getComparisonName() { - return faction.getComparisonName(); - } +package me.staartvin.plugins.pluginlibrary.hooks.factions; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.UUID; + +import org.bukkit.Chunk; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +import com.massivecraft.factions.Rel; +import com.massivecraft.factions.entity.BoardColl; +import com.massivecraft.factions.entity.FactionColl; +import com.massivecraft.factions.entity.MFlag; +import com.massivecraft.massivecore.ps.PS; + +/** + * Represents the {@link com.massivecraft.factions.entity.Faction} class. + *
This class mirroring is used so developers don't have to import the API of Factions. + *

+ * Date created: 23:56:42 + * 13 aug. 2015 + * @author Staartvin + * + */ +public class Faction { + private final com.massivecraft.factions.entity.Faction faction; + + public Faction(com.massivecraft.factions.entity.Faction fac) { + if (fac == null) { + throw new NullPointerException("Faction is null!"); + } + faction = fac; + } + + /** + * Gets the name of the faction. + *
When using other API calls, always use {@link #getId()} (where applicable) or {@link #getComparisonName()}. + *
Only use this method when you want to show the name of the faction to a player! + * + * @return Name of the faction. + */ + public String getName() { + return faction.getName(); + } + + /** + * Gets the description of the faction. + * + * @return description including colour codes or null if non-existent. + */ + public String getDescription() { + return faction.getDescription(); + } + + /** + * Gets the MOTD of the faction. + * + * @return String containting the MOTD, null if faction doesn't exist or has + * no MOTD. + */ + public String getMotd() { + return faction.getMotd(); + } + + /** + * Gets the time (from UNIX timestamp) when the faction was created. + * + * @return time in milliseconds of creation (UNIX) + */ + public long getCreatedAt() { + return faction.getCreatedAtMillis(); + } + + /** + * Gets the location of the home of a faction. + * + * @return A {@link Location} or null if faction is non-existent or the home + * is not set. + */ + public Location getHomeLocation() { + if (faction.getHome() == null) + return null; + + return faction.getHome().asBukkitLocation(); + } + + /** + * Gets the powerboost of the faction. + * + * @return the powerboost of the faction or null if 0. + */ + public Double getPowerBoost() { + return faction.getPowerBoost(); + } + + /** + * Sets the name of the faction. + * + * @param name New name for the faction. + */ + public void setName(String name) { + faction.setName(name); + } + + /** + * Sets the description of the faction. + * + * @param description Description to set. + */ + public void setDescription(String description) { + faction.setDescription(getDescription()); + } + + /** + * Sets the MOTD of a faction. + * + * @param motd MOTD to set to. + */ + public void setMotd(String motd) { + faction.setMotd(motd); + } + + /** + * Sets the time the faction was created at. + * + * @param time Time (in milliseconds) in UNIX timestamp. + */ + public void setCreatedAt(long time) { + faction.setCreatedAtMillis(time); + } + + /** + * Sets the location of the home of a faction. + * + * @param location Location to set the home to. + */ + public void setHomeLocation(Location location) { + faction.setHome(PS.valueOf(location)); + } + + /** + * Sets the powerboost of the faction. + * + * @param powerBoost Powerboost to set it to. + */ + public void setPowerBoost(Double powerBoost) { + faction.setPowerBoost(powerBoost); + } + + /** + * Gets the boolean value of the flag specified for this faction. + * + * @param flagId Name of the flag. You can use: open, monsters, powerloss, + * pvp, friendlyfire, explosions, offlineexplosions, firespread, + * endergrief, permanent, peaceful or infpower. + * @return true if flag is true; false if faction does not exist or flag is + * false. + * @throws NullPointerException If faction does not exist or flagId is + * invalid. + */ + public boolean getFlagValue(String flagId) { + // throw new NullPointerException("flagId"); + return faction.getFlag(flagId); + } + + /** + * Sets the value of the given flag for a faction. + * + * @param flagId Name of the flag. For a list of flags, see + * {@link #getFactionFlag(String, String)}. + * @param value Value to set the flag to. + */ + public void setFlagValue(String flagId, boolean value) { + // throw new NullPointerException("flagId"); + faction.setFlag(flagId, value); + } + + /** + * Gets a list of UUIDs that are invited to this faction. + * + * @return a list of UUIDs corresponding to players. + */ + public Set getInvitedPlayerIds() { + HashSet uuids = new HashSet(); + + for (String uuid : faction.getInvitedPlayerIds()) { + uuids.add(UUID.fromString(uuid)); + } + + return uuids; + } + + /** + * Checks whether a player is invited or not. + * + * @param uuid UUID to check. + * @return true if invited; false otherwise. + */ + public boolean isInvited(UUID uuid) { + return this.getInvitedPlayerIds().contains(uuid); + } + + /** + * Gets the current power of the faction. + * + * @return power of the faction. + */ + public double getPower() { + return faction.getPower(); + } + + /** + * Gets the leader of the faction. + * + * @return {@link MPlayer} that is the leader of this faction or null if not + * found. + */ + public MPlayer getLeader() { + + if (faction.getLeader() == null) return null; + + return new MPlayer(faction.getLeader()); + } + + /** + * Gets the chunks the faction has claimed. + * + * @return a list of claimed chunks. + */ + public List getChunks() { + Set chunks = BoardColl.get().getChunks(faction); + List realChunks = new ArrayList(); + + for (PS chunk : chunks) { + if (chunk == null) + continue; + + realChunks.add(chunk.asBukkitChunk()); + } + + return realChunks; + } + + /** + * Gets the relation wish of this faction to another faction.
+ * Will return a relationship type. This can be ALLY, TRUCE, NEUTRAL and + * ENEMY. + * + * @param otherFaction Other faction. + * @return A relationship type or null if the other faction was not found. + */ + public String getRelationWish(Faction otherFaction) { + com.massivecraft.factions.entity.Faction otherFac = FactionColl.get() + .get(otherFaction.getId()); + + if (otherFac == null) + return null; + + Rel rel = faction.getRelationWish(otherFac); + + if (rel == null) + return null; + + return rel.toString(); + } + + /** + * Sets the relation wish of this faction to another faction.
+ * For a list of relation types, see {@link #getRelationWish(Faction)} + *
NOTE: You can only try to set the relation as a wish, as the other faction has to accept it. + *
There is no setRelation(). + * + * @param otherFaction The other faction to set the relation to. + * @param relation Relation type. + */ + public void setRelationWish(Faction otherFaction, String relation) { + com.massivecraft.factions.entity.Faction otherFac = FactionColl.get() + .get(otherFaction.getId()); + + if (otherFac == null) + return; + + Rel rel = Rel.valueOf(relation.toUpperCase()); + + if (rel == null) + return; + + faction.setRelationWish(otherFac, rel); + } + + /** + * Gets the relation of this faction to another faction.
+ * Will return a relationship type. This can be ALLY, TRUCE, NEUTRAL and + * ENEMY. + * + * @param otherFaction Other faction. + * @return A relationship type or null if the other faction was not found. + */ + public String getRelationTo(Faction otherFaction) { + com.massivecraft.factions.entity.Faction otherFac = FactionColl.get() + .get(otherFaction.getId()); + + if (otherFac == null) + return null; + + Rel rel = faction.getRelationTo(otherFac); + + if (rel == null) + return null; + + return rel.toString(); + } + + /** + * Gets a list of online players that are member of this faction. + * + * @return a list containing all online-member players. + */ + public List getOnlinePlayers() { + return faction.getOnlinePlayers(); + } + + /** + * Gets the amount of chunks owned by this faction. + * + * @return amount of chunks owned. + */ + public int getLandCount() { + return this.getChunks().size(); + } + + /** + * Sends a message to all online players of this faction. + * @param message Message to send. + */ + public void sendMessage(String message) { + faction.sendMessage(message); + } + + /** + * Gets the maximum amount of power this faction may have. + * @return maximum power amount or null if it doesn't exist. Can also return 999999 if max power is infinite (due to flag). + */ + public Double getPowerMax() { + return faction.getPowerMax(); + } + + /** + * Whether or not this faction is the Wilderness. + * @return true if the Wilderness; false otherwise. + */ + public boolean isWilderness() { + return faction.isNone(); + } + + /** + * Whether or not this faction is the Safezone. + * @return true if the Safezone; false otherwise. + */ + public boolean isSafezone() { + return !faction.getFlag(MFlag.ID_PVP); + } + + /** + * Whether or not this faction is the Warzone. + * @return true if the Warzone; false otherwise. + */ + public boolean isWarzone() { + // Faction allows pvp and is not normal + return faction.getFlag(MFlag.ID_PVP) && !faction.isNormal(); + } + + /** + * Gets the id of this faction. + *
Internally used to reference unique factions. + * @return id of the faction. + */ + public String getId() { + return faction.getId(); + } + + /** + * Gets the 'comparison name' of the faction. + *
When retrieving the name of the faction via {@link #getName()}, it will also include colour codes. + *
This method will remove those colour codes and is internally used by Factions to reference each seperate Faction. + * @return Unique name of Faction without colour codes. + */ + public String getComparisonName() { + return faction.getComparisonName(); + } } \ No newline at end of file diff --git a/src/me/staartvin/plugins/pluginlibrary/hooks/factions/MPlayer.java b/src/me/staartvin/plugins/pluginlibrary/hooks/factions/MPlayer.java index 55e4528..5267f8f 100644 --- a/src/me/staartvin/plugins/pluginlibrary/hooks/factions/MPlayer.java +++ b/src/me/staartvin/plugins/pluginlibrary/hooks/factions/MPlayer.java @@ -1,279 +1,279 @@ -package me.staartvin.plugins.pluginlibrary.hooks.factions; - -import java.util.UUID; - -import com.massivecraft.factions.Rel; -import com.massivecraft.factions.entity.FactionColl; - -/** - * Represents the {@link com.massivecraft.factions.entity.MPlayer} class. - *
This class mirroring is used so developers don't have to import the API of Factions. - *
This can either be a console or a real player. You can check with {@link #isConsole()} and {@link #isPlayer()}. - *

- * Date created: 23:56:36 - * 13 aug. 2015 - * @author Staartvin - * - */ -public class MPlayer { - - private final com.massivecraft.factions.entity.MPlayer mPlayer; - - public MPlayer(com.massivecraft.factions.entity.MPlayer mPlayer) { - if (mPlayer == null) { - throw new NullPointerException("MPlayer is null!"); - } - - this.mPlayer = mPlayer; - } - - /** - * Gets the faction id of the faction that the player is part of. - *
This will never be null. If a player does not belong to a 'human-made' faction, - *
it will return the id of the wilderness, warzone or safezone. - * @return A faction id corresponding to the faction the player is currently in. - */ - public String getFactionId() { - return mPlayer.getFactionId(); - } - - /** - * Gets the faction the player is part of. - *
This will never be null. See {@link #getFactionId()} for more info. - * @return The faction a player is part of. - */ - public Faction getFaction() { - return new Faction(mPlayer.getFaction()); - } - - /** - * Gets the role of the player in his current faction. - *
This will never be null as the player is always in a faction. See {@link #getFactionId()} for more info. - *
Roles can be LEADER, OFFICER, MEMBER and RECRUIT. - * @return The player's role in the current faction. - */ - public String getRole() { - Rel rel = mPlayer.getRole(); - - return rel.toString(); - } - - /** - * Sets the role of a player in his current faction. - *
See {@link #getRole()} for more info about the roles. - * @param role Role type. - */ - public void setRole(String role) { - Rel rel = Rel.valueOf(role); - - if (rel == null) return; - - mPlayer.setRole(rel); - } - - /** - * Gets the title of the player in his current faction. - *
The title is just for fun. It's not connected to any game mechanic. - * @return the title of the player. - */ - public String getTitle() { - return mPlayer.getTitle(); - } - - /** - * Sets the title of the player in his current faction. - *
The title is just for fun. It's not connected to any game mechanic. - * @param title String to change the title to. - */ - public void setTitle(String title) { - mPlayer.setTitle(title); - } - - /** - * Gets the power boost of this player. - * @return Power boost value. - */ - public double getPowerBoost() { - return mPlayer.getPowerBoost(); - } - - /** - * Sets the power boost of this player. - * @param boost Boost to set it to. - */ - public void setPowerBoost(double boost) { - mPlayer.setPower(boost); - } - - /** - * Gets the maximum power this player can have. - * @return Maximum power. - */ - public double getPowerMax() { - return mPlayer.getPowerMax(); - } - - /** - * Gets the minimum power this player can have. - * @return Minimum power. - */ - public double getPowerMin() { - return mPlayer.getPowerMin(); - } - - /** - * Gets the amount of power this player gets per hour. - * @return Amount of power gained per hour. - */ - public double getPowerPerHour() { - return mPlayer.getPowerMax(); - } - - /** - * Gets the amount of power this player loses when he dies. - * @return Amount of power lost on death. - */ - public double getPowerPerDeath() { - return mPlayer.getPowerMin(); - } - - /** - * Gets the power this player currently has. - * @return Current power of player. - */ - public double getPower() { - return mPlayer.getPower(); - } - - /** - * Sets the power this player currently has. - * @param power Amount to change it to. - */ - public void setPower(double power) { - mPlayer.setPower(power); - } - - /** - * Whether this player is using the admin mode of Factions. - * @return True if using admin mode; false otherwise. - */ - public boolean isUsingAdminMode() { - return mPlayer.isUsingAdminMode(); - } - - /** - * Sets whether the player is using admin mode. - * @param value Value to set the use of admin mode to. - */ - public void setUsingAdminMode(boolean value) { - mPlayer.setUsingAdminMode(value); - } - - /** - * Whether or not this player is in its own territory (land of its faction). - * @return true if the player is; false otherwise. - */ - public boolean isInOwnTerritory() { - return mPlayer.isInOwnTerritory(); - } - - /** - * Whether or not this player is in enemy territory (land of another faction). - * @return true if the player is; false otherwise. - */ - public boolean isInEnemyTerritory() { - return mPlayer.isInEnemyTerritory(); - } - - /** - * Gets the UUID of this player. - * @return UUID of the player. - */ - public UUID getUUID() { - return mPlayer.getUuid(); - } - - /** - * Gets the relation from this player towards another player. - *
The relation types it can return are: LEADER, OFFICER, MEMBER, RECRUIT, ALLY, TRUCE, NEUTRAL and ENEMY. - * @param otherPlayer Other player. - * @return A relation type or null if the other player was not found. - */ - public String getRelationTo(MPlayer otherPlayer) { - com.massivecraft.factions.entity.MPlayer player = com.massivecraft.factions.entity.MPlayer.get(otherPlayer.getUUID()); - - if (player == null) return null; - - Rel rel = mPlayer.getRelationTo(player); - - if (rel == null) return null; - - return rel.toString(); - } - - /** - * Gets the relation from this player towards a faction. - *
The relation types it can return are: LEADER, OFFICER, MEMBER, RECRUIT, ALLY, TRUCE, NEUTRAL and ENEMY. - * @param faction A faction. - * @return A relation type or null if the faction was not found. - */ - public String getRelationTo(Faction faction) { - if (faction == null) return null; - - Rel rel = mPlayer.getRelationTo(FactionColl.get().get(faction.getId())); - - if (rel == null) return null; - - return rel.toString(); - } - - /** - * Whether this player is currently auto claiming land for his faction. - * @return true if he is; false otherwise. - */ - public boolean isAutoClaiming() { - return mPlayer.getAutoClaimFaction() != null; - } - - /** - * Whether this player is currently part of a non-default (so no Wilderness, Safezone or Warzone) faction. - * @return true if the player is; false otherwise. - */ - public boolean hasFaction() { - return mPlayer.hasFaction(); - } - - /** - * Wipes all faction data of this player. - *
Will delete the current faction he's in, his title, his role and sets auto claiming to false. - *
Take caution with this method, I've not tested it. - */ - public void resetFactionData() { - mPlayer.resetFactionData(); - } - - /** - * Gets the name of this player. - * @return Name of the player. - */ - public String getName() { - return mPlayer.getName(); - } - - /** - * Whether this player is the console. - * @return true if this player is the console; false otherwise. - */ - public boolean isConsole() { - return mPlayer.isConsole(); - } - - /** - * Whether this player is the a real player. - * @return true if this player is a real player; false otherwise. - */ - public boolean isPlayer() { - return mPlayer.isPlayer(); - } - -} +package me.staartvin.plugins.pluginlibrary.hooks.factions; + +import java.util.UUID; + +import com.massivecraft.factions.Rel; +import com.massivecraft.factions.entity.FactionColl; + +/** + * Represents the {@link com.massivecraft.factions.entity.MPlayer} class. + *
This class mirroring is used so developers don't have to import the API of Factions. + *
This can either be a console or a real player. You can check with {@link #isConsole()} and {@link #isPlayer()}. + *

+ * Date created: 23:56:36 + * 13 aug. 2015 + * @author Staartvin + * + */ +public class MPlayer { + + private final com.massivecraft.factions.entity.MPlayer mPlayer; + + public MPlayer(com.massivecraft.factions.entity.MPlayer mPlayer) { + if (mPlayer == null) { + throw new NullPointerException("MPlayer is null!"); + } + + this.mPlayer = mPlayer; + } + + /** + * Gets the faction id of the faction that the player is part of. + *
This will never be null. If a player does not belong to a 'human-made' faction, + *
it will return the id of the wilderness, warzone or safezone. + * @return A faction id corresponding to the faction the player is currently in. + */ + public String getFactionId() { + return mPlayer.getFactionId(); + } + + /** + * Gets the faction the player is part of. + *
This will never be null. See {@link #getFactionId()} for more info. + * @return The faction a player is part of. + */ + public Faction getFaction() { + return new Faction(mPlayer.getFaction()); + } + + /** + * Gets the role of the player in his current faction. + *
This will never be null as the player is always in a faction. See {@link #getFactionId()} for more info. + *
Roles can be LEADER, OFFICER, MEMBER and RECRUIT. + * @return The player's role in the current faction. + */ + public String getRole() { + Rel rel = mPlayer.getRole(); + + return rel.toString(); + } + + /** + * Sets the role of a player in his current faction. + *
See {@link #getRole()} for more info about the roles. + * @param role Role type. + */ + public void setRole(String role) { + Rel rel = Rel.valueOf(role); + + if (rel == null) return; + + mPlayer.setRole(rel); + } + + /** + * Gets the title of the player in his current faction. + *
The title is just for fun. It's not connected to any game mechanic. + * @return the title of the player. + */ + public String getTitle() { + return mPlayer.getTitle(); + } + + /** + * Sets the title of the player in his current faction. + *
The title is just for fun. It's not connected to any game mechanic. + * @param title String to change the title to. + */ + public void setTitle(String title) { + mPlayer.setTitle(title); + } + + /** + * Gets the power boost of this player. + * @return Power boost value. + */ + public double getPowerBoost() { + return mPlayer.getPowerBoost(); + } + + /** + * Sets the power boost of this player. + * @param boost Boost to set it to. + */ + public void setPowerBoost(double boost) { + mPlayer.setPower(boost); + } + + /** + * Gets the maximum power this player can have. + * @return Maximum power. + */ + public double getPowerMax() { + return mPlayer.getPowerMax(); + } + + /** + * Gets the minimum power this player can have. + * @return Minimum power. + */ + public double getPowerMin() { + return mPlayer.getPowerMin(); + } + + /** + * Gets the amount of power this player gets per hour. + * @return Amount of power gained per hour. + */ + public double getPowerPerHour() { + return mPlayer.getPowerMax(); + } + + /** + * Gets the amount of power this player loses when he dies. + * @return Amount of power lost on death. + */ + public double getPowerPerDeath() { + return mPlayer.getPowerMin(); + } + + /** + * Gets the power this player currently has. + * @return Current power of player. + */ + public double getPower() { + return mPlayer.getPower(); + } + + /** + * Sets the power this player currently has. + * @param power Amount to change it to. + */ + public void setPower(double power) { + mPlayer.setPower(power); + } + + /** + * Whether this player is using the admin mode of Factions. + * @return True if using admin mode; false otherwise. + */ + public boolean isUsingAdminMode() { + return mPlayer.isUsingAdminMode(); + } + + /** + * Sets whether the player is using admin mode. + * @param value Value to set the use of admin mode to. + */ + public void setUsingAdminMode(boolean value) { + mPlayer.setUsingAdminMode(value); + } + + /** + * Whether or not this player is in its own territory (land of its faction). + * @return true if the player is; false otherwise. + */ + public boolean isInOwnTerritory() { + return mPlayer.isInOwnTerritory(); + } + + /** + * Whether or not this player is in enemy territory (land of another faction). + * @return true if the player is; false otherwise. + */ + public boolean isInEnemyTerritory() { + return mPlayer.isInEnemyTerritory(); + } + + /** + * Gets the UUID of this player. + * @return UUID of the player. + */ + public UUID getUUID() { + return mPlayer.getUuid(); + } + + /** + * Gets the relation from this player towards another player. + *
The relation types it can return are: LEADER, OFFICER, MEMBER, RECRUIT, ALLY, TRUCE, NEUTRAL and ENEMY. + * @param otherPlayer Other player. + * @return A relation type or null if the other player was not found. + */ + public String getRelationTo(MPlayer otherPlayer) { + com.massivecraft.factions.entity.MPlayer player = com.massivecraft.factions.entity.MPlayer.get(otherPlayer.getUUID()); + + if (player == null) return null; + + Rel rel = mPlayer.getRelationTo(player); + + if (rel == null) return null; + + return rel.toString(); + } + + /** + * Gets the relation from this player towards a faction. + *
The relation types it can return are: LEADER, OFFICER, MEMBER, RECRUIT, ALLY, TRUCE, NEUTRAL and ENEMY. + * @param faction A faction. + * @return A relation type or null if the faction was not found. + */ + public String getRelationTo(Faction faction) { + if (faction == null) return null; + + Rel rel = mPlayer.getRelationTo(FactionColl.get().get(faction.getId())); + + if (rel == null) return null; + + return rel.toString(); + } + + /** + * Whether this player is currently auto claiming land for his faction. + * @return true if he is; false otherwise. + */ + public boolean isAutoClaiming() { + return mPlayer.getAutoClaimFaction() != null; + } + + /** + * Whether this player is currently part of a non-default (so no Wilderness, Safezone or Warzone) faction. + * @return true if the player is; false otherwise. + */ + public boolean hasFaction() { + return mPlayer.hasFaction(); + } + + /** + * Wipes all faction data of this player. + *
Will delete the current faction he's in, his title, his role and sets auto claiming to false. + *
Take caution with this method, I've not tested it. + */ + public void resetFactionData() { + mPlayer.resetFactionData(); + } + + /** + * Gets the name of this player. + * @return Name of the player. + */ + public String getName() { + return mPlayer.getName(); + } + + /** + * Whether this player is the console. + * @return true if this player is the console; false otherwise. + */ + public boolean isConsole() { + return mPlayer.isConsole(); + } + + /** + * Whether this player is the a real player. + * @return true if this player is a real player; false otherwise. + */ + public boolean isPlayer() { + return mPlayer.isPlayer(); + } + +} diff --git a/src/me/staartvin/plugins/pluginlibrary/listeners/PlayerEatsFoodListener.java b/src/me/staartvin/plugins/pluginlibrary/listeners/PlayerEatsFoodListener.java index 88d3e9e..14f94e1 100644 --- a/src/me/staartvin/plugins/pluginlibrary/listeners/PlayerEatsFoodListener.java +++ b/src/me/staartvin/plugins/pluginlibrary/listeners/PlayerEatsFoodListener.java @@ -1,61 +1,61 @@ -package me.staartvin.plugins.pluginlibrary.listeners; - -import me.staartvin.plugins.pluginlibrary.Library; -import me.staartvin.plugins.pluginlibrary.PluginLibrary; -import me.staartvin.plugins.pluginlibrary.hooks.StatsHook; -import me.staartvin.plugins.pluginlibrary.hooks.customstats.FoodEatenStat; -import me.staartvin.plugins.pluginlibrary.util.Util; -import nl.lolmewn.stats.api.stat.Stat; -import nl.lolmewn.stats.api.user.StatsHolder; -import nl.lolmewn.stats.stat.DefaultStatEntry; -import nl.lolmewn.stats.stat.MetadataPair; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerItemConsumeEvent; - -/** - * This listener will listen to players eating food (for custom stat) - * - * @author Staartvin - * - */ -public class PlayerEatsFoodListener implements Listener { - - private final PluginLibrary plugin; - private final StatsHook hook; - - public PlayerEatsFoodListener(final PluginLibrary instance) { - plugin = instance; - hook = (StatsHook) PluginLibrary.getLibrary(Library.STATS); - } - - @EventHandler - public void OnEat(final PlayerItemConsumeEvent event) { - - if (event.isCancelled()) - return; - - // Stats is not available - if (!plugin.isLibraryLoaded(Library.STATS)) - return; - - Player p = event.getPlayer(); - - String foodName = Util.getFoodName(event.getItem()); - - if (foodName == null) - return; - - Stat stat = hook.getStat(FoodEatenStat.statName); - - StatsHolder holder = hook.getStatsHolder(p.getUniqueId()); - - holder.addEntry(stat, new DefaultStatEntry(1, new MetadataPair( - "foodType", foodName), new MetadataPair("world", p.getWorld() - .getName()))); - - } - -} +package me.staartvin.plugins.pluginlibrary.listeners; + +import me.staartvin.plugins.pluginlibrary.Library; +import me.staartvin.plugins.pluginlibrary.PluginLibrary; +import me.staartvin.plugins.pluginlibrary.hooks.StatsHook; +import me.staartvin.plugins.pluginlibrary.hooks.customstats.FoodEatenStat; +import me.staartvin.plugins.pluginlibrary.util.Util; +import nl.lolmewn.stats.api.stat.Stat; +import nl.lolmewn.stats.api.user.StatsHolder; +import nl.lolmewn.stats.stat.DefaultStatEntry; +import nl.lolmewn.stats.stat.MetadataPair; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerItemConsumeEvent; + +/** + * This listener will listen to players eating food (for custom stat) + * + * @author Staartvin + * + */ +public class PlayerEatsFoodListener implements Listener { + + private final PluginLibrary plugin; + private final StatsHook hook; + + public PlayerEatsFoodListener(final PluginLibrary instance) { + plugin = instance; + hook = (StatsHook) PluginLibrary.getLibrary(Library.STATS); + } + + @EventHandler + public void OnEat(final PlayerItemConsumeEvent event) { + + if (event.isCancelled()) + return; + + // Stats is not available + if (!plugin.isLibraryLoaded(Library.STATS)) + return; + + Player p = event.getPlayer(); + + String foodName = Util.getFoodName(event.getItem()); + + if (foodName == null) + return; + + Stat stat = hook.getStat(FoodEatenStat.statName); + + StatsHolder holder = hook.getStatsHolder(p.getUniqueId()); + + holder.addEntry(stat, new DefaultStatEntry(1, new MetadataPair( + "foodType", foodName), new MetadataPair("world", p.getWorld() + .getName()))); + + } + +} diff --git a/src/me/staartvin/plugins/pluginlibrary/listeners/PlayerKillsMobListener.java b/src/me/staartvin/plugins/pluginlibrary/listeners/PlayerKillsMobListener.java index 112161e..2727b4f 100644 --- a/src/me/staartvin/plugins/pluginlibrary/listeners/PlayerKillsMobListener.java +++ b/src/me/staartvin/plugins/pluginlibrary/listeners/PlayerKillsMobListener.java @@ -1,113 +1,113 @@ -package me.staartvin.plugins.pluginlibrary.listeners; - -import me.staartvin.plugins.pluginlibrary.Library; -import me.staartvin.plugins.pluginlibrary.PluginLibrary; -import me.staartvin.plugins.pluginlibrary.hooks.StatsHook; -import me.staartvin.plugins.pluginlibrary.hooks.customstats.MobKilledStat; -import nl.lolmewn.stats.api.stat.Stat; -import nl.lolmewn.stats.api.user.StatsHolder; -import nl.lolmewn.stats.stat.DefaultStatEntry; -import nl.lolmewn.stats.stat.MetadataPair; - -import org.bukkit.entity.Chicken; -import org.bukkit.entity.Creeper; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Guardian; -import org.bukkit.entity.Player; -import org.bukkit.entity.Rabbit; -import org.bukkit.entity.Rabbit.Type; -import org.bukkit.entity.Skeleton; -import org.bukkit.entity.Skeleton.SkeletonType; -import org.bukkit.entity.Spider; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDeathEvent; - -/** - * This listener will listen to players killing mobs (for custom stat) - * - * @author Staartvin - * - */ -public class PlayerKillsMobListener implements Listener { - - private final PluginLibrary plugin; - private final StatsHook hook; - - public PlayerKillsMobListener(final PluginLibrary instance) { - plugin = instance; - hook = (StatsHook) PluginLibrary.getLibrary(Library.STATS); - } - - @EventHandler - public void OnKill(final EntityDeathEvent event) { - - // Stats is not available - if (!plugin.isLibraryLoaded(Library.STATS)) - return; - - final Entity e = event.getEntity(); - if (e.getLastDamageCause() instanceof EntityDamageByEntityEvent) { - final EntityDamageByEntityEvent nEvent = (EntityDamageByEntityEvent) e - .getLastDamageCause(); - if (nEvent.getDamager() instanceof Player) { - - String extraType = null; - - if (e instanceof Skeleton) { - Skeleton ske = (Skeleton) e; - - if (ske.getSkeletonType() == SkeletonType.WITHER) { - extraType = "WITHER"; - } - } else if (e instanceof Creeper) { - Creeper cre = (Creeper) e; - - if (cre.isPowered()) { - extraType = "POWERED"; - } - } else if (e instanceof Chicken) { - Chicken mob = (Chicken) e; - - if (mob.getPassenger() != null) { - extraType = "JOCKEY"; - } - } else if (e instanceof Rabbit) { - Rabbit mob = (Rabbit) e; - - if (mob.getRabbitType() == Type.THE_KILLER_BUNNY) { - extraType = "KILLER"; - } - } else if (e instanceof Spider) { - Spider mob = (Spider) e; - - if (mob.getPassenger() != null) { - extraType = "JOCKEY"; - } - } else if (e instanceof Guardian) { - Guardian mob = (Guardian) e; - - if (mob.isElder()) { - extraType = "ELDER"; - } - } - - if (extraType == null) { - return; - } - - Stat mobkilled = hook.getStat(MobKilledStat.statName); - - StatsHolder holder = hook.getStatsHolder(nEvent.getDamager() - .getUniqueId()); - - holder.addEntry(mobkilled, new DefaultStatEntry(1, - new MetadataPair("entityType", e.getType().toString()), - new MetadataPair("extraType", extraType), - new MetadataPair("world", e.getLocation().getWorld() - .getName().toString()))); - } - } - } -} +package me.staartvin.plugins.pluginlibrary.listeners; + +import me.staartvin.plugins.pluginlibrary.Library; +import me.staartvin.plugins.pluginlibrary.PluginLibrary; +import me.staartvin.plugins.pluginlibrary.hooks.StatsHook; +import me.staartvin.plugins.pluginlibrary.hooks.customstats.MobKilledStat; +import nl.lolmewn.stats.api.stat.Stat; +import nl.lolmewn.stats.api.user.StatsHolder; +import nl.lolmewn.stats.stat.DefaultStatEntry; +import nl.lolmewn.stats.stat.MetadataPair; + +import org.bukkit.entity.Chicken; +import org.bukkit.entity.Creeper; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Guardian; +import org.bukkit.entity.Player; +import org.bukkit.entity.Rabbit; +import org.bukkit.entity.Rabbit.Type; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Skeleton.SkeletonType; +import org.bukkit.entity.Spider; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDeathEvent; + +/** + * This listener will listen to players killing mobs (for custom stat) + * + * @author Staartvin + * + */ +public class PlayerKillsMobListener implements Listener { + + private final PluginLibrary plugin; + private final StatsHook hook; + + public PlayerKillsMobListener(final PluginLibrary instance) { + plugin = instance; + hook = (StatsHook) PluginLibrary.getLibrary(Library.STATS); + } + + @EventHandler + public void OnKill(final EntityDeathEvent event) { + + // Stats is not available + if (!plugin.isLibraryLoaded(Library.STATS)) + return; + + final Entity e = event.getEntity(); + if (e.getLastDamageCause() instanceof EntityDamageByEntityEvent) { + final EntityDamageByEntityEvent nEvent = (EntityDamageByEntityEvent) e + .getLastDamageCause(); + if (nEvent.getDamager() instanceof Player) { + + String extraType = null; + + if (e instanceof Skeleton) { + Skeleton ske = (Skeleton) e; + + if (ske.getSkeletonType() == SkeletonType.WITHER) { + extraType = "WITHER"; + } + } else if (e instanceof Creeper) { + Creeper cre = (Creeper) e; + + if (cre.isPowered()) { + extraType = "POWERED"; + } + } else if (e instanceof Chicken) { + Chicken mob = (Chicken) e; + + if (mob.getPassenger() != null) { + extraType = "JOCKEY"; + } + } else if (e instanceof Rabbit) { + Rabbit mob = (Rabbit) e; + + if (mob.getRabbitType() == Type.THE_KILLER_BUNNY) { + extraType = "KILLER"; + } + } else if (e instanceof Spider) { + Spider mob = (Spider) e; + + if (mob.getPassenger() != null) { + extraType = "JOCKEY"; + } + } else if (e instanceof Guardian) { + Guardian mob = (Guardian) e; + + if (mob.isElder()) { + extraType = "ELDER"; + } + } + + if (extraType == null) { + return; + } + + Stat mobkilled = hook.getStat(MobKilledStat.statName); + + StatsHolder holder = hook.getStatsHolder(nEvent.getDamager() + .getUniqueId()); + + holder.addEntry(mobkilled, new DefaultStatEntry(1, + new MetadataPair("entityType", e.getType().toString()), + new MetadataPair("extraType", extraType), + new MetadataPair("world", e.getLocation().getWorld() + .getName().toString()))); + } + } + } +} diff --git a/src/me/staartvin/plugins/pluginlibrary/util/Util.java b/src/me/staartvin/plugins/pluginlibrary/util/Util.java index 1892ee7..19ad2ed 100644 --- a/src/me/staartvin/plugins/pluginlibrary/util/Util.java +++ b/src/me/staartvin/plugins/pluginlibrary/util/Util.java @@ -1,182 +1,182 @@ -package me.staartvin.plugins.pluginlibrary.util; - -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -/** - * Util class - *

- * Date created: 17:38:32 - * 12 aug. 2015 - * @author Staartvin - * - */ -public class Util { - - /** - * Get the name of this food item. - * - * @param item ItemStack to get the name of. - * @return Name of food, or null if not a valid food item. - */ - public static String getFoodName(ItemStack item) { - // Returns null if not a valid food item - // Got Materials from https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html - - if (item == null) - return null; - - switch (item.getType()) { - case APPLE: - return "APPLE"; - case BAKED_POTATO: - return "BAKED_POTATO"; - case BREAD: - return "BREAD"; - case CAKE_BLOCK: // not working atm - return "CAKE_BLOCK"; - case CARROT_ITEM: - return "CARROT_ITEM"; - case COOKED_CHICKEN: - return "COOKED_CHICKEN"; - case COOKED_FISH: { - if (item.getDurability() == (short) 1) { - return "COOKED_SALMON"; - } - return "COOKED_FISH"; - } - case COOKED_MUTTON: - return "COOKED_MUTTON"; - case GRILLED_PORK: - return "GRILLED_PORK"; - case COOKED_RABBIT: - return "COOKED_RABBIT"; - case COOKIE: - return "COOKIE"; - case GOLDEN_APPLE: { - if (item.getDurability() == (short) 1) { - return "ENCHANTED_GOLDEN_APPLE"; - } - return "GOLDEN_APPLE"; - } - case GOLDEN_CARROT: - return "GOLDEN_CARROT"; - case MELON: - return "MELON"; - case MUSHROOM_SOUP: - return "MUSHROOM_SOUP"; - case RABBIT_STEW: - return "RABBIT_STEW"; - case RAW_BEEF: - return "RAW_BEEF"; - case RAW_CHICKEN: - return "RAW_CHICKEN"; - case RAW_FISH: { - if (item.getDurability() == (short) 1) { - return "RAW_SALMON"; - } else if (item.getDurability() == (short) 2) { - return "CLOWNFISH"; - } else if (item.getDurability() == (short) 3) { - return "PUFFERFISH"; - } - return "RAW_FISH"; - } - case POISONOUS_POTATO: - return "POISONOUS_POTATO"; - case POTATO: - return "POTATO"; - case PUMPKIN_PIE: - return "PUMPKIN_PIE"; - case MUTTON: - return "MUTTON"; // raw - case COOKED_BEEF: - return "COOKED_BEEF"; - case RABBIT: - return "RABBIT"; - case ROTTEN_FLESH: - return "ROTTEN_FLESH"; - case SPIDER_EYE: - return "SPIDER_EYE"; - default: - return null; - } - } - - @SuppressWarnings("deprecation") - public static ItemStack getFoodItemFromName(String name) { - // Cannot use switch, is only supported in Java 1.7+ - - if (name == null) - return null; - - name = name.toUpperCase(); - name = name.replace(" ", "_"); - - if (name.equals("APPLE")) { - return new ItemStack(Material.APPLE, 1); - } else if (name.equals("BAKED_POTATO")) { - return new ItemStack(Material.BAKED_POTATO, 1); - } else if (name.equals("BREAD")) { - return new ItemStack(Material.BREAD, 1); - } else if (name.equals("CAKE_BLOCK")) { - return new ItemStack(Material.CAKE_BLOCK, 1); - } else if (name.equals("CARROT_ITEM")) { - return new ItemStack(Material.CARROT_ITEM, 1); - } else if (name.equals("COOKED_CHICKEN")) { - return new ItemStack(Material.COOKED_CHICKEN, 1); - } else if (name.equals("COOKED_FISH")) { - return new ItemStack(Material.COOKED_FISH, 1); - } else if (name.equals("COOKED_SALMON")) { - return new ItemStack(Material.COOKED_FISH.getId(), 1, (short) 1); - } else if (name.equals("COOKED_MUTTON")) { - return new ItemStack(Material.COOKED_MUTTON, 1); - } else if (name.equals("GRILLED_PORK")) { - return new ItemStack(Material.GRILLED_PORK, 1); - } else if (name.equals("COOKED_RABBIT")) { - return new ItemStack(Material.COOKED_RABBIT, 1); - } else if (name.equals("COOKIE")) { - return new ItemStack(Material.COOKIE, 1); - } else if (name.equals("GOLDEN_APPLE")) { - return new ItemStack(Material.GOLDEN_APPLE, 1); - } else if (name.equals("ENCHANTED_GOLDEN_APPLE")) { - return new ItemStack(Material.GOLDEN_APPLE.getId(), 1, (short) 1); - } else if (name.equals("GOLDEN_CARROT")) { - return new ItemStack(Material.GOLDEN_CARROT, 1); - } else if (name.equals("MELON")) { - return new ItemStack(Material.MELON, 1); - } else if (name.equals("MUSHROOM_SOUP")) { - return new ItemStack(Material.MUSHROOM_SOUP, 1); - } else if (name.equals("RABBIT_STEW")) { - return new ItemStack(Material.RABBIT_STEW, 1); - } else if (name.equals("RAW_BEEF")) { - return new ItemStack(Material.RAW_BEEF, 1); - } else if (name.equals("RAW_CHICKEN")) { - return new ItemStack(Material.RAW_CHICKEN, 1); - } else if (name.equals("RAW_FISH")) { - return new ItemStack(Material.RAW_FISH, 1); - } else if (name.equals("RAW_SALMON")) { - return new ItemStack(Material.RAW_FISH.getId(), 1, (short) 1); - } else if (name.equals("CLOWNFISH")) { - return new ItemStack(Material.RAW_FISH.getId(), 1, (short) 2); - } else if (name.equals("PUFFERFISH")) { - return new ItemStack(Material.RAW_FISH.getId(), 1, (short) 3); - } else if (name.equals("POISONOUS_POTATO")) { - return new ItemStack(Material.POISONOUS_POTATO, 1); - } else if (name.equals("POTATO")) { - return new ItemStack(Material.POTATO, 1); - } else if (name.equals("PUMPKIN_PIE")) { - return new ItemStack(Material.PUMPKIN_PIE, 1); - } else if (name.equals("MUTTON")) { - return new ItemStack(Material.MUTTON, 1); - } else if (name.equals("COOKED_BEEF")) { - return new ItemStack(Material.COOKED_BEEF, 1); - } else if (name.equals("RABBIT")) { - return new ItemStack(Material.RABBIT, 1); - } else if (name.equals("ROTTEN_FLESH")) { - return new ItemStack(Material.ROTTEN_FLESH, 1); - } else if (name.equals("SPIDER_EYE")) { - return new ItemStack(Material.SPIDER_EYE, 1); - } else - return null; - } -} +package me.staartvin.plugins.pluginlibrary.util; + +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +/** + * Util class + *

+ * Date created: 17:38:32 + * 12 aug. 2015 + * @author Staartvin + * + */ +public class Util { + + /** + * Get the name of this food item. + * + * @param item ItemStack to get the name of. + * @return Name of food, or null if not a valid food item. + */ + public static String getFoodName(ItemStack item) { + // Returns null if not a valid food item + // Got Materials from https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html + + if (item == null) + return null; + + switch (item.getType()) { + case APPLE: + return "APPLE"; + case BAKED_POTATO: + return "BAKED_POTATO"; + case BREAD: + return "BREAD"; + case CAKE_BLOCK: // not working atm + return "CAKE_BLOCK"; + case CARROT_ITEM: + return "CARROT_ITEM"; + case COOKED_CHICKEN: + return "COOKED_CHICKEN"; + case COOKED_FISH: { + if (item.getDurability() == (short) 1) { + return "COOKED_SALMON"; + } + return "COOKED_FISH"; + } + case COOKED_MUTTON: + return "COOKED_MUTTON"; + case GRILLED_PORK: + return "GRILLED_PORK"; + case COOKED_RABBIT: + return "COOKED_RABBIT"; + case COOKIE: + return "COOKIE"; + case GOLDEN_APPLE: { + if (item.getDurability() == (short) 1) { + return "ENCHANTED_GOLDEN_APPLE"; + } + return "GOLDEN_APPLE"; + } + case GOLDEN_CARROT: + return "GOLDEN_CARROT"; + case MELON: + return "MELON"; + case MUSHROOM_SOUP: + return "MUSHROOM_SOUP"; + case RABBIT_STEW: + return "RABBIT_STEW"; + case RAW_BEEF: + return "RAW_BEEF"; + case RAW_CHICKEN: + return "RAW_CHICKEN"; + case RAW_FISH: { + if (item.getDurability() == (short) 1) { + return "RAW_SALMON"; + } else if (item.getDurability() == (short) 2) { + return "CLOWNFISH"; + } else if (item.getDurability() == (short) 3) { + return "PUFFERFISH"; + } + return "RAW_FISH"; + } + case POISONOUS_POTATO: + return "POISONOUS_POTATO"; + case POTATO: + return "POTATO"; + case PUMPKIN_PIE: + return "PUMPKIN_PIE"; + case MUTTON: + return "MUTTON"; // raw + case COOKED_BEEF: + return "COOKED_BEEF"; + case RABBIT: + return "RABBIT"; + case ROTTEN_FLESH: + return "ROTTEN_FLESH"; + case SPIDER_EYE: + return "SPIDER_EYE"; + default: + return null; + } + } + + @SuppressWarnings("deprecation") + public static ItemStack getFoodItemFromName(String name) { + // Cannot use switch, is only supported in Java 1.7+ + + if (name == null) + return null; + + name = name.toUpperCase(); + name = name.replace(" ", "_"); + + if (name.equals("APPLE")) { + return new ItemStack(Material.APPLE, 1); + } else if (name.equals("BAKED_POTATO")) { + return new ItemStack(Material.BAKED_POTATO, 1); + } else if (name.equals("BREAD")) { + return new ItemStack(Material.BREAD, 1); + } else if (name.equals("CAKE_BLOCK")) { + return new ItemStack(Material.CAKE_BLOCK, 1); + } else if (name.equals("CARROT_ITEM")) { + return new ItemStack(Material.CARROT_ITEM, 1); + } else if (name.equals("COOKED_CHICKEN")) { + return new ItemStack(Material.COOKED_CHICKEN, 1); + } else if (name.equals("COOKED_FISH")) { + return new ItemStack(Material.COOKED_FISH, 1); + } else if (name.equals("COOKED_SALMON")) { + return new ItemStack(Material.COOKED_FISH.getId(), 1, (short) 1); + } else if (name.equals("COOKED_MUTTON")) { + return new ItemStack(Material.COOKED_MUTTON, 1); + } else if (name.equals("GRILLED_PORK")) { + return new ItemStack(Material.GRILLED_PORK, 1); + } else if (name.equals("COOKED_RABBIT")) { + return new ItemStack(Material.COOKED_RABBIT, 1); + } else if (name.equals("COOKIE")) { + return new ItemStack(Material.COOKIE, 1); + } else if (name.equals("GOLDEN_APPLE")) { + return new ItemStack(Material.GOLDEN_APPLE, 1); + } else if (name.equals("ENCHANTED_GOLDEN_APPLE")) { + return new ItemStack(Material.GOLDEN_APPLE.getId(), 1, (short) 1); + } else if (name.equals("GOLDEN_CARROT")) { + return new ItemStack(Material.GOLDEN_CARROT, 1); + } else if (name.equals("MELON")) { + return new ItemStack(Material.MELON, 1); + } else if (name.equals("MUSHROOM_SOUP")) { + return new ItemStack(Material.MUSHROOM_SOUP, 1); + } else if (name.equals("RABBIT_STEW")) { + return new ItemStack(Material.RABBIT_STEW, 1); + } else if (name.equals("RAW_BEEF")) { + return new ItemStack(Material.RAW_BEEF, 1); + } else if (name.equals("RAW_CHICKEN")) { + return new ItemStack(Material.RAW_CHICKEN, 1); + } else if (name.equals("RAW_FISH")) { + return new ItemStack(Material.RAW_FISH, 1); + } else if (name.equals("RAW_SALMON")) { + return new ItemStack(Material.RAW_FISH.getId(), 1, (short) 1); + } else if (name.equals("CLOWNFISH")) { + return new ItemStack(Material.RAW_FISH.getId(), 1, (short) 2); + } else if (name.equals("PUFFERFISH")) { + return new ItemStack(Material.RAW_FISH.getId(), 1, (short) 3); + } else if (name.equals("POISONOUS_POTATO")) { + return new ItemStack(Material.POISONOUS_POTATO, 1); + } else if (name.equals("POTATO")) { + return new ItemStack(Material.POTATO, 1); + } else if (name.equals("PUMPKIN_PIE")) { + return new ItemStack(Material.PUMPKIN_PIE, 1); + } else if (name.equals("MUTTON")) { + return new ItemStack(Material.MUTTON, 1); + } else if (name.equals("COOKED_BEEF")) { + return new ItemStack(Material.COOKED_BEEF, 1); + } else if (name.equals("RABBIT")) { + return new ItemStack(Material.RABBIT, 1); + } else if (name.equals("ROTTEN_FLESH")) { + return new ItemStack(Material.ROTTEN_FLESH, 1); + } else if (name.equals("SPIDER_EYE")) { + return new ItemStack(Material.SPIDER_EYE, 1); + } else + return null; + } +} diff --git a/src/plugin.yml b/src/plugin.yml index b0f754b..4f90abe 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ -name: PluginLibrary -author: Staartvin -main: me.staartvin.plugins.pluginlibrary.PluginLibrary -version: 1.0 -description: A library plugin that allows developers to easily get a lot of data from other plugins. +name: PluginLibrary +author: Staartvin +main: me.staartvin.plugins.pluginlibrary.PluginLibrary +version: 1.0 +description: A library plugin that allows developers to easily get a lot of data from other plugins. softdepend: [Autorank, Stats, mcMMO, Factions, afkTerminator, OnTime, RoyalCommands, UltimateCore] \ No newline at end of file