mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Improvements
This commit is contained in:
parent
c423f273c5
commit
50cb6c4ca9
@ -62,6 +62,12 @@ public class AntiSpam extends FreedomService
|
|||||||
public void onAsyncPlayerChat(AsyncPlayerChatEvent event)
|
public void onAsyncPlayerChat(AsyncPlayerChatEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String message = event.getMessage().trim();
|
String message = event.getMessage().trim();
|
||||||
|
|
||||||
final FPlayer playerdata = plugin.pl.getPlayerSync(player);
|
final FPlayer playerdata = plugin.pl.getPlayerSync(player);
|
||||||
@ -104,6 +110,11 @@ public class AntiSpam extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (fPlayer.incrementAndGetMsgCount() > MSG_PER_CYCLE)
|
if (fPlayer.incrementAndGetMsgCount() > MSG_PER_CYCLE)
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg(player.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
|
FUtil.bcastMsg(player.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
|
||||||
|
@ -4,7 +4,8 @@ import me.totalfreedom.totalfreedommod.player.FPlayer;
|
|||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.SoundCategory;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -70,10 +71,13 @@ public class ChatManager extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (((float) caps / (float) message.length()) > 0.65) //Compute a ratio so that longer sentences can have more caps.
|
if (((float) caps / (float) message.length()) > 0.65) //Compute a ratio so that longer sentences can have more caps.
|
||||||
|
{
|
||||||
|
if (!plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
message = message.toLowerCase();
|
message = message.toLowerCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check for adminchat
|
// Check for adminchat
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
final FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
||||||
@ -84,6 +88,9 @@ public class ChatManager extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for mentions
|
||||||
|
checkMentions(message);
|
||||||
|
|
||||||
// Finally, set message
|
// Finally, set message
|
||||||
event.setMessage(message);
|
event.setMessage(message);
|
||||||
|
|
||||||
@ -100,10 +107,33 @@ public class ChatManager extends FreedomService
|
|||||||
event.setFormat(format);
|
event.setFormat(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkMentions(String message)
|
||||||
|
{
|
||||||
|
checkMentions(message, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkMentions(String message, boolean adminOnly)
|
||||||
|
{
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
// This is so if admins for some reason mention non-admins in admin chat, they won't be notified
|
||||||
|
if (adminOnly && !plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ChatColor.stripColor(message).toLowerCase().contains("@" + player.getName().toLowerCase()))
|
||||||
|
{
|
||||||
|
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_PLING, SoundCategory.PLAYERS, 100F, 0.9F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void adminChat(CommandSender sender, String message)
|
public void adminChat(CommandSender sender, String message)
|
||||||
{
|
{
|
||||||
String name = sender.getName() + " " + plugin.rm.getDisplay(sender).getColoredTag() + ChatColor.WHITE;
|
String name = sender.getName() + " " + plugin.rm.getDisplay(sender).getColoredTag() + ChatColor.WHITE;
|
||||||
FLog.info("[ADMIN] " + name + ": " + message);
|
FLog.info("[ADMIN] " + name + ": " + message);
|
||||||
|
checkMentions(message, true);
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
|
@ -26,7 +26,7 @@ public class LoginProcess extends FreedomService
|
|||||||
//
|
//
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private boolean lockdownEnabled = false;
|
private static boolean lockdownEnabled = false;
|
||||||
|
|
||||||
public LoginProcess(TotalFreedomMod plugin)
|
public LoginProcess(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
@ -14,11 +15,13 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
public class Muter extends FreedomService
|
public class Muter extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final List<String> MUTE_COMMANDS = Arrays.asList(StringUtils.split("say,me,msg,tell,reply,mail", ","));
|
public static final List<String> MUTE_COMMANDS = Arrays.asList(StringUtils.split("say,me,msg,tell,reply,mail", ","));
|
||||||
|
public final List<String> MUTED_PLAYERS = new ArrayList();
|
||||||
|
|
||||||
public Muter(TotalFreedomMod plugin)
|
public Muter(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
@ -38,16 +41,19 @@ public class Muter extends FreedomService
|
|||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
|
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
|
||||||
{
|
{
|
||||||
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
||||||
|
|
||||||
if (!fPlayer.isMuted())
|
if (!fPlayer.isMuted())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.al.isAdminSync(event.getPlayer()))
|
if (plugin.al.isAdminSync(player))
|
||||||
{
|
{
|
||||||
fPlayer.setMuted(false);
|
fPlayer.setMuted(false);
|
||||||
|
MUTED_PLAYERS.remove(player.getName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,4 +107,17 @@ public class Muter extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
|
if (MUTED_PLAYERS.contains(player.getName()))
|
||||||
|
{
|
||||||
|
playerdata.setMuted(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,12 @@ public class ServerPing extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (LoginProcess.isLockdownEnabled())
|
||||||
|
{
|
||||||
|
event.setMotd(ChatColor.RED + "Server is in lock-down.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (Bukkit.hasWhitelist())
|
if (Bukkit.hasWhitelist())
|
||||||
{
|
{
|
||||||
event.setMotd(ChatColor.RED + "Whitelist enabled.");
|
event.setMotd(ChatColor.RED + "Whitelist enabled.");
|
||||||
@ -55,8 +61,7 @@ public class ServerPing extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// String baseMotd = ConfigEntry.SERVER_MOTD.getString().replace("%mcversion%", plugin.si.getVersion());
|
String baseMotd = ConfigEntry.SERVER_MOTD.getString().replace("%mcversion%", plugin.si.getVersion());
|
||||||
String baseMotd = ConfigEntry.SERVER_MOTD.getString();
|
|
||||||
baseMotd = baseMotd.replace("\\n", "\n");
|
baseMotd = baseMotd.replace("\\n", "\n");
|
||||||
baseMotd = FUtil.colorize(baseMotd);
|
baseMotd = FUtil.colorize(baseMotd);
|
||||||
|
|
||||||
|
@ -8,17 +8,21 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_CONSOLE)
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_CONSOLE)
|
||||||
@CommandParameters(description = "Telnet command - Send a chat message with chat formatting over telnet.", usage = "/<command> <message...>", aliases = "csay")
|
@CommandParameters(description = "Telnet command - Send a chat message with chat formatting over telnet.", usage = "/<command> <message>", aliases = "csay")
|
||||||
public class Command_consolesay extends FreedomCommand
|
public class Command_consolesay extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (args.length > 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg(String.format("§7[CONSOLE]§f<§c%s§f> %s", sender.getName(), StringUtils.join(args, " ")));
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String message = StringUtils.join(args, " ");
|
||||||
|
plugin.cm.checkMentions(message);
|
||||||
|
FUtil.bcastMsg(String.format("§7[CONSOLE] §f<§c%s§f> %s", sender.getName(), StringUtils.join(args, " ")));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,8 @@ public class Command_say extends FreedomCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugin.cm.checkMentions(message);
|
||||||
|
|
||||||
FUtil.bcastMsg(String.format("[Server:%s] %s", sender.getName(), message), ChatColor.LIGHT_PURPLE);
|
FUtil.bcastMsg(String.format("[Server:%s] %s", sender.getName(), message), ChatColor.LIGHT_PURPLE);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -62,6 +62,7 @@ public class Command_stfu extends FreedomCommand
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
plugin.mu.MUTED_PLAYERS.clear();
|
||||||
msg("Unmuted " + count + " players.");
|
msg("Unmuted " + count + " players.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.GameRuleHandler;
|
import me.totalfreedom.totalfreedommod.GameRuleHandler;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
@ -70,7 +69,7 @@ public class Command_toggle extends FreedomCommand
|
|||||||
else if (args[0].equals("firespread"))
|
else if (args[0].equals("firespread"))
|
||||||
{
|
{
|
||||||
toggle("Fire spread is", ConfigEntry.ALLOW_FIRE_SPREAD);
|
toggle("Fire spread is", ConfigEntry.ALLOW_FIRE_SPREAD);
|
||||||
((TotalFreedomMod)this.plugin).gr.setGameRule(GameRuleHandler.GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean());
|
plugin.gr.setGameRule(GameRuleHandler.GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (args[0].equals("prelog"))
|
else if (args[0].equals("prelog"))
|
||||||
|
@ -25,8 +25,6 @@ public class Command_wipeflatlands extends FreedomCommand
|
|||||||
player.kickPlayer("Server is going offline for flatlands wipe, come back in a few minutes.");
|
player.kickPlayer("Server is going offline for flatlands wipe, come back in a few minutes.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plugin.cpb.isEnabled())
|
|
||||||
{
|
|
||||||
if (!plugin.amp.enabled)
|
if (!plugin.amp.enabled)
|
||||||
{
|
{
|
||||||
server.shutdown();
|
server.shutdown();
|
||||||
@ -35,18 +33,6 @@ public class Command_wipeflatlands extends FreedomCommand
|
|||||||
{
|
{
|
||||||
plugin.amp.restartServer();
|
plugin.amp.restartServer();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
new BukkitRunnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
plugin.cpb.clearDatabase(plugin.wm.flatlands.getWorld(), true);
|
|
||||||
}
|
|
||||||
}.runTaskAsynchronously(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -287,6 +287,7 @@ public class FPlayer
|
|||||||
public void setMuted(boolean muted)
|
public void setMuted(boolean muted)
|
||||||
{
|
{
|
||||||
FUtil.cancel(unmuteTask);
|
FUtil.cancel(unmuteTask);
|
||||||
|
plugin.mu.MUTED_PLAYERS.remove(getPlayer().getName());
|
||||||
unmuteTask = null;
|
unmuteTask = null;
|
||||||
|
|
||||||
if (!muted)
|
if (!muted)
|
||||||
@ -298,14 +299,25 @@ public class FPlayer
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugin.mu.MUTED_PLAYERS.add(getPlayer().getName());
|
||||||
|
|
||||||
unmuteTask = new BukkitRunnable()
|
unmuteTask = new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
|
{
|
||||||
|
if (getPlayer() != null)
|
||||||
{
|
{
|
||||||
FUtil.adminAction("TotalFreedom", "Unmuting " + getPlayer().getName(), false);
|
FUtil.adminAction("TotalFreedom", "Unmuting " + getPlayer().getName(), false);
|
||||||
setMuted(false);
|
setMuted(false);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FUtil.adminAction("TotalFreedom", "Unmuting " + getName(), false);
|
||||||
|
plugin.mu.MUTED_PLAYERS.remove(getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
}.runTaskLater(plugin, AUTO_PURGE_TICKS);
|
}.runTaskLater(plugin, AUTO_PURGE_TICKS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user