From 5cfb525a1f0a01231dcaa85f84fc5ffaf8e66622 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 8 Dec 2019 12:41:09 -0500 Subject: [PATCH] more freedom i guess? --- .../totalfreedommod/AntiSpam.java | 10 -- .../totalfreedommod/ChatManager.java | 33 +---- .../command/Command_tabcolor.java | 4 +- .../hub/HubWorldRestrictions.java | 133 ------------------ src/main/resources/config.yml | 2 +- 5 files changed, 6 insertions(+), 176 deletions(-) delete mode 100644 src/main/java/me/totalfreedom/totalfreedommod/hub/HubWorldRestrictions.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/AntiSpam.java b/src/main/java/me/totalfreedom/totalfreedommod/AntiSpam.java index 799dc314..b568e337 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/AntiSpam.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/AntiSpam.java @@ -83,16 +83,6 @@ public class AntiSpam extends FreedomService event.setCancelled(true); return; } - - // Check for message repeat - if (playerdata.getLastMessage().equalsIgnoreCase(message)) - { - FSync.playerMsg(player, "Please do not repeat messages."); - event.setCancelled(true); - return; - } - - playerdata.setLastMessage(message); } @EventHandler(priority = EventPriority.LOW) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java b/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java index 0a7ef8ad..e3345816 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java @@ -53,23 +53,14 @@ public class ChatManager extends FreedomService { final Player player = event.getPlayer(); String message = event.getMessage().trim(); - - if (plugin.al.isAdmin(player)) + // Format colors { - // Format color + message = FUtil.colorize(message); message = message.replaceAll(ChatColor.BOLD.toString(), "&l"); - message = message.replaceAll(ChatColor.MAGIC.toString(), "&k"); message = message.replaceAll(ChatColor.ITALIC.toString(), "&o"); message = message.replaceAll(ChatColor.UNDERLINE.toString(), "&n"); message = message.replaceAll(ChatColor.STRIKETHROUGH.toString(), "&m"); - message = FUtil.colorize(message); } - else - { - // Strip color from messages - message = ChatColor.stripColor(message); - } - // Truncate messages that are too long - 256 characters is vanilla client max if (message.length() > 256) { @@ -77,26 +68,6 @@ public class ChatManager extends FreedomService FSync.playerMsg(player, "Message was shortened because it was too long to send."); } - // Check for caps - if (message.length() >= 6) - { - int caps = 0; - for (char c : message.toCharArray()) - { - if (Character.isUpperCase(c)) - { - 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(); - } - } - } - // Check for adminchat final FPlayer fPlayer = plugin.pl.getPlayerSync(player); if (fPlayer.inAdminChat()) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tabcolor.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tabcolor.java index 1f6f1027..ae56f860 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tabcolor.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tabcolor.java @@ -56,7 +56,9 @@ public class Command_tabcolor extends FreedomCommand playerSender.setPlayerListName(StringUtils.substring(color + sender.getName(), 0, 16)); - msg("ok dad"); + final String newTabColor = color + ChatColor.stripColor(playerSender.getDisplayName()).trim() + ChatColor.WHITE; + + msg("Your tab name will now appear as: " + newTabColor); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/hub/HubWorldRestrictions.java b/src/main/java/me/totalfreedom/totalfreedommod/hub/HubWorldRestrictions.java deleted file mode 100644 index 5d18a4b7..00000000 --- a/src/main/java/me/totalfreedom/totalfreedommod/hub/HubWorldRestrictions.java +++ /dev/null @@ -1,133 +0,0 @@ -package me.totalfreedom.totalfreedommod.hub; - -import java.util.Arrays; -import java.util.List; -import me.totalfreedom.totalfreedommod.FreedomService; -import me.totalfreedom.totalfreedommod.TotalFreedomMod; -import me.totalfreedom.totalfreedommod.util.FUtil; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.player.PlayerArmorStandManipulateEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEvent; - -public class HubWorldRestrictions extends FreedomService -{ - - public final List ALLOWED_COMMANDS = Arrays.asList( - "list", "opall", "gmc", "gms", "gma", "gmsp", "purgeall", "stfu", "tempban", "gtfo", "noob", "flatlands", "adminworld", "masterbuilderworld", "world", "nether", "spawn", "tpo", "tp", "expel", "item", "i", "give", "adminchat", "adventure", "creative", "survival", "spectator", "say", "blockcmd", "blockpvp", "blockredstone", "stoplag", "halt-activity", "nickclean", "nick", "nicknyan", "vanish", "verify", "verifynoadmin", "co", "coreprotect", "core", "mobpurge", "logs", "links", "vote", "o", "linkdiscord"); - - public HubWorldRestrictions(TotalFreedomMod plugin) - { - super(plugin); - } - - @Override - protected void onStart() - { - } - - @Override - protected void onStop() - { - } - - public boolean doRestrict(Player player) - { - /*if (!FUtil.isExecutive(player.getName()) && player.getWorld().equals(plugin.wm.hubworld.getWorld())) - { - return true; - } - - return false;*/ - return true; - } - - @EventHandler(priority = EventPriority.NORMAL) - public void onBlockPlace(BlockPlaceEvent event) - { - final Player player = event.getPlayer(); - - if (doRestrict(player)) - { - player.sendMessage(ChatColor.RED + "Only Executives can do this in the Hub World!"); - event.setCancelled(true); - } - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onBlockBreak(BlockBreakEvent event) - { - final Player player = event.getPlayer(); - - if (doRestrict(player)) - { - player.sendMessage(ChatColor.RED + "Only Executives can do this in the Hub World!"); - event.setCancelled(true); - } - } - - @EventHandler(priority = EventPriority.NORMAL) - public void onPlayerInteract(PlayerInteractEvent event) - { - final Player player = event.getPlayer(); - - if (doRestrict(player)) - { - player.sendMessage(ChatColor.RED + "Only Executives can do this in the Hub World!"); - event.setCancelled(true); - } - } - - @EventHandler(priority = EventPriority.NORMAL) - public void onArmorStandManipulate(PlayerArmorStandManipulateEvent event) - { - final Player player = event.getPlayer(); - - if (doRestrict(player)) - { - player.sendMessage(ChatColor.RED + "Only Executives can do this in the Hub World!"); - event.setCancelled(true); - } - } - - @EventHandler(priority = EventPriority.NORMAL) - public void onEntityDamageByEntity(EntityDamageByEntityEvent event) - { - if (event.getDamager() instanceof Player) - { - Player player = (Player)event.getDamager(); - - if (doRestrict(player)) - { - player.sendMessage(ChatColor.RED + "Only Executives can do this in the Hub World!"); - event.setCancelled(true); - } - } - } - - @EventHandler(priority = EventPriority.NORMAL) - public void onCommandPreprocess(PlayerCommandPreprocessEvent event) - { - final Player player = event.getPlayer(); - if (doRestrict(player)) - { - String command = event.getMessage().split("\\s+")[0].substring(1, event.getMessage().split("\\s+")[0].length()).toLowerCase(); - - if (ALLOWED_COMMANDS.contains(command)) - { - event.setCancelled(false); - } - else if (command.startsWith("")) - { - player.sendMessage(ChatColor.RED + "Only Executives are allowed to execute commands in the Hub World!"); - event.setCancelled(true); - } - } - } -} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index a375956b..d13bf380 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -129,7 +129,7 @@ allow: frostwalker: false unsafe_enchantments: true bells: true - armorstands: false + armorstands: true minecarts: false clearonjoin: false tpronjoin: false