how to make custom Tag?

Discussion in 'Spigot Plugin Help' started by Ver_Elite, Jun 24, 2016.

Thread Status:
Not open for further replies.
  1. so guys i wanted to make Custom Tag but i don't know how i want do it like this

    Tag.PNG

    tag like [Tag][Player]

    so i need to know how to do it

    i want to do like /tag (player) (tag)
     
  2. You could do this with a permission plugin like PermissionsEx and a chat plugin like Essentials + Essentialschat.

    Edit:
    If you have enough money, I would highly suggest buying DeluxeChat.
     
  3. Do it in Groupmanager, change the prefix. Boom. lock this thread please :)
     
  4. I am not too sure about this one, but just using GM won't be enough, he'll need a chat plugin too.

    And, PEX is superior GroupManager.
     
  5. Could I have your server ip? I can help you out ingame right now.
     
  6. I'm not the one looking for help, you are quoting the wrong person ;)
     
  7. xD lol my bad
     
  8. i mean i wanted to code it
     
  9. Ohh. I suggest you learn Java, Spigot developers aren't too keen about spoon-feeding.
     
  10. its a simple text before a variable. Do you have any experience with java?
     
  11. i already make code /tag but when i do like /tag (player) (tag) it still same tag with who have permission. i set it in AsyncPlayerChatEvent
     
  12. so did you achieve it??
     
  13. I suggest you start a new thread in the correct forum section and provide more information.
     
  14. i am but it same tag who have permission it mean all player with permission can have the tag
    so that why i need to do custom tag
     
  15. Code (Text):
    public String checkTag(Player player){
            String Tag = null;
            if(player.hasPermission("tag.staffmember")) {
                Tag = ChatColor.translateAlternateColorCodes('&', "&8[&7" + plugin.getConfig().getString("CMS.Tag.StaffMember") + "&8] ");
            } else if(player.hasPermission("tag.developer")) {
                Tag = ChatColor.translateAlternateColorCodes('&', "&8[&7" + plugin.getConfig().getString("CMS.Tag.Developer") + "&8] ");
            } else if(player.hasPermission("tag.bestpvper")) {
                Tag = ChatColor.translateAlternateColorCodes('&', "&8[&7" + plugin.getConfig().getString("CMS.Tag.BestPvPer") + "&8] ");
            } else
                Tag = ChatColor.translateAlternateColorCodes('&', "");
            return Tag;
        }
    this code what i do before and i wanted to make custom tag
     
  16. Add the tag before
     
  17. Code (Text):
    package me.cms.commands;

    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import me.cms.Main;
    import net.md_5.bungee.api.ChatColor;

    public class Tag implements CommandExecutor {
    Main plugin;
       
        public Tag(Main instance){
            plugin = instance;
        }

        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if(cmd.getName().equalsIgnoreCase("tag")) {
                if(sender.hasPermission("system.tag")) {
                    if(args.length == 0){
                        sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lCMS &8» &6Please use /tag list"));
                    }
                    else if(args[0].equalsIgnoreCase("list")){
                        if(args.length == 1){
                            sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lCMS &8» &6/tag (tagname) (tag)"));
                            sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lCMS &8» &6List of Tag"));
                            sender.sendMessage(ChatColor.translateAlternateColorCodes('&', " &7staffmember"));
                            sender.sendMessage(ChatColor.translateAlternateColorCodes('&', " &7developer"));
                            sender.sendMessage(ChatColor.translateAlternateColorCodes('&', " &7bestpvper"));
                        }
                    }
                    else if(args[0].equalsIgnoreCase("staffmember")){
                        if (args.length < 2) {
                            sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lCMS &8» &6Please use /tag staffmember (tag)"));
                            return true;
                        }
                        StringBuilder sb = new StringBuilder();
                        for(int i = 1; i < args.length; i++) {
                            sb.append(args[i]).append("");
                        }

                        String tag = sb.toString().trim();
                        plugin.getConfig().set("CMS.Tag.StaffMember", tag);
                        plugin.saveConfig();
                        sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lCMS &8» &6Tag for &7staffmember &6has been set to &8[&7"  + tag + "&8]"));
                        sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lCMS &8» &6Permission &btag.staffmember"));
                        return true;
                    }
                    else if(args[0].equalsIgnoreCase("developer")){
                        if (args.length < 2) {
                            sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lCMS &8» &6Please use /tag developer (tag)"));
                            return true;
                        }
                        StringBuilder sb = new StringBuilder();
                        for(int i = 1; i < args.length; i++) {
                            sb.append(args[i]).append("");
                        }

                        String tag = sb.toString().trim();
                        plugin.getConfig().set("CMS.Tag.Developer", tag);
                        plugin.saveConfig();
                        sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lCMS &8» &6Tag for &7developer &6has been set to &8[&7"  + tag + "&8]"));
                        sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lCMS &8» &6Permission &btag.developer"));
                        return true;
                    }
                    else if(args[0].equalsIgnoreCase("bestpvper")){
                        if (args.length < 2) {
                            sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lCMS &8» &6Please use /tag bestpvper (tag)"));
                            return true;
                        }
                        StringBuilder sb = new StringBuilder();
                        for(int i = 1; i < args.length; i++) {
                            sb.append(args[i]).append("");
                        }

                        String tag = sb.toString().trim();
                        plugin.getConfig().set("CMS.Tag.BestPvPer", tag);
                        plugin.saveConfig();
                        sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lCMS &8» &6Tag for &7bestpvper &6has been set to &8[&7"  + tag + "&8]"));
                        sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lCMS &8» &6Permission &btag.bestpvper"));
                        return true;
                    }

                } else sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lCMS &8» &6You need to be a &bADMIN &6or higher to use this command!"));
           
            }    
            return true;
        }
    }
     
  18. Code (Text):
    package me.cms.commands;

    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.AsyncPlayerChatEvent;
    import org.bukkit.event.player.PlayerCommandPreprocessEvent;
    import org.bukkit.event.player.PlayerJoinEvent;

    import me.cms.Main;
    import net.md_5.bungee.api.ChatColor;

    public class listener implements Listener {
       
    Main plugin;
       
        public listener(Main instance) {
            plugin = instance;
            }
       
        @EventHandler
        public void onPlayerJoin(PlayerJoinEvent e){
            Player player = e.getPlayer();
            player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("CMS.MOTD").replace("{player}", player.getName())));
        }
       
        @EventHandler
        public void onPlayerCommand(PlayerCommandPreprocessEvent e) {
            String msg = e.getMessage().toLowerCase();
            if (msg.startsWith("/op")) {
                e.setCancelled(true);
                e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lConsole &8» &6Only the console can use this command!"));
               
            }
        }
        @EventHandler
        public void onChat(AsyncPlayerChatEvent e) {
            Player player = e.getPlayer();
            String format = e.getFormat();
            String prefix = "Replacement";
            if(player.hasPermission("chat.staff")) {
            e.setFormat(format.replace("{TAG}", ChatColor.translateAlternateColorCodes('&', prefix)));
            e.setFormat(ChatColor.translateAlternateColorCodes('&', checkTag(player) + checkPrefix(player) + player.getName() + " &7» &e" + e.getMessage()));
            } else if(player.hasPermission("chat.donator")){
                e.setFormat(ChatColor.translateAlternateColorCodes('&', checkTag(player) + checkPrefix(player) + player.getName() + " &7» &f" + e.getMessage()));
            } else e.setFormat(ChatColor.translateAlternateColorCodes('&', checkTag(player) + checkPrefix(player) + player.getName() + " &7» &7" + e.getMessage()));
        }
        public String checkPrefix(Player player) {
            String prefix;
           
            if(player.hasPermission("rank.admin")) {
                prefix = ChatColor.translateAlternateColorCodes('&', "&c[ADMIN] &e");
            } else if(player.hasPermission("rank.owner")) {
                prefix = ChatColor.translateAlternateColorCodes('&', "&c[OWNER] &6");
            } else if (player.hasPermission("rank.moderator")) {
                prefix = ChatColor.translateAlternateColorCodes('&', "&2[MOD] &2");
            } else if(player.hasPermission("rank.helper")) {
                prefix = ChatColor.translateAlternateColorCodes('&', "&3[HELPER] &3");
            } else if(player.hasPermission("rank.jrhelper")) {
                prefix = ChatColor.translateAlternateColorCodes('&', "&3[JRHELPER] &3");
            } else if(player.hasPermission("rank.builder")) {
                prefix = ChatColor.translateAlternateColorCodes('&', "&e[BUILDER] &e");
            } else if(player.hasPermission("rank.legendary")) {
                prefix = ChatColor.translateAlternateColorCodes('&', "&8[&cLE&6G&aEN&bDA&dRY&8] &5");
            } else if(player.hasPermission("rank.demonic")) {
                prefix = ChatColor.translateAlternateColorCodes('&', "&8[&cDEMONIC&8] &c");
            } else if(player.hasPermission("rank.hero")) {
                prefix = ChatColor.translateAlternateColorCodes('&', "&8[&dHERO&8] &d");
            } else if(player.hasPermission("rank.gladiator")) {
                prefix = ChatColor.translateAlternateColorCodes('&', "&8[&9GLADIATOR&8] &9");
            } else if(player.hasPermission("rank.titan")) {
                prefix = ChatColor.translateAlternateColorCodes('&', "&8[&aTITAN&8] &a");
            } else if(player.hasPermission("rank.vanguard")) {
                prefix = ChatColor.translateAlternateColorCodes('&', "&8[&6VANGUARD&8] &6");
            } else if(player.hasPermission("rank.phantom")) {
                prefix = ChatColor.translateAlternateColorCodes('&', "&8[&bPHANTOM&8] &b");
            } else
                prefix = ChatColor.translateAlternateColorCodes('&', "&8");
            return prefix;
           
        }
        public String checkTag(Player player){
            String Tag = null;
            if(player.hasPermission("tag.staffmember")) {
                Tag = ChatColor.translateAlternateColorCodes('&', "&8[&7" + plugin.getConfig().getString("CMS.Tag.StaffMember") + "&8] ");
            } else if(player.hasPermission("tag.developer")) {
                Tag = ChatColor.translateAlternateColorCodes('&', "&8[&7" + plugin.getConfig().getString("CMS.Tag.Developer") + "&8] ");
            } else if(player.hasPermission("tag.bestpvper")) {
                Tag = ChatColor.translateAlternateColorCodes('&', "&8[&7" + plugin.getConfig().getString("CMS.Tag.BestPvPer") + "&8] ");
            } else
                Tag = ChatColor.translateAlternateColorCodes('&', "");
            return Tag;
        }

    }
    this is full code of listener
     
  19. Yo please post in another section, I don't do java code anymore. If it's c# Ill be glad to help <3
     
Thread Status:
Not open for further replies.