I was wondering this for a while. Why won't this points system work? Code:java package minedexnetwork.net.stats; import java.util.HashMap; import org.bukkit.Bukkit;import org.bukkit.ChatColor;import org.bukkit.Sound;import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.entity.PlayerDeathEvent;import org.bukkit.event.player.AsyncPlayerChatEvent; public class StatsL implements Listener { private static HashMap<Player, Integer> points = new HashMap<Player, Integer>(); public void System(PlayerDeathEvent event) { Player killed = (Player) event.getEntity().getPlayer(); Player killer = (Player) event.getEntity().getKiller(); if(!points.containsKey(killed)){ points.put(killed, + 88); } else if(points.containsKey(killed)){ points.put(killed, points.get(killed) - points.get(killed)/8); } else if(points.containsKey(killer)){ points.put(killer, points.get(killer) + points.get(killed)/8); } else if(!points.containsKey(killer)){ points.put(killer, points.get(killer) + 112); } } @EventHandler public void onPlayerChat(AsyncPlayerChatEvent e) { Player player = (Player) e.getPlayer(); e.setFormat(ChatColor.AQUA + "[" + ChatColor.DARK_GRAY + points.get(player) + ChatColor.AQUA + "] " + ChatColor.YELLOW + "%s" + ChatColor.YELLOW + ChatColor.BOLD + " >>> " + ChatColor.WHITE + "%s"); player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 0); } }
BeefyPlays You don't have @Eventhandler on the death event. Also why do you have System as the event name? It's not a good idea to use reserved words in java You will also need to register your events for the events to work. (If you haven't done this in the main class) Another suggestion would be a config, or else all the points would clear during a reload.
I know, I was planing to add the config later. I do have my events registered. I forgot System was a java word. I will try changing it and I will give you more infomation
jthort System is not a reserved word in Java. I think you meant @EventHandler and not @OnEnable. System was the method name. Not the event name. I still agree that they shouldn't use System as the method name seeing as it breaks convention by starting with an uppercase letter and is a misleading name.
I feel like a complete idiot. I was making it a method not a event. Now the problem is when I kill someone my points stay at 95 or null. Here is the error http://pastebin.com/YuL9xn9w Nevermind! I've fixed this but how would you go about saving the players scores in the config? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
BeefyPlays BTW... When i looked at this stack trace: http://pastebin.com/YuL9xn9w I couldn't help but notice that your package is formatted all wrong: Code:java minedexnetwork.net.stats.StatsL.kills(StatsL.java:46) it should be: Code:java net.minedexnetwork.stats.StatsL