summaryrefslogtreewikicommitdiff
path: root/src/main/java/net/tylermurphy/hideAndSeek/game/Disguiser.java
diff options
context:
space:
mode:
authorTyler Murphy <tylermurphy534@gmail.com>2022-07-27 18:20:11 -0400
committerTyler Murphy <tylermurphy534@gmail.com>2022-07-27 18:20:11 -0400
commite4abbae6af086e4ea71bb20e25d29b3ed646ae83 (patch)
tree5d5170c074a3a6b05bfcc909426ba2d5e4f597db /src/main/java/net/tylermurphy/hideAndSeek/game/Disguiser.java
parentSave Inventorys on Leave (diff)
downloadkenshinshideandseek-e4abbae6af086e4ea71bb20e25d29b3ed646ae83.tar.gz
kenshinshideandseek-e4abbae6af086e4ea71bb20e25d29b3ed646ae83.tar.bz2
kenshinshideandseek-e4abbae6af086e4ea71bb20e25d29b3ed646ae83.zip
blockhunt start
Diffstat (limited to 'src/main/java/net/tylermurphy/hideAndSeek/game/Disguiser.java')
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/game/Disguiser.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/Disguiser.java b/src/main/java/net/tylermurphy/hideAndSeek/game/Disguiser.java
new file mode 100644
index 0000000..b4f70ad
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/game/Disguiser.java
@@ -0,0 +1,62 @@
+package net.tylermurphy.hideAndSeek.game;
+
+import org.bukkit.Material;
+import org.bukkit.entity.FallingBlock;
+import org.bukkit.entity.Player;
+import org.bukkit.potion.PotionEffect;
+import org.bukkit.potion.PotionEffectType;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class Disguiser {
+
+ private final Map<Player, FallingBlock> blocks;
+
+ public Disguiser(){
+ this.blocks = new HashMap<>();
+ }
+
+ public FallingBlock getBlock(Player player){
+ return blocks.get(player);
+ }
+
+ public boolean contains(FallingBlock block) { return blocks.containsValue(block); }
+
+ public boolean disguised(Player player) { return blocks.containsKey(player); }
+
+ public void check(){
+ for(Map.Entry<Player, FallingBlock> set : blocks.entrySet()){
+ Player player = set.getKey();
+ FallingBlock block = set.getValue();
+ if(block.isDead()){
+ block.remove();
+ FallingBlock replacement = player.getLocation().getWorld().spawnFallingBlock(player.getLocation(), block.getMaterial(), (byte)0);
+ replacement.setGravity(false);
+ replacement.setDropItem(false);
+ blocks.put(player, replacement);
+ }
+ }
+ }
+
+ public void disguise(Player player, Material material){
+ if(blocks.containsKey(player)){
+ FallingBlock block = blocks.get(player);
+ block.remove();
+ }
+ FallingBlock block = player.getLocation().getWorld().spawnFallingBlock(player.getLocation(), material, (byte)0);
+ block.setGravity(false);
+ block.setDropItem(false);
+ blocks.put(player, block);
+ player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 1000000, 0,false, false));
+ }
+
+ public void reveal(Player player){
+ if(!blocks.containsKey(player)) return;
+ FallingBlock block = blocks.get(player);
+ block.remove();
+ blocks.remove(player);
+ player.removePotionEffect(PotionEffectType.INVISIBILITY);
+ }
+
+}