From 64350787032d9e8bca2098e4a71224b332ac8c49 Mon Sep 17 00:00:00 2001 From: Super_ Date: Thu, 16 Jul 2020 00:06:58 -0400 Subject: [PATCH] /sit --- .idea/uiDesigner.xml | 124 ++++++++++++++++++ .../totalfreedom/totalfreedommod/Sitter.java | 34 +++++ .../totalfreedommod/TotalFreedomMod.java | 2 + .../totalfreedommod/command/Command_sit.java | 34 +++++ 4 files changed, 194 insertions(+) create mode 100644 .idea/uiDesigner.xml create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/Sitter.java create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_sit.java diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 00000000..e96534fb --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/totalfreedommod/Sitter.java b/src/main/java/me/totalfreedom/totalfreedommod/Sitter.java new file mode 100644 index 00000000..b90fd260 --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/Sitter.java @@ -0,0 +1,34 @@ +package me.totalfreedom.totalfreedommod; + +import me.totalfreedom.totalfreedommod.command.Command_sit; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Entity; +import org.bukkit.event.EventHandler; +import org.spigotmc.event.entity.EntityDismountEvent; + +public class Sitter extends FreedomService +{ + @Override + public void onStart() + { + } + + @Override + public void onStop() + { + } + + @EventHandler + public void onEntityDismount(EntityDismountEvent e) + { + Entity dm = e.getDismounted(); + if (dm instanceof ArmorStand) + { + if (Command_sit.STANDS.contains(dm)) + { + Command_sit.STANDS.remove(dm); + dm.remove(); + } + } + } +} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java index ef126ca0..65ab1ac3 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java @@ -133,6 +133,7 @@ public class TotalFreedomMod extends JavaPlugin public WorldRestrictions wr; public SignBlocker snp; public EntityWiper ew; + public Sitter st; //public HubWorldRestrictions hwr; // // Bridges @@ -238,6 +239,7 @@ public class TotalFreedomMod extends JavaPlugin gr = new GameRuleHandler(); snp = new SignBlocker(); ew = new EntityWiper(); + st = new Sitter(); // Single admin utils cs = new CommandSpy(); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_sit.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_sit.java new file mode 100644 index 00000000..6ef233dd --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_sit.java @@ -0,0 +1,34 @@ +package me.totalfreedom.totalfreedommod.command; + +import java.util.ArrayList; +import java.util.List; +import me.totalfreedom.totalfreedommod.rank.Rank; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; + +@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandParameters(description = "Sit at the current place you are at.", usage = "/") +public class Command_sit extends FreedomCommand +{ + public static List STANDS = new ArrayList<>(); + + public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole) + { + if (args.length != 0) + { + return false; + } + ArmorStand stand = (ArmorStand) playerSender.getWorld().spawnEntity(playerSender.getLocation().clone().subtract(0.0, 1.7, 0.0), EntityType.ARMOR_STAND); + stand.setGravity(false); + stand.setAI(false); + stand.setVisible(false); + stand.setInvulnerable(true); + stand.addPassenger(playerSender); + STANDS.add(stand); + msg("You are now sitting."); + return true; + } +}