Skip to content

Commit

Permalink
Dependency updates and Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
SageSphinx63920 committed Jan 26, 2024
1 parent b7b7d86 commit 710159f
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/api-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'corretto'
server-id: github
cache: maven
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/javadocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ on:
#branches: [ main ]
workflow_dispatch:


jobs:
javadoc:
runs-on: ubuntu-latest
steps:
- name: Checkout 🙃
uses: actions/checkout@v4

- name: Set up JDK 17 🛠
- name: Set up JDK 21 🛠
uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: 'corretto'
cache: 'maven'

Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.20.1-R0.1-SNAPSHOT</version>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -228,21 +228,21 @@
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.4</version>
<version>2.11.5</version>
<scope>provided</scope>
</dependency>

<!-- Provided via custom loader -->
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.43.2.1</version>
<version>3.45.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>3.2.0</version>
<version>3.3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/de/hdg/keklist/Keklist.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ public void onLoad() {
return;
}

if(Bukkit.getServer().getMinecraftVersion().equals("1.20")) {
getLogger().severe(translations.get("paper.version.unsupported"));
Bukkit.getPluginManager().disablePlugin(this);
return;
}

//Init utilities after paper checkÏ
configUtil = new KeklistConfigUtil(this);

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/hdg/keklist/KeklistLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ 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.43.0.0"), "compile"));
resolver.addDependency(new Dependency(new DefaultArtifact("org.mariadb.jdbc:mariadb-java-client:3.2.0"), "compile"));
resolver.addDependency(new Dependency(new DefaultArtifact("org.xerial:sqlite-jdbc:3.45.0.0"), "compile"));
resolver.addDependency(new Dependency(new DefaultArtifact("org.mariadb.jdbc:mariadb-java-client:3.3.2"), "compile"));
resolver.addDependency(new Dependency(new DefaultArtifact("club.minnced:discord-webhooks:0.8.4"), "compile"));

