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:
parent
0a429cf311
commit
75171a7ba4
@ -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. */
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user