Skip to content

Commit

Permalink
Fix #47 and now using own maven repo
Browse files Browse the repository at this point in the history
  • Loading branch information
SageSphinx63920 committed Aug 30, 2023
1 parent 3e0a519 commit d58ed3b
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 31 deletions.
16 changes: 12 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
</scm>

<distributionManagement>
<repository>
<!--repository>
<id>github</id>
<name>GitHub Simpcity Apache Maven Packages</name>
<url>https://maven.pkg.github.com/Simpig-city/Keklist</url>
</repository>
</repository-->

<!--repository>
<repository>
<id>keklist-releases</id>
<name>Keklist release versions</name>
<url>https://repo.sageee.xyz/releases</url>
Expand All @@ -58,7 +58,7 @@
<id>keklist-snapshots</id>
<name>Keklist snapshot versions</name>
<url>https://repo.sageee.xyz/snapshots</url>
</snapshotRepository-->
</snapshotRepository>
</distributionManagement>
<issueManagement>
<system>Github</system>
Expand All @@ -79,6 +79,14 @@
<release>${java.version}</release>
<source>${java.version}</source>
<target>${java.version}</target>

<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.28</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
Expand Down
2 changes: 1 addition & 1 deletion settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
http://maven.apache.org/xsd/settings-1.0.0.xsd">

<activeProfiles>
<activeProfile>github</activeProfile>
<activeProfile>own</activeProfile>
</activeProfiles>

<profiles>
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/de/hdg/keklist/Keklist.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import com.google.gson.JsonPrimitive;
import de.hdg.keklist.api.KeklistAPI;
import de.hdg.keklist.api.KeklistChannelListener;
import de.hdg.keklist.commands.Blacklist;
import de.hdg.keklist.commands.BlacklistCommand;
import de.hdg.keklist.commands.KeklistCommand;
import de.hdg.keklist.commands.Whitelist;
import de.hdg.keklist.commands.WhitelistCommand;
import de.hdg.keklist.database.DB;
import de.hdg.keklist.events.BlacklistRemoveMotd;
import de.hdg.keklist.events.ListPingEvent;
Expand Down Expand Up @@ -116,8 +116,8 @@ public void onLoad() {

@Override
public void onEnable() {
registerCommand(new Whitelist());
registerCommand(new Blacklist());
registerCommand(new WhitelistCommand());
registerCommand(new BlacklistCommand());

// Manage commands are handled in the command itself
registerCommand(new KeklistCommand());
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/de/hdg/keklist/KeklistLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public void classloader(@NotNull PluginClasspathBuilder pluginClasspathBuilder)
resolver.addRepository(new RemoteRepository.Builder("maven", "default", "https://repo.maven.apache.org/maven2").build());

resolver.addDependency(new Dependency(new DefaultArtifact("com.squareup.okhttp3:okhttp:5.0.0-alpha.11"), "compile"));
resolver.addDependency(new Dependency(new DefaultArtifact("org.xerial:sqlite-jdbc:3.42.0.0"), "compile"));
resolver.addDependency(new Dependency(new DefaultArtifact("org.mariadb.jdbc:mariadb-java-client:3.1.2"), "compile"));
resolver.addDependency(new Dependency(new DefaultArtifact("club.minnced:discord-webhooks:0.8.2"), "compile"));
resolver.addDependency(new Dependency(new DefaultArtifact("org.xerial:sqlite-jdbc:3.42.0.1"), "compile"));
resolver.addDependency(new Dependency(new DefaultArtifact("org.mariadb.jdbc:mariadb-java-client:3.2.0"), "compile"));
resolver.addDependency(new Dependency(new DefaultArtifact("club.minnced:discord-webhooks:0.8.4"), "compile"));

pluginClasspathBuilder.addLibrary(resolver);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
import java.text.SimpleDateFormat;
import java.util.*;

public class Blacklist extends Command {
public class BlacklistCommand extends Command {

private static final OkHttpClient client = new OkHttpClient();
private static final Gson gson = new GsonBuilder().setPrettyPrinting().setLenient().create();
private static final TypeToken<Map<String, String>> token = new TypeToken<>() {
};

public Blacklist() {
public BlacklistCommand() {
super("blacklist");
setAliases(List.of("bl"));
setUsage(Keklist.getTranslations().get("blacklist.usage"));
Expand Down
30 changes: 22 additions & 8 deletions src/main/java/de/hdg/keklist/commands/KeklistCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLab
try {
Keklist.getInstance().getConfig().save(new File(Keklist.getInstance().getDataFolder(), "config.yml"));
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.hasPermission("keklist.manage")) {
if (player.hasPermission("keklist.manage.blacklist")) {
player.sendMessage(Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("blacklist.enabled")));
}
}

Bukkit.getConsoleSender().sendMessage(Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("blacklist.enabled")));
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand All @@ -60,10 +62,12 @@ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLab
try {
Keklist.getInstance().getConfig().save(new File(Keklist.getInstance().getDataFolder(), "config.yml"));
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.hasPermission("keklist.manage")) {
if (player.hasPermission("keklist.manage.blacklist")) {
player.sendMessage(Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("blacklist.disabled")));
}
}

Bukkit.getConsoleSender().sendMessage(Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("blacklist.disabled")));
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand All @@ -78,10 +82,12 @@ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLab
try {
Keklist.getInstance().getConfig().save(new File(Keklist.getInstance().getDataFolder(), "config.yml"));
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.hasPermission("keklist.manage")) {
if (player.hasPermission("keklist.manage.blacklist")) {
player.sendMessage(Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("blacklist.allow-blacklisted")));
}
}

Bukkit.getConsoleSender().sendMessage(Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("blacklist.allow-blacklisted")));
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand All @@ -96,10 +102,12 @@ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLab
try {
Keklist.getInstance().getConfig().save(new File(Keklist.getInstance().getDataFolder(), "config.yml"));
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.hasPermission("keklist.manage")) {
if (player.hasPermission("keklist.manage.blacklist")) {
player.sendMessage(Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("blacklist.disallow-blacklisted")));
}
}