pluginClasspathBuilder.addLibrary(resolver);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/hdg/keklist/commands/KeklistCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLab
if (args.length == 3) {
if (args[2].equalsIgnoreCase("vanilla")) {
for (OfflinePlayer player : Bukkit.getWhitelistedPlayers()) {
Bukkit.dispatchCommand(sender, "keklist whitelist add " + player.getName());
Bukkit.dispatchCommand(sender, "keklist whitelist add: " + player.getName());
}

sender.sendMessage(Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("whitelist.imported")));
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/de/hdg/keklist/database/DB.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public void connect() {
count.incrementAndGet();
} catch (SQLException | java.io.IOException ex) {
ex.printStackTrace();
Bukkit.getPluginManager().disablePlugin(plugin);
} catch (ClassNotFoundException e) {
plugin.getLogger().severe(Keklist.getTranslations().get("database.driver-missing"));
Bukkit.getPluginManager().disablePlugin(plugin);
Expand Down Expand Up @@ -114,7 +115,7 @@ public void run() {
public ResultSet onQuery(@NotNull @Language("SQL") final String query, Object... preparedArgs) {
if (isConnected()) {
try {
FutureTask<ResultSet> task = new FutureTask<>(new Callable<ResultSet>() {
FutureTask<ResultSet> task = new FutureTask<>(new Callable<>() {
PreparedStatement ps;

public ResultSet call() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.bukkit.NamespacedKey;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.block.sign.Side;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
Expand Down Expand Up @@ -50,12 +51,13 @@ public void onBlacklistClick(InventoryClickEvent event) throws SQLException {
player.getWorld().setBlockData(location, Material.DARK_OAK_SIGN.createBlockData());

Sign sign = (Sign) player.getWorld().getBlockState(location);
sign.setWaxed(false);
sign.getPersistentDataContainer().set(new NamespacedKey(Keklist.getInstance(), "blacklistMode"), PersistentDataType.STRING, "add");
sign.line(0, Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("gui.blacklist.sign.line")));
sign.line(1, Component.empty());
sign.getSide(Side.FRONT).line(0, Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("gui.blacklist.sign.line")));
sign.getSide(Side.FRONT).line(1, Component.empty());
sign.update();

Bukkit.getScheduler().runTaskLater(Keklist.getInstance(), () -> player.openSign(sign), 5);
Bukkit.getScheduler().runTaskLater(Keklist.getInstance(), () -> player.openSign(sign, Side.FRONT), 5);
}
case DARK_PRISMARINE -> {
Location location = player.getLocation();
Expand All @@ -65,12 +67,13 @@ public void onBlacklistClick(InventoryClickEvent event) throws SQLException {
player.getWorld().setBlockData(location, Material.DARK_OAK_SIGN.createBlockData());

Sign sign = (Sign) player.getWorld().getBlockState(location);
sign.setWaxed(false);
sign.getPersistentDataContainer().set(new NamespacedKey(Keklist.getInstance(), "blacklistMode"), PersistentDataType.STRING, "remove");
sign.line(0, Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("gui.blacklist.sign.line")));
sign.line(1, Component.empty());
sign.getSide(Side.FRONT).line(0, Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("gui.blacklist.sign.line")));
sign.getSide(Side.FRONT).line(1, Component.empty());
sign.update();

Bukkit.getScheduler().runTaskLater(Keklist.getInstance(), () -> player.openSign(sign), 5);
Bukkit.getScheduler().runTaskLater(Keklist.getInstance(), () -> player.openSign(sign, Side.FRONT), 5);

}
case PLAYER_HEAD -> player.openInventory(getPage(0, 0, false, false, false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.bukkit.NamespacedKey;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.block.sign.Side;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
Expand Down Expand Up @@ -50,12 +51,13 @@ public void onWhitelistClick(InventoryClickEvent event) throws SQLException {
player.getWorld().setBlockData(location, Material.SPRUCE_SIGN.createBlockData());

Sign sign = (Sign) player.getWorld().getBlockState(location);
sign.setWaxed(false);
sign.getPersistentDataContainer().set(new NamespacedKey(Keklist.getInstance(), "whitelistMode"), PersistentDataType.STRING, "add");
sign.line(0, Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("gui.whitelist.sign.line")));
sign.line(1, Component.empty());
sign.getSide(Side.FRONT).line(0, Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("gui.whitelist.sign.line")));
sign.getSide(Side.FRONT).line(1, Component.empty());
sign.update();

Bukkit.getScheduler().runTaskLater(Keklist.getInstance(), () -> player.openSign(sign), 5);
Bukkit.getScheduler().runTaskLater(Keklist.getInstance(), () -> player.openSign(sign, Side.FRONT), 5);
}
case PRISMARINE_SHARD -> {
Location location = player.getLocation();
Expand All @@ -65,12 +67,13 @@ public void onWhitelistClick(InventoryClickEvent event) throws SQLException {
player.getWorld().setBlockData(location, Material.SPRUCE_SIGN.createBlockData());

Sign sign = (Sign) player.getWorld().getBlockState(location);
sign.setWaxed(false);
sign.getPersistentDataContainer().set(new NamespacedKey(Keklist.getInstance(), "whitelistMode"), PersistentDataType.STRING, "remove");
sign.line(0, Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("gui.whitelist.sign.line")));
sign.line(1, Component.empty());
sign.getSide(Side.FRONT).line(0, Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("gui.whitelist.sign.line")));
sign.getSide(Side.FRONT).line(1, Component.empty());
sign.update();

Bukkit.getScheduler().runTaskLater(Keklist.getInstance(), () -> player.openSign(sign), 5);
Bukkit.getScheduler().runTaskLater(Keklist.getInstance(), () -> player.openSign(sign, Side.FRONT), 5);
}
case PLAYER_HEAD -> player.openInventory(getPage(0, 0, false, false));
case ARROW -> GuiManager.openMainGUI(player);
Expand Down Expand Up @@ -242,7 +245,7 @@ public static Inventory getPage(int pageIndex, int skipIndex, boolean onlyPlayer
// Next Page
if (onlyIP) {
ResultSet ips = Keklist.getDatabase().onQuery("SELECT * FROM whitelistIp");
List<ItemStack> skippedIPs = new ArrayList<>();
List<ItemStack> skippedIPs;

while (ips.next()) {
ItemStack ip = new ItemStack(Material.BOOK);
Expand Down Expand Up @@ -281,18 +284,18 @@ public static Inventory getPage(int pageIndex, int skipIndex, boolean onlyPlayer
}


// Last page must be only IPs
// The Last page must be only IPs
if (skipIndex > 18) {
previousPageMeta.getPersistentDataContainer().set(new NamespacedKey(Keklist.getInstance(), "onlyIP"), PersistentDataType.INTEGER, 1); // Workaround for missing boolean
previousPageMeta.getPersistentDataContainer().set(new NamespacedKey(Keklist.getInstance(), "skipIndex"), PersistentDataType.INTEGER, skipIndex - 18); // We must start at skipIndex - 18 for the page before
} else
previousPageMeta.getPersistentDataContainer().set(new NamespacedKey(Keklist.getInstance(), "skipIndex"), PersistentDataType.INTEGER, -1); // We must start at 0 for the page before

// NOTE : pageIndex*18 = player heads to skip if not onlyIP mode is active
// NOTE: pageIndex*18 = player heads to skip if not onlyIP mode is active
} else {
ResultSet players = Keklist.getDatabase().onQuery("SELECT * FROM whitelist");
ResultSet isIPThere = Keklist.getDatabase().onQuery("SELECT ip FROM whitelistIp LIMIT 1");
List<ItemStack> skippedHeads = new ArrayList<>();
List<ItemStack> skippedHeads;

while (players.next()) {
ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
Expand Down Expand Up @@ -372,14 +375,14 @@ public static Inventory getPage(int pageIndex, int skipIndex, boolean onlyPlayer
}
}

// Last page must be only Players
// The Last page must be only Players
if (skipIndex > 18 && onlyPlayer) {
previousPageMeta.getPersistentDataContainer().set(new NamespacedKey(Keklist.getInstance(), "onlyPlayer"), PersistentDataType.INTEGER, 1); // Workaround for missing boolean
previousPageMeta.getPersistentDataContainer().set(new NamespacedKey(Keklist.getInstance(), "skipIndex"), PersistentDataType.INTEGER, skipIndex - 18); // We must start at skipIndex - 18 for the page before
} else
previousPageMeta.getPersistentDataContainer().set(new NamespacedKey(Keklist.getInstance(), "skipIndex"), PersistentDataType.INTEGER, -1); // We must start at 0 for the page before

// NOTE : pageIndex shows if it's the first page
// NOTE: pageIndex shows if it's the first page
}


Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/lang/en-us.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"limbo.error": "No Player online to limbo player! Waiting for next event...",
"paper.required": "This plugin requires a modern version of Paper to run!",
"paper.version.unsupported": "1.20 is not supported! Please use a version newer than 1.20 and come on... 1.20 is not even supported by Paper!",
"invalid-syntax": "<red>Invalid syntax!",
"config-reloaded": "<green>Config reloaded!",
"bstats.done": "Successfully enabled bStats!",
Expand Down
10 changes: 5 additions & 5 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ cp ./target/keklist-1.0-SNAPSHOT.jar ./testserver/plugins

cd ./testserver || exit

build=$(curl -s -L "https://api.purpurmc.org/v2/purpur/1.20.1/latest/" | jq -r '.build')
build=$(curl -s -L "https://api.purpurmc.org/v2/purpur/1.20.2/latest/" | jq -r '.build')
currentVersion=$(jq -r '.currentVersion' version_history.json)

echo "Latest build: git-Purpur-$build (MC: 1.20.1)"
echo "Latest build: git-Purpur-$build (MC: 1.20.2)"
echo "Current version: $currentVersion"
# Compare the two values and output the result
if [[ "git-Purpur-$build (MC: 1.20.1)" == "$currentVersion" ]]; then
echo "The server build is up-to-date."
if [[ "git-Purpur-$build (MC: 1.20.2)" == "$currentVersion" ]]; then
echo "The server build is up to date."
else
echo "The build is out-of-date. Downloading the latest one..."
curl -L https://api.purpurmc.org/v2/purpur/1.20.1/latest/download -o server.jar
curl -L https://api.purpurmc.org/v2/purpur/1.20.2/latest/download -o server.jar
fi
java -Xms4096M -Xmx4096M --add-modules=jdk.incubator.vector -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar server.jar

0 comments on commit 710159f

Please sign in to comment.