Compare commits

..

12 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
7 changed files with 51 additions and 47 deletions

View File

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

View File

@@ -137,18 +137,15 @@ public class PlaceholderAPIPlugin extends JavaPlugin {
Class.forName("org.bukkit.event.server.ServerLoadEvent");
new ServerLoadEventListener(this);
} catch (ExceptionInInitializerError | ClassNotFoundException exception) {
Bukkit.getScheduler().runTaskLater(this, new Runnable() {
@Override
public void run() {
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.entrySet().stream().forEach(hook -> PlaceholderAPI.registerPlaceholderHook(hook.getKey(), hook.getValue()));
}
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);
}
}, 20*15);
}, 1);
}
if (config.checkUpdates()) {
new UpdateChecker(this).fetch();
@@ -157,7 +154,7 @@ public class PlaceholderAPIPlugin extends JavaPlugin {
enableCloud();
}
setupMetrics();
getServer().getScheduler().runTaskLater(this, this::checkHook, 20 * 30);
getServer().getScheduler().runTaskLater(this, this::checkHook, 40);
}
@Override
@@ -196,8 +193,10 @@ public class PlaceholderAPIPlugin extends JavaPlugin {
} catch (Exception ex) {
author = "the author of the hook's plugin";
}
getLogger().warning(((EZPlaceholderHook) h).getPluginName() + " is currently using a deprecated method to hook into PlaceholderAPI. This will be disabled after the next update. " +
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());
}
});
}

View File

@@ -1,6 +1,7 @@
package me.clip.placeholderapi;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@@ -8,22 +9,29 @@ import org.bukkit.event.server.ServerLoadEvent;
public class ServerLoadEventListener implements Listener {
private PlaceholderAPIPlugin plugin;
private PlaceholderAPIPlugin plugin;
public ServerLoadEventListener(PlaceholderAPIPlugin instance) {
plugin = instance;
Bukkit.getPluginManager().registerEvents(this, instance);
}
@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.entrySet().stream().forEach(hook -> {
PlaceholderAPI.registerPlaceholderHook(hook.getKey(), hook.getValue());
});
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

@@ -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,9 +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
permissions:
placeholderapi.*:
description: ability to use all commands
@@ -39,4 +38,4 @@ permissions:
commands:
placeholderapi:
description: PlaceholderAPI command
aliases: [clipsplaceholderapi, papi]
aliases: [papi]