Bukkit.getConsoleSender().sendMessage(Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("blacklist.disallow-blacklisted")));
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand All @@ -112,7 +120,8 @@ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLab
sender.sendMessage(Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("keklist.usage.command")));
}
}
}
} else
sender.sendMessage(Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("keklist.manage.disabled")));
}

case "whitelist" -> {
Expand Down Expand Up @@ -143,10 +152,12 @@ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLab
try {
Keklist.getInstance().getConfig().save(new File(Keklist.getInstance().getDataFolder(), "config.yml"));
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.hasPermission("keklist.manage")) {
if (player.hasPermission("keklist.manage.whitelist")) {
player.sendMessage(Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("whitelist.enabled")));
}
}

Bukkit.getConsoleSender().sendMessage(Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("whitelist.enabled")));
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand All @@ -161,10 +172,12 @@ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLab
try {
Keklist.getInstance().getConfig().save(new File(Keklist.getInstance().getDataFolder(), "config.yml"));
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.hasPermission("keklist.manage")) {
if (player.hasPermission("keklist.manage.whitelist")) {
player.sendMessage(Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("whitelist.disabled")));
}
}

Bukkit.getConsoleSender().sendMessage(Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("whitelist.disabled")));
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand All @@ -176,7 +189,8 @@ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLab
default ->
sender.sendMessage(Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("keklist.usage.command")));
}
}
} else
sender.sendMessage(Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("keklist.manage.disabled")));
}

default ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
import java.text.SimpleDateFormat;
import java.util.*;

