diff --git a/pom.xml b/pom.xml
index ae5a257..7aa4760 100644
--- a/pom.xml
+++ b/pom.xml
@@ -72,12 +72,5 @@
1.21.3-R0.1-SNAPSHOT
provided
-
- com.ericdebouwer
- ZombieApocalypse
- 1.4.11
- system
- ${project.basedir}/src/main/lib/ZombieApocalypse.jar
-
diff --git a/src/main/java/net/thedawnph/servercore_za/Commands/AboutZA.java b/src/main/java/net/thedawnph/servercore_za/Commands/AboutZA.java
new file mode 100644
index 0000000..9c124e1
--- /dev/null
+++ b/src/main/java/net/thedawnph/servercore_za/Commands/AboutZA.java
@@ -0,0 +1,13 @@
+package net.thedawnph.servercore_za.Commands;
+
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+
+public class AboutZA implements CommandExecutor {
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ sender.sendMessage("Server Core for Zombie Apocalypse \n Developed by princepines for TheDawnPH");
+ return true;
+ }
+}
diff --git a/src/main/java/net/thedawnph/servercore_za/Commands/SpawnEvent.java b/src/main/java/net/thedawnph/servercore_za/Commands/SpawnEvent.java
new file mode 100644
index 0000000..90dcc88
--- /dev/null
+++ b/src/main/java/net/thedawnph/servercore_za/Commands/SpawnEvent.java
@@ -0,0 +1,18 @@
+package net.thedawnph.servercore_za.Commands;
+
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+public class SpawnEvent implements CommandExecutor {
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ if (sender instanceof Player player) {
+ player.teleport(player.getWorld().getSpawnLocation());
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
diff --git a/src/main/java/net/thedawnph/servercore_za/Servercore_za.java b/src/main/java/net/thedawnph/servercore_za/Servercore_za.java
index df1e5b6..4fb1864 100644
--- a/src/main/java/net/thedawnph/servercore_za/Servercore_za.java
+++ b/src/main/java/net/thedawnph/servercore_za/Servercore_za.java
@@ -1,7 +1,11 @@
package net.thedawnph.servercore_za;
+import net.thedawnph.servercore_za.Commands.AboutZA;
+import net.thedawnph.servercore_za.Commands.SpawnEvent;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
+
+import java.util.Objects;
import java.util.logging.Logger;
@@ -44,5 +48,8 @@ public final class Servercore_za extends JavaPlugin {
// getServer().getPluginManager().registerEvents(new DisableMonsters(), this); // working in progress
getServer().getPluginManager().registerEvents(new OneNightSleep(), this);
new StartNighttimeTask(this);
+ // commands
+ Objects.requireNonNull(this.getCommand("spawn")).setExecutor(new SpawnEvent());
+ Objects.requireNonNull(this.getCommand("aboutza")).setExecutor(new AboutZA());
}
}
diff --git a/src/main/java/net/thedawnph/servercore_za/StartNighttimeTask.java b/src/main/java/net/thedawnph/servercore_za/StartNighttimeTask.java
index 76af2b0..b294a19 100644
--- a/src/main/java/net/thedawnph/servercore_za/StartNighttimeTask.java
+++ b/src/main/java/net/thedawnph/servercore_za/StartNighttimeTask.java
@@ -1,6 +1,5 @@
package net.thedawnph.servercore_za;
-import com.ericdebouwer.zombieapocalypse.api.ApocalypseAPI;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Entity;
@@ -11,9 +10,8 @@ import org.bukkit.plugin.java.JavaPlugin;
public class StartNighttimeTask {
- private final ApocalypseAPI apocalypseAPI = ApocalypseAPI.getInstance();
private final JavaPlugin plugin;
- private boolean isApocalyptic = false;
+ public boolean isApocalyptic = false;
public static int randomizer(int min, int max) {
return (int) ((Math.random() * (max - min)) + min);
@@ -43,32 +41,28 @@ public class StartNighttimeTask {
// Check if it is nighttime
if (time >= 12541 && time <= 23458) {
- int random = randomizer(0, 4);
+ int random = randomizer(0, 2);
if (!Bukkit.getOnlinePlayers().isEmpty() && !isApocalyptic) {
- if (plugin.getConfig().getInt("ZA-duration") == 0 && random == 1) {
+ if (random == 1) {
// Start the apocalypse
- apocalypseAPI.startApocalypse(
- worldName, true
- );
+ isApocalyptic = true;
// Play raid horn sound for all players
for (Player player : Bukkit.getOnlinePlayers()) {
player.playSound(player.getLocation(), "item.goat_horn.sound.5", 16.0f, 1.0f);
}
- } else if (plugin.getConfig().getInt("ZA-duration") != 0 && random == 1) {
- // Start the apocalypse
- apocalypseAPI.startApocalypse(
- worldName,
- plugin.getConfig().getInt("ZA-duration"),
- plugin.getConfig().getInt("ZA-mobs"),
- true
- );
- // Play raid horn sound for all players
+ // spawn zombies around players in the world with a radius set on config
+ int radius = plugin.getConfig().getInt("zombie-radius");
+ int amount = plugin.getConfig().getInt("zombie-amount");
for (Player player : Bukkit.getOnlinePlayers()) {
- player.playSound(player.getLocation(), "item.goat_horn.sound.5", 16.0f, 1.0f);
+ for (int mobs = 0; mobs < amount; mobs++) {
+ int x = randomizer(10, radius);
+ int z = randomizer(10, radius);
+ world.spawnEntity(player.getLocation().add(x, world.getHighestBlockYAt(x, z), z), org.bukkit.entity.EntityType.ZOMBIE);
+ }
}
- } else if (random != 1) {
+ } else {
// send message to all players
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage("The night is quiet...");
@@ -79,12 +73,14 @@ public class StartNighttimeTask {
}
} else {
if (isApocalyptic) {
- // End the apocalypse
- apocalypseAPI.endApocalypse(worldName, true);
+ // kill all zombies
+ world.getEntities().stream()
+ .filter(entity -> entity.getType().name().equals("ZOMBIE"))
+ .forEach(Entity::remove);
// Play raid horn sound for all players
for (Player player : Bukkit.getOnlinePlayers()) {
- player.playSound(player.getLocation(), "item.goat_horn.sound.3", 16.0f, 1.0f);
+ player.playSound(player.getLocation(), "item.goat_horn.sound.6", 16.0f, 1.0f);
}
// Remove all dropped items from the world
diff --git a/src/main/java/net/thedawnph/servercore_za/ZombieKill.java b/src/main/java/net/thedawnph/servercore_za/ZombieKill.java
index 1356e5e..7c66e81 100644
--- a/src/main/java/net/thedawnph/servercore_za/ZombieKill.java
+++ b/src/main/java/net/thedawnph/servercore_za/ZombieKill.java
@@ -1,6 +1,5 @@
package net.thedawnph.servercore_za;
-import com.ericdebouwer.zombieapocalypse.api.ApocalypseAPI;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDeathEvent;
@@ -26,11 +25,9 @@ public class ZombieKill implements Listener {
@EventHandler
public void onEntityDeath(EntityDeathEvent event) {
- ApocalypseAPI apocalypseAPI = ApocalypseAPI.getInstance();
- boolean isApocalyptic = apocalypseAPI.isApocalypse(Objects.requireNonNull(getConfig().getString("worldname")));
if (event.getEntity().getType().equals(EntityType.ZOMBIE)) {
- if (isApocalyptic) {
+ if (getConfig().getBoolean("zombie-drops-enabled")) {
event.getDrops().clear();
List items = getConfig().getStringList("zombie-drops");
event.getDrops().add(new ItemStack(Objects.requireNonNull(Material.getMaterial(Objects.requireNonNull(items.get(randomizer(0, items.size())))))));
diff --git a/src/main/lib/ZombieApocalypse.jar b/src/main/lib/ZombieApocalypse.jar
deleted file mode 100644
index ca4416e..0000000
Binary files a/src/main/lib/ZombieApocalypse.jar and /dev/null differ
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 2960f37..6a2f4f4 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -1,6 +1,6 @@
worldname: "world" # Name of the world to spawn zombies in
-ZA-duration: 7 # In minutes, default is 7 minutes (or 1 minecraft night)
-ZA-mobs: 2 # Number of mobs to spawn per chunk, default is 2, ZA-duration must be configured
+max-zombies: 50 # Maximum amount of zombies to spawn
+radius: 100 # Radius around the player to spawn zombies
zombie-drops:
- "IRON_INGOT"
- "GOLD_INGOT"
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 27c6617..a123624 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,8 +1,15 @@
name: servercore_za
-version: '1.1.2'
+version: '2.0.0'
main: net.thedawnph.servercore_za.Servercore_za
api-version: '1.20'
authors: [ princepines ]
description: Server Core for TheDawnPH Zombie Apocalypse
website: https://thedawnph.net
-depend: [ZombieApocalypse]
+depend: [ ZombiesPlugin, QualityArmory ]
+commands:
+ spawn:
+ description: Teleport to Spawn
+ usage: /spawn
+ aboutza:
+ description: About TheDawnPH Zombie Apocalypse
+ usage: /aboutza