diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index f0be312..0c3fc47 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -3,7 +3,7 @@ 4.0.0 FPChatX FPChatX - 1.0.1-BETA + 1.0.3-BETA src/main/java diff --git a/pom.xml b/pom.xml index 9c5e38b..89c0d72 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 FPChatX FPChatX - 1.0.3-BETA + 1.0.4-BETA spigot-repo diff --git a/src/main/java/com/fpghoti/fpchatx/FPChat.java b/src/main/java/com/fpghoti/fpchatx/FPChat.java index 8c81244..c1f5161 100644 --- a/src/main/java/com/fpghoti/fpchatx/FPChat.java +++ b/src/main/java/com/fpghoti/fpchatx/FPChat.java @@ -35,6 +35,7 @@ import com.fpghoti.fpchatx.command.commands.LeaveCommand; import com.fpghoti.fpchatx.command.commands.ChannelsCommand; import com.fpghoti.fpchatx.command.commands.CreateCommand; import com.fpghoti.fpchatx.command.commands.MessageCommand; +import com.fpghoti.fpchatx.command.commands.PrefixCommand; import com.fpghoti.fpchatx.command.commands.ReloadCommand; import com.fpghoti.fpchatx.command.commands.ReplyCommand; import com.fpghoti.fpchatx.command.commands.RevokeBadgeCommand; @@ -175,7 +176,7 @@ public class FPChat extends JavaPlugin { Commands.register(new HelpCommand(this)); Commands.register(new RevokeBadgeCommand(this)); Commands.register(new GiveBadgeCommand(this)); - + Commands.register(new PrefixCommand(this)); } public MainConfig getMainConfig() { diff --git a/src/main/java/com/fpghoti/fpchatx/command/commands/PrefixCommand.java b/src/main/java/com/fpghoti/fpchatx/command/commands/PrefixCommand.java new file mode 100644 index 0000000..08a53ca --- /dev/null +++ b/src/main/java/com/fpghoti/fpchatx/command/commands/PrefixCommand.java @@ -0,0 +1,52 @@ +package com.fpghoti.fpchatx.command.commands; + +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.fpghoti.fpchatx.FPChat; +import com.fpghoti.fpchatx.chat.ChatFilter; +import com.fpghoti.fpchatx.command.Commands; +import com.fpghoti.fpchatx.permission.Permission; +import com.fpghoti.fpchatx.player.FPlayer; + +public class PrefixCommand extends Commands { + + public PrefixCommand(FPChat plugin) { + super(plugin); + name = "Prefix"; + description = "Sets your own prefix"; + syntax = ChatColor.GRAY + "/fpc prefix " + ChatColor.GOLD + ""; + minArgs = 1; + maxArgs = 1; + labels.add("fpc prefix"); + labels.add("fpchat prefix"); + labels.add("ch prefix"); + } + + @Override + public void execute(CommandSender sender, String[] args) { + FPlayer p = null; + Boolean console = true; + if(sender instanceof Player){ + console = false; + p = FPlayer.getPlayer((Player) sender); + } + + if(console) { + FPlayer.errMsg(p, "This command cannot be used by console."); + return; + } + + if(Permission.canChangePrefix(p)){ + String prefix = ChatColor.translateAlternateColorCodes('&', ChatFilter.filterWord(args[0])); + if(Permission.canChangePrefix(p)) { + p.setPrefix(prefix); + FPlayer.goodMsg(p, "Set prefix to: " + prefix); + }else { + FPlayer.errMsg(p, Permission.noPerm); + } + } + } + +} diff --git a/src/main/java/com/fpghoti/fpchatx/permission/Permission.java b/src/main/java/com/fpghoti/fpchatx/permission/Permission.java index 9839ab6..d9427ed 100644 --- a/src/main/java/com/fpghoti/fpchatx/permission/Permission.java +++ b/src/main/java/com/fpghoti/fpchatx/permission/Permission.java @@ -18,6 +18,30 @@ public class Permission { return false; } + public static boolean canChangePrefix(FPlayer p) { + return p.hasPermission("fpchat.changeprefix"); + } + + public static boolean canChangePrefix(String playername) { + if(FPlayer.getPlayer(playername) != null) { + FPlayer p = FPlayer.getPlayer(playername); + return canChangePrefix(p); + } + return false; + } + + public static boolean canChangeSuffix(FPlayer p) { + return p.hasPermission("fpchat.changesuffix"); + } + + public static boolean canChangeSuffix(String playername) { + if(FPlayer.getPlayer(playername) != null) { + FPlayer p = FPlayer.getPlayer(playername); + return canChangeSuffix(p); + } + return false; + } + public static boolean canShoutColor(FPlayer p) { return p.hasPermission("fpchat.shoutcolor"); } diff --git a/src/main/java/com/fpghoti/fpchatx/player/FPlayer.java b/src/main/java/com/fpghoti/fpchatx/player/FPlayer.java index 29e0ff6..1d7f65d 100644 --- a/src/main/java/com/fpghoti/fpchatx/player/FPlayer.java +++ b/src/main/java/com/fpghoti/fpchatx/player/FPlayer.java @@ -273,6 +273,22 @@ public class FPlayer { this.shoutVisible = false; } + public boolean setPrefix(String prefix) { + if(isOnline() && getPlayer() != null) { + VaultUtil.chat.setPlayerPrefix(getPlayer(), prefix); + return true; + } + return false; + } + + public boolean setSuffix(String suffix) { + if(isOnline() && getPlayer() != null) { + VaultUtil.chat.setPlayerPrefix(getPlayer(), suffix); + return true; + } + return false; + } + public boolean isHushed() { return this.hushed; } @@ -497,11 +513,11 @@ public class FPlayer { } FPlayer.errMsg(this, "You must wait " + Integer.toString(i) + time + "before you can shout again."); } - + if(hushed) { FPlayer.errMsg(this, "You are unable to perform this action, because you have been hushed."); } - + if(isOnline() && (shoutCooldown == 0 || !FPChat.getPlugin().getMainConfig().shoutCooldownEnabled() ) && !isHushed()) { if(Permission.canShout(this)) { Player p = Bukkit.getPlayer(uuid);