Everything works in my plugin, but one thing... Ok, I made a plugin for my server where you open up a redstone torch and you can choose if you want the death messages sent to you privately or do you want to see everyone's, well whenever it's on everyone's, both players can see the broadcast, it just dosen't work and has alot of bugs, if anyone can help me with my plugin's problems and give me some advice, that'd be great. Code: Code: package me.Alex.LegacyCore; import java.util.ArrayList; import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; public class Death implements Listener { public static ArrayList<String> global = new ArrayList<>(); public static ArrayList<String> secret = new ArrayList<>(); @EventHandler public void onDeath(PlayerDeathEvent e){ Player p = e.getEntity(); Player k = p.getKiller(); double health = k.getHealth(); double decimal = health - (int) health; if(decimal < .25) decimal = 0.0; else if(decimal > .75) decimal = 1.0; else decimal = 0.5; p.getWorld().playEffect(p.getLocation(), Effect.STEP_SOUND, 152); p.getWorld().playEffect(p.getLocation(), Effect.STEP_SOUND, 152); p.getWorld().playEffect(p.getLocation(), Effect.STEP_SOUND, 152); p.getWorld().playEffect(p.getLocation(), Effect.STEP_SOUND, 152); p.getWorld().playEffect(p.getLocation(), Effect.STEP_SOUND, 152); if(global.contains(p.getName())){ double correctHealth = (int) health + decimal; Bukkit.broadcastMessage("§b§lFFA §7» " + p.getDisplayName() + " §7was slain by " + k.getDisplayName() + " §4" + correctHealth + "❤"); } if(secret.contains(p.getName())){ double correctHealth = (int) health + decimal; p.sendMessage("§b§lFFA §7» §7You were killed by " + k.getDisplayName()); p.sendMessage("§b§lFFA §7» §7Your killer had §4" + correctHealth + "❤"); } } @EventHandler public void onClick(PlayerInteractEvent e){ Player p = e.getPlayer(); Action a = e.getAction(); if(a==Action.RIGHT_CLICK_BLOCK || a==Action.RIGHT_CLICK_AIR){ ItemStack hand = p.getItemInHand(); if(hand!=null&&hand.getType()==Material.REDSTONE_TORCH_ON){ Inventory inv = Bukkit.createInventory(null, 9, "§bMessage Preferences"); ItemStack i = new ItemStack(Material.SUGAR, 1); ItemMeta im = i.getItemMeta(); im.setDisplayName("§bEnable Global Death Messages"); ItemStack i2 = new ItemStack(Material.SULPHUR, 1); ItemMeta im2 = i2.getItemMeta(); im2.setDisplayName("§bEnable Private Death Messages"); i.setItemMeta(im); i2.setItemMeta(im2); inv.setItem(1, i); inv.setItem(7, i2); p.openInventory(inv); } } } @EventHandler public void onC2lik(InventoryClickEvent e1){ HumanEntity ee = e1.getWhoClicked(); if((ee instanceof Player)){ Player p = (Player)ee; if(e1.getInventory().getName().equals("§bMessage Preferences")){ e1.setCancelled(true); ItemStack cl = e1.getCurrentItem(); if (cl!=null){ if(cl.getType()==Material.SUGAR){ secret.remove(p.getName()); global.add(p.getName()); p.sendMessage("§b§lFFA §7» §4" + p.getName() + "§7's chat preference has been set to §7'§bGlobal§7'"); } } } } } @EventHandler public void onC2l2ik(InventoryClickEvent e1){ HumanEntity ee = e1.getWhoClicked(); if((ee instanceof Player)){ Player p = (Player)ee; if(e1.getInventory().getName().equals("§bMessage Preferences")){ e1.setCancelled(true); ItemStack cl = e1.getCurrentItem(); if (cl!=null){ if(cl.getType()==Material.SULPHUR){ global.remove(p.getName()); secret.add(p.getName()); p.sendMessage("§b§lFFA §7» §4" + p.getName() + "§7's chat preference has been set to §7'§bPrivate§7'"); } } } } } } Maybe someway to send a message privately to the certain array list?
@Luflexed You are broadcasting the death message to the whole server You are not setting the death message that the whole server sees anyway. Please use encapsulation and remove those un-needed static modifiers. (not related to problem, but it is good practice)
@teej107 So when a player dies, if they are in a certain array list, I can send the public message to the players in the array list.