fix: variable is not shared, so it's useless

This commit is contained in:
aro 2023-02-07 16:00:35 +01:00
parent a3005111c7
commit cb8cf571b8
5 changed files with 24 additions and 16 deletions

View file

@ -12,7 +12,6 @@ import java.io.IOException;
import java.util.logging.Logger;
public class Nicko {
private boolean bungeecord = false;
private ConfigurationManager configManager;
private Logger logger;
private File dataFolder;
@ -24,7 +23,6 @@ public class Nicko {
public void initBungeecord(Plugin bungee) {
logger = bungee.getLogger();
dataFolder = bungee.getDataFolder();
bungeecord = true;
initNicko();
}
@ -75,12 +73,4 @@ public class Nicko {
public void setConfig(Configuration config) {
this.config = config;
}
public boolean isBungeecord() {
return bungeecord;
}
public void setBungeecord(boolean bungeecord) {
this.bungeecord = bungeecord;
}
}

View file

@ -1,10 +1,13 @@
package net.artelnatif.nicko.bukkit.event;
import net.artelnatif.nicko.Nicko;
import net.artelnatif.nicko.bukkit.NickoBukkit;
import net.artelnatif.nicko.bukkit.appearance.AppearanceManager;
import net.artelnatif.nicko.disguise.ActionResult;
import net.artelnatif.nicko.bukkit.i18n.I18N;
import net.artelnatif.nicko.bukkit.i18n.I18NDict;
import net.artelnatif.nicko.disguise.NickoProfile;
import net.artelnatif.nicko.storage.PlayerDataStore;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -15,12 +18,19 @@ public class PlayerJoinListener implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
final Player player = event.getPlayer();
NickoBukkit.getInstance().getNicko().getDataStore().storeName(player);
final Nicko nicko = NickoBukkit.getInstance().getNicko();
final PlayerDataStore dataStore = nicko.getDataStore();
dataStore.storeName(player);
if (nicko.getConfig().isBungeecord()) {
}
dataStore.performProfileUpdate(player.getUniqueId(), NickoProfile.EMPTY_PROFILE);
Bukkit.getScheduler().runTaskLater(NickoBukkit.getInstance(), () -> {
final AppearanceManager appearanceManager = AppearanceManager.get(player);
// TODO: 12/5/22 Update from BungeeCord
if (appearanceManager.hasData()) {
final ActionResult<Void> actionResult = appearanceManager.updatePlayer(appearanceManager.needsASkinChange());
if (!actionResult.isError()) {

View file

@ -24,7 +24,7 @@ public class SettingsGUI {
};
final Nicko nicko = NickoBukkit.getInstance().getNicko();
if (!nicko.getConfig().isBungeecord() && nicko.isBungeecord()) {
if (!nicko.getConfig().isBungeecord()) {
dynamicStructure[1] = dynamicStructure[1].replace("T", "U");
}

View file

@ -26,7 +26,6 @@ public class NickoBungee extends Plugin {
getLogger().severe("Nicko can't enable BungeeCord support without SQL storage.");
getLogger().severe("The plugin will not continue.");
nicko.getDataStore().getStorage().setError(true);
nicko.setBungeecord(false);
onDisable();
return;
}

View file

@ -22,7 +22,7 @@ public class PlayerDataStore {
public PlayerDataStore(Nicko nicko) {
this.nicko = nicko;
this.storage = nicko.getConfig().isLocal() && !nicko.isBungeecord() ? new JSONStorage(nicko) : new SQLStorage(nicko);
this.storage = nicko.getConfig().isLocal() && !nicko.getConfig().isBungeecord() ? new JSONStorage(nicko) : new SQLStorage(nicko);
}
public void storeName(Player player) {
@ -43,6 +43,15 @@ public class PlayerDataStore {
names.clear();
}
public void performProfileUpdate(UUID uuid, NickoProfile profile) {
if (!profiles.containsKey(uuid)) {
profiles.put(uuid, profile);
return;
}
profiles.replace(uuid, profile);
}
public Optional<NickoProfile> getData(UUID uuid) {
if (storage.isError()) {
return Optional.empty();