forked from Upstream/CitizensCMD
Completely reorder the plugin enabling to be cleaner
- Added a case for medium time display - Reduced the tick delay for loading cooldowns and added a tick delay for loading the datamanager
This commit is contained in:
parent
0011f2282e
commit
87cb2cf335
@ -96,21 +96,13 @@ public final class CitizensCMD extends JavaPlugin {
|
|||||||
private String newVersion;
|
private String newVersion;
|
||||||
private DisplayFormat displayFormat;
|
private DisplayFormat displayFormat;
|
||||||
|
|
||||||
private Map<String, Boolean> waitingList;
|
private final Map<String, Boolean> waitingList = new HashMap<>();;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
settings = SettingsManagerBuilder
|
|
||||||
.withYamlFile(Paths.get(getDataFolder().getPath(), "config.yml"))
|
|
||||||
.configurationData(Settings.class)
|
|
||||||
.useDefaultMigrationService()
|
|
||||||
.create();
|
|
||||||
|
|
||||||
audiences = BukkitAudiences.create(this);
|
audiences = BukkitAudiences.create(this);
|
||||||
final Audience console = audiences.console();
|
final Audience console = audiences.console();
|
||||||
|
|
||||||
setLang(settings.getProperty(Settings.LANG));
|
|
||||||
|
|
||||||
if (!hasCitizens() && settings.getProperty(Settings.CITIZENS_CHECK)) {
|
if (!hasCitizens() && settings.getProperty(Settings.CITIZENS_CHECK)) {
|
||||||
console.sendMessage(TAG.append(LEGACY.deserialize("&cCitizens &7is needed for this plugin to work!")));
|
console.sendMessage(TAG.append(LEGACY.deserialize("&cCitizens &7is needed for this plugin to work!")));
|
||||||
console.sendMessage(TAG.append(LEGACY.deserialize("&cCitizens.jar &7is not installed on the server!")));
|
console.sendMessage(TAG.append(LEGACY.deserialize("&cCitizens.jar &7is not installed on the server!")));
|
||||||
@ -118,40 +110,19 @@ public final class CitizensCMD extends JavaPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
commandManager = BukkitCommandManager.create(this);
|
// Enabling lets go!
|
||||||
|
|
||||||
final Metrics metrics = new Metrics(this, 2652);
|
|
||||||
Util.setUpMetrics(metrics, settings);
|
|
||||||
|
|
||||||
console.sendMessage(TAG.append(LEGACY.deserialize("&3Citizens&cCMD &8&o" + getDescription().getVersion())));
|
console.sendMessage(TAG.append(LEGACY.deserialize("&3Citizens&cCMD &8&o" + getDescription().getVersion())));
|
||||||
console.sendMessage(TAG.append(LEGACY.deserialize("&8by &3Mateus Moreira &c@LichtHund &8& Maintained by &3HexedHero")));
|
console.sendMessage(TAG.append(LEGACY.deserialize("&8by &3Mateus Moreira &c@LichtHund &8& Maintained by &3HexedHero")));
|
||||||
|
|
||||||
permissionsManager = new PermissionsManager(this);
|
// Settings
|
||||||
|
settings = SettingsManagerBuilder
|
||||||
dataHandler = new DataHandler(this);
|
.withYamlFile(Paths.get(getDataFolder().getPath(), "config.yml"))
|
||||||
dataHandler.initialize();
|
.configurationData(Settings.class)
|
||||||
|
.useDefaultMigrationService()
|
||||||
cooldownHandler = new CooldownHandler(this);
|
.create();
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> cooldownHandler.initialize(), 30L);
|
|
||||||
|
|
||||||
registerCommands();
|
|
||||||
registerEvents();
|
|
||||||
|
|
||||||
console.sendMessage(TAG.append(lang.getMessage(Messages.USING_LANGUAGE)));
|
|
||||||
|
|
||||||
if (hasPAPI()) {
|
|
||||||
console.sendMessage(TAG.append(lang.getMessage(Messages.PAPI_AVAILABLE)));
|
|
||||||
papi = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setupEconomy()) {
|
|
||||||
console.sendMessage(TAG.append(lang.getMessage(Messages.VAULT_AVAILABLE)));
|
|
||||||
}
|
|
||||||
|
|
||||||
waitingList = new HashMap<>();
|
|
||||||
|
|
||||||
|
setLang(settings.getProperty(Settings.LANG));
|
||||||
setShift(settings.getProperty(Settings.SHIFT_CONFIRM));
|
setShift(settings.getProperty(Settings.SHIFT_CONFIRM));
|
||||||
|
|
||||||
switch (settings.getProperty(Settings.TIME_DISPLAY).toLowerCase()) {
|
switch (settings.getProperty(Settings.TIME_DISPLAY).toLowerCase()) {
|
||||||
case "short":
|
case "short":
|
||||||
displayFormat = DisplayFormat.SHORT;
|
displayFormat = DisplayFormat.SHORT;
|
||||||
@ -161,11 +132,48 @@ public final class CitizensCMD extends JavaPlugin {
|
|||||||
displayFormat = DisplayFormat.FULL;
|
displayFormat = DisplayFormat.FULL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "medium":
|
||||||
default:
|
default:
|
||||||
displayFormat = DisplayFormat.MEDIUM;
|
displayFormat = DisplayFormat.MEDIUM;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
console.sendMessage(TAG.append(lang.getMessage(Messages.USING_LANGUAGE)));
|
||||||
|
|
||||||
|
// Permissions
|
||||||
|
permissionsManager = new PermissionsManager(this);
|
||||||
|
|
||||||
|
// Commands and Events
|
||||||
|
commandManager = BukkitCommandManager.create(this);
|
||||||
|
registerCommands();
|
||||||
|
registerEvents();
|
||||||
|
|
||||||
|
// Hooks
|
||||||
|
if (hasPAPI()) {
|
||||||
|
console.sendMessage(TAG.append(lang.getMessage(Messages.PAPI_AVAILABLE)));
|
||||||
|
papi = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setupEconomy()) {
|
||||||
|
console.sendMessage(TAG.append(lang.getMessage(Messages.VAULT_AVAILABLE)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Data
|
||||||
|
dataHandler = new DataHandler(this);
|
||||||
|
cooldownHandler = new CooldownHandler(this);
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> { dataHandler.initialize(); cooldownHandler.initialize(); }, 1L);
|
||||||
|
|
||||||
|
// API
|
||||||
|
api = new CitizensCMDAPI(dataHandler);
|
||||||
|
|
||||||
|
// Metrics
|
||||||
|
final Metrics metrics = new Metrics(this, 2652);
|
||||||
|
Util.setUpMetrics(metrics, settings);
|
||||||
|
|
||||||
|
// Tasks
|
||||||
|
new UpdateScheduler(this).runTaskTimerAsynchronously(this, 72000L, 72000L);
|
||||||
|
new CooldownScheduler(this).runTaskTimerAsynchronously(this, 36000L, 36000L);
|
||||||
|
|
||||||
|
// Check for updates
|
||||||
if (settings.getProperty(Settings.CHECK_UPDATES)) {
|
if (settings.getProperty(Settings.CHECK_UPDATES)) {
|
||||||
final SpigotUpdater updater = new SpigotUpdater(this, 30224);
|
final SpigotUpdater updater = new SpigotUpdater(this, 30224);
|
||||||
try {
|
try {
|
||||||
@ -179,11 +187,6 @@ public final class CitizensCMD extends JavaPlugin {
|
|||||||
} catch (final Exception ignored) {
|
} catch (final Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
api = new CitizensCMDAPI(dataHandler);
|
|
||||||
|
|
||||||
new UpdateScheduler(this).runTaskTimerAsynchronously(this, 72000L, 72000L);
|
|
||||||
new CooldownScheduler(this).runTaskTimerAsynchronously(this, 36000L, 36000L);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user