Advertisement
Guest User

Untitled

a guest
May 8th, 2011
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. package me.Unscrewed.RolePlay;
  2. import org.bukkit.ChatColor;
  3. import org.bukkit.entity.Entity;
  4. import org.bukkit.entity.Player;
  5. import org.bukkit.event.block.Action;
  6. import org.bukkit.event.player.PlayerInteractEntityEvent;
  7. import org.bukkit.event.player.PlayerInteractEvent;
  8. import org.bukkit.event.player.PlayerListener;
  9. import com.iConomy.iConomy;
  10. import com.iConomy.system.Account;
  11. import com.iConomy.system.Holdings;
  12. public class Robber extends PlayerListener {
  13. @Override
  14. public void onPlayerInteractEntity(PlayerInteractEntityEvent event){ //must have cb build 747+
  15. Player player = event.Player();
  16. Holdings account = iConomy.getAccount(player.getName()).getHoldings();
  17.  
  18. if(RolePlay.RPRobberUsers.contains(player)){
  19.  
  20. Player robbedPlayer;
  21. Entity ent = event.getRightClicked();
  22. if(ent instanceof Player){
  23. robbedPlayer = (Player)ent;
  24. }
  25. if(robbedPlayer != null){
  26. Holdings robbedPlayerHoldings = iConomy.getAccount(robbedPlayer.getName()).getHoldings();
  27.  
  28. if(!RolePlay.RPRobberUsers.contains(robbedPlayer) && !RolePlay.RPPoliceUsers.contains(robbedPlayer)){ //You check that your robbedPlayer is not a member of robbers or police
  29.  
  30. //----iConomy Part----
  31.  
  32. int amount = 1; //Configurable amount!
  33.  
  34. player.sendMessage(ChatColor.RED + "[RolePlay] " + ChatColor.AQUA + "You robbed " + iConomy.format(amount) + " from someone!"); //iConomy provides function to automatically format balances!
  35.  
  36. account.add(amount); //Player on the server always has an account :) If he doesn't, iConomy creates one
  37.  
  38. robbedPlayerHoldings.subtract(amount);
  39.  
  40. //-----------------Is Dead-----------------\\
  41.  
  42. if(RolePlay.isRobber && player.isDead()){
  43. RolePlay.isCivilian = true;
  44. RolePlay.isPolice = false;
  45. RolePlay.isRobber = false;
  46.  
  47. }
  48.  
  49. else{
  50.  
  51. // -- empty -- \\
  52.  
  53. }
  54. }
  55. }
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement