refactor: preparing config for massive refactor

This commit is contained in:
aro 2023-01-28 16:39:34 +01:00
parent 836bbd3f90
commit 69e2e95598
35 changed files with 49 additions and 58 deletions

View file

@ -119,7 +119,7 @@ public class NickoBukkit extends JavaPlugin {
if (config.isBungeecordSupport()) {
if (support.stopIfBungeeCordIsNotEnabled()) {
getLogger().info("Enabling BungeeCord support...");
getServer().getMessenger().registerIncomingPluginChannel(this, NickoBungee.NICKO_PLUGIN_CHANNEL_UPDATE, new PluginMessageHandler());
getServer().getMessenger().registerIncomingPluginChannel(this, NickoBungee.PROXY_UPDATE, new PluginMessageHandler());
}
}

View file

@ -3,7 +3,7 @@ package net.artelnatif.nicko.gui.items.skin;
import de.studiocode.invui.item.ItemProvider;
import de.studiocode.invui.item.builder.ItemBuilder;
import de.studiocode.invui.item.impl.BaseItem;
import net.artelnatif.nicko.anvil.AnvilManager;
import net.artelnatif.nicko.bukkit.anvil.AnvilManager;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;

View file

@ -3,7 +3,7 @@ package net.artelnatif.nicko.gui.items.skin;
import de.studiocode.invui.item.ItemProvider;
import de.studiocode.invui.item.builder.ItemBuilder;
import de.studiocode.invui.item.impl.BaseItem;
import net.artelnatif.nicko.anvil.AnvilManager;
import net.artelnatif.nicko.bukkit.anvil.AnvilManager;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;

View file

@ -3,7 +3,7 @@ package net.artelnatif.nicko.gui.items.skin;
import de.studiocode.invui.item.ItemProvider;
import de.studiocode.invui.item.builder.ItemBuilder;
import de.studiocode.invui.item.impl.BaseItem;
import net.artelnatif.nicko.anvil.AnvilManager;
import net.artelnatif.nicko.bukkit.anvil.AnvilManager;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;

View file

@ -1,25 +0,0 @@
package net.artelnatif.nicko.bungee.event;
import net.artelnatif.nicko.bungee.NickoBungee;
import net.artelnatif.nicko.bungee.pluginchannel.PluginMessageUtils;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.ServerSwitchEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
import java.util.ArrayList;
public class ServerSwitchListener implements Listener {
@EventHandler
public void onSwitch(ServerSwitchEvent event) {
final ProxiedPlayer player = event.getPlayer();
final Server server = player.getServer();
System.out.println("NickoBungee.NICKO_PLUGIN_CHANNEL_UPDATE = " + NickoBungee.NICKO_PLUGIN_CHANNEL_UPDATE);
final ArrayList<String> payload = new ArrayList<>();
payload.add(player.getUniqueId().toString());
PluginMessageUtils.sendMessage(server.getInfo(), NickoBungee.NICKO_PLUGIN_CHANNEL_UPDATE, payload);
}
}

View file

@ -6,8 +6,8 @@ import net.md_5.bungee.api.config.ServerInfo;
import java.util.ArrayList;
public class PluginMessageUtils {
public static void sendMessage(final ServerInfo info, final String channel, final ArrayList<String> payload) {
public class PluginMessageSender {
public static void send(final ServerInfo info, final String channel, final ArrayList<String> payload) {
if (info == null) { return; }
final ByteArrayDataOutput output = ByteStreams.newDataOutput();

View file

@ -1,11 +1,14 @@
package net.artelnatif.nicko.config;
import net.artelnatif.nicko.NickoBukkit;
import net.artelnatif.nicko.Nicko;
import net.artelnatif.nicko.bukkit.NickoBukkit;
import net.artelnatif.nicko.bungee.NickoBungee;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
public class NickoConfiguration {
private final NickoBukkit nicko;
private final Nicko nicko;
private String prefix;
private Boolean bungeecordSupport;
@ -14,7 +17,7 @@ public class NickoConfiguration {
private String sqlUsername, sqlPassword, sqlAddress;
public NickoConfiguration(NickoBukkit nicko) {
public NickoConfiguration(Nicko nicko) {
this.nicko = nicko;
}
@ -121,6 +124,7 @@ public class NickoConfiguration {
}
private FileConfiguration getConfig() {
return nicko.getConfig();
final YamlConfiguration configuration = new YamlConfiguration();
return ;
}
}

View file

@ -1,32 +1,44 @@
# Nicko ${project.version} - Config:
prefix: "§8[§6Nicko§8] "
# This is the Nicko configuration file.
# This file contains all the configuration for
# the Bukkit AND Bungeecord versions of Nicko.
# Nicko is smart and will only read its configuration
# section based on what it's enabled as.
# For example, if Nicko is enabled as a Bukkit plugin,
# it will only read the "Bukkit" section of the config file.
# As a result, modifying any other section is useless.
###########
# GENERAL #
###########
common:
storage:
# SQL database's address
address: "localhost"
# SQL database's username.
username: ""
# SQL database's password.
password: ""
#################
# BUKKIT/SPIGOT #
#################
bukkit:
# Nicko's messages prefix.
prefix: "§8[§6Nicko§8] "
# Indicates wherever the data will be stored
# locally through a .json file or a (My)SQL database.
local_storage: true
bungeecord:
# Enables Bungeecord support, switching through servers will transfer player's disguise.
# Accepted values: false (Disabled), true (Enabled)
enabled: false
redis:
username: ""
password: ""
# Time To Live, the time the data will be stored on a player-by-player basis.
ttl: -1
use_bungeecord: false
# Localisation:
locale:
# Nicko will copy the English locale as "lang.yml"
# and will use the translations in that file when "Server Custom"
# is selected as the player's locale.
use_custom_locale: false
storage:
# Indicates wherever the data will be stored
# locally through a .json file or a (My)SQL database.
local: true
# SQL database's address
address: "localhost"
# SQL database's username.
username: ""
# SQL database's password.
password: ""