Skip to content

Commit

Permalink
Add PAPI placeholders with SubServers.Client
Browse files Browse the repository at this point in the history
  • Loading branch information
ME1312 committed Jul 5, 2020
1 parent db8aff5 commit 1564eaa
Show file tree
Hide file tree
Showing 20 changed files with 563 additions and 14 deletions.
Expand Up @@ -219,6 +219,14 @@ default int permaEdit(ObjectMap<String> edit) {
*/
boolean isRunning();

/**
* If the Server is Online<br>
* <b>This method can only be true when a SubData connection is made!</b>
*
* @return Online Status
*/
boolean isOnline();

/**
* Grabs the Host of the Server
*
Expand Down
Expand Up @@ -85,6 +85,11 @@ public boolean isAvailable() {
return !updating && getHost().isAvailable();
}

@Override
public boolean isOnline() {
return isRunning() && started;
}

@Override
public void setTemplate(String template) {
SubAPI.getInstance().getInternals().getPluginManager().callEvent(new SubEditServerEvent(null, this, new NamedContainer<String, Object>("template", template), false));
Expand Down Expand Up @@ -176,6 +181,7 @@ public ObjectMap<String> forSubData() {
sinfo.set("dir", getPath());
sinfo.set("exec", getExecutable());
sinfo.set("running", isRunning());
sinfo.set("online", isOnline());
sinfo.set("stop-cmd", getStopCommand());
sinfo.set("stop-action", getStopAction().toString());
sinfo.set("auto-run", SubAPI.getInstance().getInternals().servers.get().getMap("Servers").getMap(getName(), new ObjectMap<String>()).getBoolean("Run-On-Launch", false));
Expand Down
Expand Up @@ -300,7 +300,7 @@ public void execute(CommandSender sender, String[] args) {
if (server.getGroups().size() > 0) sender.sendMessage(" -> Group" + ((server.getGroups().size() > 1)?"s:":": " + ChatColor.WHITE + server.getGroups().get(0)));
if (server.getGroups().size() > 1) for (String group : server.getGroups()) sender.sendMessage(" - " + ChatColor.WHITE + group);
sender.sendMessage(" -> Address: " + ChatColor.WHITE + server.getAddress().getAddress().getHostAddress()+':'+server.getAddress().getPort());
if (server instanceof SubServer) sender.sendMessage(" -> Running: " + ((((SubServer) server).isRunning())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
if (server instanceof SubServer) sender.sendMessage(" -> " + ((((SubServer) server).isOnline())?"Online":"Running") + ": " + ((((SubServer) server).isRunning())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
if (!(server instanceof SubServer) || ((SubServer) server).isRunning()) {
sender.sendMessage(" -> Connected: " + ((server.getSubData()[0] != null)?ChatColor.GREEN+"yes"+((server.getSubData().length > 1)?ChatColor.AQUA+" +"+(server.getSubData().length-1)+" subchannel"+((server.getSubData().length == 2)?"":"s"):""):ChatColor.RED+"no"));
sender.sendMessage(" -> Players: " + ChatColor.AQUA + server.getGlobalPlayers().size() + " online");
Expand Down
10 changes: 10 additions & 0 deletions SubServers.Client/Bukkit/pom.xml
Expand Up @@ -26,6 +26,10 @@
<id>puharesource-repo</id>
<url>https://repo.puha.io/repo/</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>

<dependencies>
Expand Down Expand Up @@ -61,6 +65,12 @@
<version>1.5.11</version> <!-- Use this plugin to enable title messages on 1.8, 1.9, and 1.10 servers -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.10.6</version> <!-- Use this plugin to fill variables in other supported plugins -->
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down

0 comments on commit 1564eaa

Please sign in to comment.