Compare commits

...

28 Commits

Author SHA1 Message Date
extendedclip
9377129554 We don't even need an api version. It breaks stuff.. 2019-05-10 10:48:40 -04:00
extendedclip
f4409a6d92 Fix numerical order of expansions in papi ecloud list 2019-05-10 10:28:59 -04:00
extendedclip
c902485718 Remove clipsplaceholderapi since its no longer just clips placeholder api 2019-05-10 10:09:17 -04:00
extendedclip
09db82a840 Set API version to 1.14 even though it doesnt matter to us 2019-05-10 10:07:18 -04:00
extendedclip
9b667fe383 Bump version to 2.10.2 for release 2019-05-10 10:05:52 -04:00
darbyjack
00333f9a4e Changed to use authors instead of hardcoded. 2019-05-09 18:47:16 -05:00
darbyjack
5472be631c Added myself as an author to the plugin. 2019-05-09 17:09:21 -05:00
darbyjack
68fa793354 Added documentation / explanation for the ServerLoadEvent 2019-05-08 22:22:01 -05:00
darbyjack
111f5462fc Cleaned up excess code in TimeUtils 2019-05-08 22:19:57 -05:00
darbyjack
62e282cc0e Initial attempt at preventing EzPlaceholderHook from working. 2019-05-08 15:36:57 -05:00
darbyjack
5aaa9720c8 Changed to use easier way. 2019-05-08 15:05:30 -05:00
darbyjack
9a2fb89e43 Changed placeholders to register 1 tick after server startup. 2019-05-08 15:04:46 -05:00
extendedclip
fc1a2af011 Merge branch 'master' of https://github.com/PlaceholderAPI/PlaceholderAPI 2019-05-07 14:17:00 -04:00
extendedclip
82e92ce777 set version for 2.10.1 release 2019-05-07 14:16:23 -04:00
Mitchell Cook
9b317c2210 Someone forgot how to use lambdas properly (#111) 2019-05-06 16:21:15 -04:00
darbyjack
927f942236 Print out console warnings for the plugins still using EzPlaceholderHook 2019-05-06 09:05:19 -05:00
extendedclip
75c3027e05 This will not be around for much longer. Plugin authors need to update to use PlaceholderExpansion rather than this class. 2019-05-05 13:59:40 -04:00
extendedclip
a2d408aea9 Possible solution for placeholders that register externally before PlaceholderAPI registers expansions 2019-05-05 13:21:28 -04:00
extendedclip
5386b7c23d Remove load option 2019-05-05 10:39:05 -04:00
extendedclip
a741f35139 Check if server supports ServerLoadEvent and if so register the listener, if not delay registration of placeholders for 15 seconds. 2019-05-05 10:38:42 -04:00
extendedclip
1e25f35aac Remove ServerLoadEvent listener 2019-05-05 10:37:54 -04:00
extendedclip
3042e49ddb Move ServerLoadEvent listener to its own class 2019-05-05 10:37:01 -04:00
extendedclip
6495a386a0 Remove EZPlaceholderHook which has been deprecated for over a year. TOODLES! 2019-05-04 21:25:44 -04:00
extendedclip
cee214cc98 Remove PluginEnableEvent listener. Not needed anymore. 2019-05-04 20:15:00 -04:00
extendedclip
41390d8ef4 Remove clean method calls 2019-05-04 20:13:04 -04:00
extendedclip
c0f6cf225f Remove useless "expansion cache" that I don't even know ever worked. Intention was to cache any expansion that isn't registered due to the dependency not being loaded yet when expansion registration initialized. Non issue now that registration happens in ServerLoadEvent. 2019-05-04 20:08:47 -04:00
extendedclip
16d0a4f690 Register expansions in the ServerLoadEvent which is called after the server startup process is complete.
Fixes #103
2019-05-04 19:56:59 -04:00
extendedclip
8f600aec25 Update to 2.10.0-DEV builds 2019-05-04 19:55:35 -04:00
9 changed files with 87 additions and 71 deletions

View File

@@ -6,7 +6,7 @@
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.10.0</version>
<version>2.10.2</version>
<name>PlaceholderAPI</name>
<description>An awesome placeholder provider!</description>
<url>http://extendedclip.com</url>

View File

@@ -30,6 +30,7 @@ import me.clip.placeholderapi.expansion.ExpansionManager;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.expansion.Version;
import me.clip.placeholderapi.expansion.cloud.ExpansionCloudManager;
import me.clip.placeholderapi.external.EZPlaceholderHook;
import me.clip.placeholderapi.updatechecker.UpdateChecker;
import me.clip.placeholderapi.util.TimeUtil;
import org.bstats.bukkit.Metrics;
@@ -132,8 +133,20 @@ public class PlaceholderAPIPlugin extends JavaPlugin {
setupOptions();
getCommand("placeholderapi").setExecutor(new PlaceholderAPICommands(this));
new PlaceholderListener(this);
getLogger().info("Placeholder expansion registration initializing...");
expansionManager.registerAllExpansions();
try {
Class.forName("org.bukkit.event.server.ServerLoadEvent");
new ServerLoadEventListener(this);
} catch (ExceptionInInitializerError | ClassNotFoundException exception) {
Bukkit.getScheduler().runTaskLater(this, () -> {
getLogger().info("Placeholder expansion registration initializing...");
//fetch any hooks that may have registered externally onEnable first otherwise they will be lost
final Map<String, PlaceholderHook> alreadyRegistered = PlaceholderAPI.getPlaceholders();
getExpansionManager().registerAllExpansions();
if (alreadyRegistered != null && !alreadyRegistered.isEmpty()) {
alreadyRegistered.forEach(PlaceholderAPI::registerPlaceholderHook);
}
}, 1);
}
if (config.checkUpdates()) {
new UpdateChecker(this).fetch();
}
@@ -141,13 +154,13 @@ public class PlaceholderAPIPlugin extends JavaPlugin {
enableCloud();
}
setupMetrics();
getServer().getScheduler().runTaskLater(this, this::checkHook, 40);
}
@Override
public void onDisable() {
disableCloud();
PlaceholderAPI.unregisterAll();
expansionManager.clean();
expansionManager = null;
Bukkit.getScheduler().cancelTasks(this);
serverVersion = null;
@@ -156,7 +169,6 @@ public class PlaceholderAPIPlugin extends JavaPlugin {
public void reloadConf(CommandSender s) {
boolean cloudEnabled = this.expansionCloud != null;
expansionManager.clean();
PlaceholderAPI.unregisterAllProvidedExpansions();
reloadConfig();
setupOptions();
@@ -171,6 +183,24 @@ public class PlaceholderAPIPlugin extends JavaPlugin {
+ " &aplaceholder hooks successfully registered!"));
}
private void checkHook() {
Map<String, PlaceholderHook> loaded = PlaceholderAPI.getPlaceholders();
loaded.values().forEach(h -> {
if (h instanceof EZPlaceholderHook) {
String author;
try {
author = Bukkit.getPluginManager().getPlugin(((EZPlaceholderHook) h).getPluginName()).getDescription().getAuthors().toString();
} catch (Exception ex) {
author = "the author of the hook's plugin";
}
getLogger().severe(((EZPlaceholderHook) h).getPluginName() + " is currently using a deprecated method to hook into PlaceholderAPI. Placeholders for that plugin no longer work. " +
"Please consult {author} and urge them to update it ASAP.".replace("{author}", author));
// disable the hook on startup
PlaceholderAPI.unregisterPlaceholderHook(((EZPlaceholderHook) h).getPlaceholderName());
}
});
}
private void setupOptions() {
booleanTrue = config.booleanTrue();
if (booleanTrue == null) {

View File

@@ -26,11 +26,9 @@ import java.util.Set;
import me.clip.placeholderapi.events.ExpansionUnregisterEvent;
import me.clip.placeholderapi.expansion.Cacheable;
import me.clip.placeholderapi.expansion.Cleanable;
import me.clip.placeholderapi.expansion.ExpansionManager;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.expansion.Taskable;
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
import me.clip.placeholderapi.external.EZPlaceholderHook;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -38,7 +36,6 @@ import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
public class PlaceholderListener implements Listener {
@@ -77,17 +74,6 @@ public class PlaceholderListener implements Listener {
}
}
@EventHandler
public void onEnable(PluginEnableEvent event) {
ExpansionManager m = plugin.getExpansionManager();
PlaceholderExpansion e = m.getCachedExpansion(event.getPlugin().getName().toLowerCase());
if (e != null && e.canRegister()) {
if (e.isRegistered() || m.registerExpansion(e)) {
m.removeCachedExpansion(e.getRequiredPlugin());
}
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onPluginUnload(PluginDisableEvent e) {
@@ -107,22 +93,7 @@ public class PlaceholderListener implements Listener {
PlaceholderHook i = hook.getValue();
if (i instanceof EZPlaceholderHook) {
EZPlaceholderHook h = (EZPlaceholderHook) i;
if (h.getPluginName() == null) {
continue;
}
if (h.getPluginName().equalsIgnoreCase(n)) {
if (PlaceholderAPI.unregisterPlaceholderHook(hook.getKey())) {
plugin.getLogger()
.info("Unregistered placeholder hook for placeholder: " + h.getPlaceholderName());
break;
}
}
} else if (i instanceof PlaceholderExpansion) {
if (i instanceof PlaceholderExpansion) {
PlaceholderExpansion ex = (PlaceholderExpansion) i;

View File

@@ -0,0 +1,37 @@
package me.clip.placeholderapi;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.server.ServerLoadEvent;
public class ServerLoadEventListener implements Listener {
private PlaceholderAPIPlugin plugin;
public ServerLoadEventListener(PlaceholderAPIPlugin instance) {
plugin = instance;
Bukkit.getPluginManager().registerEvents(this, instance);
}
/**
* This method will be called when the server is first loaded
*
* The goal of the method is to register all the expansions as soon as possible
* especially before players can join
*
* This will ensure no issues with expanions and hooks.
* @param e the server load event
*/
@EventHandler
public void onServerLoad(ServerLoadEvent e) {
plugin.getLogger().info("Placeholder expansion registration initializing...");
final Map<String, PlaceholderHook> alreadyRegistered = PlaceholderAPI.getPlaceholders();
plugin.getExpansionManager().registerAllExpansions();
if (alreadyRegistered != null && !alreadyRegistered.isEmpty()) {
alreadyRegistered.forEach(PlaceholderAPI::registerPlaceholderHook);
}
}
}

View File

@@ -20,13 +20,6 @@
*/
package me.clip.placeholderapi.commands;
import static me.clip.placeholderapi.util.Msg.color;
import static me.clip.placeholderapi.util.Msg.msg;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
@@ -37,6 +30,14 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static me.clip.placeholderapi.util.Msg.color;
import static me.clip.placeholderapi.util.Msg.msg;
public class ExpansionCloudCommands implements CommandExecutor {
private PlaceholderAPIPlugin plugin;
@@ -327,7 +328,7 @@ public class ExpansionCloudCommands implements CommandExecutor {
expansions.put(exp.getName(), exp);
}
List<String> ce = expansions.keySet().stream().sorted().collect(Collectors.toList());
int i = 1;
int i = (int) ex.keySet().toArray()[0]+1;
for (String name : ce) {
if (expansions.get(name) == null) {
continue;

View File

@@ -49,7 +49,7 @@ public class PlaceholderAPICommands implements CommandExecutor {
if (args.length == 0) {
Msg.msg(s, "PlaceholderAPI &7version &b&o" + plugin.getDescription().getVersion(),
"&fCreated by&7: &bextended_clip",
"&fCreated by&7: &b" + plugin.getDescription().getAuthors(),
"&fPapi commands: &b/papi help",
"&fEcloud commands: &b/papi ecloud");
return true;

View File

@@ -22,7 +22,6 @@ package me.clip.placeholderapi.expansion;
import java.io.File;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -36,8 +35,6 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.Listener;
public final class ExpansionManager {
private final Map<String, PlaceholderExpansion> cache = new HashMap<>();
private PlaceholderAPIPlugin plugin;
public ExpansionManager(PlaceholderAPIPlugin instance) {
@@ -48,18 +45,6 @@ public final class ExpansionManager {
}
}
public void clean() {
cache.clear();
}
public PlaceholderExpansion getCachedExpansion(String plugin) {
return cache.getOrDefault(plugin, null);
}
public boolean removeCachedExpansion(String identifier) {
return cache.remove(identifier) != null;
}
public PlaceholderExpansion getRegisteredExpansion(String name) {
for (Entry<String, PlaceholderHook> hook : PlaceholderAPI.getPlaceholders().entrySet()) {
if (hook.getValue() instanceof PlaceholderExpansion) {
@@ -112,9 +97,6 @@ public final class ExpansionManager {
}
}
if (!expansion.canRegister()) {
if (expansion.getRequiredPlugin() != null) {
cache.put(expansion.getRequiredPlugin().toLowerCase(), expansion);
}
return false;
}
if (!expansion.register()) {

View File

@@ -27,9 +27,7 @@ public class TimeUtil {
if (seconds < 60) {
switch (type) {
case DAYS:
return "0";
case HOURS:
return "0";
case MINUTES:
return "0";
case SECONDS:
@@ -44,7 +42,6 @@ public class TimeUtil {
if (minutes < 60) {
switch (type) {
case DAYS:
return "0";
case HOURS:
return "0";
case MINUTES:
@@ -118,9 +115,9 @@ public class TimeUtil {
int secondsLeft = seconds - s;
if (minutes < 60) {
if (secondsLeft > 0) {
return String.valueOf(minutes + "m " + secondsLeft + "s");
return minutes + "m " + secondsLeft + "s";
} else {
return String.valueOf(minutes + "m");
return minutes + "m";
}
}
if (minutes < 1440) {

View File

@@ -1,10 +1,8 @@
name: ${project.name}
main: me.clip.placeholderapi.PlaceholderAPIPlugin
version: ${project.version}
author: [extended_clip]
authors: [extended_clip, Glare]
description: ${project.description}
api-version: 1.13
load: STARTUP
permissions:
placeholderapi.*:
description: ability to use all commands
@@ -40,4 +38,4 @@ permissions:
commands:
placeholderapi:
description: PlaceholderAPI command
aliases: [clipsplaceholderapi, papi]
aliases: [papi]