forked from TotalFreedomMC/TotalFreedomMod
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split gcmd sub cmds out n other stuff
- Loading branch information
1 parent
891e5c2
commit 76bb2d0
Showing
21 changed files
with
430 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
src/main/java/me/totalfreedom/totalfreedommod/command/Command_banip.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package me.totalfreedom.totalfreedommod.command; | ||
|
||
import me.totalfreedom.totalfreedommod.banning.Ban; | ||
import me.totalfreedom.totalfreedommod.rank.Rank; | ||
import me.totalfreedom.totalfreedommod.util.FLog; | ||
import me.totalfreedom.totalfreedommod.util.FUtil; | ||
import org.apache.commons.lang.ArrayUtils; | ||
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.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true) | ||
@CommandParameters(description = "Bans the specified ip.", usage = "/<command> <ip> [reason] [-q]") | ||
public class Command_banip extends FreedomCommand | ||
{ | ||
|
||
@Override | ||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) | ||
{ | ||
if (args.length == 0) | ||
{ | ||
return false; | ||
} | ||
|
||
boolean silent = false; | ||
|
||
String reason = null; | ||
|
||
String ip = args[0]; | ||
|
||
if (!FUtil.isValidIPv4(ip)) | ||
{ | ||
msg(ip + " is not a valid IP address", ChatColor.RED); | ||
return true; | ||
} | ||
|
||
if (plugin.bm.getByIp(ip) != null) | ||
{ | ||
msg("The IP " + ip + " is already banned", ChatColor.RED); | ||
return true; | ||
} | ||
|
||
if (args[args.length - 1].equalsIgnoreCase("-q")) | ||
{ | ||
silent = true; | ||
|
||
if (args.length >= 2) | ||
{ | ||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " "); | ||
} | ||
} | ||
else if (args.length > 1) | ||
{ | ||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " "); | ||
} | ||
|
||
// Ban player | ||
Ban ban = Ban.forPlayerIp(ip, sender, null, reason); | ||
plugin.bm.addBan(ban); | ||
|
||
// Kick player and handle others on IP | ||
for (Player player : server.getOnlinePlayers()) | ||
{ | ||
if (FUtil.getIp(player).equals(ip)) | ||
{ | ||
player.kickPlayer(ban.bakeKickMessage()); | ||
} | ||
|
||
if (!silent) | ||
{ | ||
// Broadcast | ||
FLog.info(ChatColor.RED + sender.getName() + " - Banned the IP " + ip); | ||
String message = ChatColor.RED + sender.getName() + " - Banned " + (plugin.al.isAdmin(player) ? "the IP " + ip : "an IP"); | ||
player.sendMessage(message); | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
src/main/java/me/totalfreedom/totalfreedommod/command/Command_banname.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package me.totalfreedom.totalfreedommod.command; | ||
|
||
import me.totalfreedom.totalfreedommod.banning.Ban; | ||
import me.totalfreedom.totalfreedommod.rank.Rank; | ||
import me.totalfreedom.totalfreedommod.util.FUtil; | ||
import org.apache.commons.lang.ArrayUtils; | ||
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.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true) | ||
@CommandParameters(description = "Bans the specified name.", usage = "/<command> <name> [reason] [-q]") | ||
public class Command_banname extends FreedomCommand | ||
{ | ||
|
||
@Override | ||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) | ||
{ | ||
if (args.length == 0) | ||
{ | ||
return false; | ||
} | ||
|
||
boolean silent = false; | ||
|
||
String reason = null; | ||
|
||
String name = args[0];; | ||
|
||
if (plugin.bm.getByUsername(name) != null) | ||
{ | ||
msg("The name " + name + " is already banned", ChatColor.RED); | ||
return true; | ||
} | ||
|
||
if (args[args.length - 1].equalsIgnoreCase("-q")) | ||
{ | ||
silent = true; | ||
|
||
if (args.length >= 2) | ||
{ | ||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " "); | ||
} | ||
} | ||
else if (args.length > 1) | ||
{ | ||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " "); | ||
} | ||
|
||
// Ban player | ||
Ban ban = Ban.forPlayerName(name, sender, null, reason); | ||
plugin.bm.addBan(ban); | ||
|
||
if (!silent) | ||
{ | ||
FUtil.adminAction(sender.getName(), "Banned the name " + name, true); | ||
} | ||
|
||
Player player = getPlayer(name); | ||
if (player != null) | ||
{ | ||
player.kickPlayer(ban.bakeKickMessage()); | ||
} | ||
return true; | ||
} | ||
} |
Oops, something went wrong.