public class Whitelist extends Command {
public class WhitelistCommand extends Command {

private static final OkHttpClient client = new OkHttpClient();
private static final Gson gson = new GsonBuilder().setPrettyPrinting().setLenient().create();
private static final TypeToken<Map<String, String>> token = new TypeToken<>() {
};

public Whitelist() {
public WhitelistCommand() {
super("whitelist");
setDescription(Keklist.getTranslations().get("whitelist.description"));
setAliases(List.of("wl"));
Expand Down Expand Up @@ -85,7 +85,7 @@ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLab

if (type.equals(WhiteListType.JAVA)) {
Request request = new Request.Builder().url("https://api.mojang.com/users/profiles/minecraft/" + args[1]).build();
client.newCall(request).enqueue(new Whitelist.UserWhitelistAddCallback(sender));
client.newCall(request).enqueue(new WhitelistCommand.UserWhitelistAddCallback(sender));
} else if (type.equals(WhiteListType.IPv4) || type.equals(WhiteListType.IPv6)) {
ResultSet rs = Keklist.getDatabase().onQuery("SELECT * FROM whitelistIp WHERE ip = ?", args[1]);

Expand Down Expand Up @@ -171,15 +171,15 @@ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLab
return false;
}

if (type.equals(Whitelist.WhiteListType.IPv4) || type.equals(Whitelist.WhiteListType.IPv6)) {
if (type.equals(WhitelistCommand.WhiteListType.IPv4) || type.equals(WhitelistCommand.WhiteListType.IPv6)) {
ResultSet rs = Keklist.getDatabase().onQuery("SELECT * FROM whitelistIp WHERE ip = ?", args[1]);

if (rs.next()) {
sendInfo(rs, sender, args[1]);
} else
sender.sendMessage(Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("blacklist.not-blacklisted", args[1])));

} else if (type.equals(Whitelist.WhiteListType.JAVA) || type.equals(Whitelist.WhiteListType.BEDROCK)) {
} else if (type.equals(WhitelistCommand.WhiteListType.JAVA) || type.equals(WhitelistCommand.WhiteListType.BEDROCK)) {
ResultSet rs = Keklist.getDatabase().onQuery("SELECT * FROM whitelist WHERE name = ?", args[1]);

if (rs.next()) {
Expand Down
9 changes: 5 additions & 4 deletions src/main/resources/assets/lang/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
"blacklist.motd.syntax": "<red>Invalid syntax! Please use: /blacklist motd <IPv4>",
"blacklist.already-blacklisted": "<white>%s <red>is already blacklisted!",
"blacklist.not-blacklisted": "<white>%s <red>is not blacklisted!",
"blacklist.enabled": "<green>Blacklist is now enabled!",
"blacklist.enabled": "<green>Blacklist is now <dark_green>enabled!",
"blacklist.already-enabled": "<red>Blacklist is already enabled!",
"blacklist.disabled": "<green>Blacklist is now disabled!",
"blacklist.disabled": "<green>Blacklist is now <red>disabled!",
"blacklist.already-disabled": "<red>Blacklist is already disabled!",
"blacklist.allow-blacklisted": "<green>Blacklisted players are now allowed to join with an admin online!",
"blacklist.already-allow-blacklisted": "<red>Blacklisted players are already allowed to join with an admin online!",
Expand All @@ -76,9 +76,9 @@
"whitelist.removed": "<green>Successfully removed <white>%s <green>from the whitelist!",
"whitelist.already-whitelisted": "<white>%s <red>is already whitelisted!",
"whitelist.not-whitelisted": "<white>%s <red>is not whitelisted!",
"whitelist.enabled": "<green>Whitelist is now enabled!",
"whitelist.enabled": "<green>Whitelist is now <dark_green>enabled!",
"whitelist.already-enabled": "<red>Whitelist is already enabled!",
"whitelist.disabled": "<green>Whitelist is now disabled!",
"whitelist.disabled": "<green>Whitelist is now <red>disabled!",
"whitelist.already-disabled": "<red>Whitelist is already disabled!",
"whitelist.info": "<gray><b><u>Whitelist Info",
"whitelist.info.entry": "<gold>Entry: <white>%s",
Expand Down Expand Up @@ -220,6 +220,7 @@
"keklist.usage": "/keklist <blacklist/whitelist/reload> [feature/enable/disable]",
"keklist.usage.command": "Please use: /keklist <blacklist/whitelist/reload> [feature/enable/disable]",
"keklist.description": "Command to manage the Keklist plugin features.",
"keklist.manage.disabled": "<red>This command is disabled due to security reasons! <grey><i>This can be enabled in the config.",

"http.error": "<red>Could not connect to the Mojang-API!",
"http.not-found": "<red>Could not find the player! More information: %s",
Expand Down

0 comments on commit d58ed3b

Please sign in to comment.