develop-bloodmoon #10
@@ -33,43 +33,43 @@ import java.util.concurrent.ThreadLocalRandom;
|
|||||||
|
|
||||||
@SuppressWarnings("FieldCanBeLocal")
|
@SuppressWarnings("FieldCanBeLocal")
|
||||||
public class Bloodmoon extends Appliance {
|
public class Bloodmoon extends Appliance {
|
||||||
// für alle Dimensionen? einstellbar machen?
|
public final Map<EntityType, Set<MobEffect>> affectedMobEffectMap = Map.ofEntries(
|
||||||
|
Map.entry(EntityType.ZOMBIE, Set.of(
|
||||||
public final Map<EntityType, Set<MobEffect>> affectedMobEffectMap = Map.of(
|
|
||||||
EntityType.ZOMBIE, Set.of(
|
|
||||||
new MobEffect.PotionMobEffect(PotionEffectType.WITHER, 7, 1)
|
new MobEffect.PotionMobEffect(PotionEffectType.WITHER, 7, 1)
|
||||||
),
|
)),
|
||||||
EntityType.SKELETON, Set.of(
|
Map.entry(EntityType.SKELETON, Set.of(
|
||||||
new MobEffect.PotionMobEffect(PotionEffectType.SLOWNESS, 3.5, 1)
|
new MobEffect.PotionMobEffect(PotionEffectType.SLOWNESS, 3.5, 1)
|
||||||
),
|
)),
|
||||||
EntityType.SPIDER, Set.of(
|
Map.entry(EntityType.SPIDER, Set.of(
|
||||||
new MobEffect.PotionMobEffect(PotionEffectType.POISON, 4, 1),
|
new MobEffect.PotionMobEffect(PotionEffectType.POISON, 4, 1),
|
||||||
new MobEffect.PotionMobEffect(PotionEffectType.NAUSEA, 6, 10)
|
new MobEffect.PotionMobEffect(PotionEffectType.NAUSEA, 6, 10)
|
||||||
),
|
)),
|
||||||
EntityType.CREEPER, Set.of(
|
Map.entry(EntityType.CREEPER, Set.of(
|
||||||
new MobEffect.LightningMobEffect()
|
new MobEffect.LightningMobEffect()
|
||||||
),
|
)),
|
||||||
EntityType.HUSK, Set.of(
|
Map.entry(EntityType.HUSK, Set.of(
|
||||||
new MobEffect.PotionMobEffect(PotionEffectType.WITHER, 7, 1)
|
new MobEffect.PotionMobEffect(PotionEffectType.WITHER, 7, 1)
|
||||||
),
|
)),
|
||||||
EntityType.DROWNED, Set.of(
|
Map.entry(EntityType.STRAY, Set.of()),
|
||||||
|
Map.entry(EntityType.DROWNED, Set.of(
|
||||||
new MobEffect.PotionMobEffect(PotionEffectType.WITHER, 7, 1)
|
new MobEffect.PotionMobEffect(PotionEffectType.WITHER, 7, 1)
|
||||||
),
|
)),
|
||||||
EntityType.WITCH, Set.of(),
|
Map.entry(EntityType.WITCH, Set.of()),
|
||||||
EntityType.ZOMBIE_VILLAGER, Set.of(
|
Map.entry(EntityType.ZOMBIE_VILLAGER, Set.of(
|
||||||
new MobEffect.PotionMobEffect(PotionEffectType.WITHER, 7, 1)
|
new MobEffect.PotionMobEffect(PotionEffectType.WITHER, 7, 1)
|
||||||
),
|
)),
|
||||||
EntityType.PHANTOM, Set.of(
|
Map.entry(EntityType.PHANTOM, Set.of(
|
||||||
new MobEffect.PotionMobEffect(PotionEffectType.LEVITATION, 1.5, 3)
|
new MobEffect.PotionMobEffect(PotionEffectType.LEVITATION, 1.5, 3)
|
||||||
),
|
)),
|
||||||
EntityType.ENDERMAN, Set.of(
|
Map.entry(EntityType.ENDERMAN, Set.of(
|
||||||
new MobEffect.PotionMobEffect(PotionEffectType.SLOWNESS, 2.5, 2)
|
new MobEffect.PotionMobEffect(PotionEffectType.SLOWNESS, 2.5, 2)
|
||||||
)
|
))
|
||||||
);
|
);
|
||||||
public final int expMultiplier = 3;
|
public final int expMultiplier = 3;
|
||||||
public final double mobDamageMultiplier = 2;
|
public final double mobDamageMultiplier = 2;
|
||||||
public final double mobHealthMultiplier = 2;
|
public final double mobHealthMultiplier = 2;
|
||||||
|
|
||||||
|
private final ThreadLocalRandom random = ThreadLocalRandom.current();
|
||||||
private boolean isActive = false;
|
private boolean isActive = false;
|
||||||
private final BossBar bossBar = BossBar.bossBar(
|
private final BossBar bossBar = BossBar.bossBar(
|
||||||
Component.text("Blutmond", NamedTextColor.DARK_RED),
|
Component.text("Blutmond", NamedTextColor.DARK_RED),
|
||||||
@@ -89,10 +89,11 @@ public class Bloodmoon extends Appliance {
|
|||||||
EntityType.SKELETON,
|
EntityType.SKELETON,
|
||||||
EntityType.SPIDER
|
EntityType.SPIDER
|
||||||
);
|
);
|
||||||
private final Map<Player, @Nullable BukkitTask> hordeSpawnTasks = new HashMap<>();
|
private final Map<Player, @Nullable BukkitTask> hordeSpawnTasks = new WeakHashMap<>();
|
||||||
private long lastBloodmoonStartTick = 0;
|
private long lastBloodmoonStartTick = 0;
|
||||||
public final int ticksPerDay = 24000;
|
public final int ticksPerDay = 24000;
|
||||||
public final int bloodmoonLength = ticksPerDay/2;
|
public final int bloodmoonLength = ticksPerDay/2;
|
||||||
|
public final int preStartMessageTicks = Ticks.TICKS_PER_SECOND * 50;
|
||||||
private final int bloodmoonFreeDaysAtStart = 3;
|
private final int bloodmoonFreeDaysAtStart = 3;
|
||||||
private final int bloodmoonStartTime = ticksPerDay/2;
|
private final int bloodmoonStartTime = ticksPerDay/2;
|
||||||
private final int bloodmoonDayInterval = 30;
|
private final int bloodmoonDayInterval = 30;
|
||||||
@@ -145,7 +146,7 @@ public class Bloodmoon extends Appliance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getRandomHordeSpawnDelay() {
|
private int getRandomHordeSpawnDelay() {
|
||||||
return this.hordeSpawnRateTicks + ThreadLocalRandom.current().nextInt(this.hordeSpawnRateVariationTicks);
|
return this.hordeSpawnRateTicks + this.random.nextInt(this.hordeSpawnRateVariationTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startHordeSpawning(int delay) {
|
private void startHordeSpawning(int delay) {
|
||||||
@@ -155,7 +156,7 @@ public class Bloodmoon extends Appliance {
|
|||||||
private void startHordeSpawning(int delay, Player player) {
|
private void startHordeSpawning(int delay, Player player) {
|
||||||
@Nullable BukkitTask task = this.hordeSpawnTasks.get(player);
|
@Nullable BukkitTask task = this.hordeSpawnTasks.get(player);
|
||||||
if(task != null) task.cancel();
|
if(task != null) task.cancel();
|
||||||
|
Pupsi marked this conversation as resolved
|
|||||||
task = Bukkit.getScheduler().runTaskLater(
|
BukkitTask newTask = Bukkit.getScheduler().runTaskLater(
|
||||||
Main.instance(),
|
Main.instance(),
|
||||||
() -> {
|
() -> {
|
||||||
if(!this.bloodmoonIsActive()) return;
|
if(!this.bloodmoonIsActive()) return;
|
||||||
@@ -164,7 +165,7 @@ public class Bloodmoon extends Appliance {
|
|||||||
},
|
},
|
||||||
delay
|
delay
|
||||||
);
|
);
|
||||||
this.hordeSpawnTasks.put(player, task);
|
this.hordeSpawnTasks.put(player, newTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayerToBossBar(Player player) {
|
public void addPlayerToBossBar(Player player) {
|
||||||
@@ -187,9 +188,9 @@ public class Bloodmoon extends Appliance {
|
|||||||
public void spawnRandomHorde(Player player) {
|
public void spawnRandomHorde(Player player) {
|
||||||
if(!this.hordesEnabled) return;
|
if(!this.hordesEnabled) return;
|
||||||
if(!player.getGameMode().equals(GameMode.SURVIVAL)) return;
|
if(!player.getGameMode().equals(GameMode.SURVIVAL)) return;
|
||||||
ThreadLocalRandom random = ThreadLocalRandom.current();
|
|
||||||
EntityType hordeEntityType = this.hordeMobList.get(random.nextInt(this.hordeMobList.size()));
|
EntityType hordeEntityType = this.hordeMobList.get(this.random.nextInt(this.hordeMobList.size()));
|
||||||
int hordeSize = random.nextInt(this.hordeMinPopulation, this.hordeMaxPopulation + 1);
|
int hordeSize = this.random.nextInt(this.hordeMinPopulation, this.hordeMaxPopulation + 1);
|
||||||
this.spawnHorde(player, hordeSize, hordeEntityType);
|
this.spawnHorde(player, hordeSize, hordeEntityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +208,7 @@ public class Bloodmoon extends Appliance {
|
|||||||
|
|
||||||
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 = this.random.nextDouble(0, 2*Math.PI);
|
||||||
Location mobSpawnLocation = player.getLocation().add(
|
Location mobSpawnLocation = player.getLocation().add(
|
||||||
Math.sin(spawnRadiant)*this.hordeSpawnDistance,
|
Math.sin(spawnRadiant)*this.hordeSpawnDistance,
|
||||||
0,
|
0,
|
||||||
@@ -220,7 +221,7 @@ public class Bloodmoon extends Appliance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<ItemStack> getRandomBonusDrops() {
|
public List<ItemStack> getRandomBonusDrops() {
|
||||||
int itemCount = ThreadLocalRandom.current().nextInt(this.minBonusDrops, this.maxBonusDrops + 1);
|
int itemCount = this.random.nextInt(this.minBonusDrops, this.maxBonusDrops + 1);
|
||||||
List<ItemStack> result = new ArrayList<>();
|
List<ItemStack> result = new ArrayList<>();
|
||||||
for(int i = 0; i < itemCount; i++) {
|
for(int i = 0; i < itemCount; i++) {
|
||||||
result.add(this.getRandomBonusDrop());
|
result.add(this.getRandomBonusDrop());
|
||||||
@@ -228,9 +229,9 @@ public class Bloodmoon extends Appliance {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
|||||||
private ItemStack getRandomBonusDrop() {
|
private @Nullable ItemStack getRandomBonusDrop() {
|
||||||
int totalWeight = this.bonusDropWeightMap.values().stream().mapToInt(value -> value).sum();
|
int totalWeight = this.bonusDropWeightMap.values().stream().mapToInt(value -> value).sum();
|
||||||
|
Pupsi marked this conversation as resolved
MineTec
commented
eine klassenvariable eine klassenvariable `random` würde wahrscheinlich sinn machen
|
|||||||
int randomInt = ThreadLocalRandom.current().nextInt(0, totalWeight + 1);
|
int randomInt = this.random.nextInt(0, totalWeight + 1);
|
||||||
int cumulativeWeight = 0;
|
int cumulativeWeight = 0;
|
||||||
for(Map.Entry<ItemStack, Integer> entry : this.bonusDropWeightMap.entrySet()) {
|
for(Map.Entry<ItemStack, Integer> entry : this.bonusDropWeightMap.entrySet()) {
|
||||||
cumulativeWeight += entry.getValue();
|
cumulativeWeight += entry.getValue();
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class BloodmoonSetting extends BoolSetting implements CategorizedSetting
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Material icon() {
|
protected Material icon() {
|
||||||
return Material.CLOCK;
|
return Material.SKELETON_SKULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.list
|
|||||||
import com.destroystokyo.paper.event.server.ServerTickStartEvent;
|
import com.destroystokyo.paper.event.server.ServerTickStartEvent;
|
||||||
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
|
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
|
||||||
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.Bloodmoon;
|
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.Bloodmoon;
|
||||||
|
import net.kyori.adventure.util.Ticks;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
@@ -18,12 +19,12 @@ public class BloodmoonTimeListener extends ApplianceListener<Bloodmoon> {
|
|||||||
this.getAppliance().stopBloodmoon();
|
this.getAppliance().stopBloodmoon();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.getAppliance().updateBossBar();
|
if(currentTime % Ticks.TICKS_PER_SECOND == 0) this.getAppliance().updateBossBar();
|
||||||
if(this.getAppliance().isStartTick(currentTime + this.getAppliance().ticksPerDay)) {
|
if(this.getAppliance().isStartTick(currentTime + this.getAppliance().ticksPerDay)) {
|
||||||
this.getAppliance().sendAnnouncementMessages();
|
this.getAppliance().sendAnnouncementMessages();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(this.getAppliance().isStartTick(currentTime + 1000)) {
|
if(this.getAppliance().isStartTick(currentTime + this.getAppliance().preStartMessageTicks)) {
|
||||||
this.getAppliance().sendPreStartMessages();
|
this.getAppliance().sendPreStartMessages();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user
hier die Variable aus dem map.get zu überschreiben sieht komisch aus
Mach doch eine neue Variable, du setzt unten ja sowiso manuell .put