From 5bdf50813d994d645f8cbb4452e6c54540d7bf17 Mon Sep 17 00:00:00 2001 From: drfiveminusmint Date: Thu, 27 Jun 2024 19:08:03 -0400 Subject: [PATCH 1/4] A bunch of stuff --- .idea/.gitignore | 3 ++ .idea/compiler.xml | 13 +++++ .idea/encodings.xml | 7 +++ .idea/jarRepositories.xml | 35 ++++++++++++++ .idea/misc.xml | 12 +++++ .idea/modules.xml | 8 ++++ .idea/vcs.xml | 6 +++ Movecraft-Overheat.iml | 14 ++++++ .../MovecraftOverheatCommand.java | 1 - .../disaster/SurfaceExplosionDisaster.java | 4 +- .../disaster/SurfaceFireDisaster.java | 4 +- .../listener/WeaponFireListener.java | 33 ++++++++++++- .../movecraftoverheat/tracking/CraftHeat.java | 9 +++- .../tracking/HeatManager.java | 1 + src/main/resources/config.yml | 8 +++- target/classes/config.yml | 47 +++++++++++++++++++ target/classes/plugin.yml | 12 +++++ 17 files changed, 207 insertions(+), 10 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/compiler.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 Movecraft-Overheat.iml create mode 100644 target/classes/config.yml create mode 100644 target/classes/plugin.yml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..2812d6a --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..dcae4a7 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..9dc782b --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..2bc54b6 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Movecraft-Overheat.iml b/Movecraft-Overheat.iml new file mode 100644 index 0000000..ad42100 --- /dev/null +++ b/Movecraft-Overheat.iml @@ -0,0 +1,14 @@ + + + + + + + SPIGOT + ADVENTURE + + 1 + + + + \ No newline at end of file diff --git a/src/main/java/net/countercraft/movecraft/movecraftoverheat/MovecraftOverheatCommand.java b/src/main/java/net/countercraft/movecraft/movecraftoverheat/MovecraftOverheatCommand.java index 7c5c75d..154a454 100644 --- a/src/main/java/net/countercraft/movecraft/movecraftoverheat/MovecraftOverheatCommand.java +++ b/src/main/java/net/countercraft/movecraft/movecraftoverheat/MovecraftOverheatCommand.java @@ -2,7 +2,6 @@ import net.countercraft.movecraft.craft.Craft; import net.countercraft.movecraft.craft.CraftManager; -import net.countercraft.movecraft.craft.PlayerCraft; import net.countercraft.movecraft.craft.type.CraftType; import net.countercraft.movecraft.movecraftoverheat.tracking.CraftHeat; import net.countercraft.movecraft.util.ChatUtils; diff --git a/src/main/java/net/countercraft/movecraft/movecraftoverheat/disaster/SurfaceExplosionDisaster.java b/src/main/java/net/countercraft/movecraft/movecraftoverheat/disaster/SurfaceExplosionDisaster.java index eb1e8a3..0d2b106 100644 --- a/src/main/java/net/countercraft/movecraft/movecraftoverheat/disaster/SurfaceExplosionDisaster.java +++ b/src/main/java/net/countercraft/movecraft/movecraftoverheat/disaster/SurfaceExplosionDisaster.java @@ -3,10 +3,10 @@ import net.countercraft.movecraft.MovecraftLocation; import net.countercraft.movecraft.craft.Craft; import net.countercraft.movecraft.craft.PlayerCraft; -import net.countercraft.movecraft.libs.net.kyori.adventure.key.Key; -import net.countercraft.movecraft.libs.net.kyori.adventure.sound.Sound; import net.countercraft.movecraft.movecraftoverheat.tracking.CraftHeat; import net.countercraft.movecraft.util.ChatUtils; +import net.kyori.adventure.key.Key; +import net.kyori.adventure.sound.Sound; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.EntityType; diff --git a/src/main/java/net/countercraft/movecraft/movecraftoverheat/disaster/SurfaceFireDisaster.java b/src/main/java/net/countercraft/movecraft/movecraftoverheat/disaster/SurfaceFireDisaster.java index 449b394..105b44e 100644 --- a/src/main/java/net/countercraft/movecraft/movecraftoverheat/disaster/SurfaceFireDisaster.java +++ b/src/main/java/net/countercraft/movecraft/movecraftoverheat/disaster/SurfaceFireDisaster.java @@ -3,10 +3,10 @@ import net.countercraft.movecraft.MovecraftLocation; import net.countercraft.movecraft.craft.Craft; import net.countercraft.movecraft.craft.PlayerCraft; -import net.countercraft.movecraft.libs.net.kyori.adventure.key.Key; -import net.countercraft.movecraft.libs.net.kyori.adventure.sound.Sound; import net.countercraft.movecraft.movecraftoverheat.tracking.CraftHeat; import net.countercraft.movecraft.util.ChatUtils; +import net.kyori.adventure.key.Key; +import net.kyori.adventure.sound.Sound; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; diff --git a/src/main/java/net/countercraft/movecraft/movecraftoverheat/listener/WeaponFireListener.java b/src/main/java/net/countercraft/movecraft/movecraftoverheat/listener/WeaponFireListener.java index 1e84acd..e33dca0 100644 --- a/src/main/java/net/countercraft/movecraft/movecraftoverheat/listener/WeaponFireListener.java +++ b/src/main/java/net/countercraft/movecraft/movecraftoverheat/listener/WeaponFireListener.java @@ -1,20 +1,27 @@ package net.countercraft.movecraft.movecraftoverheat.listener; +import net.countercraft.movecraft.MovecraftLocation; import net.countercraft.movecraft.combat.features.tracking.events.CraftFireWeaponEvent; import net.countercraft.movecraft.combat.features.tracking.types.Fireball; import net.countercraft.movecraft.combat.features.tracking.types.TNTCannon; import net.countercraft.movecraft.craft.Craft; +import net.countercraft.movecraft.craft.CraftManager; import net.countercraft.movecraft.movecraftoverheat.Keys; import net.countercraft.movecraft.movecraftoverheat.MovecraftOverheat; import net.countercraft.movecraft.movecraftoverheat.config.Settings; import net.countercraft.movecraft.movecraftoverheat.tracking.CraftHeat; +import net.countercraft.movecraft.util.MathUtils; +import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityExplodeEvent; public class WeaponFireListener implements Listener { - @EventHandler - public void onFire (CraftFireWeaponEvent event) { + @EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onWeaponFire (CraftFireWeaponEvent event) { Craft craft = event.getCraft(); CraftHeat craftHeat = MovecraftOverheat.getInstance().getHeatManager().getHeat(craft); if (craftHeat == null) { @@ -38,4 +45,26 @@ public void onFire (CraftFireWeaponEvent event) { craftHeat.addHeat(Settings.HeatPerTNT*multiplier); } } + + @EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onEntityExplode (EntityExplodeEvent event) { + // Don't run this check if there's no per shot heat cost + if (Settings.HeatPerGunShot <= 0) return; + // Only detect explosions in ballistic water or lava for the purposes of catching cannon shots + Location location = event.getLocation(); + if (!(location.getBlock().isLiquid())) return; + Craft craft = MathUtils.fastNearestCraftToLoc(CraftManager.getInstance().getCrafts(), location); + // Check if the location is within the craft's hitbox + + if (!craft.getHitBox().contains(new MovecraftLocation(location.getBlockX(), location.getBlockY(), location.getBlockZ()))) + return; + CraftHeat craftHeat = MovecraftOverheat.getInstance().getHeatManager().getHeat(craft); + if (craftHeat == null) { + return; + } + if (!craftHeat.hasFiredThisTick()) { + craftHeat.setFiredThisTick(true); + craftHeat.addHeat(Settings.HeatPerGunShot); + } + } } diff --git a/src/main/java/net/countercraft/movecraft/movecraftoverheat/tracking/CraftHeat.java b/src/main/java/net/countercraft/movecraft/movecraftoverheat/tracking/CraftHeat.java index 07d1aba..e0fda1a 100644 --- a/src/main/java/net/countercraft/movecraft/movecraftoverheat/tracking/CraftHeat.java +++ b/src/main/java/net/countercraft/movecraft/movecraftoverheat/tracking/CraftHeat.java @@ -22,6 +22,8 @@ public class CraftHeat { private long lastUpdate; private long lastDisaster; private boolean silenced; + + private boolean firedThisTick; private final BossBar bossBar; public CraftHeat (@NotNull Craft c) { @@ -122,7 +124,7 @@ public long getLastDisaster() { return lastDisaster; } - public boolean getIsSilenced () { + public boolean isSilenced() { return silenced; } @@ -142,4 +144,9 @@ private void updateBossBar () { public void removeBossBar () { bossBar.removeAll(); } + + public boolean hasFiredThisTick () {return firedThisTick;} + + public void setFiredThisTick (boolean b) {firedThisTick = b;} + } diff --git a/src/main/java/net/countercraft/movecraft/movecraftoverheat/tracking/HeatManager.java b/src/main/java/net/countercraft/movecraft/movecraftoverheat/tracking/HeatManager.java index d97e91f..a7624cf 100644 --- a/src/main/java/net/countercraft/movecraft/movecraftoverheat/tracking/HeatManager.java +++ b/src/main/java/net/countercraft/movecraft/movecraftoverheat/tracking/HeatManager.java @@ -19,6 +19,7 @@ public class HeatManager extends BukkitRunnable { public void run() { long time = System.currentTimeMillis(); for (CraftHeat heat : heatTracking.values()) { + if (heat.hasFiredThisTick()) heat.setFiredThisTick(false); if (heat.getLastUpdate() + Settings.HeatCheckInterval >= time) { continue; } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 2bbe5f9..f9b7469 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -15,8 +15,8 @@ HeatPerGunShot: 30.0 HeatSinkBlocks: gold_block: 10.0 -#Similar to Heat Sink Blocks, but for heat dissapation instead -#Each block of these materials will contribute [multiplier] times as much to the craft's heat dissapation +#Similar to Heat Sink Blocks, but for heat dissipation instead +#Each block of these materials will contribute [multiplier] times as much to the craft's heat dissipation RadiatorBlocks: lapis_block: 10.0 @@ -39,5 +39,9 @@ Disasters: RandomChance: 0.3 RandomChancePowerFactor: 0.001 +# Prevent crafts above a certain heat threshold from firing weapons +SilenceOverheatedCrafts: true +SilenceHeatThreshold: 2.0 + #Enable/disable debug mode (CURRENTLY UNIMPLEMENTED) DebugMode: false diff --git a/target/classes/config.yml b/target/classes/config.yml new file mode 100644 index 0000000..f9b7469 --- /dev/null +++ b/target/classes/config.yml @@ -0,0 +1,47 @@ +#Heat generated by each TNT dispensed +HeatPerTNT: 2.5 + +#Heat generated by each fireball dispensed +HeatPerFireball: 0.1 + +#Amount of heat from a gun firing. (CURRENTLY UNIMPLEMENTED) +#Multiple guns firing on the same game tick will trick the plugin into thinking they're one shot +#So you may want to require players to space the shots on their ships out over multiple ticks +HeatPerGunShot: 30.0 + +#Heat Sink Blocks have a multiplier associated with them that modifies the amount of heat capacity they give compared to base blocks +#For instance a block with a value of 10 will give 10 times as much heat capacity per block compared to a normal block +#Fractional, zero, or negative values also work, for blocks that contribute less to or even reduce a ship's heat capacity +HeatSinkBlocks: + gold_block: 10.0 + +#Similar to Heat Sink Blocks, but for heat dissipation instead +#Each block of these materials will contribute [multiplier] times as much to the craft's heat dissipation +RadiatorBlocks: + lapis_block: 10.0 + +#The number of milliseconds that the plugin will wait between heat capacity recalculations. +#Reducing this will make the heat mechanics seem smoother, but may cause lag. +HeatCheckInterval: 1000 + +#The number of milliseconds that the plugin will wait between disaster checks. +#Has a minimal effect on lag, but decreasing this will increase the frequency of disasters. +DisasterCheckInterval: 10000 + +Disasters: + SurfaceFire: + HeatThreshold: 1.0 + RandomChance: 0.3 + RandomChancePowerFactor: 0.001 + + SurfaceExplosion: + HeatThreshold: 1.5 + RandomChance: 0.3 + RandomChancePowerFactor: 0.001 + +# Prevent crafts above a certain heat threshold from firing weapons +SilenceOverheatedCrafts: true +SilenceHeatThreshold: 2.0 + +#Enable/disable debug mode (CURRENTLY UNIMPLEMENTED) +DebugMode: false diff --git a/target/classes/plugin.yml b/target/classes/plugin.yml new file mode 100644 index 0000000..5187583 --- /dev/null +++ b/target/classes/plugin.yml @@ -0,0 +1,12 @@ +name: Movecraft-Overheat +version: '1.0' +main: net.countercraft.movecraft.movecraftoverheat.MovecraftOverheat +api-version: 1.14 +prefix: Movecraft-Overheat +authors: [ a4bde ] +depend: [Movecraft, Movecraft-Combat] +description: A plugin that adds heat, overheating, and cooling mechanics to Movecraft. +commands: + movecraftoverheat: + description: The master command for Movecraft-Overheat. + usage: /movecraftoverheat [check] From e8dc1e701b9418f1596d9c4701a867bf5924082c Mon Sep 17 00:00:00 2001 From: Nicole <52045376+drfiveminusmint@users.noreply.github.com> Date: Thu, 27 Jun 2024 19:13:24 -0400 Subject: [PATCH 2/4] Delete target/classes directory i messed up --- target/classes/config.yml | 47 --------------------------------------- target/classes/plugin.yml | 12 ---------- 2 files changed, 59 deletions(-) delete mode 100644 target/classes/config.yml delete mode 100644 target/classes/plugin.yml diff --git a/target/classes/config.yml b/target/classes/config.yml deleted file mode 100644 index f9b7469..0000000 --- a/target/classes/config.yml +++ /dev/null @@ -1,47 +0,0 @@ -#Heat generated by each TNT dispensed -HeatPerTNT: 2.5 - -#Heat generated by each fireball dispensed -HeatPerFireball: 0.1 - -#Amount of heat from a gun firing. (CURRENTLY UNIMPLEMENTED) -#Multiple guns firing on the same game tick will trick the plugin into thinking they're one shot -#So you may want to require players to space the shots on their ships out over multiple ticks -HeatPerGunShot: 30.0 - -#Heat Sink Blocks have a multiplier associated with them that modifies the amount of heat capacity they give compared to base blocks -#For instance a block with a value of 10 will give 10 times as much heat capacity per block compared to a normal block -#Fractional, zero, or negative values also work, for blocks that contribute less to or even reduce a ship's heat capacity -HeatSinkBlocks: - gold_block: 10.0 - -#Similar to Heat Sink Blocks, but for heat dissipation instead -#Each block of these materials will contribute [multiplier] times as much to the craft's heat dissipation -RadiatorBlocks: - lapis_block: 10.0 - -#The number of milliseconds that the plugin will wait between heat capacity recalculations. -#Reducing this will make the heat mechanics seem smoother, but may cause lag. -HeatCheckInterval: 1000 - -#The number of milliseconds that the plugin will wait between disaster checks. -#Has a minimal effect on lag, but decreasing this will increase the frequency of disasters. -DisasterCheckInterval: 10000 - -Disasters: - SurfaceFire: - HeatThreshold: 1.0 - RandomChance: 0.3 - RandomChancePowerFactor: 0.001 - - SurfaceExplosion: - HeatThreshold: 1.5 - RandomChance: 0.3 - RandomChancePowerFactor: 0.001 - -# Prevent crafts above a certain heat threshold from firing weapons -SilenceOverheatedCrafts: true -SilenceHeatThreshold: 2.0 - -#Enable/disable debug mode (CURRENTLY UNIMPLEMENTED) -DebugMode: false diff --git a/target/classes/plugin.yml b/target/classes/plugin.yml deleted file mode 100644 index 5187583..0000000 --- a/target/classes/plugin.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Movecraft-Overheat -version: '1.0' -main: net.countercraft.movecraft.movecraftoverheat.MovecraftOverheat -api-version: 1.14 -prefix: Movecraft-Overheat -authors: [ a4bde ] -depend: [Movecraft, Movecraft-Combat] -description: A plugin that adds heat, overheating, and cooling mechanics to Movecraft. -commands: - movecraftoverheat: - description: The master command for Movecraft-Overheat. - usage: /movecraftoverheat [check] From d492c60d70877c7ac6086f09c1dbe82effcadc63 Mon Sep 17 00:00:00 2001 From: Nicole <52045376+drfiveminusmint@users.noreply.github.com> Date: Thu, 27 Jun 2024 19:13:48 -0400 Subject: [PATCH 3/4] Delete .idea directory --- .idea/.gitignore | 3 --- .idea/compiler.xml | 13 ------------- .idea/encodings.xml | 7 ------- .idea/jarRepositories.xml | 35 ----------------------------------- .idea/misc.xml | 12 ------------ .idea/modules.xml | 8 -------- .idea/vcs.xml | 6 ------ 7 files changed, 84 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/jarRepositories.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 26d3352..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 2812d6a..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index aa00ffa..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml deleted file mode 100644 index dcae4a7..0000000 --- a/.idea/jarRepositories.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 9dc782b..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 2bc54b6..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 666fa8788d040bf3478c67ff04125bdc9241f6ad Mon Sep 17 00:00:00 2001 From: Nicole <52045376+drfiveminusmint@users.noreply.github.com> Date: Thu, 27 Jun 2024 19:17:04 -0400 Subject: [PATCH 4/4] Delete Movecraft-Overheat.iml chat can somone clip that --- Movecraft-Overheat.iml | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 Movecraft-Overheat.iml diff --git a/Movecraft-Overheat.iml b/Movecraft-Overheat.iml deleted file mode 100644 index ad42100..0000000 --- a/Movecraft-Overheat.iml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - SPIGOT - ADVENTURE - - 1 - - - - \ No newline at end of file