Added prefix command
This commit is contained in:
parent
c35d359d44
commit
3e4811ca65
|
@ -3,7 +3,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>FPChatX</groupId>
|
||||
<artifactId>FPChatX</artifactId>
|
||||
<version>1.0.1-BETA</version>
|
||||
<version>1.0.3-BETA</version>
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<resources>
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -4,7 +4,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>FPChatX</groupId>
|
||||
<artifactId>FPChatX</artifactId>
|
||||
<version>1.0.3-BETA</version>
|
||||
<version>1.0.4-BETA</version>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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 + "<prefix>";
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue