diff --git a/src/main/java/com/graywolf336/jail/JailMain.java b/src/main/java/com/graywolf336/jail/JailMain.java index f370fd5..d6089c6 100644 --- a/src/main/java/com/graywolf336/jail/JailMain.java +++ b/src/main/java/com/graywolf336/jail/JailMain.java @@ -13,6 +13,7 @@ import com.graywolf336.jail.command.CommandHandler; import com.graywolf336.jail.command.JailHandler; import com.graywolf336.jail.enums.Lang; import com.graywolf336.jail.enums.Settings; +import com.graywolf336.jail.interfaces.IJailStickManager; import com.graywolf336.jail.legacy.LegacyManager; import com.graywolf336.jail.listeners.CacheListener; import com.graywolf336.jail.listeners.CellSignListener; @@ -38,7 +39,7 @@ public class JailMain extends JavaPlugin { private JailIO io; private JailManager jm; private JailPayManager jpm; - private JailStickManager jsm; + private IJailStickManager jsm; private JailTimer jt; private JailVoteManager jvm; private PrisonerManager pm; @@ -306,7 +307,7 @@ public class JailMain extends JavaPlugin { } /** Gets the {@link JailStickManager} instance. */ - public JailStickManager getJailStickManager() { + public IJailStickManager getJailStickManager() { return this.jsm; } diff --git a/src/main/java/com/graywolf336/jail/JailStickManager.java b/src/main/java/com/graywolf336/jail/JailStickManager.java index f373d41..adf5619 100644 --- a/src/main/java/com/graywolf336/jail/JailStickManager.java +++ b/src/main/java/com/graywolf336/jail/JailStickManager.java @@ -8,6 +8,7 @@ import org.bukkit.Material; import com.graywolf336.jail.beans.Stick; import com.graywolf336.jail.enums.Settings; +import com.graywolf336.jail.interfaces.IJailStickManager; /** * Manages the jail stick users. @@ -17,7 +18,7 @@ import com.graywolf336.jail.enums.Settings; * @since 3.0.0 * */ -public class JailStickManager { +public class JailStickManager implements IJailStickManager { private ArrayList stickers; private HashMap sticks; @@ -79,56 +80,27 @@ public class JailStickManager { int c = sticks.size(); pl.getLogger().info("Loaded " + c + " jail stick" + (c == 1 ? "" : "s") + "."); } - - /** - * Gets the {@link Stick jail stick} by the provided {@link Material}, can be null. - * - * @param mat of the stick to get - * @return The {@link Stick jail stick} - */ + public Stick getStick(Material mat) { return this.sticks.get(mat); } - /** Checks if the provided Material is a valid {@link Stick jail stick}. */ public boolean isValidStick(Material mat) { return this.sticks.containsKey(mat); } - /** - * Adds a player to be using a jail stick, with the uuid of the player. - * - * @param id of the player to add - */ public void addUsingStick(UUID id) { this.stickers.add(id); } - /** - * Removes a player from using a jail stick, with the uuid of the player. - * - * @param id of the player to remove using a jail stick - */ public void removeUsingStick(UUID id) { this.stickers.remove(id); } - /** - * Returns whether or not the player is using a jail stick. - * - * @param id of the player to check if using one - * @return true if the player is using a jail stick, false if not - */ public boolean isUsingJailStick(UUID id) { return this.stickers.contains(id); } - /** - * Toggles whether the player is using a jail stick, returning the true if enabled false if disabled. - * - * @param id of the player to toggle using a stick - * @return true if we enabled it, false if we disabled it. - */ public boolean toggleUsingStick(UUID id) { if(this.stickers.contains(id)) { this.stickers.remove(id); @@ -139,7 +111,6 @@ public class JailStickManager { } } - /** Removes all the users currently using the sticks. */ public void removeAllStickUsers() { for(UUID id : stickers) { this.removeUsingStick(id); diff --git a/src/main/java/com/graywolf336/jail/JailsAPI.java b/src/main/java/com/graywolf336/jail/JailsAPI.java index 524adf2..caa1525 100644 --- a/src/main/java/com/graywolf336/jail/JailsAPI.java +++ b/src/main/java/com/graywolf336/jail/JailsAPI.java @@ -1,5 +1,7 @@ package com.graywolf336.jail; +import com.graywolf336.jail.interfaces.IJailStickManager; + /** * The static api interface for Jail plugin. * @@ -40,12 +42,12 @@ public class JailsAPI { } /** - * The instance of the {@link JailStickManager} which handles all the jail sticks. + * Gets an instance of the {@link IJailStickManager} which handles all the jail sticks. * - * @return instance of the {@link JailStickManager} - * @see JailStickManager + * @return an instance of the {@link IJailStickManager} + * @see IJailStickManager */ - public static JailStickManager getJailStickManager() { + public static IJailStickManager getJailStickManager() { return pl.getJailStickManager(); } diff --git a/src/main/java/com/graywolf336/jail/interfaces/IJailStickManager.java b/src/main/java/com/graywolf336/jail/interfaces/IJailStickManager.java new file mode 100644 index 0000000..f923de2 --- /dev/null +++ b/src/main/java/com/graywolf336/jail/interfaces/IJailStickManager.java @@ -0,0 +1,67 @@ +package com.graywolf336.jail.interfaces; + +import java.util.UUID; + +import org.bukkit.Material; + +import com.graywolf336.jail.beans.Stick; + +/** + * Interface for the jail stick manager. + * + * @author graywolf336 + * @version 1.0.0 + * @since 3.0.0 + * + */ +public interface IJailStickManager { + + /** + * Gets the {@link Stick jail stick} by the provided {@link Material}, can be null. + * + * @param mat of the stick to get + * @return The {@link Stick jail stick} + */ + public Stick getStick(Material mat); + + /** + * Checks if the provided Material is a valid {@link Stick jail stick} + * + * @param mat the {@link Material} to check + * @return whether the provided material is a valid stick + */ + public boolean isValidStick(Material mat); + + /** + * Adds a player to be using a jail stick, with the uuid of the player. + * + * @param id of the player to add + */ + public void addUsingStick(UUID id); + + /** + * Removes a player from using a jail stick, with the uuid of the player. + * + * @param id of the player to remove using a jail stick + */ + public void removeUsingStick(UUID id); + + /** + * Returns whether or not the player is using a jail stick. + * + * @param id of the player to check if using one + * @return true if the player is using a jail stick, false if not + */ + public boolean isUsingJailStick(UUID id); + + /** + * Toggles whether the player is using a jail stick, returning the true if enabled false if disabled. + * + * @param id of the player to toggle using a stick + * @return true if we enabled it, false if we disabled it. + */ + public boolean toggleUsingStick(UUID id); + + /** Removes all the users currently using the sticks. */ + public void removeAllStickUsers(); +}