mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Redid qop and qdeop, again. I think this will work best :D
Please code in the "Allman" style in regards to indenting and bracket placement, at least in this project :D
This commit is contained in:
parent
9abdf265e4
commit
85ae29ad43
@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
|
|||||||
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -25,12 +24,12 @@ public class Command_ops extends TFM_Command
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("list"))
|
if (args[0].equalsIgnoreCase("list"))
|
||||||
{
|
{
|
||||||
String ops = "";
|
String ops = "";
|
||||||
String delim = "";
|
String delim = "";
|
||||||
for (OfflinePlayer p : server.getOperators()) {
|
for (OfflinePlayer p : server.getOperators())
|
||||||
|
{
|
||||||
ops += delim;
|
ops += delim;
|
||||||
ops += p.getName();
|
ops += p.getName();
|
||||||
delim = ",";
|
delim = ",";
|
||||||
|
@ -16,10 +16,19 @@ public class Command_qdeop extends TFM_Command
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
|
if (!(senderIsConsole || sender.isOp()))
|
||||||
{
|
{
|
||||||
|
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
boolean matched_player = false;
|
boolean matched_player = false;
|
||||||
for (Player p : server.matchPlayer(args[0]))
|
|
||||||
|
String target_name = args[0].toLowerCase();
|
||||||
|
|
||||||
|
for (Player p : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (p.getName().toLowerCase().indexOf(target_name) > 0 || p.getDisplayName().toLowerCase().indexOf(target_name) > 0)
|
||||||
{
|
{
|
||||||
matched_player = true;
|
matched_player = true;
|
||||||
|
|
||||||
@ -27,25 +36,11 @@ public class Command_qdeop extends TFM_Command
|
|||||||
p.setOp(false);
|
p.setOp(false);
|
||||||
p.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
|
p.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!matched_player)
|
if (!matched_player)
|
||||||
{
|
{
|
||||||
for (Player p : server.getOnlinePlayers())
|
TFM_Util.playerMsg(sender, "No targets matched.");
|
||||||
{
|
|
||||||
if (args[0].toLowerCase().startsWith(p.getDisplayName().toLowerCase()))
|
|
||||||
{
|
|
||||||
TFM_Util.adminAction(sender.getName(), "De-opping " + p.getName(), false);
|
|
||||||
p.setOp(false);
|
|
||||||
p.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sender.sendMessage("No targets matched.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -24,7 +24,11 @@ public class Command_qop extends TFM_Command
|
|||||||
|
|
||||||
boolean matched_player = false;
|
boolean matched_player = false;
|
||||||
|
|
||||||
for (Player p : server.matchPlayer(args[0]))
|
String target_name = args[0].toLowerCase();
|
||||||
|
|
||||||
|
for (Player p : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (p.getName().toLowerCase().indexOf(target_name) > 0 || p.getDisplayName().toLowerCase().indexOf(target_name) > 0)
|
||||||
{
|
{
|
||||||
matched_player = true;
|
matched_player = true;
|
||||||
|
|
||||||
@ -32,6 +36,7 @@ public class Command_qop extends TFM_Command
|
|||||||
p.setOp(true);
|
p.setOp(true);
|
||||||
p.sendMessage(TotalFreedomMod.YOU_ARE_OP);
|
p.sendMessage(TotalFreedomMod.YOU_ARE_OP);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!matched_player)
|
if (!matched_player)
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,6 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
public class TFM_BlockListener implements Listener
|
public class TFM_BlockListener implements Listener
|
||||||
{
|
{
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onBlockBurn(BlockBurnEvent event)
|
public void onBlockBurn(BlockBurnEvent event)
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,6 @@ import org.bukkit.event.entity.*;
|
|||||||
|
|
||||||
public class TFM_EntityListener implements Listener
|
public class TFM_EntityListener implements Listener
|
||||||
{
|
{
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onEntityExplode(EntityExplodeEvent event)
|
public void onEntityExplode(EntityExplodeEvent event)
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,6 @@ public class TFM_PlayerListener implements Listener
|
|||||||
{
|
{
|
||||||
private static final SimpleDateFormat date_format = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
private static final SimpleDateFormat date_format = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
||||||
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPlayerInteract(PlayerInteractEvent event)
|
public void onPlayerInteract(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
@ -301,8 +300,7 @@ public class TFM_PlayerListener implements Listener
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String m = event.getMessage();
|
final Player p = event.getPlayer();
|
||||||
Player p = event.getPlayer();
|
|
||||||
|
|
||||||
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
|
||||||
playerdata.incrementMsgCount();
|
playerdata.incrementMsgCount();
|
||||||
@ -337,28 +335,37 @@ public class TFM_PlayerListener implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String message = event.getMessage().trim();
|
||||||
|
|
||||||
|
// strip color from messages
|
||||||
|
message = ChatColor.stripColor(message);
|
||||||
|
|
||||||
// truncate messages that are too long
|
// truncate messages that are too long
|
||||||
if (m.length() > 95)
|
if (message.length() > 95)
|
||||||
{
|
{
|
||||||
event.setMessage(m.substring(0, 95));
|
message = message.substring(0, 95);
|
||||||
TFM_Util.playerMsg(p, "Message was shortened, because it was too long to send.");
|
TFM_Util.playerMsg(p, "Message was shortened, because it was too long to send.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for caps
|
// check for caps
|
||||||
int caps = 0;
|
if (message.length() >= 6)
|
||||||
for (int i=0; i<m.length(); i++)
|
{
|
||||||
|
int caps = 0;
|
||||||
|
for (char c : message.toCharArray())
|
||||||
|
{
|
||||||
|
if (Character.isUpperCase(c))
|
||||||
{
|
{
|
||||||
if (Character.isUpperCase(m.charAt(i)))
|
|
||||||
caps++;
|
caps++;
|
||||||
}
|
}
|
||||||
if(caps > 6)
|
}
|
||||||
|
if (((float) caps / (float) message.length()) > 0.75) //Compute a ratio so that longer sentences can have more caps.
|
||||||
{
|
{
|
||||||
event.setMessage(m.toLowerCase());
|
message = message.toLowerCase();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// strip color from messages
|
// finally, set message
|
||||||
event.setMessage(ChatColor.stripColor(event.getMessage()));
|
event.setMessage(message);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,6 @@ import org.bukkit.event.weather.WeatherChangeEvent;
|
|||||||
|
|
||||||
public class TFM_WeatherListener implements Listener
|
public class TFM_WeatherListener implements Listener
|
||||||
{
|
{
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onThunderChange(ThunderChangeEvent event)
|
public void onThunderChange(ThunderChangeEvent event)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user