From e8eda422953cb614adbd39636103b9c266c40946 Mon Sep 17 00:00:00 2001 From: ZeroEpoch1969 <13510767+ZeroEpoch1969@users.noreply.github.com> Date: Sat, 21 Jul 2018 17:45:56 -0700 Subject: [PATCH] lotta commands --- .../totalfreedommod/TotalFreedomMod.java | 2 + .../command/Command_eject.java | 35 ++++++++++++ .../command/Command_gravity.java | 21 +++++++ .../command/Command_releaseparrots.java | 34 +++++++++++ .../totalfreedommod/command/Command_ride.java | 40 +++++++++++++ .../command/Command_setcompass.java | 37 ++++++++++++ .../command/Command_spectate.java | 46 +++++++++++++++ .../totalfreedommod/fun/MobStacker.java | 56 +++++++++++++++++++ 8 files changed, 271 insertions(+) create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_eject.java create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_gravity.java create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_releaseparrots.java create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_ride.java create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_setcompass.java create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectate.java create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/fun/MobStacker.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java index d6781dfb..9e00ab68 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java @@ -95,6 +95,7 @@ public class TotalFreedomMod extends AeroPlugin public ServerPing sp; public ItemFun it; public Landminer lm; + public MobStacker ms; public MP44 mp; public Jumppads jp; public Trailer tr; @@ -210,6 +211,7 @@ public class TotalFreedomMod extends AeroPlugin // Fun it = services.registerService(ItemFun.class); lm = services.registerService(Landminer.class); + ms = services.registerService(MobStacker.class); mp = services.registerService(MP44.class); jp = services.registerService(Jumppads.class); tr = services.registerService(Trailer.class); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_eject.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_eject.java new file mode 100644 index 00000000..c4009d40 --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_eject.java @@ -0,0 +1,35 @@ +package me.totalfreedom.totalfreedommod.command; + +import me.totalfreedom.totalfreedommod.rank.Rank; +import org.apache.commons.lang3.StringUtils; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; + +@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME) +@CommandParameters(description = "Eject everything off of you.", usage = "/") +public class Command_eject extends FreedomCommand +{ + + @Override + public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + + List names = new ArrayList(); + + for (Entity entity : playerSender.getPassengers()) + { + names.add(entity.getName()); + } + + msg("Ejecting " + StringUtils.join(names, ", ") + ".", ChatColor.GREEN); + playerSender.eject(); + + return true; + } +} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gravity.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gravity.java new file mode 100644 index 00000000..35e85071 --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gravity.java @@ -0,0 +1,21 @@ +package me.totalfreedom.totalfreedommod.command; + +import me.totalfreedom.totalfreedommod.rank.Rank; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandParameters(description = "Make other people your bitch.", usage = "/") +public class Command_gravity extends FreedomCommand +{ + + @Override + public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + playerSender.setGravity(!playerSender.hasGravity()); + msg((playerSender.hasGravity() ? "En" : "Dis") + "abled gravity.", (playerSender.hasGravity() ? ChatColor.GREEN : ChatColor.RED)); + return true; + } +} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_releaseparrots.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_releaseparrots.java new file mode 100644 index 00000000..dffb683d --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_releaseparrots.java @@ -0,0 +1,34 @@ +package me.totalfreedom.totalfreedommod.command; + +import me.totalfreedom.totalfreedommod.rank.Rank; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; + +@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandParameters(description = "Release parrots from your shoulders.", usage = "/", aliases="removeparrots") +public class Command_releaseparrots extends FreedomCommand +{ + + @Override + public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + Entity leftShoulderEntity = playerSender.getShoulderEntityLeft(); + Entity rightShoulderEntity = playerSender.getShoulderEntityRight(); + if (leftShoulderEntity != null && leftShoulderEntity.getType().equals(EntityType.PARROT)) + { + playerSender.setShoulderEntityLeft(null); + msg("Removed the parrot on your left shoulder."); + } + + if (rightShoulderEntity != null && rightShoulderEntity.getType().equals(EntityType.PARROT)) + { + playerSender.setShoulderEntityRight(null); + msg("Removed the parrot on your right shoulder."); + } + + return true; + } +} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ride.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ride.java new file mode 100644 index 00000000..e6f5b44b --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ride.java @@ -0,0 +1,40 @@ +package me.totalfreedom.totalfreedommod.command; + +import me.totalfreedom.totalfreedommod.rank.Rank; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME) +@CommandParameters(description = "Make other people your bitch.", usage = "/ ") +public class Command_ride extends FreedomCommand +{ + + @Override + public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + + if (args.length < 1) + { + return false; + } + + final Player player = getPlayer(args[0]); + if (player == null) + { + msg(PLAYER_NOT_FOUND); + return true; + } + + if (player == playerSender) + { + msg("You can't ride yourself. smh.", ChatColor.RED); + return true; + } + + player.addPassenger(playerSender); + + return true; + } +} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setcompass.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setcompass.java new file mode 100644 index 00000000..8bf04f18 --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setcompass.java @@ -0,0 +1,37 @@ +package me.totalfreedom.totalfreedommod.command; + +import me.totalfreedom.totalfreedommod.rank.Rank; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME) +@CommandParameters(description = "Set your compass to a position.", usage = "/ ") +public class Command_setcompass extends FreedomCommand +{ + + @Override + public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + + if (args.length < 3) + { + return false; + } + + try + { + Location location = new Location(playerSender.getWorld(), Integer.valueOf(args[0]), Integer.valueOf(args[1]), Integer.valueOf(args[2])); + playerSender.setCompassTarget(location); + msg("Successfully set your compass coordinates to X: " + args[0] + ", Y: " + args[1] + ", Z: " + args[2] + ".", ChatColor.GREEN); + } + catch (NumberFormatException e) + { + msg("One or more of your coordinates are not a valid integer.", ChatColor.RED); + } + + return true; + } +} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectate.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectate.java new file mode 100644 index 00000000..1308fe6a --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectate.java @@ -0,0 +1,46 @@ +package me.totalfreedom.totalfreedommod.command; + +import me.totalfreedom.totalfreedommod.rank.Rank; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME) +@CommandParameters(description = "Quickly spectate someone.", usage = "/ ", aliases="spec") +public class Command_spectate extends FreedomCommand +{ + + @Override + public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + + if (args.length == 0) + { + return false; + } + + Player player = getPlayer(args[0]); + if (player == null) + { + msg(PLAYER_NOT_FOUND); + return true; + } + + if (player.getGameMode().equals(GameMode.SPECTATOR)) + { + msg("You cannot spectate other players that are in spectator mode.", ChatColor.RED); + return true; + } + + if (!playerSender.getGameMode().equals(GameMode.SPECTATOR)) + { + playerSender.setGameMode(GameMode.SPECTATOR); + } + + playerSender.setSpectatorTarget(player); + + return true; + } +} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/fun/MobStacker.java b/src/main/java/me/totalfreedom/totalfreedommod/fun/MobStacker.java new file mode 100644 index 00000000..ac894466 --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/fun/MobStacker.java @@ -0,0 +1,56 @@ +package me.totalfreedom.totalfreedommod.fun; + +import me.totalfreedom.totalfreedommod.FreedomService; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; +import org.bukkit.Material; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class MobStacker extends FreedomService +{ + + public MobStacker(TotalFreedomMod plugin) + { + super(plugin); + } + + @Override + protected void onStart() + { + } + + @Override + protected void onStop() + { + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onEntityDamage(EntityDamageByEntityEvent event) + { + if (event.getEntity() instanceof Player || !(event.getDamager() instanceof Player)) + { + return; + } + + Player attacker = (Player)event.getDamager(); + + if (!plugin.al.isSeniorAdmin(attacker)) + { + return; + } + + ItemStack item = attacker.getInventory().getItemInMainHand(); + + if (item != null && item.getType().equals(Material.POTATO_ITEM)) + { + event.setCancelled(true); + attacker.addPassenger(event.getEntity()); + } + + + } + +}