fix: variable is not shared, so it's useless
This commit is contained in:
parent
a3005111c7
commit
cb8cf571b8
5 changed files with 24 additions and 16 deletions
|
@ -12,7 +12,6 @@ import java.io.IOException;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class Nicko {
|
public class Nicko {
|
||||||
private boolean bungeecord = false;
|
|
||||||
private ConfigurationManager configManager;
|
private ConfigurationManager configManager;
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
private File dataFolder;
|
private File dataFolder;
|
||||||
|
@ -24,7 +23,6 @@ public class Nicko {
|
||||||
public void initBungeecord(Plugin bungee) {
|
public void initBungeecord(Plugin bungee) {
|
||||||
logger = bungee.getLogger();
|
logger = bungee.getLogger();
|
||||||
dataFolder = bungee.getDataFolder();
|
dataFolder = bungee.getDataFolder();
|
||||||
bungeecord = true;
|
|
||||||
initNicko();
|
initNicko();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,12 +73,4 @@ public class Nicko {
|
||||||
public void setConfig(Configuration config) {
|
public void setConfig(Configuration config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBungeecord() {
|
|
||||||
return bungeecord;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBungeecord(boolean bungeecord) {
|
|
||||||
this.bungeecord = bungeecord;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
package net.artelnatif.nicko.bukkit.event;
|
package net.artelnatif.nicko.bukkit.event;
|
||||||
|
|
||||||
|
import net.artelnatif.nicko.Nicko;
|
||||||
import net.artelnatif.nicko.bukkit.NickoBukkit;
|
import net.artelnatif.nicko.bukkit.NickoBukkit;
|
||||||
import net.artelnatif.nicko.bukkit.appearance.AppearanceManager;
|
import net.artelnatif.nicko.bukkit.appearance.AppearanceManager;
|
||||||
import net.artelnatif.nicko.disguise.ActionResult;
|
import net.artelnatif.nicko.disguise.ActionResult;
|
||||||
import net.artelnatif.nicko.bukkit.i18n.I18N;
|
import net.artelnatif.nicko.bukkit.i18n.I18N;
|
||||||
import net.artelnatif.nicko.bukkit.i18n.I18NDict;
|
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.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
@ -15,12 +18,19 @@ public class PlayerJoinListener implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
final Player player = event.getPlayer();
|
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(), () -> {
|
Bukkit.getScheduler().runTaskLater(NickoBukkit.getInstance(), () -> {
|
||||||
final AppearanceManager appearanceManager = AppearanceManager.get(player);
|
final AppearanceManager appearanceManager = AppearanceManager.get(player);
|
||||||
|
|
||||||
// TODO: 12/5/22 Update from BungeeCord
|
|
||||||
|
|
||||||
if (appearanceManager.hasData()) {
|
if (appearanceManager.hasData()) {
|
||||||
final ActionResult<Void> actionResult = appearanceManager.updatePlayer(appearanceManager.needsASkinChange());
|
final ActionResult<Void> actionResult = appearanceManager.updatePlayer(appearanceManager.needsASkinChange());
|
||||||
if (!actionResult.isError()) {
|
if (!actionResult.isError()) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class SettingsGUI {
|
||||||
};
|
};
|
||||||
|
|
||||||
final Nicko nicko = NickoBukkit.getInstance().getNicko();
|
final Nicko nicko = NickoBukkit.getInstance().getNicko();
|
||||||
if (!nicko.getConfig().isBungeecord() && nicko.isBungeecord()) {
|
if (!nicko.getConfig().isBungeecord()) {
|
||||||
dynamicStructure[1] = dynamicStructure[1].replace("T", "U");
|
dynamicStructure[1] = dynamicStructure[1].replace("T", "U");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ public class NickoBungee extends Plugin {
|
||||||
getLogger().severe("Nicko can't enable BungeeCord support without SQL storage.");
|
getLogger().severe("Nicko can't enable BungeeCord support without SQL storage.");
|
||||||
getLogger().severe("The plugin will not continue.");
|
getLogger().severe("The plugin will not continue.");
|
||||||
nicko.getDataStore().getStorage().setError(true);
|
nicko.getDataStore().getStorage().setError(true);
|
||||||
nicko.setBungeecord(false);
|
|
||||||
onDisable();
|
onDisable();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class PlayerDataStore {
|
||||||
|
|
||||||
public PlayerDataStore(Nicko nicko) {
|
public PlayerDataStore(Nicko nicko) {
|
||||||
this.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) {
|
public void storeName(Player player) {
|
||||||
|
@ -43,6 +43,15 @@ public class PlayerDataStore {
|
||||||
names.clear();
|
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) {
|
public Optional<NickoProfile> getData(UUID uuid) {
|
||||||
if (storage.isError()) {
|
if (storage.isError()) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
|
Loading…
Reference in a new issue