From 0ae835aa04e9bbeef89bdd0c9dc44424e17d653f Mon Sep 17 00:00:00 2001 From: speedxx <43330808+speedxx@users.noreply.github.com> Date: Tue, 28 Jul 2020 23:14:58 -0400 Subject: [PATCH] weSmart sourcetype fixes; making sure in game commands work only in game --- .../command/Command_adminworld.java | 4 +-- .../command/Command_deafen.java | 6 ++-- .../command/Command_hubworld.java | 5 ++- .../command/Command_jumppads.java | 4 +-- .../command/Command_masterbuilderworld.java | 4 +-- .../command/Command_potion.java | 32 ++++++++----------- .../totalfreedommod/command/Command_rank.java | 4 +-- .../totalfreedommod/command/Command_ro.java | 6 ++-- .../command/Command_spectate.java | 9 ++++-- .../totalfreedommod/command/Command_tag.java | 12 +++++++ src/main/resources/plugin.yml | 2 +- 11 files changed, 49 insertions(+), 39 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminworld.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminworld.java index 46cc1798..bf1406eb 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminworld.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminworld.java @@ -57,7 +57,7 @@ public class Command_adminworld extends FreedomCommand { if (!(sender instanceof Player) || playerSender == null) { - return true; + return false; } World adminWorld = null; @@ -198,4 +198,4 @@ public class Command_adminworld extends FreedomCommand } return Collections.emptyList(); } -} +} \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deafen.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deafen.java index 4a38db0a..f8c2e113 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deafen.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deafen.java @@ -9,8 +9,8 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; -@CommandPermissions(level = Rank.OP, source = SourceType.BOTH) -@CommandParameters(description = "Makes random sounds to everyone online.", usage = "/") +@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandParameters(description = "Makes random sounds.", usage = "/") public class Command_deafen extends FreedomCommand { @@ -48,4 +48,4 @@ public class Command_deafen extends FreedomCommand { return min + (random.nextDouble() * ((max - min) + 1.0)); } -} +} \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_hubworld.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_hubworld.java index bacadfdc..4e9eff37 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_hubworld.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_hubworld.java @@ -57,7 +57,7 @@ public class Command_hubworld extends FreedomCommand { if (!(sender instanceof Player) || playerSender == null) { - return true; + return false; } World hubWorld = null; @@ -198,5 +198,4 @@ public class Command_hubworld extends FreedomCommand super(string); } } - -} +} \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_jumppads.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_jumppads.java index 1f6e7faf..604ce9be 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_jumppads.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_jumppads.java @@ -10,7 +10,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.OP, source = SourceType.BOTH) +@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Toggles jumppads on/off, view the status of jumppads, or make them sideways.", usage = "/ >", aliases = "launchpads,jp") public class Command_jumppads extends FreedomCommand { @@ -113,4 +113,4 @@ public class Command_jumppads extends FreedomCommand return Collections.emptyList(); } -} +} \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_masterbuilderworld.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_masterbuilderworld.java index b3d02757..b368a18b 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_masterbuilderworld.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_masterbuilderworld.java @@ -57,7 +57,7 @@ public class Command_masterbuilderworld extends FreedomCommand { if (!(sender instanceof Player) || playerSender == null) { - return true; + return false; } World masterBuilderWorld = null; @@ -199,4 +199,4 @@ public class Command_masterbuilderworld extends FreedomCommand } } -} +} \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java index 72eab67c..d2c40f9d 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java @@ -70,20 +70,18 @@ public class Command_potion extends FreedomCommand } } - if (!target.equals(playerSender)) - { - if (!plugin.al.isAdmin(sender)) - { - msg(ChatColor.RED + "Only admins can clear potion effects from other players."); - return true; - } - } - else if (senderIsConsole) + if (senderIsConsole) { msg("You must specify a target player when using this command from the console."); return true; } + if (!plugin.al.isAdmin(sender)) + { + msg(ChatColor.RED + "Only admins can clear potion effects from other players."); + return true; + } + for (PotionEffect potion_effect : target.getActivePotionEffects()) { target.removePotionEffect(potion_effect.getType()); @@ -113,20 +111,18 @@ public class Command_potion extends FreedomCommand } } - if (!target.equals(playerSender)) - { - if (!plugin.al.isAdmin(sender)) - { - sender.sendMessage(ChatColor.RED + "Only admins can apply potion effects to other players."); - return true; - } - } - else if (senderIsConsole) + if (senderIsConsole) { sender.sendMessage("You must specify a target player when using this command from the console."); return true; } + if (!plugin.al.isAdmin(sender)) + { + sender.sendMessage(ChatColor.RED + "Only admins can apply potion effects to other players."); + return true; + } + PotionEffectType potion_effect_type = PotionEffectType.getByName(args[1]); if (potion_effect_type == null) { diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rank.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rank.java index 916a564c..ab7e02bb 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rank.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rank.java @@ -15,7 +15,7 @@ public class Command_rank extends FreedomCommand @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - if (isConsole() && args.length == 0) + if (senderIsConsole && args.length == 0) { for (Player player : server.getOnlinePlayers()) { @@ -72,4 +72,4 @@ public class Command_rank extends FreedomCommand return sb.toString(); } -} +} \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ro.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ro.java index 96885fe9..548b68b9 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ro.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ro.java @@ -17,7 +17,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = false) +@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Remove all blocks of a certain type in the radius of certain players.", usage = "/ [radius (default=50)] [player]") public class Command_ro extends FreedomCommand { @@ -58,7 +58,7 @@ public class Command_ro extends FreedomCommand } } - int radius = 20; + int radius = 50; if (args.length >= 2) { try @@ -179,4 +179,4 @@ public class Command_ro extends FreedomCommand return affected; } -} +} \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectate.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectate.java index 94c93620..a32179e5 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectate.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectate.java @@ -15,7 +15,6 @@ 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; @@ -39,8 +38,12 @@ public class Command_spectate extends FreedomCommand playerSender.setGameMode(GameMode.SPECTATOR); } - playerSender.setSpectatorTarget(player); + if (playerSender.getWorld() != player.getWorld()) + { + playerSender.teleport(player); + } + playerSender.setSpectatorTarget(player); return true; } -} +} \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java index 244cbed8..d002aa47 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java @@ -138,6 +138,12 @@ public class Command_tag extends FreedomCommand } else if ("set".equalsIgnoreCase(args[0])) { + if (senderIsConsole) + { + msg("\"/tag set\" can't be used from the console."); + return true; + } + final String inputTag = StringUtils.join(args, " ", 1, args.length); final String strippedTag = StringUtils.replaceEachRepeatedly(StringUtils.strip(inputTag), new String[] @@ -183,6 +189,12 @@ public class Command_tag extends FreedomCommand } else if (args[0].equalsIgnoreCase("gradient")) { + if (senderIsConsole) + { + msg("\"/tag gradient\" can't be used from the console."); + return true; + } + String from = "", to = ""; java.awt.Color awt1, awt2; try diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 3e6f5636..7229c243 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,6 +2,6 @@ name: TotalFreedomMod main: me.totalfreedom.totalfreedommod.TotalFreedomMod version: ${project.version} description: Plugin for the Total Freedom server. -softdepend: [BukkitTelnet, Essentials, LibsDisguises, WorldEdit, TFGuilds] +softdepend: [BukkitTelnet, Essentials, LibsDisguises, WorldEdit] authors: [Madgeek1450, Prozza] api-version: 1.15 \ No newline at end of file