Plugin category: Fun Suggested name: SnowballFun What I want: When you hit someone else with a snowball you get a point! In chat everytime you hit someone with a snowball it will say "&cYou have hit &6%player &cand received a point! You now have &6%amount &cpoints!" And when you get hit... it says "&cYou have been hit with a snowball by &6%player&c!" This plugin should work throughout the server. Ideas for commands: /toplist | This will show who has the most points a player has Ideas for permissions: snowball.player | This allows them to to the following above. When I'd like it by: Two weeks before christmas
This can be done using a plugin called Skript. There is already a script on the Skript forums for paintball. You can just modify it slightly and use it.
http://dev.bukkit.org/bukkit-plugins/paintball_pure_war/ Currently it's only TDM, but FFA will come in the future.
I actually made a plugin very similar to this for someone else, I am sure I could modify it for your needs if you still need it?
I could make ths using SKRIPT (im pro at that ) but when it comes to java im still elarning, I may try complete this project
@ShadowRaidNETok I won't be able to start it until Thursday because I am away right now. If anyone else can do this before me please go ahead. ShadowRaidNET Last post. Look up.
ShadowRaidNET I don't know how to get the top player but if anyone else wants to do this here is all the other stuff besides getting the top player Code: Code:java package me.pieman.sfun; import org.bukkit.Bukkit;import org.bukkit.ChatColor;import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.entity.ProjectileHitEvent;import org.bukkit.event.player.PlayerJoinEvent;import org.bukkit.plugin.java.JavaPlugin; public class SnowballFun extends JavaPlugin implements Listener{ public void onEnable(){ Bukkit.getServer().getPluginManager().registerEvents(this, this); saveConfig(); } public void onDisable(){ saveConfig(); } @EventHandler public void onPlayerJoin(PlayerJoinEvent e){ Player p = e.getPlayer(); if(getConfig().get("points." + p.getName()) == null){ getConfig().set("points." + p.getName(), 0.0); return; } } @EventHandler public void onProjectileHit(ProjectileHitEvent e){ if(e.getEntity().getShooter() instanceof Player && e.getEntity() instanceof Player){ Player shooter = (Player) e.getEntity().getShooter(); Player hurt = (Player) e.getEntity(); if(!(shooter.hasPermission("snowball.player"))) return; int points = getConfig().getInt("points." + shooter.getName()); getConfig().set("points." + shooter.getName(), points + 1); shooter.sendMessage(ChatColor.RED + "You have hit " + hurt.getName() + " and received a point!" + ChatColor.RED + " You now have " + ChatColor.RED + getConfig().getInt("points." + shooter.getName()) + ChatColor.RED + " points!"); hurt.sendMessage(ChatColor.RED + "You have been hit with a snowball by " + shooter.getName() + "!"); saveConfig(); return; } }} plugin.yml: Code: name: SnowballFun main: me.pieman.sfun.SnowballFun version: 1.0 author: PieMan456 permissons: snowball.player: default: true
PieMan456 Untested code: Code:java public String topPlayer(){ Set<String> keys = getConfig().getConfigurationSection("points").getKeys(false); String currentRecord = ""; int currentPoints = -1; for(String key:keys){ if(getConfig().getInt("points."+key)>currentPoints){ currentPoints = getConfig().getInt("points."+key); currentRecord = key; } } return currentRecord;}
PieMan456 You could improve that by not saving the stats back to file on each snowball hit, but cache all player stats (from online players) and write changes back every once and a while. For getting the top player you could go through all players, one by one, and if you have no "suggested" player yet, or the player has more points than your last "top" player, you overwrite your "top" player with the new, current player you are looking at. Pseudo code: bestPlayer = null; bestPlayerPoints = 0; for (String player : allPlayers) { if (bestPlayer == null || getPointsOf(player) > bestPlayerPoints) { bestPlayer = player; bestPlayerPoints = getPointsOf(player); } } return bestPlayer; Edit: ninja'd
blablubbabc That was a damn long ninja And right about the cashing, prefer using hashmaps for that, and if I want to store multiple vars for players in different worlds: hashmap in a hashmap in a hashmap ( world, player, value ) int points = getConfig.getInt("points."+topPlayer());
i like this but there needs to be a cooldown inbetween a hit and the next on the same player cause without that people would just spam snowballs at some whos afk