Head Bounty System

Discussion in 'Archived: Plugin Requests' started by Won_The_Day, Mar 14, 2014.

  1. Offline

    Won_The_Day

    Plugin category: Fun

    Suggested name: HeadBounty

    What I want: Basically like the bounty system on Extronus. If a player kills another player their bounty goes up by a certain amount.(Configurable in the config if possible) Then if someone kills that player and gets their head, they can sell it for the amount of bounty that player has accumulated. So here's a layout of how it goes.

    Player1 kills random player.
    +$50 added to Player1's bounty.
    Player1 kills another random player.
    +$50 added to Player1's bounty.
    $100 total bounty for player1.
    Player2 kills player1 and gets their head.
    They sell Player1's head for $100 using a sign made by an admin.
    Player1's bounty resets.

    Ideas for commands:
    - /bounty {player} - Checks the bounty of a certain player.
    - /bounty - Checks that players bounty.
    - /bounty list - Shows a list of top 10 bounties on the server.

    Ideas for permissions: No permissions needed, unless you feel they are necessary.

    When I'd like it by: When ever possible. Thanks.
     
  2. Offline

    Won_The_Day

  3. Hmmm... I'll give it a shot. Starting tomorrow :)
    EDIT: I'm not very familiar with signs though... What about a command for it?
     
  4. Offline

    Squawkers13

    This seems interesting...
    How about an ability for players to set the bounty on another player?
    (Would require permission, and maybe a certain amount of server money)
    Ex: /bounty set {player} 100
     
  5. Offline

    Won_The_Day

    BlubDaLegend Thank you! And yeah you can just make a command for it if you need to. Also if you can, make it to where a player can't sell their own head.

    Squawkers13 Setting the bounty of a player would ruin the purpose of them getting kills to work their bounty higher.
     
  6. Offline

    Squawkers13

  7. Offline

    Won_The_Day

  8. Squawkers13 Thanks for the idea!

    Won_The_Day I could add a config line to disable and enable Squawkers' idea.
     
  9. Offline

    Asgernohns

  10. Offline

    timtower Administrator Administrator Moderator

    Hook into Vault, problem solved.
     
  11. Offline

    Asgernohns

    What do you mean?
     
  12. Offline

    timtower Administrator Administrator Moderator

    Vault has an economy system so that you don't need to ask for the economy plugin anymore since it supports loads of plugins.
     
  13. Offline

    Asgernohns

    timtower okay but how do i do that :/
     
  14. Offline

    timtower Administrator Administrator Moderator

  15. Offline

    Asgernohns

  16. Offline

    timtower Administrator Administrator Moderator

    You also don't need everything from it.
    This goes in your onEnable
    Code:java
    1. if (!setupEconomy() ) {
    2. getLogger().severe("Disabled due to no Economy plugin found!");
    3. return;
    4. }

    This goes somewhere else ( function )
    Code:java
    1. private boolean setupEconomy() {
    2. if (getServer().getPluginManager().getPlugin("Vault") == null) {
    3. return false;
    4. }
    5. RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
    6. if (rsp == null) {
    7. return false;
    8. }
    9. econ = rsp.getProvider();
    10. return econ != null;
    11. }

    Make sure to reference Vault and also make sure to make a field out of econ
     
  17. Offline

    Asgernohns

    timtower You can see my code here and see if its correct
    Code:java
    1. import java.util.HashMap;
    2. import java.util.logging.Logger;
    3.  
    4. import net.milkbowl.vault.Vault;
    5. import net.milkbowl.vault.economy.Economy;
    6.  
    7. import org.bukkit.Bukkit;
    8. import org.bukkit.ChatColor;
    9. import org.bukkit.Material;
    10. import org.bukkit.block.Sign;
    11. import org.bukkit.configuration.file.FileConfiguration;
    12. import org.bukkit.entity.Player;
    13. import org.bukkit.event.EventHandler;
    14. import org.bukkit.event.Listener;
    15. import org.bukkit.event.block.Action;
    16. import org.bukkit.event.block.SignChangeEvent;
    17. import org.bukkit.event.entity.EntityDeathEvent;
    18. import org.bukkit.event.entity.PlayerDeathEvent;
    19. import org.bukkit.event.player.PlayerInteractEvent;
    20. import org.bukkit.plugin.PluginDescriptionFile;
    21. import org.bukkit.plugin.RegisteredServiceProvider;
    22. import org.bukkit.plugin.java.JavaPlugin;
    23.  
    24. public class HeadBounty extends JavaPlugin implements Listener{
    25.  
    26. public final Logger logger = Logger.getLogger("Minecraft");
    27. public static HeadBounty plugin;
    28. public final Vault v = new Vault();
    29.  
    30.  
    31. public HashMap<String, Integer> bountyPrice = new HashMap<String, Integer>();
    32.  
    33. private boolean setupEconomy(){
    34. if(getServer().getPluginManager().getPlugin("Vault") == null){
    35. return false;
    36. }
    37.  
    38. RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
    39.  
    40. if(rsp == null){
    41. return false;
    42. }
    43. Economy econ = rsp.getProvider();
    44. return econ != null;
    45. }
    46.  
    47. public void loadConfiguration(){
    48. FileConfiguration config = getConfig();
    49. config.addDefault("Player_kill_count", Integer.valueOf(50));
    50. getConfig().options().copyDefaults(true);
    51. }
    52.  
    53. public void onEnable(){
    54. loadConfiguration();
    55. PluginDescriptionFile pdf = this.getDescription();
    56. this.logger.info(pdf.getName()+ "v "+pdf.getVersion()+" Has been enabled!");
    57. Bukkit.getPluginManager().registerEvents(this, this);
    58.  
    59. if(!setupEconomy()){
    60. logger.severe("Disabled! You dont have a econonmy plugin!");
    61. }
    62. }
    63.  
    64. @EventHandler
    65. public void onSignCreate(SignChangeEvent sign){
    66. Player p = sign.getPlayer();
    67. if(sign.getLine(0).equalsIgnoreCase("[HeadBounty]")){
    68. if(p.hasPermission("headbounty.placesign")){
    69. sign.setLine(0, "["+ChatColor.ITALIC+""+ChatColor.RED+"HeadBounty"+ChatColor.WHITE+"]");
    70.  
    71. p.sendMessage(ChatColor.GREEN+"HeadBounty Sign has been created succesfull!");
    72. }
    73. }
    74. }
    75.  
    76. @EventHandler
    77. public void onPlayerInteract(PlayerInteractEvent e){
    78. if(e.getAction() == Action.RIGHT_CLICK_BLOCK){
    79. if(e.getClickedBlock().getType() == Material.SIGN || e.getClickedBlock().getType() == Material.SIGN_POST){
    80. Sign sign = (Sign) e.getClickedBlock().getState();
    81.  
    82. if(sign.getLine(0).equalsIgnoreCase("["+ChatColor.ITALIC+""+ChatColor.RED+"HeadBounty"+ChatColor.WHITE+"]")){
    83.  
    84. }
    85. }
    86. }
    87. }
    88.  
    89. @EventHandler
    90. public void onEntityDeath(EntityDeathEvent e){
    91.  
    92. }
    93.  
    94. }
    95.  
     
  18. Offline

    timtower Administrator Administrator Moderator

    Asgernohns Remove this:
    public final Vault v = new Vault();
    Won't do anything. And declare econ as a field, not as a local value
     
  19. Offline

    Asgernohns

    timtower alright thanks :) but the server needs vault right?
     
  20. Offline

    timtower Administrator Administrator Moderator

    If a server doesn't has that these days then they don't use any plugins using any economy system :p
     
  21. Offline

    Asgernohns

    timtower
    I am also making a hashmap called bountyPrice, and i don't know how to ADD to a hashmap<String, Integer>()
    some of my code:
    Code:java
    1. @EventHandler
    2. public void onEntityDeath(PlayerDeathEvent e){
    3. Player killed = e.getEntity();
    4. Player killer = e.getEntity().getKiller();
    5.  
    6. if(!bountyPrice.containsKey(killed.getName())){
    7.  
    8. Bukkit.broadcastMessage(ChatColor.RED+"50$ bounty added to "+ChatColor.DARK_RED+killer.getName());
    9. }else if(bountyPrice.containsKey(killed.getName())){
    10. econ.bankDeposit(killer.getName(), bountyPrice.get(killed.getName()));
    11. bountyPrice.remove(killed);
    12. Bukkit.broadcastMessage(ChatColor.GREEN+"");
    13. }
     
  22. Offline

    timtower Administrator Administrator Moderator

    Asgernohns Somewhere in your code ( probably at the top )
    private HashMap<String,Integer> bountyPrice = new HashMap<String,Integer>();

    Further coding questions can go by PM
     
  23. Offline

    blablubbabc

    Won_The_Day
    Maybe you would want to add in that the killed players loose at least the amount the killing player gets added as head bounty (50$ in your example). Otherwise it could be abused by players which kill each other only to increase their head bounty and then letting themself be killed by their friend to get and split their bounty.
     
  24. Offline

    Won_The_Day

    Asgernohns Yes I do have Vault on my server so don't worry :p

    blablubbabc I like the idea, it would stop players from abusing the system.
     
  25. Offline

    Asgernohns

    Won_The_Day I has made the plugin now :) I'm now going to test it and see if its working :) You could have provided us with a bit more infomation on how the plugin works. if player1 have a bounty and player2 kills him, player2 will not get a bounty on himself.
     
  26. Offline

    Won_The_Day

    Asgernohns Awesome! It should just be like if player1 kills player2, $50 is added to player1's bounty and recently suggested that player2's bounty would be -$50.
     
  27. Offline

    Asgernohns

    Won_The_Day i made the bounties in a gta v kinda style and how they work
     
  28. Offline

    Won_The_Day

    Asgernohns Okay cool, how is the testing going?
     
  29. Offline

    Asgernohns

    Im going to sleep now, so no more testing for today. I still have some bugs to squash... :3 Won_The_Day
     
  30. Offline

    Won_The_Day

Share This Page