Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. public class Soupe estende JavaPlugin implements Listener {
  2.  
  3. public void onEnable ( ) {
  4. Bukkit. getServer ( ) . getPluginManager ( ) . registerEvents ( this , this ) ;
  5. saveDefaultConfig ( ) ;
  6. }
  7.  
  8. @Gestore di eventi
  9. public void onPlayerInteract ( PlayerInteractEvent e ) {
  10. Giocatore p = e. getPlayer ( ) ;
  11. if ( e. getAction ( ) == Azione . RIGHT_CLICK_BLOCK || e. getAction ( ) == Azione . RIGHT_CLICK_AIR && ( p. getItemInHand ( ) . getType ( ) == Materiale. MUSHROOM_SOUP ) ) {
  12. if ( p. hasPermission ( "soupe.use" ) ) {
  13. p. setHealth ( Math . min ( p. getMaxHealth ( ) , p. getHealth ( ) + getConfig ( ) . getInt ( "health-to-give" ) ) ) ;
  14. p. setFoodLevel ( Math . min ( 20 , p. getFoodLevel ( ) + getConfig ( ) . getInt ( "food-to-give" ) ) )) ;
  15. if ( Material. matchMaterial ( getConfig ( ) . getString ( "material-to-replace" ) ) ! = null ) {
  16. p. getInventory ( ) . setItemInHand ( new ItemStack ( Material. getMaterial ( getConfig ( ) . getString ( "material-to-replace" ) ) , 1 ) ) ;
  17. } else {
  18. p. getInventory ( ) . setItemInHand ( new ItemStack ( Material. BOWL , 1 ) ) ;
  19. }
  20. p. getWorld ( ) . playEffect ( p. getLocation ( ) , Effect. SMOKE , 31 ) ;
  21. p. updateInventory ( ) ;
  22. e. setCancelled ( true ) ;
  23. }
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement