### config.yml"); - } - } catch (IOException e) { - Log.toLog(this.getClass(), e); - } - } - private void appendBenchmarks(StringBuilder content) { content.append("
```
"); - FileUtil.lines(configFile, Charset.forName("UTF-8")) - .stream().filter(line -> !line.toLowerCase().contains("pass") && !line.toLowerCase().contains("secret")) - .forEach(line -> content.append(line).append("
")); - content.append("```
### Benchmarks
```
"); try { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/pages/NetworkPage.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/pages/NetworkPage.java index 16175b197..073cafbd0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/pages/NetworkPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/pages/NetworkPage.java @@ -13,6 +13,7 @@ import com.djrapitops.plan.system.webserver.cache.PageId; import com.djrapitops.plan.system.webserver.cache.ResponseCache; import com.djrapitops.plan.system.webserver.response.pages.parts.NetworkPageContent; import com.djrapitops.plan.utilities.file.FileUtil; +import com.djrapitops.plan.utilities.html.structure.AnalysisPluginsTabContentCreator; import static com.djrapitops.plan.data.store.keys.NetworkKeys.*; @@ -51,6 +52,13 @@ public class NetworkPage implements Page { ResponseCache.loadResponse(PageId.NETWORK_CONTENT.id(), NetworkPageContent::new); placeholderReplacer.put("tabContentServers", networkPageContent.getContents()); + String[] content = AnalysisPluginsTabContentCreator.createContent(networkContainer.getUnsafe(NetworkKeys.PLAYERS_MUTATOR), null); + String nav = content[0]; + String tabs = content[1]; + + placeholderReplacer.put("navPluginsTabs", nav); + placeholderReplacer.put("tabsPlugins", tabs); + return placeholderReplacer.apply(FileUtil.getStringFromResource("web/network.html")); } catch (Exception e) { throw new ParseException(e); diff --git a/Plan/src/main/resources/bungee.yml b/Plan/src/main/resources/bungee.yml index 365f2b64d..0b1e9b6f6 100644 --- a/Plan/src/main/resources/bungee.yml +++ b/Plan/src/main/resources/bungee.yml @@ -1,4 +1,4 @@ name: Plan author: Rsl1122 main: com.djrapitops.plan.PlanBungee -version: 4.4.4 \ No newline at end of file +version: 4.4.5 \ No newline at end of file diff --git a/Plan/src/main/resources/bungeeconfig.yml b/Plan/src/main/resources/bungeeconfig.yml index 02d582993..0a659ed81 100644 --- a/Plan/src/main/resources/bungeeconfig.yml +++ b/Plan/src/main/resources/bungeeconfig.yml @@ -148,4 +148,9 @@ Servers: Example: WebServerPort: 8034 ServerName: Example - ThemeBase: Default \ No newline at end of file + ThemeBase: Default +# ----------------------------------------------------- +Plugins: + BuyCraft: + # http://help.buycraft.net/article/36-where-to-find-the-secret-key + Secret: "-" \ No newline at end of file diff --git a/Plan/src/main/resources/plugin.yml b/Plan/src/main/resources/plugin.yml index 8583e4134..55c0b3fe7 100644 --- a/Plan/src/main/resources/plugin.yml +++ b/Plan/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ name: Plan author: Rsl1122 main: com.djrapitops.plan.Plan -version: 4.4.4 +version: 4.4.5 softdepend: - EssentialsX - Towny diff --git a/Plan/src/main/resources/web/network.html b/Plan/src/main/resources/web/network.html index 77dfe6b25..869b50233 100644 --- a/Plan/src/main/resources/web/network.html +++ b/Plan/src/main/resources/web/network.html @@ -130,6 +130,15 @@ Network Players +
+ * API#addPluginDataSource uses the same method from HookHandler. + * + * @param hookH HookHandler instance for registering the data sources. + * @throws NoClassDefFoundError when the plugin class can not be found. + */ + @SuppressWarnings("ResultOfMethodCallIgnored") + public LiteBansBungeeHook(HookHandler hookH) { + super(hookH); + try { + Database.get(); + enabled = true; + } catch (NoClassDefFoundError | NoSuchFieldError | NoSuchMethodError | Exception e) { + if (Settings.DEV_MODE.isTrue()) { + Log.toLog(this.getClass(), e); + } + enabled = false; + } + } + + public void hook() throws NoClassDefFoundError { + if (enabled) { + LiteBansDatabaseQueries db = new LiteBansDatabaseQueries(getTablePrefix()); + addPluginDataSource(new LiteBansData(db)); + } + } + + private String getTablePrefix() { + String tablePrefix = "libeans_"; + try { + File litebansDataFolder = ProxyServer.getInstance().getPluginManager().getPlugin("LiteBans").getDataFolder(); + File configFile = new File(litebansDataFolder, "config.yml"); + + Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile); + tablePrefix = configuration.getString("sql.table_prefix"); + } catch (NullPointerException | IOException e) { + Logger.getLogger("Plan").log(Level.WARNING, "Could not get Litebans table prefix, using default (litebans_). " + e.toString()); + } + return tablePrefix; + } +} diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansData.java index 48cde675c..f58704be9 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansData.java @@ -44,7 +44,7 @@ public class LiteBansData extends PluginData implements BanData { public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { inspectContainer.addValue(Icon.called("balance-scale").of(Color.RED) + - "Hover over 'What' column entry for offence reasons", ""); + " Hover over 'What' column entry for offence reasons", ""); String what = getWithIcon("Effect", Icon.called("times-circle").of(Family.REGULAR)); String by = getWithIcon("By", Icon.called("gavel")); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDatabaseQueries.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDatabaseQueries.java index 3c9f90332..f11cfb0b2 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDatabaseQueries.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDatabaseQueries.java @@ -5,7 +5,6 @@ import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStat import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; import com.djrapitops.plan.system.database.databases.sql.tables.Table; import litebans.api.Database; -import org.bukkit.Bukkit; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -30,10 +29,9 @@ public class LiteBansDatabaseQueries extends Table { private final String selectSQL; - public LiteBansDatabaseQueries() { + public LiteBansDatabaseQueries(String tablePrefix) { super("litebans", null); database = Database.get(); - String tablePrefix = Bukkit.getPluginManager().getPlugin("LiteBans").getConfig().getString("sql.table_prefix"); banTable = tablePrefix + "bans"; mutesTable = tablePrefix + "mutes"; warningsTable = tablePrefix + "warnings"; diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/react/ReactDataTask.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/react/ReactDataTask.java index 7510e0c88..2a44728a2 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/react/ReactDataTask.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/react/ReactDataTask.java @@ -7,8 +7,8 @@ import com.djrapitops.plugin.task.AbsRunnable; import com.volmit.react.React; import com.volmit.react.api.GraphSampleLine; import com.volmit.react.api.SampledType; -import com.volmit.react.util.GMap; import com.volmit.react.util.M; +import com.volmit.react.volume.lang.collections.GMap; import java.util.ArrayList; import java.util.EnumMap; diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/PlayerVersionListener.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/BukkitPlayerVersionListener.java similarity index 92% rename from PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/PlayerVersionListener.java rename to PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/BukkitPlayerVersionListener.java index da82d60f8..ca41fbd7e 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/PlayerVersionListener.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/BukkitPlayerVersionListener.java @@ -24,11 +24,11 @@ import java.util.UUID; * @author Rsl1122 * @since 3.5.0 */ -public class PlayerVersionListener implements Listener { +public class BukkitPlayerVersionListener implements Listener { private ViaAPI viaAPI; - public PlayerVersionListener(ViaAPI viaAPI) { + public BukkitPlayerVersionListener(ViaAPI viaAPI) { this.viaAPI = viaAPI; } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/BungeePlayerVersionListener.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/BungeePlayerVersionListener.java new file mode 100644 index 000000000..382fedc1d --- /dev/null +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/BungeePlayerVersionListener.java @@ -0,0 +1,46 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.djrapitops.pluginbridge.plan.viaversion; + +import com.djrapitops.plan.api.exceptions.database.DBOpException; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.processing.Processing; +import com.djrapitops.plugin.api.utility.log.Log; +import net.md_5.bungee.api.event.PostLoginEvent; +import net.md_5.bungee.api.plugin.Listener; +import net.md_5.bungee.event.EventHandler; +import us.myles.ViaVersion.api.ViaAPI; + +import java.util.UUID; + +/** + * Class responsible for listening join events for Version protocol. + * + * @author Rsl1122 + * @since 3.5.0 + */ +public class BungeePlayerVersionListener implements Listener { + + private ViaAPI viaAPI; + + public BungeePlayerVersionListener(ViaAPI viaAPI) { + this.viaAPI = viaAPI; + } + + @EventHandler + public void onJoin(PostLoginEvent event) { + UUID uuid = event.getPlayer().getUniqueId(); + int playerVersion = viaAPI.getPlayerVersion(uuid); + Processing.submitNonCritical(() -> { + try { + new ProtocolTable((SQLDB) Database.getActive()).saveProtocolVersion(uuid, playerVersion); + } catch (DBOpException e) { + Log.toLog(this.getClass(), e); + } + }); + } +} diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/Protocol.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/Protocol.java index b99764fb7..a98417036 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/Protocol.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/Protocol.java @@ -25,6 +25,8 @@ public class Protocol { */ public static String getMCVersion(int protocolVersion) { switch (protocolVersion) { + case 401: + return "1.13.1"; case 390: case 391: case 392: diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionBukkitHook.java similarity index 89% rename from PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionHook.java rename to PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionBukkitHook.java index bcaaa9f12..4db2dc27e 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionHook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionBukkitHook.java @@ -16,7 +16,7 @@ import us.myles.ViaVersion.api.ViaAPI; * @author Rsl1122 * @since 3.1.0 */ -public class ViaVersionHook extends Hook { +public class ViaVersionBukkitHook extends Hook { /** * Hooks the plugin and registers it's PluginData objects. @@ -25,7 +25,7 @@ public class ViaVersionHook extends Hook { * * @param hookH HookHandler instance for registering the data sources. */ - public ViaVersionHook(HookHandler hookH) { + public ViaVersionBukkitHook(HookHandler hookH) { super("us.myles.ViaVersion.ViaVersionPlugin", hookH); } @@ -42,7 +42,7 @@ public class ViaVersionHook extends Hook { Log.toLog(this.getClass().getName(), e); return; } - plan.registerListener(new PlayerVersionListener(api)); + plan.registerListener(new BukkitPlayerVersionListener(api)); addPluginDataSource(new ViaVersionData(table)); } } \ No newline at end of file diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionBungeeHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionBungeeHook.java new file mode 100644 index 000000000..41addff02 --- /dev/null +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionBungeeHook.java @@ -0,0 +1,48 @@ +package com.djrapitops.pluginbridge.plan.viaversion; + +import com.djrapitops.plan.PlanBungee; +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.data.plugin.HookHandler; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plugin.api.utility.log.Log; +import com.djrapitops.pluginbridge.plan.Hook; +import us.myles.ViaVersion.api.Via; +import us.myles.ViaVersion.api.ViaAPI; + +/** + * A Class responsible for hooking to ViaVersion and registering data sources. + * + * @author Rsl1122 + * @since 3.1.0 + */ +public class ViaVersionBungeeHook extends Hook { + + /** + * Hooks the plugin and registers it's PluginData objects. + *
+ * API#addPluginDataSource uses the same method from HookHandler. + * + * @param hookH HookHandler instance for registering the data sources. + */ + public ViaVersionBungeeHook(HookHandler hookH) { + super("us.myles.ViaVersion.BungeePlugin", hookH); + } + + public void hook() throws NoClassDefFoundError { + if (!enabled) { + return; + } + PlanBungee plan = PlanBungee.getInstance(); + ViaAPI api = Via.getAPI(); + ProtocolTable table = new ProtocolTable((SQLDB) Database.getActive()); + try { + table.createTable(); + } catch (DBException e) { + Log.toLog(this.getClass().getName(), e); + return; + } + plan.registerListener(new BungeePlayerVersionListener(api)); + addPluginDataSource(new ViaVersionData(table)); + } +} \ No newline at end of file