From d48568f9cc6e6e66465a22e6095668e45b71bd2f Mon Sep 17 00:00:00 2001 From: YuTian <2953516620@qq.com> Date: Thu, 15 Aug 2024 13:47:21 +0800 Subject: [PATCH] new-1 --- .../com/yaohun/enderdragonwar/game/Game.java | 5 +++++ .../enderdragonwar/listener/GameListener.java | 22 +++++++++++++++++++ .../listener/PlayerListener.java | 15 ------------- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/yaohun/enderdragonwar/game/Game.java b/src/main/java/com/yaohun/enderdragonwar/game/Game.java index b207301..5b143de 100644 --- a/src/main/java/com/yaohun/enderdragonwar/game/Game.java +++ b/src/main/java/com/yaohun/enderdragonwar/game/Game.java @@ -4,6 +4,7 @@ import com.yaohun.enderdragonwar.EnderDragonWar; import com.yaohun.enderdragonwar.util.BossBarUtil; import org.bukkit.Bukkit; import org.bukkit.GameMode; +import org.bukkit.GameRule; import org.bukkit.World; import org.bukkit.attribute.Attribute; import org.bukkit.boss.BarColor; @@ -89,6 +90,10 @@ public class Game { return; } 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.liveTime = 1000 * 60 * 60 * 3; initPlayerData(player); diff --git a/src/main/java/com/yaohun/enderdragonwar/listener/GameListener.java b/src/main/java/com/yaohun/enderdragonwar/listener/GameListener.java index eb3ff05..7e560fc 100644 --- a/src/main/java/com/yaohun/enderdragonwar/listener/GameListener.java +++ b/src/main/java/com/yaohun/enderdragonwar/listener/GameListener.java @@ -1,10 +1,13 @@ package com.yaohun.enderdragonwar.listener; import com.yaohun.enderdragonwar.EnderDragonWar; +import org.bukkit.entity.Creeper; import org.bukkit.entity.EnderDragon; +import org.bukkit.entity.LightningStrike; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerJoinEvent; @@ -30,6 +33,25 @@ public class GameListener implements Listener { 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 public void onDeath(PlayerDeathEvent event) { event.setDeathMessage(null); diff --git a/src/main/java/com/yaohun/enderdragonwar/listener/PlayerListener.java b/src/main/java/com/yaohun/enderdragonwar/listener/PlayerListener.java index 09afefa..25ca211 100644 --- a/src/main/java/com/yaohun/enderdragonwar/listener/PlayerListener.java +++ b/src/main/java/com/yaohun/enderdragonwar/listener/PlayerListener.java @@ -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 public void onPlayerBreakBlock(BlockBreakEvent event) { Player player = event.getPlayer();