major version revision
- removed dependecy to ZombieApocalypse, instead uses ZombiesPlugin and QualityArmory (Guns) - Added Spawn Command, AboutZA - Rebased StartNighttimeTask to add zombies near player - Rebased ZombieKill for detection of isApocalypse
This commit is contained in:
parent
add7525674
commit
95c537e849
7
pom.xml
7
pom.xml
@ -72,12 +72,5 @@
|
|||||||
<version>1.21.3-R0.1-SNAPSHOT</version>
|
<version>1.21.3-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.ericdebouwer</groupId>
|
|
||||||
<artifactId>ZombieApocalypse</artifactId>
|
|
||||||
<version>1.4.11</version>
|
|
||||||
<scope>system</scope>
|
|
||||||
<systemPath>${project.basedir}/src/main/lib/ZombieApocalypse.jar</systemPath>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,7 +1,11 @@
|
|||||||
package net.thedawnph.servercore_za;
|
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.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.logging.Logger;
|
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 DisableMonsters(), this); // working in progress
|
||||||
getServer().getPluginManager().registerEvents(new OneNightSleep(), this);
|
getServer().getPluginManager().registerEvents(new OneNightSleep(), this);
|
||||||
new StartNighttimeTask(this);
|
new StartNighttimeTask(this);
|
||||||
|
// commands
|
||||||
|
Objects.requireNonNull(this.getCommand("spawn")).setExecutor(new SpawnEvent());
|
||||||
|
Objects.requireNonNull(this.getCommand("aboutza")).setExecutor(new AboutZA());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package net.thedawnph.servercore_za;
|
package net.thedawnph.servercore_za;
|
||||||
|
|
||||||
import com.ericdebouwer.zombieapocalypse.api.ApocalypseAPI;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -11,9 +10,8 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
public class StartNighttimeTask {
|
public class StartNighttimeTask {
|
||||||
|
|
||||||
private final ApocalypseAPI apocalypseAPI = ApocalypseAPI.getInstance();
|
|
||||||
private final JavaPlugin plugin;
|
private final JavaPlugin plugin;
|
||||||
private boolean isApocalyptic = false;
|
public boolean isApocalyptic = false;
|
||||||
|
|
||||||
public static int randomizer(int min, int max) {
|
public static int randomizer(int min, int max) {
|
||||||
return (int) ((Math.random() * (max - min)) + min);
|
return (int) ((Math.random() * (max - min)) + min);
|
||||||
@ -43,32 +41,28 @@ public class StartNighttimeTask {
|
|||||||
|
|
||||||
// Check if it is nighttime
|
// Check if it is nighttime
|
||||||
if (time >= 12541 && time <= 23458) {
|
if (time >= 12541 && time <= 23458) {
|
||||||
int random = randomizer(0, 4);
|
int random = randomizer(0, 2);
|
||||||
if (!Bukkit.getOnlinePlayers().isEmpty() && !isApocalyptic) {
|
if (!Bukkit.getOnlinePlayers().isEmpty() && !isApocalyptic) {
|
||||||
if (plugin.getConfig().getInt("ZA-duration") == 0 && random == 1) {
|
if (random == 1) {
|
||||||
// Start the apocalypse
|
// Start the apocalypse
|
||||||
apocalypseAPI.startApocalypse(
|
isApocalyptic = true;
|
||||||
worldName, true
|
|
||||||
);
|
|
||||||
|
|
||||||
// Play raid horn sound for all players
|
// Play raid horn sound for all players
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
player.playSound(player.getLocation(), "item.goat_horn.sound.5", 16.0f, 1.0f);
|
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()) {
|
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
|
// send message to all players
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
player.sendMessage("The night is quiet...");
|
player.sendMessage("The night is quiet...");
|
||||||
@ -79,12 +73,14 @@ public class StartNighttimeTask {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isApocalyptic) {
|
if (isApocalyptic) {
|
||||||
// End the apocalypse
|
// kill all zombies
|
||||||
apocalypseAPI.endApocalypse(worldName, true);
|
world.getEntities().stream()
|
||||||
|
.filter(entity -> entity.getType().name().equals("ZOMBIE"))
|
||||||
|
.forEach(Entity::remove);
|
||||||
|
|
||||||
// Play raid horn sound for all players
|
// Play raid horn sound for all players
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
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
|
// Remove all dropped items from the world
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package net.thedawnph.servercore_za;
|
package net.thedawnph.servercore_za;
|
||||||
|
|
||||||
import com.ericdebouwer.zombieapocalypse.api.ApocalypseAPI;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
@ -26,11 +25,9 @@ public class ZombieKill implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityDeath(EntityDeathEvent event) {
|
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 (event.getEntity().getType().equals(EntityType.ZOMBIE)) {
|
||||||
if (isApocalyptic) {
|
if (getConfig().getBoolean("zombie-drops-enabled")) {
|
||||||
event.getDrops().clear();
|
event.getDrops().clear();
|
||||||
List<String> items = getConfig().getStringList("zombie-drops");
|
List<String> items = getConfig().getStringList("zombie-drops");
|
||||||
event.getDrops().add(new ItemStack(Objects.requireNonNull(Material.getMaterial(Objects.requireNonNull(items.get(randomizer(0, items.size())))))));
|
event.getDrops().add(new ItemStack(Objects.requireNonNull(Material.getMaterial(Objects.requireNonNull(items.get(randomizer(0, items.size())))))));
|
||||||
|
|||||||
Binary file not shown.
@ -1,6 +1,6 @@
|
|||||||
worldname: "world" # Name of the world to spawn zombies in
|
worldname: "world" # Name of the world to spawn zombies in
|
||||||
ZA-duration: 7 # In minutes, default is 7 minutes (or 1 minecraft night)
|
max-zombies: 50 # Maximum amount of zombies to spawn
|
||||||
ZA-mobs: 2 # Number of mobs to spawn per chunk, default is 2, ZA-duration must be configured
|
radius: 100 # Radius around the player to spawn zombies
|
||||||
zombie-drops:
|
zombie-drops:
|
||||||
- "IRON_INGOT"
|
- "IRON_INGOT"
|
||||||
- "GOLD_INGOT"
|
- "GOLD_INGOT"
|
||||||
|
|||||||
@ -1,8 +1,15 @@
|
|||||||
name: servercore_za
|
name: servercore_za
|
||||||
version: '1.1.2'
|
version: '2.0.0'
|
||||||
main: net.thedawnph.servercore_za.Servercore_za
|
main: net.thedawnph.servercore_za.Servercore_za
|
||||||
api-version: '1.20'
|
api-version: '1.20'
|
||||||
authors: [ princepines ]
|
authors: [ princepines ]
|
||||||
description: Server Core for TheDawnPH Zombie Apocalypse
|
description: Server Core for TheDawnPH Zombie Apocalypse
|
||||||
website: https://thedawnph.net
|
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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user