mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-28 04:37:37 +00:00
Misc
This commit is contained in:
parent
35d0631387
commit
1ef9ec5211
@ -40,7 +40,7 @@ public class Command_cage extends TFM_Command
|
||||
Material cage_material_inner = Material.AIR;
|
||||
if (args.length >= 2)
|
||||
{
|
||||
if (args[1].equalsIgnoreCase("end") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("stop"))
|
||||
if (TFM_Util.isStopCommand(args[1]))
|
||||
{
|
||||
playerdata.setCaged(false);
|
||||
playerdata.regenerateHistory();
|
||||
|
@ -39,7 +39,7 @@ public class Command_orbit extends TFM_Command
|
||||
|
||||
if (args.length >= 2)
|
||||
{
|
||||
if (args[1].equalsIgnoreCase("stop") || args[1].equalsIgnoreCase("end"))
|
||||
if (TFM_Util.isStopCommand(args[1]))
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + "Stopped orbiting " + p.getName());
|
||||
playerdata.stopOrbiting();
|
||||
|
@ -1,68 +1,58 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Command_qjail extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Player p;
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
//Deop
|
||||
p.setOp(false);
|
||||
|
||||
//Set gamemode to survival:
|
||||
p.setGameMode(GameMode.SURVIVAL);
|
||||
|
||||
//Clear inventory:
|
||||
p.getInventory().clear();
|
||||
|
||||
//Strike with lightning effect:
|
||||
final Location target_pos = p.getLocation();
|
||||
for (int x = -1; x <= 1; x++)
|
||||
{
|
||||
for (int z = -1; z <= 1; z++)
|
||||
{
|
||||
final Location strike_pos = new Location(target_pos.getWorld(), target_pos.getBlockX() + x, target_pos.getBlockY(), target_pos.getBlockZ() + z);
|
||||
target_pos.getWorld().strikeLightning(strike_pos);
|
||||
}
|
||||
}
|
||||
|
||||
//Send to jail "mgjail":
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tjail %s mgjail 1y", p.getName().replace(" ", "").trim()));
|
||||
|
||||
TFM_Util.bcastMsg(p.getName() + " has been JAILED!", ChatColor.RED);
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
// @Override
|
||||
// public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
// {
|
||||
// if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
|
||||
// {
|
||||
// if (args.length < 1)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// Player p;
|
||||
// try
|
||||
// {
|
||||
// p = getPlayer(args[0]);
|
||||
// }
|
||||
// catch (CantFindPlayerException ex)
|
||||
// {
|
||||
// sender.sendMessage(ex.getMessage());
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// //Deop
|
||||
// p.setOp(false);
|
||||
//
|
||||
// //Set gamemode to survival:
|
||||
// p.setGameMode(GameMode.SURVIVAL);
|
||||
//
|
||||
// //Clear inventory:
|
||||
// p.getInventory().clear();
|
||||
//
|
||||
// //Strike with lightning effect:
|
||||
// final Location target_pos = p.getLocation();
|
||||
// for (int x = -1; x <= 1; x++)
|
||||
// {
|
||||
// for (int z = -1; z <= 1; z++)
|
||||
// {
|
||||
// final Location strike_pos = new Location(target_pos.getWorld(), target_pos.getBlockX() + x, target_pos.getBlockY(), target_pos.getBlockZ() + z);
|
||||
// target_pos.getWorld().strikeLightning(strike_pos);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //Send to jail "mgjail":
|
||||
// Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tjail %s mgjail 1y", p.getName().replace(" ", "").trim()));
|
||||
//
|
||||
// TFM_Util.bcastMsg(p.getName() + " has been JAILED!", ChatColor.RED);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class Command_stacker extends TFM_Command
|
||||
// {
|
||||
// if (args.length >= 1)
|
||||
// {
|
||||
// if (args[0].equalsIgnoreCase("end") || args[0].equalsIgnoreCase("stop"))
|
||||
// if (TFM_Util.isStopCommand(args[0]))
|
||||
// {
|
||||
// for (World world : Bukkit.getWorlds())
|
||||
// {
|
||||
|
@ -27,7 +27,7 @@ public class Command_tossmob extends TFM_Command
|
||||
CreatureType creature = CreatureType.PIG;
|
||||
if (args.length >= 1)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("end"))
|
||||
if (TFM_Util.isStopCommand(args[0]))
|
||||
{
|
||||
playerData.disableMobThrower();
|
||||
sender.sendMessage(ChatColor.GREEN + "MobThrower is disabled.");
|
||||
|
@ -217,27 +217,34 @@ public class TFM_PlayerListener extends PlayerListener
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// String message = event.getMessage().toLowerCase();
|
||||
// if (Pattern.compile("\\sbe\\s.*admin").matcher(message).find()
|
||||
// || Pattern.compile("\\shave\\s.*admin").matcher(message).find())
|
||||
// {
|
||||
// log.info("Kicked " + p.getName() + " for being annoying.");
|
||||
// p.kickPlayer("No, bitch.");
|
||||
// event.setCancelled(true);
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
String command = event.getMessage();
|
||||
Player player = event.getPlayer();
|
||||
Player p = event.getPlayer();
|
||||
|
||||
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
|
||||
playerdata.incrementMsgCount();
|
||||
|
||||
if (playerdata.getMsgCount() > 10)
|
||||
{
|
||||
p.setOp(false);
|
||||
p.kickPlayer("No Spamming");
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 1m", p.getName()));
|
||||
TFM_Util.bcastMsg(p.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
|
||||
playerdata.resetMsgCount();
|
||||
|
||||
TFM_Util.wipeDropEntities(true);
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.preprocessLogEnabled)
|
||||
{
|
||||
log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), command));
|
||||
log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", p.getName(), ChatColor.stripColor(p.getDisplayName()), command));
|
||||
}
|
||||
|
||||
command = command.toLowerCase().trim();
|
||||
@ -246,21 +253,21 @@ public class TFM_PlayerListener extends PlayerListener
|
||||
|
||||
if (Pattern.compile("^/stop").matcher(command).find())
|
||||
{
|
||||
if (!TFM_Util.isUserSuperadmin(player, plugin))
|
||||
if (!TFM_Util.isUserSuperadmin(p, plugin))
|
||||
{
|
||||
block_command = true;
|
||||
}
|
||||
}
|
||||
else if (Pattern.compile("^/reload").matcher(command).find())
|
||||
{
|
||||
if (!TFM_Util.isUserSuperadmin(player, plugin))
|
||||
if (!TFM_Util.isUserSuperadmin(p, plugin))
|
||||
{
|
||||
block_command = true;
|
||||
}
|
||||
}
|
||||
else if (Pattern.compile("^/save-").matcher(command).find())
|
||||
{
|
||||
if (!TFM_Util.isUserSuperadmin(player, plugin))
|
||||
if (!TFM_Util.isUserSuperadmin(p, plugin))
|
||||
{
|
||||
block_command = true;
|
||||
}
|
||||
@ -268,22 +275,22 @@ public class TFM_PlayerListener extends PlayerListener
|
||||
|
||||
if (block_command)
|
||||
{
|
||||
player.kickPlayer("That command is prohibited.");
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 1m", player.getName()));
|
||||
TFM_Util.bcastMsg(player.getName() + " was automatically kicked for using evil commands.", ChatColor.RED);
|
||||
p.kickPlayer("That command is prohibited.");
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 1m", p.getName()));
|
||||
TFM_Util.bcastMsg(p.getName() + " was automatically kicked for using evil commands.", ChatColor.RED);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Pattern.compile("^/time").matcher(command).find())
|
||||
{
|
||||
player.sendMessage(ChatColor.GRAY + "Server-side time changing is disabled. Please use /ptime to set your own personal time.");
|
||||
p.sendMessage(ChatColor.GRAY + "Server-side time changing is disabled. Please use /ptime to set your own personal time.");
|
||||
block_command = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (block_command)
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "That command is prohibited.");
|
||||
p.sendMessage(ChatColor.RED + "That command is prohibited.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -310,6 +317,11 @@ public class TFM_PlayerListener extends PlayerListener
|
||||
{
|
||||
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(event.getPlayer(), plugin);
|
||||
playerdata.disarmMP44();
|
||||
if (playerdata.isCaged())
|
||||
{
|
||||
playerdata.regenerateHistory();
|
||||
playerdata.clearHistory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -317,6 +329,11 @@ public class TFM_PlayerListener extends PlayerListener
|
||||
{
|
||||
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(event.getPlayer(), plugin);
|
||||
playerdata.disarmMP44();
|
||||
if (playerdata.isCaged())
|
||||
{
|
||||
playerdata.regenerateHistory();
|
||||
playerdata.clearHistory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -9,6 +9,7 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
@ -500,4 +501,19 @@ public class TFM_Util
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
private static final List<String> stop_commands = new ArrayList<String>();
|
||||
static
|
||||
{
|
||||
stop_commands.add("stop");
|
||||
stop_commands.add("off");
|
||||
stop_commands.add("end");
|
||||
stop_commands.add("halt");
|
||||
stop_commands.add("die");
|
||||
}
|
||||
|
||||
public static boolean isStopCommand(String command)
|
||||
{
|
||||
return stop_commands.contains(command.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
@ -86,9 +86,6 @@ commands:
|
||||
qdeop:
|
||||
description: Quick De-Op - deop someone based on a partial name.
|
||||
usage: /<command> <partialname>
|
||||
qjail:
|
||||
description: Quick Jail - Quickly jail someone (mgjail must be set as a jail!)
|
||||
usage: /<command> <partialname>
|
||||
qop:
|
||||
description: Quick Op - op someone based on a partial name.
|
||||
usage: /<command> <partialname>
|
||||
|
Loading…
Reference in New Issue
Block a user