Skip to content

Commit

Permalink
Merge pull request #8 from LewMC/1.2.0
Browse files Browse the repository at this point in the history
1.2.0
  • Loading branch information
lewmilburn authored May 26, 2024
2 parents 97b3b4a + 28cc2b0 commit d764619
Show file tree
Hide file tree
Showing 16 changed files with 843 additions and 233 deletions.
34 changes: 0 additions & 34 deletions .github/workflows/maven-publish.yml

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Java CI with Maven

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml
2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>net.lewmc</groupId>
<artifactId>kryptonite</artifactId>
<name>Kryptonite</name>
<version>1.1.2</version>
<version>1.2.0-SNAPSHOT</version>
<build>
<resources>
<resource>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>net.lewmc</groupId>
<artifactId>kryptonite</artifactId>
<version>1.1.2</version>
<version>1.2.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Kryptonite</name>
Expand Down
37 changes: 28 additions & 9 deletions src/main/java/net/lewmc/kryptonite/Kryptonite.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.lewmc.kryptonite.utils.UpdateUtil;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.util.Objects;

public final class Kryptonite extends JavaPlugin {
Expand Down Expand Up @@ -36,17 +37,26 @@ public void onEnable() {
int pluginId = 21962; // <-- Replace with the id of your plugin!
new Metrics(this, pluginId);

this.initFilesystem();
this.loadCommands();
this.checkSoftware();

this.log.info("Startup completed.");
}

private void initFilesystem() {
UpdateUtil update = new UpdateUtil(this);

this.saveDefaultConfig();

File kitsFile = new File(getDataFolder() + File.separator + "kos.yml");
if (!kitsFile.exists()) {
saveResource("kos.yml", false);
}

update.VersionCheck();
update.UpdateConfig();

loadCommands();
checkSoftware();

this.log.info("Startup completed.");
update.UpdatePatches();
}

@Override
Expand All @@ -65,18 +75,27 @@ private void loadCommands() {

private void checkSoftware() {
if (this.getServer().getName().equals("CraftBukkit")) {
this.server = Software.CRAFTBUKKIT;
} else if (this.getServer().getName().equals("Spigot")) {
this.server = Software.SPIGOT;
File f = new File("spigot.yml");
if (f.exists()) {
this.server = Software.SPIGOT;
this.log.info("Detected server jar: Spigot.");
} else {
this.server = Software.CRAFTBUKKIT;
this.log.info("Detected server jar: CraftBukkit.");
}
this.log.warn("We highly recommend using Paper, Purpur, or Pufferfish. ");
} else if (this.getServer().getName().equals("Paper")) {
this.server = Software.PAPER;
this.log.info("Detected server jar: Paper.");
} else if (this.getServer().getName().equals("Purpur")) {
this.server = Software.PURPUR;
this.log.info("Detected server jar: Purpur.");
} else if (this.getServer().getName().equals("Pufferfish")) {
this.server = Software.PUFFERFISH;
this.log.info("Detected server jar: Pufferfish.");
} else {
this.server = Software.UNKNOWN;
this.log.severe("You are not running a CraftBukkit, Spigot, or Paper server.");
this.log.info("Detected server jar: Unknown.");
this.log.severe("This plugin may not work as expected.");
}
}
Expand Down
41 changes: 25 additions & 16 deletions src/main/java/net/lewmc/kryptonite/optimiser/Bukkit.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.lewmc.kryptonite.optimiser;

import net.lewmc.kryptonite.Kryptonite;
import net.lewmc.kryptonite.utils.LogUtil;
import org.bukkit.configuration.InvalidConfigurationException;

import java.io.File;
Expand All @@ -15,35 +16,43 @@ public Bukkit(final Kryptonite plugin) {
try {
plugin.getConfig().load(this.file);
} catch (IOException | InvalidConfigurationException e) {
throw new RuntimeException(e);
LogUtil log = new LogUtil(plugin);
log.severe("Error whilst loading CraftBukkit configuration:");
log.severe(e.getMessage());
}
}

public void spawnLimits(int monsters, int animals, int waterAnimals, int waterAmbient, int waterUndergroundCreature, int axolotls, int ambient) {
this.plugin.getConfig().set("environment.spawn-limits.monsters", monsters);
this.plugin.getConfig().set("environment.spawn-limits.animals", animals);
this.plugin.getConfig().set("environment.spawn-limits.water-animals", waterAnimals);
this.plugin.getConfig().set("environment.spawn-limits.water-ambient", waterAmbient);
this.plugin.getConfig().set("environment.spawn-limits.water-underground-creature", waterUndergroundCreature);
this.plugin.getConfig().set("environment.spawn-limits.axolotls", axolotls);
this.plugin.getConfig().set("environment.spawn-limits.ambient", ambient);
this.plugin.getConfig().set("spawn-limits.monsters", monsters);
this.plugin.getConfig().set("spawn-limits.animals", animals);
this.plugin.getConfig().set("spawn-limits.water-animals", waterAnimals);
this.plugin.getConfig().set("spawn-limits.water-ambient", waterAmbient);
this.plugin.getConfig().set("spawn-limits.water-underground-creature", waterUndergroundCreature);
this.plugin.getConfig().set("spawn-limits.axolotls", axolotls);
this.plugin.getConfig().set("spawn-limits.ambient", ambient);
}

public void ticksPer(int monsters, int animals, int waterAnimals, int waterAmbient, int waterUndergroundCreature, int axolotls, int ambient) {
this.plugin.getConfig().set("environment.ticks-per.monster-spawns", monsters);
this.plugin.getConfig().set("environment.ticks-per.animal-spawns", animals);
this.plugin.getConfig().set("environment.ticks-per.water-spawns", waterAnimals);
this.plugin.getConfig().set("environment.ticks-per.water-ambient-spawns", waterAmbient);
this.plugin.getConfig().set("environment.ticks-per.water-underground-creature-spawns", waterUndergroundCreature);
this.plugin.getConfig().set("environment.ticks-per.axolotl-spawns", axolotls);
this.plugin.getConfig().set("environment.ticks-per.ambient-spawns", ambient);
this.plugin.getConfig().set("ticks-per.monster-spawns", monsters);
this.plugin.getConfig().set("ticks-per.animal-spawns", animals);
this.plugin.getConfig().set("ticks-per.water-spawns", waterAnimals);
this.plugin.getConfig().set("ticks-per.water-ambient-spawns", waterAmbient);
this.plugin.getConfig().set("ticks-per.water-underground-creature-spawns", waterUndergroundCreature);
this.plugin.getConfig().set("ticks-per.axolotl-spawns", axolotls);
this.plugin.getConfig().set("ticks-per.ambient-spawns", ambient);
}

public void chunkGcPeriodInTicks(int value) {
this.plugin.getConfig().set("chunk-gc.period-in-ticks", value);
}

public void save() {
try {
this.plugin.getConfig().save(this.file);
} catch (IOException e) {
throw new RuntimeException(e);
LogUtil log = new LogUtil(plugin);
log.severe("Error whilst saving Bukkit configuration:");
log.severe(e.getMessage());
}
}
}
Loading

0 comments on commit d764619

Please sign in to comment.