Pretty time is sign default & reload sign lines

When the plugin reloads fire an event so that other places can know when
it happens, mostly internal. Use that new event for reloading the
plugin's sign lines in the event it happens.
This commit is contained in:
graywolf336 2015-05-27 11:34:53 -05:00
parent 0a429cf311
commit 75171a7ba4
4 changed files with 54 additions and 1 deletions

View File

@ -13,6 +13,7 @@ import com.graywolf336.jail.command.CommandHandler;
import com.graywolf336.jail.command.JailHandler;
import com.graywolf336.jail.enums.Lang;
import com.graywolf336.jail.enums.Settings;
import com.graywolf336.jail.events.JailPluginReloadedEvent;
import com.graywolf336.jail.interfaces.IJailPayManager;
import com.graywolf336.jail.interfaces.IJailStickManager;
import com.graywolf336.jail.legacy.LegacyManager;
@ -204,6 +205,7 @@ public class JailMain extends JavaPlugin {
reloadJailPayManager();
reloadJailVoteManager();
reloadUpdateCheck();
getServer().getPluginManager().callEvent(new JailPluginReloadedEvent(this));
}
/** Reloads the scoreboard manager class, useful when something is changed int he config about it. */

View File

@ -0,0 +1,40 @@
package com.graywolf336.jail.events;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import com.graywolf336.jail.JailMain;
/**
* Event thrown after the plugin is reloaded, internal usage only.
*
* <p />
*
* This event is called right after the plugin and mostly everything has reloaded.
* We listen to this event for updating various items in classes which are only
* listeners so we don't store instances of them elsewhere.
*
* @author graywolf336
* @since 3.0.0
* @version 1.0.0
*/
public class JailPluginReloadedEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private JailMain plugin;
public JailPluginReloadedEvent(JailMain main) {
this.plugin = main;
}
public JailMain getPlugin() {
return this.plugin;
}
public static HandlerList getHandlerList() {
return handlers;
}
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -13,6 +13,7 @@ import com.graywolf336.jail.Util;
import com.graywolf336.jail.beans.SimpleLocation;
import com.graywolf336.jail.enums.Lang;
import com.graywolf336.jail.enums.Settings;
import com.graywolf336.jail.events.JailPluginReloadedEvent;
import com.graywolf336.jail.events.PrisonerJailedEvent;
import com.graywolf336.jail.events.PrisonerReleasedEvent;
import com.graywolf336.jail.events.PrisonerTimeChangeEvent;
@ -154,4 +155,14 @@ public class CellSignListener implements Listener {
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void handleSignLineUpdates(JailPluginReloadedEvent event) {
List<String> lines = pl.getConfig().getStringList(Settings.CELLSIGNLINES.getPath());
if(lines.size() >= 1) lineOne = lines.get(0);
if(lines.size() >= 2) lineTwo = lines.get(1);
if(lines.size() >= 3) lineThree = lines.get(2);
if(lines.size() >= 4) lineFour = lines.get(3);
}
}

View File

@ -26,7 +26,7 @@ jailing:
blockPlaceWhiteList: ['crops', 'carrot', 'potato'] # these blocks can be placed at any time by prisoners
cellsign:
- '%player%'
- '%timeinminutes% mins'
- '%prettytime%'
- 'with a reason'
- '%reason%'
commandPenalty: 5m