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> <groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId> <artifactId>placeholderapi</artifactId>
<version>2.10.1</version> <version>2.10.2</version>
<name>PlaceholderAPI</name> <name>PlaceholderAPI</name>
<description>An awesome placeholder provider!</description> <description>An awesome placeholder provider!</description>
<url>http://extendedclip.com</url> <url>http://extendedclip.com</url>

View File

@@ -137,18 +137,15 @@ public class PlaceholderAPIPlugin extends JavaPlugin {
Class.forName("org.bukkit.event.server.ServerLoadEvent"); Class.forName("org.bukkit.event.server.ServerLoadEvent");
new ServerLoadEventListener(this); new ServerLoadEventListener(this);
} catch (ExceptionInInitializerError | ClassNotFoundException exception) { } catch (ExceptionInInitializerError | ClassNotFoundException exception) {
Bukkit.getScheduler().runTaskLater(this, new Runnable() { Bukkit.getScheduler().runTaskLater(this, () -> {
@Override getLogger().info("Placeholder expansion registration initializing...");
public void run() { //fetch any hooks that may have registered externally onEnable first otherwise they will be lost
getLogger().info("Placeholder expansion registration initializing..."); final Map<String, PlaceholderHook> alreadyRegistered = PlaceholderAPI.getPlaceholders();
//fetch any hooks that may have registered externally onEnable first otherwise they will be lost getExpansionManager().registerAllExpansions();
final Map<String, PlaceholderHook> alreadyRegistered = PlaceholderAPI.getPlaceholders(); if (alreadyRegistered != null && !alreadyRegistered.isEmpty()) {
getExpansionManager().registerAllExpansions(); alreadyRegistered.forEach(PlaceholderAPI::registerPlaceholderHook);
if (alreadyRegistered != null && !alreadyRegistered.isEmpty()) {
alreadyRegistered.entrySet().stream().forEach(hook -> PlaceholderAPI.registerPlaceholderHook(hook.getKey(), hook.getValue()));
}
} }
}, 20*15); }, 1);
} }
if (config.checkUpdates()) { if (config.checkUpdates()) {
new UpdateChecker(this).fetch(); new UpdateChecker(this).fetch();
@@ -157,7 +154,7 @@ public class PlaceholderAPIPlugin extends JavaPlugin {
enableCloud(); enableCloud();
} }
setupMetrics(); setupMetrics();
getServer().getScheduler().runTaskLater(this, this::checkHook, 20 * 30); getServer().getScheduler().runTaskLater(this, this::checkHook, 40);
} }
@Override @Override
@@ -196,8 +193,10 @@ public class PlaceholderAPIPlugin extends JavaPlugin {
} catch (Exception ex) { } catch (Exception ex) {
author = "the author of the hook's plugin"; 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)); "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; package me.clip.placeholderapi;
import java.util.Map; import java.util.Map;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@@ -8,22 +9,29 @@ import org.bukkit.event.server.ServerLoadEvent;
public class ServerLoadEventListener implements Listener { public class ServerLoadEventListener implements Listener {
private PlaceholderAPIPlugin plugin; private PlaceholderAPIPlugin plugin;
public ServerLoadEventListener(PlaceholderAPIPlugin instance) { public ServerLoadEventListener(PlaceholderAPIPlugin instance) {
plugin = instance; plugin = instance;
Bukkit.getPluginManager().registerEvents(this, instance); Bukkit.getPluginManager().registerEvents(this, instance);
} }
@EventHandler /**
public void onServerLoad(ServerLoadEvent e) { * This method will be called when the server is first loaded
plugin.getLogger().info("Placeholder expansion registration initializing..."); *
final Map<String, PlaceholderHook> alreadyRegistered = PlaceholderAPI.getPlaceholders(); * The goal of the method is to register all the expansions as soon as possible
plugin.getExpansionManager().registerAllExpansions(); * especially before players can join
if (alreadyRegistered != null && !alreadyRegistered.isEmpty()) { *
alreadyRegistered.entrySet().stream().forEach(hook -> { * This will ensure no issues with expanions and hooks.
PlaceholderAPI.registerPlaceholderHook(hook.getKey(), hook.getValue()); * @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; 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.PlaceholderAPI;
import me.clip.placeholderapi.PlaceholderAPIPlugin; import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.expansion.PlaceholderExpansion; import me.clip.placeholderapi.expansion.PlaceholderExpansion;
@@ -37,6 +30,14 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; 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 { public class ExpansionCloudCommands implements CommandExecutor {
private PlaceholderAPIPlugin plugin; private PlaceholderAPIPlugin plugin;
@@ -327,7 +328,7 @@ public class ExpansionCloudCommands implements CommandExecutor {
expansions.put(exp.getName(), exp); expansions.put(exp.getName(), exp);
} }
List<String> ce = expansions.keySet().stream().sorted().collect(Collectors.toList()); 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) { for (String name : ce) {
if (expansions.get(name) == null) { if (expansions.get(name) == null) {
continue; continue;

View File

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

View File

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

View File

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