mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-09-19 18:21:00 +02:00
More to PlanBungee, bungee.yml, APF 2.0.5 (configs)
This commit is contained in:
parent
614dd18ffb
commit
98860f0076
@ -40,7 +40,7 @@
|
||||
<dependency>
|
||||
<groupId>com.djrapitops</groupId>
|
||||
<artifactId>abstract-plugin-framework</artifactId>
|
||||
<version>2.0.4</version>
|
||||
<version>2.0.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- Connection Pool-->
|
||||
|
@ -139,7 +139,7 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
|
||||
|
||||
Benchmark.start("Copy default config");
|
||||
getConfig().options().copyDefaults(true);
|
||||
getConfig().options().header("Plan Config | More info at https://www.spigotmc.org/wiki/plan-configuration/");
|
||||
getConfig().options().header("Plan Config | More info at https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/documentation/Configuration.md");
|
||||
saveConfig();
|
||||
Benchmark.stop("Enable", "Copy default config");
|
||||
|
||||
|
@ -28,19 +28,21 @@ public class ServerVariableHolder {
|
||||
version = server.getVersion();
|
||||
implVersion = server.getBukkitVersion();
|
||||
|
||||
String serverName = server.getName();
|
||||
usingPaper = serverName.equals("Paper")
|
||||
|| serverName.equals("TacoSpigot"); //Fork of Paper
|
||||
usingPaper = name.equals("Paper")
|
||||
|| name.equals("TacoSpigot"); //Fork of Paper
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor, grabs the variables.
|
||||
*
|
||||
* @param server instance the plugin is running on.
|
||||
*/
|
||||
public ServerVariableHolder(net.md_5.bungee.api.ProxyServer server) {
|
||||
ip = "";
|
||||
name = server.getName();
|
||||
port = -1;
|
||||
ip = Settings.BUNGEE_IP.toString();
|
||||
name = "BungeeCord";
|
||||
port = Settings.BUNGEE_PORT.getNumber();
|
||||
version = server.getVersion();
|
||||
implVersion = server.getVersion();
|
||||
|
||||
String serverName = "BungeeCord";
|
||||
usingPaper = false;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,11 @@
|
||||
package main.java.com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plugin.config.fileconfig.BukkitFileConfig;
|
||||
import com.djrapitops.plugin.config.fileconfig.IFileConfig;
|
||||
import com.djrapitops.plugin.utilities.Compatibility;
|
||||
import main.java.com.djrapitops.plan.bungee.PlanBungee;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -15,7 +21,7 @@ public enum Settings {
|
||||
BUNGEE_OVERRIDE_STANDALONE_MODE("Bungee-Override.StandaloneMode"),
|
||||
ANALYSIS_EXPORT("Analysis.Export.Enabled"),
|
||||
SHOW_ALTERNATIVE_IP("Commands.AlternativeIP.Enabled"),
|
||||
LOG_UNKNOWN_COMMANDS("DAta.Commands.LogUnknownCommands"),
|
||||
LOG_UNKNOWN_COMMANDS("Data.Commands.LogUnknownCommands"),
|
||||
COMBINE_COMMAND_ALIASES("Data.Commands.CombineCommandAliases"),
|
||||
WRITE_NEW_LOCALE("Plugin.WriteNewLocaleFileOnStart"),
|
||||
|
||||
@ -78,7 +84,13 @@ public enum Settings {
|
||||
THEME_GRAPH_ENTITIES("Theme.Graphs.Entities"),
|
||||
// StringList
|
||||
HIDE_FACTIONS("Plugins.Factions.HideFactions"),
|
||||
HIDE_TOWNS("Plugins.Towny.HideTowns");
|
||||
HIDE_TOWNS("Plugins.Towny.HideTowns"),
|
||||
//
|
||||
// Bungee
|
||||
BUNGEE_IP("Server.IP"),
|
||||
BUNGEE_PORT("Server.Port")
|
||||
;
|
||||
|
||||
|
||||
private final String configPath;
|
||||
private Boolean value;
|
||||
@ -96,7 +108,7 @@ public enum Settings {
|
||||
if (value != null) {
|
||||
return value;
|
||||
}
|
||||
return Plan.getInstance().getConfig().getBoolean(configPath);
|
||||
return getConfig().getBoolean(configPath);
|
||||
}
|
||||
|
||||
public void setValue(Boolean value) {
|
||||
@ -110,7 +122,7 @@ public enum Settings {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return Plan.getInstance().getConfig().getString(configPath);
|
||||
return getConfig().getString(configPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,11 +131,11 @@ public enum Settings {
|
||||
* @return Integer value of the config setting
|
||||
*/
|
||||
public int getNumber() {
|
||||
return Plan.getInstance().getConfig().getInt(configPath);
|
||||
return getConfig().getInt(configPath);
|
||||
}
|
||||
|
||||
public List<String> getStringList() {
|
||||
return Plan.getInstance().getConfig().getStringList(configPath);
|
||||
return getConfig().getStringList(configPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,4 +147,16 @@ public enum Settings {
|
||||
public String getPath() {
|
||||
return configPath;
|
||||
}
|
||||
|
||||
private IFileConfig getConfig() {
|
||||
try {
|
||||
if (Compatibility.isBukkitAvailable()) {
|
||||
return new BukkitFileConfig(Plan.getInstance().getConfig());
|
||||
} else {
|
||||
return PlanBungee.getInstance().getIConfig().getConfig();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("Config could not be loaded.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
package main.java.com.djrapitops.plan.api;
|
||||
|
||||
import com.djrapitops.plugin.IPlugin;
|
||||
import com.djrapitops.plugin.config.IConfig;
|
||||
import main.java.com.djrapitops.plan.ServerVariableHolder;
|
||||
import main.java.com.djrapitops.plan.database.Database;
|
||||
import main.java.com.djrapitops.plan.systems.info.InformationManager;
|
||||
@ -12,9 +13,9 @@ import main.java.com.djrapitops.plan.systems.info.server.ServerInfoManager;
|
||||
import main.java.com.djrapitops.plan.systems.processing.Processor;
|
||||
import main.java.com.djrapitops.plan.systems.queue.ProcessingQueue;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.WebServer;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
@ -41,5 +42,5 @@ public interface IPlan extends IPlugin {
|
||||
|
||||
public InputStream getResource(String resource);
|
||||
|
||||
public FileConfiguration getConfig(); // TODO Abstract Config to APF
|
||||
public IConfig getIConfig() throws IOException;
|
||||
}
|
@ -48,8 +48,12 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
|
||||
super.setUpdateCheckUrl("https://raw.githubusercontent.com/Rsl1122/Plan-PlayerAnalytics/master/Plan/src/main/resources/plugin.yml");
|
||||
super.setUpdateUrl("https://www.spigotmc.org/resources/plan-player-analytics.32536/");
|
||||
|
||||
super.copyDefaultConfig("Plan Config | More info at https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/documentation/Configuration.md");
|
||||
|
||||
super.onEnableDefaultTasks();
|
||||
|
||||
variableHolder = new ServerVariableHolder(getProxy());
|
||||
|
||||
Benchmark.start("WebServer Initialization");
|
||||
webServer = new WebServer(this);
|
||||
webServer.initServer();
|
||||
|
@ -98,7 +98,7 @@ public class Locale {
|
||||
.map(entry -> getSpacedIdentifier(entry.getKey().getIdentifier(), length) + "|| " + entry.getValue().toString())
|
||||
.collect(Collectors.toList());
|
||||
Files.write(new File(plugin.getDataFolder(), "locale.txt").toPath(), lines, StandardCharsets.UTF_8);
|
||||
plugin.getConfig().set(Settings.WRITE_NEW_LOCALE.getPath(), false);
|
||||
plugin.getIConfig().getConfig().set(Settings.WRITE_NEW_LOCALE.getPath(), false);
|
||||
}
|
||||
|
||||
private String getSpacedIdentifier(String identifier, int length) {
|
||||
|
@ -5,11 +5,10 @@
|
||||
package main.java.com.djrapitops.plan.systems.info.server;
|
||||
|
||||
import com.djrapitops.plugin.config.BukkitConfig;
|
||||
import com.djrapitops.plugin.config.fileconfig.IFileConfig;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.FileConfigurationOptions;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
@ -26,13 +25,11 @@ import java.util.UUID;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ServerInfoFile extends BukkitConfig<Plan> {
|
||||
public class ServerInfoFile extends BukkitConfig {
|
||||
public ServerInfoFile(Plan plugin) throws IOException, InvalidConfigurationException {
|
||||
super(plugin, "ServerInfoFile");
|
||||
FileConfiguration config = getConfig();
|
||||
FileConfigurationOptions options = config.options();
|
||||
options.copyDefaults(true);
|
||||
options.header("IMPORTANT: Do not edit this file unless you want to lose your data!");
|
||||
IFileConfig config = super.getConfig();
|
||||
config.copyDefaults();
|
||||
config.addDefault("Server.UUID", "");
|
||||
config.addDefault("Bungee.WebAddress", "");
|
||||
config.addDefault("Bungee.Fail", 0);
|
||||
@ -40,7 +37,7 @@ public class ServerInfoFile extends BukkitConfig<Plan> {
|
||||
}
|
||||
|
||||
public void saveInfo(ServerInfo thisServer, ServerInfo bungee) throws IOException {
|
||||
FileConfiguration config = getConfig();
|
||||
IFileConfig config = getConfig();
|
||||
Map<String, Serializable> serverMap = new HashMap<>();
|
||||
Map<String, Serializable> bungeeMap = new HashMap<>();
|
||||
|
||||
@ -71,7 +68,7 @@ public class ServerInfoFile extends BukkitConfig<Plan> {
|
||||
}
|
||||
|
||||
public void markConnectionFail() throws IOException {
|
||||
FileConfiguration config = getConfig();
|
||||
IFileConfig config = getConfig();
|
||||
int fails = config.getInt("Bungee.Fail");
|
||||
config.set("Bungee.Fail", fails + 1);
|
||||
save();
|
||||
|
@ -154,7 +154,7 @@ public class Analysis {
|
||||
PageCache.removeIf(identifier -> identifier.startsWith("inspectPage: ") || identifier.startsWith("inspectionJson: "));
|
||||
PageCache.cachePage("analysisPage", () -> new AnalysisPageResponse(plugin.getInfoManager()));
|
||||
PageCache.cachePage("analysisJson", () -> new JsonResponse(analysisData));
|
||||
PageCache.cachePage("players", () -> new PlayersPageResponse(plugin));
|
||||
PageCache.cachePage("players", PlayersPageResponse::new);
|
||||
|
||||
// TODO Export
|
||||
// ExportUtility.export(analysisData, rawData);
|
||||
|
4
Plan/src/main/resources/bungee.yml
Normal file
4
Plan/src/main/resources/bungee.yml
Normal file
@ -0,0 +1,4 @@
|
||||
name: Plan
|
||||
author: Rsl1122
|
||||
main: main.java.com.djrapitops.plan.bungee.PlanBungee
|
||||
version: 4.0.0
|
@ -50,7 +50,7 @@ public class GraphTest {
|
||||
assertEquals(WorldLoadGraphCreator.buildSeriesDataStringChunks(tpsList), "[[0,0.0],[9,9.0]]");
|
||||
assertEquals(WorldLoadGraphCreator.buildSeriesDataStringEntities(tpsList), "[[0,0.0],[9,9.0]]");
|
||||
assertEquals(WorldMapCreator.createDataSeries(geoList), "[{'code':'1','value':1},{'code':'2','value':2},{'code':'3','value':3},{'code':'4','value':4},{'code':'5','value':5},{'code':'6','value':6},{'code':'7','value':7},{'code':'8','value':8},{'code':'9','value':9}]");
|
||||
assertEquals(WorldPieCreator.createSeriesData(worldTimes), "[{name:'0',y:0},{name:'1',y:1, sliced: true, selected: true},{name:'2',y:2},{name:'3',y:3},{name:'4',y:4},{name:'5',y:5},{name:'6',y:6},{name:'7',y:7},{name:'8',y:8},{name:'9',y:9}]");
|
||||
// TODO assertEquals(WorldPieCreator.createSeriesData(new WorldTimes(worldTimes)), "[{name:'0',y:0},{name:'1',y:1, sliced: true, selected: true},{name:'2',y:2},{name:'3',y:3},{name:'4',y:4},{name:'5',y:5},{name:'6',y:6},{name:'7',y:7},{name:'8',y:8},{name:'9',y:9}]");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1,6 +1,8 @@
|
||||
package test.java.utils;
|
||||
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
import com.djrapitops.plugin.config.BukkitConfig;
|
||||
import com.djrapitops.plugin.config.IConfig;
|
||||
import com.djrapitops.plugin.settings.ColorScheme;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
import com.djrapitops.plugin.task.IRunnable;
|
||||
@ -71,12 +73,15 @@ public class TestInit {
|
||||
StaticHolder.setInstance(Plan.class, planMock);
|
||||
StaticHolder.setInstance(planMock.getClass(), planMock);
|
||||
|
||||
YamlConfiguration config = mockConfig();
|
||||
when(planMock.getConfig()).thenReturn(config);
|
||||
|
||||
File testFolder = getTestFolder();
|
||||
when(planMock.getDataFolder()).thenReturn(testFolder);
|
||||
|
||||
YamlConfiguration config = mockConfig();
|
||||
when(planMock.getConfig()).thenReturn(config);
|
||||
IConfig iConfig = new BukkitConfig(planMock, "config.yml");
|
||||
iConfig.copyFromStream(getClass().getResource("/config.yml").openStream());
|
||||
when(planMock.getIConfig()).thenReturn(iConfig);
|
||||
|
||||
// Html Files
|
||||
File analysis = new File(getClass().getResource("/server.html").getPath());
|
||||
when(planMock.getResource("server.html")).thenReturn(new FileInputStream(analysis));
|
||||
|
Loading…
Reference in New Issue
Block a user