diff options
-rw-r--r-- | README.md | 20 | ||||
-rw-r--r-- | src/main/java/com/MylesAndMore/tumble/EventListener.java | 34 |
2 files changed, 42 insertions, 12 deletions
@@ -14,25 +14,21 @@ once this list is complete and all bugs are fixed, we *should* be ready for rele - [x] make the shovel in shovels mode not lose any durabilty - [x] make it so that you can't move until the game begins - [ ] make the game blocks breakable very fast, but **not instantly--very important for balancing!!** + - Basically, just set a "cooldown" on both snowballs and shovels--not a long one--but one at that - [ ] add infinite snowballs in the gamemanager for tumble mode - [x] make it so that you can't remove any of the game items from your inventory -- [ ] make snowballs actually break blocks (duh) +- [x] make snowballs actually break blocks (duh) - [x] make the randomized mode logic - [ ] set some limits on the spectator mode in-game; make it so they can't fly outside of the map -## game logic (fyi: very object-oriented) +## game logic - [x] make a Game class and object that we can initialize a new instance of with a gameType - - [ ] within this game object, while games are running: - - [x] prevent players from joining/autojoining during - - [x] keep track of when someone wins; start a new round when this happens - - [x] keep track of how many wins each player has; end the game when a player reaches 3 - - [ ] add a section in the config for a place to tp the winning player - - [ ] add logic to do this - -## game legitimacy (@MylesAndMore) - -- [ ] add some example layer generation and layer material types, from actual game @MylesAndMore +- [x] prevent players from joining/autojoining during a game +- [x] keep track of when someone wins; start a new round when this happens +- [x] keep track of how many wins each player has; end the game when a player reaches 3 + - [ ] add a section in the config for a place to tp the winning player + - [ ] add logic to do this ## configuration/customization diff --git a/src/main/java/com/MylesAndMore/tumble/EventListener.java b/src/main/java/com/MylesAndMore/tumble/EventListener.java index d1a60ad..00dbe07 100644 --- a/src/main/java/com/MylesAndMore/tumble/EventListener.java +++ b/src/main/java/com/MylesAndMore/tumble/EventListener.java @@ -8,7 +8,9 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Snowball; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerItemDamageEvent; @@ -88,6 +90,27 @@ public class EventListener implements Listener{ } @EventHandler + public void ProjectileHitEvent(ProjectileHitEvent event) { + // When a projectile hits, check to see if the gameWorld is null, + if (TumbleManager.getGameWorld() != null) { + // then check to see if the projectile hit in the gameWorld, + if (event.getHitBlock().getWorld() == Bukkit.getWorld(TumbleManager.getGameWorld())) { + // then check if the projectile was a snowball, + if (event.getEntity() instanceof Snowball) { + // then check if a player threw it, + if (event.getEntity().getShooter() instanceof Player player) { + // then check if that block is within the game area, + if (event.getHitBlock().getLocation().distanceSquared(Bukkit.getWorld(TumbleManager.getGameWorld()).getSpawnLocation()) < 402) { + // then remove that block. + event.getHitBlock().setType(Material.AIR); + } + } + } + } + } + } + + @EventHandler public void PlayerDropItemEvent(PlayerDropItemEvent event) { // When an item is dropped, make sure there is a defined gameWorld if (TumbleManager.getGameWorld() != null) { @@ -106,6 +129,17 @@ public class EventListener implements Listener{ event.setCancelled(true); } } + + @EventHandler + public void FoodLevelChangeEvent(FoodLevelChangeEvent event) { + // When someone's food level changes, check if the gameWorld is null, + if (TumbleManager.getGameWorld() != null) { + // then check if that happened in the gameWorld + if (event.getEntity().getWorld() == Bukkit.getWorld(TumbleManager.getGameWorld())) { + event.setCancelled(true); + } + } + } } |