This commit is contained in:
YuTian 2024-08-15 13:47:21 +08:00
parent 6eaa298fb1
commit d48568f9cc
3 changed files with 27 additions and 15 deletions

View File

@ -4,6 +4,7 @@ import com.yaohun.enderdragonwar.EnderDragonWar;
import com.yaohun.enderdragonwar.util.BossBarUtil; import com.yaohun.enderdragonwar.util.BossBarUtil;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.GameRule;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.boss.BarColor; import org.bukkit.boss.BarColor;
@ -89,6 +90,10 @@ public class Game {
return; return;
} }
this.player = player; this.player = player;
World world = this.player.getWorld();
world.setTime(1000);
world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false);
world.setGameRule(GameRule.DO_WEATHER_CYCLE, false);
this.startd = true; this.startd = true;
this.liveTime = 1000 * 60 * 60 * 3; this.liveTime = 1000 * 60 * 60 * 3;
initPlayerData(player); initPlayerData(player);

View File

@ -1,10 +1,13 @@
package com.yaohun.enderdragonwar.listener; package com.yaohun.enderdragonwar.listener;
import com.yaohun.enderdragonwar.EnderDragonWar; import com.yaohun.enderdragonwar.EnderDragonWar;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.EnderDragon; import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.LightningStrike;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
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.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
@ -30,6 +33,25 @@ public class GameListener implements Listener {
EnderDragonWar.game.quitGame(event.getPlayer()); EnderDragonWar.game.quitGame(event.getPlayer());
} }
@EventHandler
public void onDamage(EntityDamageByEntityEvent event) {
if (event.getEntity() instanceof Player) {
if (event.getDamager() instanceof LightningStrike) {
event.setDamage(1.0);
} else if (event.getDamager() instanceof Creeper creeper) {
event.setDamage(creeper.isPowered() ? 4.0 : 2.0);
}
} else if (event.getEntity() instanceof LightningStrike) {
if (!(event.getDamager() instanceof Player player)) {
event.setDamage(2.0);
}
} else if (event.getDamager() instanceof Creeper creeper) {
if (!(event.getEntity() instanceof Player)) {
event.setDamage(creeper.isPowered() ? 4.0 : 2.0);
}
}
}
@EventHandler @EventHandler
public void onDeath(PlayerDeathEvent event) { public void onDeath(PlayerDeathEvent event) {
event.setDeathMessage(null); event.setDeathMessage(null);

View File

@ -57,21 +57,6 @@ public class PlayerListener implements Listener {
} }
} }
@EventHandler
public void onDamage(EntityDamageByEntityEvent event) {
if (event.getEntity() instanceof Player) {
if (event.getDamager() instanceof LightningStrike) {
event.setDamage(1.0);
} else if (event.getDamager() instanceof Creeper creeper) {
event.setDamage(creeper.isPowered() ? 4 : 2.0);
}
} else if (event.getEntity() instanceof LightningStrike) {
if (!(event.getDamager() instanceof Player player)) {
event.setDamage(2.0);
}
}
}
@EventHandler @EventHandler
public void onPlayerBreakBlock(BlockBreakEvent event) { public void onPlayerBreakBlock(BlockBreakEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();