How would i make a plugin where on enable. creates a config (The config page for bukkit hasnt helped me at all) then on join. add the player to a config. then on a kill adds a kill to the player and on death adds a death to the player. i cant seem to figure it out. thanks for any help
XxZHALO13Xx We aren't going to give you code, so either keep searching or at least attempt to do something.
XxZHALO13Xx this should answer all your questions http://wiki.bukkit.org/Configuration_API_Reference Actually read through it, and try it out. If you don't even attempt to do something, then no one will help you. Only people who do not realize that spoon-feeding is wrong.
Jaaakee224 Monkey_Swag i have attempted... i can do the kill counter but idk how to save it to a config or any of that with a config
CMPSCdev Code:java import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.entity.PlayerDeathEvent; public class KillTracker implements Listener{ @EventHandler public void onDeath(PlayerDeathEvent e){ Player v = e.getEntity().getPlayer(); Player k = e.getEntity().getKiller(); if(k instanceof Player){ } else{ return; //Ignores none player kills. } } }
This will help. Seriously. http://wiki.bukkit.org/Configuration_API_Reference#Setting_Values http://wiki.bukkit.org/Configuration_API_Reference#Getting_Values EDIT: Where is your onEnable? If that is supposed to be the main class, you need to add Code:java extends JavaPlugin to the class header.
CMPSCdev i removed the config code cause it doesnt work MeRPG CMPSCdev how do i do it per player? i figured out how to store it EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Guessing here. For the killer (k) do something like this: int kills = getConfig().getInt("players." + k.getUniqueId().toString() + ".kills"); getConfig().set("players." + k.getUniqueId().toString() + ".kills", (Integer.valueOf(kills) + 1)); saveConfig();
CMPSCdev what about storing each person? CMPSCdev my class Code:java public class KillTracker implements Listener{ Core configGetter; public KillTracker(Core plugin){ plugin.getServer().getPluginManager().registerEvents(this, plugin); configGetter = plugin; } @EventHandler public void onDeath(PlayerDeathEvent e){ Player v = e.getEntity().getPlayer(); Player k = e.getEntity().getKiller(); if(k instanceof Player && v instanceof Player){ int killcount = configGetter.getConfig().getInt("kills"); int deathcount = configGetter.getConfig().getInt("deaths"); int kills = configGetter.getConfig().getInt("players." + k.getUniqueId().toString() + ".kills"); configGetter.getConfig().set("players." + k.getUniqueId().toString() + ".kills", (Integer.valueOf(kills) + 1)); configGetter.saveConfig(); k.sendMessage(ChatColor.DARK_GREEN + "You killed " + v.getName() + "! You have a total of " + killcount + " kills!"); configGetter.saveConfig(); } } } Core Code:java public class Core extends JavaPlugin{ public static Core pl; public Core plugin; public void onEnable(){ getLogger().info("Bukkit Server. V" + getVersion() + " Loaded... Starting Plugins."); getLogger().info("Magic Fight Loaded."); this.getConfig().addDefault("kills", 0); this.getConfig().addDefault("players.", null); this.getConfig().options().copyDefaults(true); saveConfig(); getServer().getPluginManager().registerEvents(new KillTracker(plugin), this); getServer().getPluginManager().registerEvents(new FireRod(), this); //REGISTER LISTENERS: getServer().getPluginManager().registerEvents(new BoomArrow(), this); getServer().getPluginManager().registerEvents(new ArrowStick(), this); getServer().getPluginManager().registerEvents(new MagicBar(), this); getServer().getPluginManager().registerEvents(new FlyFeather(), this); getServer().getPluginManager().registerEvents(new EggLaunch(), this); getServer().getPluginManager().registerEvents(new Nugget(), this); getServer().getPluginManager().registerEvents(new Join(), this); getServer().getPluginManager().registerEvents(new SnowballPull(), this); getCommand("magicfight").setExecutor(new MFC()); //REGISTER COMMANDS: getCommand("marrow").setExecutor(new BoomArrow()); getCommand("magicitems").setExecutor(new ItemsInfo()); getCommand("magicinfo").setExecutor(new MagicInfo()); plugin = this; pl = this; } private static String getVersion(){ return MinecraftServer.getServer().getVersion(); } public static Plugin getPlugin() { // TODO Auto-generated method stub return pl; } public void onDisable(){ saveConfig(); } } EDIT by Moderator: merged posts, please use the edit button instead of double posting.
XxZHALO13Xx please remove That static instance. It's complementary getter method. The enable messages. Especially the MC version, since you are adding a versioned dependency for no reason. Moreover: PlayerDeathEvent#getEntity() returns a Player, that getPlayer() call is redundant. getKiller() will always return Player. Rather, check if that is not null. Integer.valueOf(int) is redundant in this case. killcount is not the kill count of the player, rather use the kills variable since that is the kill count - 1.
Oh, how your mentioning of statics brings back memories... (http://forums.bukkit.org/threads/help-needed-partly.120852/#post-1494127) Aaahhhahahahahha Aaaahahhahhhahah Aaaahahahhhahaha Can't stop laughing now...