Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/org/polymart/mcplugin/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.polymart.mcplugin.api.PolymartAccount;
import org.polymart.mcplugin.commands.PolymartCommand;
import org.polymart.mcplugin.commands.UpdateCommand;
import org.polymart.mcplugin.hooks.PolymartExpansion;
import org.polymart.mcplugin.server.UploadServerInfo;

import java.util.*;
Expand All @@ -39,6 +40,10 @@ public void onEnable(){
UpdateCheck.setup();
UploadServerInfo.setup();

if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null){
new PolymartExpansion(this).register();
}

this.getCommand("polymart").setExecutor(new PolymartCommand());
this.getCommand("update").setExecutor(new UpdateCommand());

Expand Down
2 changes: 2 additions & 0 deletions src/org/polymart/mcplugin/actions/UpdateCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.jar.JarFile;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
Expand Down Expand Up @@ -373,6 +374,7 @@ public static void checkForUpdatesResponse(JSONWrapper wrapper, Map<String, Stri
}

upToDate.sort(Comparator.comparing((UpdateInfo a) -> a.name));
canDownloadFromPolymart = canDownloadFromPolymart.stream().filter(Objects::nonNull).collect(Collectors.toList());
canDownloadFromPolymart.sort(Comparator.comparing((UpdateInfo a) -> a.name));
untracked.sort(Comparator.comparing((UpdateInfo a) -> a.name));
updateAvailable.sort(Comparator.comparing((UpdateInfo a) -> a.name));
Expand Down
78 changes: 78 additions & 0 deletions src/org/polymart/mcplugin/hooks/PolymartExpansion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package org.polymart.mcplugin.hooks;

import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.polymart.mcplugin.Main;

public class PolymartExpansion extends PlaceholderExpansion {

private final Main plugin;

public PolymartExpansion(Main plugin) {
this.plugin = plugin;
}

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

@Override
public @NotNull String getIdentifier() {
return "polymart";
}

@Override
public @NotNull String getAuthor() {
return "Polymart";
}

@Override
public @NotNull String getVersion() {
return plugin.getServer().getVersion();
}

@Override
public @Nullable String onPlaceholderRequest(Player player, @NotNull String params) {
String[] args = params.split("_");

if (args.length == 0) {
return null;
}

switch (args[0].toLowerCase()) {
case "version":
if (args.length != 2) {
return null;
}
Plugin otherPlugin = plugin.getServer().getPluginManager().getPlugin(args[1]);
if (otherPlugin == null) {
return null;
}
return otherPlugin.getDescription().getVersion();
case "description":
if (args.length != 2) {
return null;
}
Plugin otherPlugin1 = plugin.getServer().getPluginManager().getPlugin(args[1]);
if (otherPlugin1 == null) {
return null;
}
return otherPlugin1.getDescription().getDescription();
case "author":
if (args.length != 2) {
return null;
}
Plugin otherPlugin2 = plugin.getServer().getPluginManager().getPlugin(args[1]);
if (otherPlugin2 == null) {
return null;
}
return String.join(", ", otherPlugin2.getDescription().getAuthors());
}

return null;
}
}
2 changes: 2 additions & 0 deletions src/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ api-version: "1.13"
author: Polymart
website: https://polymart.org
load: STARTUP
softdepend:
- PlaceholderAPI
commands:
polymart:
description: Polymart commands
Expand Down