Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

Commit

Permalink
Code -> removed useless code + smale changes
Browse files Browse the repository at this point in the history
  • Loading branch information
EinfacheSache committed Sep 4, 2023
1 parent 0c417d5 commit f1f3d21
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import de.cubeattack.neoprotect.core.Config;
import de.cubeattack.neoprotect.core.Core;
import de.cubeattack.neoprotect.core.NeoProtectPlugin;
import de.cubeattack.neoprotect.core.Permission;
import de.cubeattack.neoprotect.core.model.Stats;
import de.cubeattack.neoprotect.core.model.debugtool.KeepAliveResponseKey;
import net.md_5.bungee.api.CommandSender;
Expand All @@ -15,7 +14,6 @@
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.protocol.packet.KeepAlive;
import org.bstats.bungeecord.Metrics;
import org.bstats.charts.SimplePie;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -27,8 +25,7 @@ public final class NeoProtectBungee extends Plugin implements NeoProtectPlugin {

@Override
public void onLoad() {
Metrics metrics = new Metrics(this, 18726);
metrics.addCustomChart(new SimplePie("language", Config::getLanguage));
new Metrics(this, 18726);
}

@Override
Expand Down Expand Up @@ -87,9 +84,9 @@ public void sendMessage(Object receiver, String text, String clickAction, String
}

@Override
public void sendAdminMessage(Permission permission, String text, String clickAction, String clickMsg, String hoverAction, String hoverMsg) {
public void sendAdminMessage(String text, String clickAction, String clickMsg, String hoverAction, String hoverMsg) {
getProxy().getPlayers().forEach(receiver -> {
if (receiver.hasPermission("neoprotect.admin") || receiver.hasPermission(permission.value))
if (receiver.hasPermission("neoprotect.admin") || receiver.hasPermission("neoprotect.notify"))
sendMessage(receiver, text, clickAction, clickMsg, hoverAction, hoverMsg);
});
}
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/de/cubeattack/neoprotect/core/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

@SuppressWarnings("unused")
public class Config {

private static String APIKey;
private static String language;
private static boolean proxyProtocol;
private static String gameShieldID;
private static String backendID;
Expand All @@ -30,7 +28,6 @@ public static void loadConfig(Core core, FileUtils config) {
fileUtils = config;

APIKey = config.getString("APIKey", "");
language = config.getString("defaultLanguage", Locale.ENGLISH.toLanguageTag());
proxyProtocol = config.getBoolean("ProxyProtocol", true);
gameShieldID = config.getString("gameshield.serverId", "");
backendID = config.getString("gameshield.backendId", "");
Expand Down Expand Up @@ -61,10 +58,6 @@ public static String getAPIKey() {
return APIKey;
}

public static String getLanguage() {
return language;
}

public static String getGameShieldID() {
return gameShieldID;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/cubeattack/neoprotect/core/Core.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Core(NeoProtectPlugin plugin) {
Config.loadConfig(this, config);

this.restAPIRequests = new RestAPIRequests(this);
this.localization = new Localization("language", Locale.forLanguageTag(Config.getLanguage()), new File("plugins/NeoProtect/languages/"));
this.localization = new Localization("language", Locale.US, new File("plugins/NeoProtect/languages/"));

VersionUtils.updateToLatestVersion(versionResult, Config.getAutoUpdaterSettings(), 10, result -> versionResult = result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public interface NeoProtectPlugin {

void sendMessage(Object receiver, String text, String clickAction, String clickMsg, String hoverAction, String hoverMsg);

void sendAdminMessage(Permission permission, String text, String clickAction, String clickMsg, String hoverAction, String hoverMsg);
void sendAdminMessage(String text, String clickAction, String clickMsg, String hoverAction, String hoverMsg);

long sendKeepAliveMessage(long id);

Expand Down
18 changes: 0 additions & 18 deletions src/main/java/de/cubeattack/neoprotect/core/Permission.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public RestAPIManager(Core core) {
}

{
client.setConnectTimeout(4, TimeUnit.SECONDS);
client.setConnectTimeout(3, TimeUnit.SECONDS);
}

protected ResponseManager request(RequestType type, RequestBody requestBody, Object... value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import de.cubeattack.neoprotect.core.Config;
import de.cubeattack.neoprotect.core.Core;
import de.cubeattack.neoprotect.core.JsonBuilder;
import de.cubeattack.neoprotect.core.Permission;
import de.cubeattack.neoprotect.core.model.Backend;
import de.cubeattack.neoprotect.core.model.Firewall;
import de.cubeattack.neoprotect.core.model.Gameshield;
Expand Down Expand Up @@ -285,7 +284,7 @@ public void run() {

if (!attackRunning[0]) {
core.warn("Gameshield ID '" + Config.getGameShieldID() + "' is under attack");
core.getPlugin().sendAdminMessage(Permission.NOTIFY, "Gameshield ID '" + Config.getGameShieldID() + "' is under attack", null, null, null, null);
core.getPlugin().sendAdminMessage("Gameshield ID '" + Config.getGameShieldID() + "' is under attack", null, null, null, null);
attackRunning[0] = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
import de.cubeattack.neoprotect.core.Config;
import de.cubeattack.neoprotect.core.Core;
import de.cubeattack.neoprotect.core.NeoProtectPlugin;
import de.cubeattack.neoprotect.core.Permission;
import de.cubeattack.neoprotect.core.model.Stats;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
Expand All @@ -24,8 +22,7 @@ public class NeoProtectSpigot extends JavaPlugin implements NeoProtectPlugin {

@Override
public void onLoad() {
Metrics metrics = new Metrics(this, 18725);
metrics.addCustomChart(new SimplePie("language", Config::getLanguage));
new Metrics(this, 18725);
}

@Override
Expand Down Expand Up @@ -86,9 +83,9 @@ public void sendMessage(Object receiver, String text, String clickAction, String
}

@Override
public void sendAdminMessage(Permission permission, String text, String clickAction, String clickMsg, String hoverAction, String hoverMsg) {
public void sendAdminMessage(String text, String clickAction, String clickMsg, String hoverAction, String hoverMsg) {
getServer().getOnlinePlayers().forEach(pp -> {
if (pp.hasPermission("neoprotect.admin") || pp.hasPermission(permission.value))
if (pp.hasPermission("neoprotect.admin") || pp.hasPermission("neoprotect.notify"))
sendMessage(pp, text, clickAction, clickMsg, hoverAction, hoverMsg);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@
import de.cubeattack.neoprotect.core.Config;
import de.cubeattack.neoprotect.core.Core;
import de.cubeattack.neoprotect.core.NeoProtectPlugin;
import de.cubeattack.neoprotect.core.Permission;
import de.cubeattack.neoprotect.core.model.Stats;
import de.cubeattack.neoprotect.core.model.debugtool.KeepAliveResponseKey;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import org.bstats.charts.SimplePie;
import org.bstats.velocity.Metrics;

import java.util.ArrayList;
Expand All @@ -42,8 +40,7 @@ public NeoProtectVelocity(ProxyServer proxy, Logger logger, Metrics.Factory metr

@Subscribe
public void onProxyInitialize(ProxyInitializeEvent event) {
Metrics metrics = metricsFactory.make(this, 18727);
metrics.addCustomChart(new SimplePie("language", Config::getLanguage));
metricsFactory.make(this, 18727);
core = new Core(this);
new Startup(this);
}
Expand Down Expand Up @@ -105,9 +102,9 @@ public void sendMessage(Object receiver, String text, String clickAction, String
}

@Override
public void sendAdminMessage(Permission permission, String text, String clickAction, String clickMsg, String hoverAction, String hoverMsg) {
public void sendAdminMessage(String text, String clickAction, String clickMsg, String hoverAction, String hoverMsg) {
getProxy().getAllPlayers().forEach(receiver -> {
if (receiver.hasPermission("neoprotect.admin") || receiver.hasPermission(permission.value))
if (receiver.hasPermission("neoprotect.admin") || receiver.hasPermission("neoprotect.notify"))
sendMessage(receiver, text, clickAction, clickMsg, hoverAction, hoverMsg);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/bungee.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ main: de.cubeattack.neoprotect.bungee.NeoProtectBungee
name: NeoProtect
version: '${project.version}:${buildNumber}'
author: CubeAttack
website: https://einfachesache.de/discord
website: https://discord.neoprotect.net/
description: A Plugin for interact with the intern NeoProtect system
1 change: 0 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Don't change anything here if you don't know what you're doing
ProxyProtocol: true # Needed to forward the player's IP through the NeoProtect Proxy
defaultLanguage: en-US # default -> en-US (Add new file to /language for more available language https://www.oracle.com/java/technologies/javase/jdk8-jre8-suported-locales.html)
gameshield:
serverId: '' # The serverID is set automatically during setup (run in-game /np setup)
backendId: '' # The backendID is set automatically during setup (run in-game /np setup)
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: NeoProtect
version: '${project.version}:${buildNumber}'
api-version: 1.13
author: CubeAttack
website: https://einfachesache.de/discord
website: https://discord.neoprotect.net/
description: A Plugin for interact with the intern NeoProtect system
commands:
neoprotect:
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/velocity-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name":"NeoProtect",
"version":"${project.version}:${buildNumber}",
"authors":["EinfacheSache"],
"url":"https://einfachesache.de/discord",
"url":"https://discord.neoprotect.net/",
"main":"de.cubeattack.neoprotect.velocity.NeoProtectVelocity",
"description":"A Plugin for interact with the intern NeoProtect system"
}

0 comments on commit f1f3d21

Please sign in to comment.