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