mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-06-11 21:43:54 +00:00
Fixes, added /hub, removed CONSOLE restrictions on some commands
This commit is contained in:
@ -10,7 +10,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
||||
@CommandPermissions(level = Rank.TELNET_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Close server to non-admins.", usage = "/<command> [on | off]")
|
||||
public class Command_adminmode extends FreedomCommand
|
||||
{
|
||||
|
@ -11,9 +11,9 @@ import org.bukkit.ChatColor;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Cuck someone", usage = "/<command> <player>")
|
||||
public class Command_cuck extends FreedomCommand
|
||||
public class Command_cuck extends FreedomCommand
|
||||
{
|
||||
|
||||
/* This command will not work on Paper because there was a patch to remove it. This will work on Spigot and Bukkit. */
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -55,4 +55,4 @@ public class Command_cuck extends FreedomCommand
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Make some noise.", usage = "/<command>")
|
||||
public class Command_deafen extends FreedomCommand
|
||||
{
|
||||
|
@ -141,11 +141,11 @@ public class Command_gtfo extends FreedomCommand
|
||||
.append(" - ")
|
||||
.append("Banning: ")
|
||||
.append(username);
|
||||
playerMsg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + StringUtils.join(ips, ", "));
|
||||
if (reason != null)
|
||||
{
|
||||
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
|
||||
}
|
||||
playerMsg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + StringUtils.join(ips, ", "));
|
||||
FUtil.bcastMsg(bcast.toString());
|
||||
|
||||
// Kick player
|
||||
|
@ -0,0 +1,203 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import me.totalfreedom.totalfreedommod.world.WorldTime;
|
||||
import me.totalfreedom.totalfreedommod.world.WorldWeather;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Go to the MasterBuilderWorld.",
|
||||
usage = "/<command> [time <morning | noon | evening | night> | weather <off | rain | storm>]",
|
||||
aliases = "hw,hworld")
|
||||
public class Command_hubworld extends FreedomCommand
|
||||
{
|
||||
|
||||
private enum CommandMode
|
||||
{
|
||||
TELEPORT, TIME, WEATHER
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
CommandMode commandMode = null;
|
||||
|
||||
if (args.length == 0)
|
||||
{
|
||||
commandMode = CommandMode.TELEPORT;
|
||||
}
|
||||
else if (args.length >= 2)
|
||||
{
|
||||
if ("time".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
commandMode = CommandMode.TIME;
|
||||
}
|
||||
else if ("weather".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
commandMode = CommandMode.WEATHER;
|
||||
}
|
||||
}
|
||||
|
||||
if (commandMode == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
switch (commandMode)
|
||||
{
|
||||
case TELEPORT:
|
||||
{
|
||||
if (!(sender instanceof Player) || playerSender == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
World masterBuilderWorld = null;
|
||||
try
|
||||
{
|
||||
masterBuilderWorld = plugin.wm.hubworld.getWorld();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
|
||||
if (masterBuilderWorld == null || playerSender.getWorld() == masterBuilderWorld)
|
||||
{
|
||||
msg("Going to the main world.");
|
||||
playerSender.teleport(server.getWorlds().get(0).getSpawnLocation());
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Going to the Hub");
|
||||
plugin.wm.hubworld.sendToWorld(playerSender);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case TIME:
|
||||
{
|
||||
assertCommandPerms(sender, playerSender);
|
||||
|
||||
if (args.length == 2)
|
||||
{
|
||||
WorldTime timeOfDay = WorldTime.getByAlias(args[1]);
|
||||
if (timeOfDay != null)
|
||||
{
|
||||
plugin.wm.hubworld.setTimeOfDay(timeOfDay);
|
||||
msg("Hub time set to: " + timeOfDay.name());
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Invalid time of day. Can be: sunrise, noon, sunset, midnight");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case WEATHER:
|
||||
{
|
||||
assertCommandPerms(sender, playerSender);
|
||||
|
||||
if (args.length == 2)
|
||||
{
|
||||
WorldWeather weatherMode = WorldWeather.getByAlias(args[1]);
|
||||
if (weatherMode != null)
|
||||
{
|
||||
plugin.wm.hubworld.setWeatherMode(weatherMode);
|
||||
msg("Hub weather set to: " + weatherMode.name());
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Invalid weather mode. Can be: off, rain, storm");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (PermissionDeniedException ex)
|
||||
{
|
||||
if (ex.getMessage().isEmpty())
|
||||
{
|
||||
return noPerms();
|
||||
}
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (!plugin.al.isAdmin(sender))
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (args.length == 1)
|
||||
{
|
||||
return Arrays.asList("time", "weather");
|
||||
}
|
||||
else if (args.length == 2)
|
||||
{
|
||||
if (args[0].equals("time"))
|
||||
{
|
||||
return Arrays.asList("morning", "noon", "evening", "night");
|
||||
}
|
||||
else if (args[0].equals("weather"))
|
||||
{
|
||||
return Arrays.asList("off", "rain", "storm");
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// TODO: Redo this properly
|
||||
private void assertCommandPerms(CommandSender sender, Player playerSender) throws PermissionDeniedException
|
||||
{
|
||||
if (!(sender instanceof Player) || playerSender == null || !plugin.al.isSeniorAdmin(playerSender))
|
||||
{
|
||||
throw new PermissionDeniedException();
|
||||
}
|
||||
}
|
||||
|
||||
private class PermissionDeniedException extends Exception
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private PermissionDeniedException()
|
||||
{
|
||||
super("");
|
||||
}
|
||||
|
||||
private PermissionDeniedException(String string)
|
||||
{
|
||||
super(string);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Kick all non-admins on server.", usage = "/<command>")
|
||||
public class Command_kicknoob extends FreedomCommand
|
||||
{
|
||||
|
@ -19,24 +19,6 @@ public class Command_opall extends FreedomCommand
|
||||
|
||||
boolean doSetGamemode = false;
|
||||
GameMode targetGamemode = GameMode.CREATIVE;
|
||||
if (args.length != 0)
|
||||
{
|
||||
if (args[0].equals("-c"))
|
||||
{
|
||||
doSetGamemode = true;
|
||||
targetGamemode = GameMode.CREATIVE;
|
||||
}
|
||||
else if (args[0].equals("-s"))
|
||||
{
|
||||
doSetGamemode = true;
|
||||
targetGamemode = GameMode.SURVIVAL;
|
||||
}
|
||||
else if (args[0].equals("-a"))
|
||||
{
|
||||
doSetGamemode = true;
|
||||
targetGamemode = GameMode.ADVENTURE;
|
||||
}
|
||||
}
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Manage permanently banned players and IPs.", usage = "/<command> reload")
|
||||
public class Command_permban extends FreedomCommand
|
||||
{
|
||||
|
@ -1,113 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
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.NON_OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Shows nearby people sorted by distance.", usage = "/<command> [range]")
|
||||
public class Command_radar extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
Location playerSenderos = playerSender.getLocation();
|
||||
|
||||
List<RadarData> radar_data = new ArrayList<>();
|
||||
|
||||
for (Player player : playerSenderos.getWorld().getPlayers())
|
||||
{
|
||||
if (!player.equals(playerSender))
|
||||
{
|
||||
try
|
||||
{
|
||||
radar_data.add(new RadarData(player, playerSenderos.distance(player.getLocation()), player.getLocation()));
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (radar_data.isEmpty())
|
||||
{
|
||||
msg("You are the only player in this world. (" + ChatColor.GREEN + "Forever alone..." + ChatColor.YELLOW + ")", ChatColor.YELLOW); //lol
|
||||
return true;
|
||||
}
|
||||
|
||||
Collections.sort(radar_data, new RadarData());
|
||||
|
||||
msg("People nearby in " + playerSenderos.getWorld().getName() + ":", ChatColor.YELLOW);
|
||||
|
||||
int countmax = 5;
|
||||
if (args.length == 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
countmax = Math.max(1, Math.min(64, Integer.parseInt(args[0])));
|
||||
}
|
||||
catch (NumberFormatException nfex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
for (RadarData i : radar_data)
|
||||
{
|
||||
msg(String.format("%s - %d",
|
||||
i.player.getName(),
|
||||
Math.round(i.distance)), ChatColor.YELLOW);
|
||||
|
||||
if (--countmax <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private class RadarData implements Comparator<RadarData>
|
||||
{
|
||||
|
||||
public Player player;
|
||||
public double distance;
|
||||
public Location location;
|
||||
|
||||
public RadarData(Player player, double distance, Location location)
|
||||
{
|
||||
this.player = player;
|
||||
this.distance = distance;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public RadarData()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(RadarData t1, RadarData t2)
|
||||
{
|
||||
if (t1.distance > t2.distance)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (t1.distance < t2.distance)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Broadcasts the given message. Supports colors.", usage = "/<command> <message>")
|
||||
public class Command_rawsay extends FreedomCommand
|
||||
{
|
||||
|
@ -42,8 +42,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
|
||||
case "clean":
|
||||
{
|
||||
checkConsole();
|
||||
checkRank(Rank.TELNET_ADMIN);
|
||||
checkRank(Rank.SENIOR_ADMIN);
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Cleaning admin list", true);
|
||||
plugin.al.deactivateOldEntries(true);
|
||||
@ -54,7 +53,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
|
||||
case "reload":
|
||||
{
|
||||
checkRank(Rank.SUPER_ADMIN);
|
||||
checkRank(Rank.SENIOR_ADMIN);
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Reloading the admin list", true);
|
||||
plugin.al.load();
|
||||
@ -64,9 +63,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
|
||||
case "setrank":
|
||||
{
|
||||
checkConsole();
|
||||
checkNotHostConsole();
|
||||
checkRank(Rank.SENIOR_CONSOLE);
|
||||
checkRank(Rank.SENIOR_ADMIN);
|
||||
|
||||
if (args.length < 3)
|
||||
{
|
||||
@ -158,7 +155,6 @@ public class Command_saconfig extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
checkConsole();
|
||||
checkRank(Rank.TELNET_ADMIN);
|
||||
|
||||
// Player already an admin?
|
||||
@ -330,7 +326,6 @@ public class Command_saconfig extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
checkConsole();
|
||||
checkRank(Rank.TELNET_ADMIN);
|
||||
|
||||
Player player = getPlayer(args[1]);
|
||||
|
@ -10,6 +10,8 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.ChatColor;
|
||||
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Unbans a player", usage = "/<command> <username> [-r[estore]]")
|
||||
@ -35,7 +37,8 @@ public class Command_unban extends FreedomCommand
|
||||
username = entry.getUsername();
|
||||
ips.addAll(entry.getIps());
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Unbanning " + username + " and IPs: " + StringUtils.join(ips, ", "), true);
|
||||
FUtil.adminAction(sender.getName(), "Unbanning " + username, true);
|
||||
playerMsg(sender, ChatColor.GRAY + username + " has been unbanned and IP is: " + StringUtils.join(ips, ", "));
|
||||
plugin.bm.removeBan(plugin.bm.getByUsername(username));
|
||||
|
||||
if (args.length >= 2)
|
||||
|
@ -0,0 +1,34 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
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.BOTH)
|
||||
@CommandParameters(description = "Information on how to vote", usage = "/<command>", aliases = "ai")
|
||||
public class Command_vote extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
List<String> voteInfo = ConfigEntry.VOTING_INFO.getStringList();
|
||||
|
||||
if (voteInfo.isEmpty())
|
||||
{
|
||||
msg("There is no voting information set in the config.", ChatColor.RED);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg(FUtil.colorize(StringUtils.join(voteInfo, "\n")));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user