Skip to content

Commit

Permalink
Create an interface to easily retrieve AFK information from a hook.
Browse files Browse the repository at this point in the history
  • Loading branch information
Staartvin committed Dec 2, 2019
1 parent c435bf7 commit 1e20fb1
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.staartvin</groupId>
<artifactId>PluginLibrary</artifactId>
<version>1.2.2-SNAPSHOT-${BUILD_NUMBER}</version>
<version>1.2.3-SNAPSHOT-${BUILD_NUMBER}</version>

<build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import me.edge209.afkTerminator.AfkDetect;
import me.edge209.afkTerminator.AfkDetect.AFKMACHINES;
import me.staartvin.plugins.pluginlibrary.Library;
import me.staartvin.plugins.pluginlibrary.hooks.afkmanager.AFKManager;

import java.util.UUID;

Expand All @@ -15,7 +16,7 @@
* @author Staartvin
*
*/
public class AFKTerminatorHook extends LibraryHook {
public class AFKTerminatorHook extends LibraryHook implements AFKManager {

/*
* (non-Javadoc)
Expand Down Expand Up @@ -109,4 +110,14 @@ public String getAFKMachineType(UUID uuid) {

return type.toString();
}

@Override
public boolean isAFK(UUID uuid) {
return this.isAFKMachineDetected(uuid);
}

@Override
public boolean hasAFKData() {
return true;
}
}
8 changes: 7 additions & 1 deletion src/me/staartvin/plugins/pluginlibrary/hooks/CMIHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.Zrips.CMI.CMI;
import com.Zrips.CMI.Containers.CMIUser;
import me.staartvin.plugins.pluginlibrary.Library;
import me.staartvin.plugins.pluginlibrary.hooks.afkmanager.AFKManager;

import java.util.UUID;

Expand All @@ -14,7 +15,7 @@
* @author Staartvin
*
*/
public class CMIHook extends LibraryHook {
public class CMIHook extends LibraryHook implements AFKManager {

/*
* (non-Javadoc)
Expand Down Expand Up @@ -56,4 +57,9 @@ public boolean isAFK(UUID uuid) {
return user.isAfk();
}

@Override
public boolean hasAFKData() {
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
import me.staartvin.plugins.pluginlibrary.Library;
import me.staartvin.plugins.pluginlibrary.hooks.afkmanager.AFKManager;

import java.util.UUID;

Expand All @@ -14,7 +15,7 @@
* @author Staartvin
*
*/
public class EssentialsXHook extends LibraryHook {
public class EssentialsXHook extends LibraryHook implements AFKManager {

private Essentials essentials;

Expand Down Expand Up @@ -95,4 +96,9 @@ public boolean isAFK(UUID uuid) {
return user.isAfk();
}

@Override
public boolean hasAFKData() {
return true;
}

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package me.staartvin.plugins.pluginlibrary.hooks;

import me.staartvin.plugins.pluginlibrary.Library;
import me.staartvin.plugins.pluginlibrary.hooks.afkmanager.AFKManager;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.royaldev.royalcommands.RoyalCommands;
import org.royaldev.royalcommands.WorldManager;

import java.util.UUID;

/**
* RoyalCommands library,
* <a href="http://dev.bukkit.org/bukkit-plugins/royalcommands/">link</a>.
Expand All @@ -16,7 +20,7 @@
* @author Staartvin
*
*/
public class RoyalCommandsHook extends LibraryHook {
public class RoyalCommandsHook extends LibraryHook implements AFKManager {

private RoyalCommands api;

Expand Down Expand Up @@ -106,4 +110,13 @@ public Inventory getOfflineEnderInventory(OfflinePlayer player, String worldName
return WorldManager.il.getOfflinePlayerEnderInventory(player, worldName);
}

@Override
public boolean isAFK(UUID uuid) {
return isAFK(Bukkit.getPlayer(uuid));
}

@Override
public boolean hasAFKData() {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.staartvin.plugins.pluginlibrary.hooks;

import me.staartvin.plugins.pluginlibrary.Library;
import me.staartvin.plugins.pluginlibrary.hooks.afkmanager.AFKManager;

import java.util.UUID;

Expand All @@ -13,7 +14,7 @@
* @author Staartvin
*
*/
public class UltimateCoreHook extends LibraryHook {
public class UltimateCoreHook extends LibraryHook implements AFKManager {

// private UltimateCore api;

Expand Down Expand Up @@ -51,6 +52,7 @@ public boolean hook() {
public boolean isAFK(UUID uuid) {

return false;

// if (!isAvailable()) {
// return false;
// }
Expand All @@ -63,4 +65,9 @@ public boolean isAFK(UUID uuid) {
//
// return player.isAfk();
}

@Override
public boolean hasAFKData() {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package me.staartvin.plugins.pluginlibrary.hooks.afkmanager;

import java.util.UUID;

public interface AFKManager {

boolean isAFK(UUID uuid);

boolean hasAFKData();

}

0 comments on commit 1e20fb1

Please sign in to comment.