Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.besho.kituser;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- 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.PlayerJoinEvent;
- import org.bukkit.plugin.java.JavaPlugin;
- public class Main extends JavaPlugin implements Listener {
- public void onEnable() {
- Bukkit.getServer().getPluginManager().registerEvents(this, this);
- if (!getConfig().contains("prefix")) {
- getConfig().set("prefix", "%p &6: ");
- }
- }
- public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
- if (!(sender instanceof Player)) {
- sender.sendMessage(ChatColor.RED + "Only players can get nicknames!");
- }
- Player p = (Player) sender;
- if (cmd.getName().equalsIgnoreCase("mycolor")) {
- if (args.length == 0) {
- sender.sendMessage("§7================§a[§8MyColor§a]§7================");
- sender.sendMessage(ChatColor.DARK_AQUA + "§2MyColor Commands :-");
- sender.sendMessage(ChatColor.DARK_AQUA + "/mycolor <color code> §6-> change your name color ");
- sender.sendMessage(ChatColor.DARK_AQUA + "/mycolor colors §6-> show all color codes");
- sender.sendMessage("§aCreator : BeshoGraphix");
- sender.sendMessage("§7================§a[§8MyColor§a]§7================");
- return true;
- }
- else if (args.length == 1){
- //-------------------------[ colors ]-------------------------//
- if (args[0].equalsIgnoreCase("1")){
- p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.DARK_BLUE + p.getName());
- this.getConfig().set(p.getName(), ChatColor.DARK_BLUE + p.getName());
- this.saveConfig();
- }
- if (args[0].equalsIgnoreCase("2")){
- p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.DARK_GREEN + p.getName());
- this.getConfig().set(p.getName(), ChatColor.DARK_GREEN + p.getName());
- this.saveConfig();
- }
- if (args[0].equalsIgnoreCase("3")){
- p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.DARK_AQUA + p.getName());
- this.getConfig().set(p.getName(), ChatColor.DARK_AQUA + p.getName());
- this.saveConfig();
- }
- if (args[0].equalsIgnoreCase("4")){
- p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.DARK_RED + p.getName());
- this.getConfig().set(p.getName(), ChatColor.DARK_RED + p.getName());
- this.saveConfig();
- }
- if (args[0].equalsIgnoreCase("5")){
- p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.DARK_PURPLE + p.getName());
- this.getConfig().set(p.getName(), ChatColor.DARK_PURPLE + p.getName());
- this.saveConfig();
- }
- if (args[0].equalsIgnoreCase("6")){
- p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.GOLD + p.getName());
- this.getConfig().set(p.getName(), ChatColor.GOLD + p.getName());
- this.saveConfig();
- }
- if (args[0].equalsIgnoreCase("7")){
- p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.GRAY + p.getName());
- this.getConfig().set(p.getName(), ChatColor.GRAY + p.getName());
- this.saveConfig();
- }
- if (args[0].equalsIgnoreCase("8")){
- p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.DARK_GRAY + p.getName());
- this.getConfig().set(p.getName(), ChatColor.DARK_GRAY + p.getName());
- this.saveConfig();
- }
- if (args[0].equalsIgnoreCase("9")){
- p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.BLUE + p.getName());
- this.getConfig().set(p.getName(), ChatColor.BLUE + p.getName());
- this.saveConfig();
- }
- if (args[0].equalsIgnoreCase("0")){
- p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.BLACK + p.getName());
- this.getConfig().set(p.getName(), ChatColor.BLACK + p.getName());
- this.saveConfig();
- }
- if (args[0].equalsIgnoreCase("a")){
- p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.GREEN + p.getName());
- this.getConfig().set(p.getName(), ChatColor.GREEN + p.getName());
- this.saveConfig();
- }
- if (args[0].equalsIgnoreCase("b")){
- p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.AQUA + p.getName());
- this.getConfig().set(p.getName(), ChatColor.AQUA + p.getName());
- this.saveConfig();
- }
- if (args[0].equalsIgnoreCase("c")){
- p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.RED + p.getName());
- this.getConfig().set(p.getName(), ChatColor.RED + p.getName());
- this.saveConfig();
- }
- if (args[0].equalsIgnoreCase("d")){
- p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.LIGHT_PURPLE + p.getName());
- this.getConfig().set(p.getName(), ChatColor.LIGHT_PURPLE + p.getName());
- this.saveConfig();
- }
- if (args[0].equalsIgnoreCase("e")){
- p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.YELLOW + p.getName());
- this.getConfig().set(p.getName(), ChatColor.YELLOW + p.getName());
- this.saveConfig();
- }
- if (args[0].equalsIgnoreCase("f")){
- p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.WHITE + p.getName());
- this.getConfig().set(p.getName(), ChatColor.WHITE + p.getName());
- this.saveConfig();
- }
- if (args[0].equalsIgnoreCase("colors")){
- p.sendMessage("§11 §r| §22 §r| §33 §r| §44 §r| §55 §r| §66 §r| §77 §r| §88 §r| §99 §r| §00 §r| §aa §r| §bb §r| §cc §r| §dd §r| §ee §r| §ff");
- }
- //-------------------------[ colors ]-------------------------//
- }
- }
- return true;
- }
- @EventHandler
- public void onPlayerChat(AsyncPlayerChatEvent e) {
- if (this.getConfig().getString(e.getPlayer().getName()) != null) {
- e.getPlayer().setDisplayName(this.getConfig().getString(e.getPlayer().getName()) + ChatColor.RESET);
- e.setFormat(ChatColor.translateAlternateColorCodes('&', getConfig().getString("prefix").replace("%p", e.getPlayer().getDisplayName()))+ ChatColor.RESET + ChatColor.translateAlternateColorCodes('&', e.getMessage()));
- }
- }
- @EventHandler
- public void player (PlayerJoinEvent t) {
- if (this.getConfig().getString(t.getPlayer().getName()) != null) {
- t.getPlayer().setPlayerListName(this.getConfig().getString(t.getPlayer().getName()) + ChatColor.RESET);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment