Replace public variable for config and language with getter

This commit is contained in:
GeorgH93 2018-06-07 00:30:48 +02:00
parent c426683360
commit c5751431ad
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
10 changed files with 41 additions and 41 deletions

View File

@ -41,7 +41,7 @@ public class ClearCommand extends MinepacksCommand
public ClearCommand(Minepacks plugin)
{
super(plugin, "clear", plugin.getLanguage().getTranslated("Commands.Description.Clean"), "backpack.clean", plugin.getLanguage().getCommandAliases("Clean"));
messageBackpackCleaned = plugin.lang.getMessage("Ingame.Clean.BackpackCleaned");
messageBackpackCleaned = plugin.getLanguage().getMessage("Ingame.Clean.BackpackCleaned");
descriptionCleanOthers = plugin.getLanguage().getTranslated("Commands.Description.CleanOthers");
helpParam = "<" + plugin.getLanguage().get("Commands.PlayerNameVariable") + ">";
}

View File

@ -41,16 +41,16 @@ public class OpenCommand extends MinepacksCommand
public OpenCommand(Minepacks plugin)
{
super(plugin, "open", plugin.lang.getTranslated("Commands.Description.Backpack"), "backpack.use", true, plugin.getLanguage().getCommandAliases("Open"));
super(plugin, "open", plugin.getLanguage().getTranslated("Commands.Description.Backpack"), "backpack.use", true, plugin.getLanguage().getCommandAliases("Open"));
this.plugin = plugin;
messageCooldown = plugin.lang.getMessage("Ingame.Open.Cooldown").replaceAll("\\{TimeLeft}", "%1\\$.1f");
messageWrongGameMode = plugin.lang.getMessage("Ingame.Open.WrongGameMode").replaceAll("\\{CurrentGameMode}", "%1\\$s").replaceAll("\\{AllowedGameModes}", "%1\\$s");
descriptionOpenOthers = plugin.lang.getTranslated("Commands.Description.OpenOthers");
messageCooldown = plugin.getLanguage().getMessage("Ingame.Open.Cooldown").replaceAll("\\{TimeLeft}", "%1\\$.1f");
messageWrongGameMode = plugin.getLanguage().getMessage("Ingame.Open.WrongGameMode").replaceAll("\\{CurrentGameMode}", "%1\\$s").replaceAll("\\{AllowedGameModes}", "%1\\$s");
descriptionOpenOthers = plugin.getLanguage().getTranslated("Commands.Description.OpenOthers");
helpParam = "<" + plugin.getLanguage().get("Commands.PlayerNameVariable") + ">";
cooldown = plugin.config.getCommandCooldown();
syncCooldown = plugin.config.isCommandCooldownSyncEnabled();
cooldown = plugin.getConfiguration().getCommandCooldown();
syncCooldown = plugin.getConfiguration().isCommandCooldownSyncEnabled();
StringBuilder allowedGameModesBuilder = new StringBuilder();
for(GameMode gameMode : plugin.getConfiguration().getAllowedGameModes())

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016-2017 GeorgH93
* Copyright (C) 2016-2018 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -54,10 +54,10 @@ public abstract class Database implements Listener
public Database(Minepacks mp)
{
plugin = mp;
useUUIDSeparators = plugin.config.getUseUUIDSeparators();
useUUIDs = plugin.config.getUseUUIDs();
bungeeCordMode = plugin.config.isBungeeCordModeEnabled();
maxAge = plugin.config.getAutoCleanupMaxInactiveDays();
useUUIDSeparators = plugin.getConfiguration().getUseUUIDSeparators();
useUUIDs = plugin.getConfiguration().getUseUUIDs();
bungeeCordMode = plugin.getConfiguration().isBungeeCordModeEnabled();
maxAge = plugin.getConfiguration().getAutoCleanupMaxInactiveDays();
unCacheStrategie = bungeeCordMode ? new OnDisconnect(this) : UnCacheStrategie.getUnCacheStrategie(this);
}
@ -77,7 +77,7 @@ public void close()
public static Database getDatabase(Minepacks plugin)
{
Database database;
switch(plugin.config.getDatabaseType().toLowerCase())
switch(plugin.getConfiguration().getDatabaseType().toLowerCase())
{
case "mysql":
database = new MySQL(plugin); break;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016, 2017 GeorgH93
* Copyright (C) 2016-2018 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -37,11 +37,11 @@ public MySQL(Minepacks mp)
protected HikariConfig getPoolConfig()
{
HikariConfig poolConfig = new HikariConfig();
poolConfig.setJdbcUrl("jdbc:mysql://" + plugin.config.getSQLHost() + "/" + plugin.config.getSQLDatabase() + "?allowMultiQueries=true&autoReconnect=true" + plugin.config.getSQLProperties());
poolConfig.setUsername(plugin.config.getSQLUser());
poolConfig.setPassword(plugin.config.getSQLPassword());
poolConfig.setJdbcUrl("jdbc:mysql://" + plugin.getConfiguration().getSQLHost() + "/" + plugin.getConfiguration().getSQLDatabase() + "?allowMultiQueries=true&autoReconnect=true" + plugin.getConfiguration().getSQLProperties());
poolConfig.setUsername(plugin.getConfiguration().getSQLUser());
poolConfig.setPassword(plugin.getConfiguration().getSQLPassword());
poolConfig.setMinimumIdle(1);
poolConfig.setMaximumPoolSize(plugin.config.getSQLMaxConnections());
poolConfig.setMaximumPoolSize(plugin.getConfiguration().getSQLMaxConnections());
return poolConfig;
}

View File

@ -103,20 +103,20 @@ public SQL(Minepacks mp)
protected void loadSettings()
{
// Load table and field names
tablePlayers = plugin.config.getUserTable();
tableBackpacks = plugin.config.getBackpackTable();
tableCooldowns = plugin.config.getCooldownTable();
fieldPlayerID = plugin.config.getDBFields("User.Player_ID", "id");
fieldPlayerName = plugin.config.getDBFields("User.Name", "name");
fieldPlayerUUID = plugin.config.getDBFields("User.UUID", "uuid");
fieldBpOwner = plugin.config.getDBFields("Backpack.Owner_ID", "owner");
fieldBpIts = plugin.config.getDBFields("Backpack.ItemStacks", "its");
fieldBpVersion = plugin.config.getDBFields("Backpack.Version", "version");
fieldBpLastUpdate = plugin.config.getDBFields("Backpack.LastUpdate", "lastUpdate");
fieldCdPlayer = plugin.config.getDBFields("Cooldown.Player_ID", "id");
fieldCdTime = plugin.config.getDBFields("Cooldown.Time", "time");
updatePlayer = plugin.config.getUpdatePlayer();
syncCooldown = plugin.config.isCommandCooldownSyncEnabled();
tablePlayers = plugin.getConfiguration().getUserTable();
tableBackpacks = plugin.getConfiguration().getBackpackTable();
tableCooldowns = plugin.getConfiguration().getCooldownTable();
fieldPlayerID = plugin.getConfiguration().getDBFields("User.Player_ID", "id");
fieldPlayerName = plugin.getConfiguration().getDBFields("User.Name", "name");
fieldPlayerUUID = plugin.getConfiguration().getDBFields("User.UUID", "uuid");
fieldBpOwner = plugin.getConfiguration().getDBFields("Backpack.Owner_ID", "owner");
fieldBpIts = plugin.getConfiguration().getDBFields("Backpack.ItemStacks", "its");
fieldBpVersion = plugin.getConfiguration().getDBFields("Backpack.Version", "version");
fieldBpLastUpdate = plugin.getConfiguration().getDBFields("Backpack.LastUpdate", "lastUpdate");
fieldCdPlayer = plugin.getConfiguration().getDBFields("Cooldown.Player_ID", "id");
fieldCdTime = plugin.getConfiguration().getDBFields("Cooldown.Time", "time");
updatePlayer = plugin.getConfiguration().getUpdatePlayer();
syncCooldown = plugin.getConfiguration().isCommandCooldownSyncEnabled();
}
@Override

View File

@ -37,7 +37,7 @@ public class ItemsCollector extends BukkitRunnable
public ItemsCollector(Minepacks plugin)
{
this.plugin = plugin;
this.radius = plugin.config.getFullInvRadius();
this.radius = plugin.getConfiguration().getFullInvRadius();
}
@Override

View File

@ -65,8 +65,8 @@ public class DisableShulkerboxes extends MinepacksListener
public DisableShulkerboxes(final Minepacks plugin)
{
super(plugin);
removeExisting = plugin.config.isShulkerboxesExistingDestroyEnabled();
dropExistingContent = plugin.config.isShulkerboxesExistingDropEnabled();
removeExisting = plugin.getConfiguration().isShulkerboxesExistingDestroyEnabled();
dropExistingContent = plugin.getConfiguration().isShulkerboxesExistingDropEnabled();
}
@EventHandler(ignoreCancelled = true)

View File

@ -37,8 +37,8 @@ public class EventListener extends MinepacksListener
public EventListener(Minepacks plugin)
{
super(plugin);
messageOwnBackpackClose = plugin.lang.getMessage("Ingame.OwnBackpackClose");
messageOtherBackpackClose = plugin.lang.getMessage("Ingame.PlayerBackpackClose").replaceAll("\\{OwnerName\\}", "%1\\$s").replaceAll("\\{OwnerDisplayName\\}", "%2\\$s");
messageOwnBackpackClose = plugin.getLanguage().getMessage("Ingame.OwnBackpackClose");
messageOtherBackpackClose = plugin.getLanguage().getMessage("Ingame.PlayerBackpackClose").replaceAll("\\{OwnerName\\}", "%1\\$s").replaceAll("\\{OwnerDisplayName\\}", "%2\\$s");
}
@EventHandler

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016-2017 GeorgH93
* Copyright (C) 2016-2018 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -53,7 +53,7 @@ public ItemFilter(final Minepacks plugin)
}
blockedMaterials.addAll(plugin.getConfiguration().getItemFilterBlacklist());
messageNotAllowedInBackpack = plugin.lang.getMessage("Ingame.NotAllowedInBackpack").replaceAll("\\{ItemName}", "%s");
messageNotAllowedInBackpack = plugin.getLanguage().getMessage("Ingame.NotAllowedInBackpack").replaceAll("\\{ItemName}", "%s");
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)

View File

@ -65,8 +65,8 @@ public class Minepacks extends JavaPlugin implements MinepacksPlugin
private static final String JENKINS_URL = "https://ci.pcgamingfreaks.at", JENKINS_JOB = "Minepacks V2";
private static Minepacks instance = null;
public Config config; //TODO Make private
public Language lang; //TODO Make private
private Config config;
private Language lang;
private Database database;
public final Map<UUID, Long> cooldowns = new HashMap<>();