minor changes, added randomizer to get chance to have ZA

This commit is contained in:
Frizth Lyco Tatierra 2025-01-15 02:16:35 +08:00
parent 425614b45c
commit add7525674
3 changed files with 25 additions and 11 deletions

View File

@ -6,7 +6,7 @@
<groupId>net.thedawnph</groupId>
<artifactId>servercore_za</artifactId>
<version>1.1.1</version>
<version>1.1.2</version>
<packaging>jar</packaging>
<name>servercore_za</name>

View File

@ -15,6 +15,10 @@ public class StartNighttimeTask {
private final JavaPlugin plugin;
private boolean isApocalyptic = false;
public static int randomizer(int min, int max) {
return (int) ((Math.random() * (max - min)) + min);
}
public StartNighttimeTask(JavaPlugin plugin) {
this.plugin = plugin;
startScheduler();
@ -36,21 +40,22 @@ public class StartNighttimeTask {
long time = world.getTime();
// Check if it is nighttime
if (time >= 12541 && time <= 23458) {
int random = randomizer(0, 4);
if (!Bukkit.getOnlinePlayers().isEmpty() && !isApocalyptic) {
// 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);
}
long duration = 0;
if (plugin.getConfig().getInt("ZA-duration") == 0) {
if (plugin.getConfig().getInt("ZA-duration") == 0 && random == 1) {
// Start the apocalypse
apocalypseAPI.startApocalypse(
worldName, true
);
} else {
// 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,
@ -58,8 +63,17 @@ public class StartNighttimeTask {
plugin.getConfig().getInt("ZA-mobs"),
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 (random != 1) {
// send message to all players
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage("The night is quiet...");
}
}
isApocalyptic = true;
}

View File

@ -1,5 +1,5 @@
name: servercore_za
version: '1.1.1'
version: '1.1.2'
main: net.thedawnph.servercore_za.Servercore_za
api-version: '1.20'
authors: [ princepines ]