develop-bloodmoon #10
@@ -8,9 +8,11 @@ import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.comma
|
|||||||
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.listener.BloodmoonEntityDamageListener;
|
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.listener.BloodmoonEntityDamageListener;
|
||||||
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.listener.BloodmoonMonsterDeathListener;
|
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.listener.BloodmoonMonsterDeathListener;
|
||||||
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.listener.BloodmoonPlayerJoinListener;
|
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.listener.BloodmoonPlayerJoinListener;
|
||||||
|
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.listener.BloodmoonTimeListener;
|
||||||
import net.kyori.adventure.bossbar.BossBar;
|
import net.kyori.adventure.bossbar.BossBar;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import net.kyori.adventure.text.format.TextDecoration;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -86,9 +88,11 @@ public class Bloodmoon extends Appliance {
|
|||||||
EntityType.SPIDER
|
EntityType.SPIDER
|
||||||
);
|
);
|
||||||
private @Nullable BukkitTask hordeSpawnTask = null;
|
private @Nullable BukkitTask hordeSpawnTask = null;
|
||||||
private final int bloodmoonLegth = 12000;
|
public final int bloodmoonLength = 12000;
|
||||||
|
public final int ticksPerDay = 24000;
|
||||||
|
Pupsi marked this conversation as resolved
Outdated
|
|||||||
|
private final int bloodmoonFreeDaysAtStart = 3;
|
||||||
private final int bloodmoonStartTime = 12000;
|
private final int bloodmoonStartTime = 12000;
|
||||||
private final int daysBetweenBloodmoons = 1;
|
private final int bloodmoonDayInterval = 2;
|
||||||
private final int minBonusDrops = 1;
|
private final int minBonusDrops = 1;
|
||||||
private final int maxBonusDrops = 4;
|
private final int maxBonusDrops = 4;
|
||||||
private final Map<ItemStack, Integer> bonusDropWeightMap = Map.of(
|
private final Map<ItemStack, Integer> bonusDropWeightMap = Map.of(
|
||||||
@@ -112,6 +116,20 @@ public class Bloodmoon extends Appliance {
|
|||||||
this.isActive = true;
|
this.isActive = true;
|
||||||
Bukkit.getOnlinePlayers().forEach(this::addPlayerToBossBar);
|
Bukkit.getOnlinePlayers().forEach(this::addPlayerToBossBar);
|
||||||
this.startHordeSpawning(this.getRandomHordeSpawnDelay());
|
this.startHordeSpawning(this.getRandomHordeSpawnDelay());
|
||||||
|
this.sendStartMessages();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopBloodmoon() {
|
||||||
|
this.isActive = false;
|
||||||
|
Bukkit.getOnlinePlayers().forEach(player -> player.hideBossBar(this.bossBar));
|
||||||
|
this.sendStopMessages();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStartTick(long tick) {
|
||||||
|
long day = tick / this.ticksPerDay;
|
||||||
|
if(day % this.bloodmoonDayInterval != 0 || day - this.bloodmoonFreeDaysAtStart <= 0) return false;
|
||||||
|
long time = tick - (day * this.ticksPerDay);
|
||||||
|
return time == this.bloodmoonStartTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getRandomHordeSpawnDelay() {
|
private int getRandomHordeSpawnDelay() {
|
||||||
@@ -131,11 +149,6 @@ public class Bloodmoon extends Appliance {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopBloodmoon() {
|
|
||||||
this.isActive = false;
|
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> player.hideBossBar(this.bossBar));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addPlayerToBossBar(Player player) {
|
public void addPlayerToBossBar(Player player) {
|
||||||
if(!this.getBloodmoonSetting(player)) return;
|
if(!this.getBloodmoonSetting(player)) return;
|
||||||
player.showBossBar(this.bossBar);
|
player.showBossBar(this.bossBar);
|
||||||
@@ -167,6 +180,18 @@ public class Bloodmoon extends Appliance {
|
|||||||
this.spawnHorde(player, hordeSize, hordeEntityType);
|
this.spawnHorde(player, hordeSize, hordeEntityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendWarningMessage(Player p) {
|
||||||
|
p.sendMessage(Component.text("Der Blutmond waltet in diesem Augenblick!", NamedTextColor.RED));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendAnnouncementMessages() {
|
||||||
|
this.sendMessage(Component.text("Der Blutmond naht; morgen wird er den Himmel beherrschen", NamedTextColor.GOLD));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendPreStartMessages() {
|
||||||
|
this.sendMessage(Component.text("Der Himmel ist heute Nacht ungewöhnlich düster", NamedTextColor.DARK_PURPLE));
|
||||||
|
}
|
||||||
|
|
||||||
private void spawnHorde(Player player, int size, EntityType type) {
|
private void spawnHorde(Player player, int size, EntityType type) {
|
||||||
for(int i = 0; i < size; i++) {
|
for(int i = 0; i < size; i++) {
|
||||||
double spawnRadiant = ThreadLocalRandom.current().nextDouble(0, 2*Math.PI);
|
double spawnRadiant = ThreadLocalRandom.current().nextDouble(0, 2*Math.PI);
|
||||||
@@ -201,12 +226,36 @@ public class Bloodmoon extends Appliance {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sendMessage(Component message) {
|
||||||
|
if(Bukkit.getOnlinePlayers().isEmpty()) return;
|
||||||
|
List<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers().stream()
|
||||||
|
Pupsi marked this conversation as resolved
MineTec
commented
ggf. Nullable annotation und schauen, ob nulls in der drop liste irgendwelche Probleme machen ggf. Nullable annotation und schauen, ob nulls in der drop liste irgendwelche Probleme machen
|
|||||||
|
.filter(this::getBloodmoonSetting)
|
||||||
|
.toList();
|
||||||
|
Pupsi marked this conversation as resolved
MineTec
commented
eine klassenvariable eine klassenvariable `random` würde wahrscheinlich sinn machen
|
|||||||
|
onlinePlayers.forEach(player -> player.sendMessage(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendStartMessages() {
|
||||||
|
this.sendMessage(
|
||||||
|
Component.empty()
|
||||||
|
.append(Component.text("Der Blutmond ist über uns", NamedTextColor.DARK_RED, TextDecoration.BOLD))
|
||||||
|
.appendNewline()
|
||||||
|
.append(Component.text("Erfahrung vervielfacht sich und Mobs lassen reichere Beute fallen", NamedTextColor.RED))
|
||||||
|
.appendNewline()
|
||||||
|
.append(Component.text("Mobs sind erstarkt und belegen dich mit finsteren Debuffs", NamedTextColor.RED))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendStopMessages() {
|
||||||
|
this.sendMessage(Component.text("Der Blutmond weicht...", NamedTextColor.GREEN, TextDecoration.BOLD));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected @NotNull List<Listener> listeners() {
|
protected @NotNull List<Listener> listeners() {
|
||||||
return List.of(
|
return List.of(
|
||||||
new BloodmoonMonsterDeathListener(),
|
new BloodmoonMonsterDeathListener(),
|
||||||
new BloodmoonPlayerJoinListener(),
|
new BloodmoonPlayerJoinListener(),
|
||||||
new BloodmoonEntityDamageListener()
|
new BloodmoonEntityDamageListener(),
|
||||||
|
new BloodmoonTimeListener()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,5 +10,6 @@ public class BloodmoonPlayerJoinListener extends ApplianceListener<Bloodmoon> {
|
|||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
if(!this.getAppliance().bloodmoonIsActive()) return;
|
if(!this.getAppliance().bloodmoonIsActive()) return;
|
||||||
this.getAppliance().addPlayerToBossBar(event.getPlayer());
|
this.getAppliance().addPlayerToBossBar(event.getPlayer());
|
||||||
|
this.getAppliance().sendWarningMessage(event.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.listener;
|
||||||
|
|
||||||
|
import com.destroystokyo.paper.event.server.ServerTickStartEvent;
|
||||||
|
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
|
||||||
|
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.Bloodmoon;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
|
public class BloodmoonTimeListener extends ApplianceListener<Bloodmoon> {
|
||||||
|
@EventHandler
|
||||||
|
public void onServerTick(ServerTickStartEvent event) {
|
||||||
|
if(this.getAppliance().isStartTick(Bukkit.getWorlds().getFirst().getFullTime())) {
|
||||||
|
this.getAppliance().startBloodmoon();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(this.getAppliance().isStartTick(Bukkit.getWorlds().getFirst().getFullTime() - this.getAppliance().bloodmoonLength)) {
|
||||||
|
this.getAppliance().stopBloodmoon();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(this.getAppliance().isStartTick(Bukkit.getWorlds().getFirst().getFullTime() + this.getAppliance().ticksPerDay)) {
|
||||||
|
this.getAppliance().sendAnnouncementMessages();
|
||||||
|
Pupsi marked this conversation as resolved
Outdated
MineTec
commented
kannst du das ein bisschen debouncen? sowas wie kannst du das ein bisschen debouncen?
sowas wie
`if(currentTime % 20 == 0) this.getAppliance().updateBossBar();`
|
|||||||
|
return;
|
||||||
|
}
|
||||||
|
if(this.getAppliance().isStartTick(Bukkit.getWorlds().getFirst().getFullTime() + 1000)) {
|
||||||
|
this.getAppliance().sendPreStartMessages();
|
||||||
|
}
|
||||||
|
Pupsi marked this conversation as resolved
Outdated
MineTec
commented
magic number in variable auslagern in der Appliance configmäßig magic number in variable auslagern in der Appliance configmäßig
|
|||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user
WeakHashMap implementierung verwenden