mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-30 02:05:41 +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)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String message = event.getMessage().trim();
|
||||
|
||||
final FPlayer playerdata = plugin.pl.getPlayerSync(player);
|
||||
@ -104,6 +110,11 @@ public class AntiSpam extends FreedomService
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (fPlayer.incrementAndGetMsgCount() > MSG_PER_CYCLE)
|
||||
{
|
||||
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.FSync;
|
||||
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.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -71,7 +72,10 @@ public class ChatManager extends FreedomService
|
||||
}
|
||||
if (((float) caps / (float) message.length()) > 0.65) //Compute a ratio so that longer sentences can have more caps.
|
||||
{
|
||||
message = message.toLowerCase();
|
||||
if (!plugin.al.isAdmin(player))
|
||||
{
|
||||
message = message.toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,6 +88,9 @@ public class ChatManager extends FreedomService
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for mentions
|
||||
checkMentions(message);
|
||||
|
||||
// Finally, set message
|
||||
event.setMessage(message);
|
||||
|
||||
@ -100,10 +107,33 @@ public class ChatManager extends FreedomService
|
||||
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)
|
||||
{
|
||||
String name = sender.getName() + " " + plugin.rm.getDisplay(sender).getColoredTag() + ChatColor.WHITE;
|
||||
FLog.info("[ADMIN] " + name + ": " + message);
|
||||
checkMentions(message, true);
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
|
@ -26,7 +26,7 @@ public class LoginProcess extends FreedomService
|
||||
//
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean lockdownEnabled = false;
|
||||
private static boolean lockdownEnabled = false;
|
||||
|
||||
public LoginProcess(TotalFreedomMod plugin)
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
@ -14,11 +15,13 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class Muter extends FreedomService
|
||||
{
|
||||
|
||||
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)
|
||||
{
|
||||
@ -38,16 +41,19 @@ public class Muter extends FreedomService
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
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())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.al.isAdminSync(event.getPlayer()))
|
||||
if (plugin.al.isAdminSync(player))
|
||||
{
|
||||
fPlayer.setMuted(false);
|
||||
MUTED_PLAYERS.remove(player.getName());
|
||||
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;
|
||||
}
|
||||
|
||||
if (LoginProcess.isLockdownEnabled())
|
||||
{
|
||||
event.setMotd(ChatColor.RED + "Server is in lock-down.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Bukkit.hasWhitelist())
|
||||
{
|
||||
event.setMotd(ChatColor.RED + "Whitelist enabled.");
|
||||
@ -55,8 +61,7 @@ public class ServerPing extends FreedomService
|
||||
return;
|
||||
}
|
||||
|
||||
// String baseMotd = ConfigEntry.SERVER_MOTD.getString().replace("%mcversion%", plugin.si.getVersion());
|
||||
String baseMotd = ConfigEntry.SERVER_MOTD.getString();
|
||||
String baseMotd = ConfigEntry.SERVER_MOTD.getString().replace("%mcversion%", plugin.si.getVersion());
|
||||
baseMotd = baseMotd.replace("\\n", "\n");
|
||||
baseMotd = FUtil.colorize(baseMotd);
|
||||
|
||||
|
@ -8,17 +8,21 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@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
|
||||
{
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
return true;
|
||||
|
@ -62,6 +62,7 @@ public class Command_stfu extends FreedomCommand
|
||||
count++;
|
||||
}
|
||||
}
|
||||
plugin.mu.MUTED_PLAYERS.clear();
|
||||
msg("Unmuted " + count + " players.");
|
||||
return true;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.GameRuleHandler;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
@ -70,7 +69,7 @@ public class Command_toggle extends FreedomCommand
|
||||
else if (args[0].equals("firespread"))
|
||||
{
|
||||
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;
|
||||
}
|
||||
else if (args[0].equals("prelog"))
|
||||
|
@ -25,27 +25,13 @@ public class Command_wipeflatlands extends FreedomCommand
|
||||
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();
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.amp.restartServer();
|
||||
}
|
||||
server.shutdown();
|
||||
}
|
||||
else
|
||||
{
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
plugin.cpb.clearDatabase(plugin.wm.flatlands.getWorld(), true);
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
plugin.amp.restartServer();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -287,6 +287,7 @@ public class FPlayer
|
||||
public void setMuted(boolean muted)
|
||||
{
|
||||
FUtil.cancel(unmuteTask);
|
||||
plugin.mu.MUTED_PLAYERS.remove(getPlayer().getName());
|
||||
unmuteTask = null;
|
||||
|
||||
if (!muted)
|
||||
@ -298,13 +299,24 @@ public class FPlayer
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.mu.MUTED_PLAYERS.add(getPlayer().getName());
|
||||
|
||||
unmuteTask = new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
FUtil.adminAction("TotalFreedom", "Unmuting " + getPlayer().getName(), false);
|
||||
setMuted(false);
|
||||
if (getPlayer() != null)
|
||||
{
|
||||
FUtil.adminAction("TotalFreedom", "Unmuting " + getPlayer().getName(), false);
|
||||
setMuted(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
FUtil.adminAction("TotalFreedom", "Unmuting " + getName(), false);
|
||||
plugin.mu.MUTED_PLAYERS.remove(getName());
|
||||
}
|
||||
}
|
||||
}.runTaskLater(plugin, AUTO_PURGE_TICKS);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user