Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Soupe estende JavaPlugin implements Listener {
- public void onEnable ( ) {
- Bukkit. getServer ( ) . getPluginManager ( ) . registerEvents ( this , this ) ;
- saveDefaultConfig ( ) ;
- }
- @Gestore di eventi
- public void onPlayerInteract ( PlayerInteractEvent e ) {
- Giocatore p = e. getPlayer ( ) ;
- if ( e. getAction ( ) == Azione . RIGHT_CLICK_BLOCK || e. getAction ( ) == Azione . RIGHT_CLICK_AIR && ( p. getItemInHand ( ) . getType ( ) == Materiale. MUSHROOM_SOUP ) ) {
- if ( p. hasPermission ( "soupe.use" ) ) {
- p. setHealth ( Math . min ( p. getMaxHealth ( ) , p. getHealth ( ) + getConfig ( ) . getInt ( "health-to-give" ) ) ) ;
- p. setFoodLevel ( Math . min ( 20 , p. getFoodLevel ( ) + getConfig ( ) . getInt ( "food-to-give" ) ) )) ;
- if ( Material. matchMaterial ( getConfig ( ) . getString ( "material-to-replace" ) ) ! = null ) {
- p. getInventory ( ) . setItemInHand ( new ItemStack ( Material. getMaterial ( getConfig ( ) . getString ( "material-to-replace" ) ) , 1 ) ) ;
- } else {
- p. getInventory ( ) . setItemInHand ( new ItemStack ( Material. BOWL , 1 ) ) ;
- }
- p. getWorld ( ) . playEffect ( p. getLocation ( ) , Effect. SMOKE , 31 ) ;
- p. updateInventory ( ) ;
- e. setCancelled ( true ) ;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement