Skip to content

Commit

Permalink
Do format changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Staartvin committed Jan 28, 2016
1 parent 2e093e1 commit b3f3178
Show file tree
Hide file tree
Showing 20 changed files with 1,406 additions and 1,049 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src">
<classpathentry including="**/*.java" kind="src" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.yml → plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ 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.
description: Allows developers to get a lot of data from other plugins without importing the APIs themselves.
softdepend: [Autorank, Stats, mcMMO, Factions, afkTerminator, OnTime, RoyalCommands, UltimateCore]
20 changes: 10 additions & 10 deletions src/me/staartvin/plugins/pluginlibrary/Library.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@
*/
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());
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;
Expand All @@ -46,8 +43,11 @@ public LibraryHook getHook() {
}

/**
* Get a library programmaticaly. This method is the same as valueOf(), but is case-insensitive.
* @param value name of the library
* 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) {
Expand Down
47 changes: 21 additions & 26 deletions src/me/staartvin/plugins/pluginlibrary/PluginLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,22 @@ public void onEnable() {

loadedLibraries.clear();

//this is a test
// this is a test
logMessage(ChatColor.GOLD + "***== Loading libraries ==***");
logMessage(ChatColor.GOLD + "***== Loaded " + ChatColor.WHITE
+ loadLibraries() + ChatColor.GOLD + " libraries! ==***");
logMessage(ChatColor.GOLD + "***== Loaded " + ChatColor.WHITE + loadLibraries() + ChatColor.GOLD
+ " libraries! ==***");

if (this.isLibraryLoaded(Library.STATS)) {
// Register custom stats so that Stats has special mobs and food eaten requirement.
// Register custom stats so that Stats has special mobs and food
// eaten requirement.
setCustomStatsManager(new CustomStatsManager(this));
this.getCustomStatsManager().registerCustomStats();
}

logMessage(ChatColor.GOLD + "Loaded libraries: "
+ getLoadedLibrariesAsString());
logMessage(ChatColor.GOLD + "Loaded libraries: " + getLoadedLibrariesAsString());

logMessage(ChatColor.GREEN + "*** Ready for plugins to send/retrieve data. ***");

logMessage(ChatColor.GREEN
+ "*** Ready for plugins to send/retrieve data. ***");

logMessage(this.getDescription().getFullName() + " is now enabled!");
}

Expand Down Expand Up @@ -81,8 +80,7 @@ public int loadLibraries() {

public void logMessage(String message) {
// This makes sure it can support colours.
this.getServer().getConsoleSender()
.sendMessage(ChatColor.GRAY + "[PluginLibrary] " + message);
this.getServer().getConsoleSender().sendMessage(ChatColor.GRAY + "[PluginLibrary] " + message);
}

/**
Expand All @@ -101,7 +99,8 @@ public List<Library> getLoadedLibraries() {
* Will throw a {@link IllegalArgumentException} when there is no library
* with the given name.
*
* @param pluginName Name of the plugin. Case-insensitive!
* @param pluginName
* Name of the plugin. Case-insensitive!
* @return {@link me.staartvin.plugins.pluginlibrary.LibraryHook} class or
* an error.
*/
Expand All @@ -110,10 +109,10 @@ public static LibraryHook getLibrary(String pluginName) {
}

/**
* @see #getLibrary(String)
* <br>
* @see #getLibrary(String) <br>
* Returns the same as {@link #getLibrary(String)}.
* @param lib Library enum to get the library hook for.
* @param lib
* Library enum to get the library hook for.
* @return {@link me.staartvin.plugins.pluginlibrary.LibraryHook} class or
* an error.
*/
Expand All @@ -124,7 +123,8 @@ public static LibraryHook getLibrary(Library lib) {
/**
* Checks to see whether the library is loaded and thus ready for use.
*
* @param lib Library to check.
* @param lib
* Library to check.
* @return true if the library is loaded; false otherwise.
*/
public boolean isLibraryLoaded(Library lib) {
Expand All @@ -144,18 +144,13 @@ private String getLoadedLibrariesAsString() {

for (int i = 0, l = loadedLibraries.size(); i < l; i++) {
if (i == 0) {
builder.append(ChatColor.DARK_AQUA
+ loadedLibraries.get(i).getPluginName() + ChatColor.RESET);
builder.append(ChatColor.DARK_AQUA + loadedLibraries.get(i).getPluginName() + ChatColor.RESET);
} else if (i == (l - 1)) {
builder.append(ChatColor.GRAY
+ " and "
+ (ChatColor.DARK_AQUA
+ loadedLibraries.get(i).getPluginName() + ChatColor.RESET));
builder.append(ChatColor.GRAY + " and "
+ (ChatColor.DARK_AQUA + loadedLibraries.get(i).getPluginName() + ChatColor.RESET));
} else {
builder.append(ChatColor.GRAY
+ ", "
+ (ChatColor.DARK_AQUA
+ loadedLibraries.get(i).getPluginName() + ChatColor.RESET));
builder.append(ChatColor.GRAY + ", "
+ (ChatColor.DARK_AQUA + loadedLibraries.get(i).getPluginName() + ChatColor.RESET));
}
}

Expand Down
91 changes: 56 additions & 35 deletions src/me/staartvin/plugins/pluginlibrary/hooks/AFKTerminatorHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import me.staartvin.plugins.pluginlibrary.Library;

/**
* afkTerminator library, <a
* href="http://dev.bukkit.org/bukkit-plugins/afkterminator/">link</a>.
* afkTerminator library,
* <a href="http://dev.bukkit.org/bukkit-plugins/afkterminator/">link</a>.
* <p>
* Date created: 16:26:41 14 aug. 2015
*
Expand All @@ -17,72 +17,93 @@
*/
public class AFKTerminatorHook extends LibraryHook {

/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#isAvailable()
*/
@Override
public boolean isAvailable() {
return this.getPlugin().getServer().getPluginManager()
.isPluginEnabled(Library.AFKTERMINATOR.getPluginName());
return this.getPlugin().getServer().getPluginManager().isPluginEnabled(Library.AFKTERMINATOR.getPluginName());
}

/* (non-Javadoc)
/*
* (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.
// 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.
* <br>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.

/**
* See if a player is suspected of using an AFK Machine. <br>
* 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.
* <br>This will return 'true' if the player's activity is confirmed to be an AFK Machine by the plugin.
* <br>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.
* See if use of an AFK machine has been confirmed for a user. <br>
* This will return 'true' if the player's activity is confirmed to be an
* AFK Machine by the plugin. <br>
* 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.
* <br>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.
/**
* If a machine is suspected or later detected, find out the timestamp of
* when the player is thought to have started using the machine. <br>
* 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.
* <br>Types possible:
* <br>VEHICLE, TETHERED_PIG, HORSE, WATER, JUMP, PISTON, FISHING, PROJECTILE or INTERACTION.
* @param uuid UUID of the player to check.
* When a player is using an AFK machine, you can get the type of the AFK
* machine. <br>
* Types possible: <br>
* 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;


if (type == null)
return null;

return type.toString();
}



}
Loading

0 comments on commit b3f3178

Please sign in to comment.