Skip to content

Commit

Permalink
Merge pull request #16 from jmanpenilla/master
Browse files Browse the repository at this point in the history
Add support for Purpur AFK API
  • Loading branch information
OffLuffy authored Nov 13, 2020
2 parents d72664d + db2fd60 commit a169201
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 11 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
![SmoothSleep](https://proxy.spigotmc.org/18a737d3282325cbb9a291e2a1b8c74fb4c98660?url=https%3A%2F%2Fi.imgur.com%2FNDOrwZO.jpg)


For more information and to download, visit the plugin's page on the Spigot website:

https://www.spigotmc.org/resources/smoothsleep.32043/

---

Please post bug reports and feature requests in the Spigot discussion thread!

https://www.spigotmc.org/threads/smoothsleep.194674/
16 changes: 5 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@

<repositories>
<repository>
<id>destroystokyo-repo</id>
<url>https://repo.destroystokyo.com/repository/maven-public/</url>
<id>purpur</id>
<url>https://repo.pl3x.net/</url>
</repository>
<repository>
<id>sonatype</id>
Expand All @@ -87,16 +87,10 @@
</repositories>

<dependencies>
<!--dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency-->
<dependency>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.16.1-R0.1-SNAPSHOT</version>
<groupId>net.pl3x.purpur</groupId>
<artifactId>purpur-api</artifactId>
<version>1.16.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/luffbox/smoothsleep/DataStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public DataStore(SmoothSleep plugin) {
Plugin cmi = pl.getServer().getPluginManager().getPlugin("CMI");
if (ess != null && ess.isEnabled()) { userHelper = new EssUserHelper(pl); }
else if (cmi != null && cmi.isEnabled()) { userHelper = new CmiUserHelper(pl); }
else if (SmoothSleep.isPurpurServer) { userHelper = new PurpurUserHelper(); }
else { userHelper = new DefUserHelper(); }

Plugin papi = pl.getServer().getPluginManager().getPlugin("PlaceholderAPI");
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/luffbox/smoothsleep/SmoothSleep.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public final class SmoothSleep extends LoggablePlugin {
TICKS_PER_MIN = 1200L;

public static String nmsver;
public static boolean isPaperServer;
public static boolean isPurpurServer;
public static boolean hasUpdate = false;

public DataStore data;
Expand All @@ -38,6 +40,8 @@ public void onEnable() {
resourceId = "32043";
nmsver = Bukkit.getServer().getClass().getPackage().getName();
nmsver = nmsver.substring(nmsver.lastIndexOf(".") + 1);
isPaperServer = classExists("com.destroystokyo.paper.PaperConfig");
isPurpurServer = classExists("net.pl3x.purpur.PurpurConfig");
hasUpdate = checkUpdate();

metrics = new Metrics(this, STAT_ID);
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/luffbox/smoothsleep/lib/LoggablePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ protected boolean checkUpdate() {
return false;
}

public static boolean classExists(String className) {
try {
Class.forName(className);
return true;
} catch (ClassNotFoundException e) {
return false;
}
}

/**
* Checks if a given level of logging is enabled in the config
* @param level The {@link LogLevel} to check
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.luffbox.smoothsleep.lib.hooks;

import org.bukkit.entity.Player;

public class PurpurUserHelper implements UserHelper {
@Override
public String getNickname(Player p) { return p.getDisplayName(); }

@Override
public boolean isAfk(Player p) { return p.isAfk(); }

@Override
public boolean isVanished(Player p) { return false; }
}

0 comments on commit a169201

Please sign in to comment.