sourcetype fixes; making sure in game commands work only in game
This commit is contained in:
speedxx 2020-07-28 23:14:58 -04:00
parent 05abebea65
commit 0ae835aa04
11 changed files with 49 additions and 39 deletions

View File

@ -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();
}
}
}

View File

@ -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 = "/<command>")
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Makes random sounds.", usage = "/<command>")
public class Command_deafen extends FreedomCommand
{
@ -48,4 +48,4 @@ public class Command_deafen extends FreedomCommand
{
return min + (random.nextDouble() * ((max - min) + 1.0));
}
}
}

View File

@ -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);
}
}
}
}

View File

@ -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 = "/<command> <on | off | info | sideways <on | off>>", aliases = "launchpads,jp")
public class Command_jumppads extends FreedomCommand
{
@ -113,4 +113,4 @@ public class Command_jumppads extends FreedomCommand
return Collections.emptyList();
}
}
}

View File

@ -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
}
}
}
}

View File

@ -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)
{

View File

@ -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();
}
}
}

View File

@ -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 = "/<command> <block> [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;
}
}
}

View File

@ -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;
}
}
}

View File

@ -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

View File

@ -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