Sueta

invi | Easy to use Inventory Library | Easy Click Events [Bl

0.1.1-pre

A very easy to use Inventory Library for Paper/Spigot developed and used by BlazingRP

·Plugin

BlazingRP/invi
A very easy to use Inventory Library for Paper/Spigot developed and used by BlazingRP

What is invi?
Take a look at this gif:

( Alternative link if gif doesn't show )
And now guess how many lines of code it is. It's 32 Lines. Take a look at the code:

Code
// Create the Window  
  Window   window  =    Window   .  create   (   "Inventory Title (Test 1)"  ,  3   )   ;  

 // Create Lore for the first Item  
ArrayList  <  String  >  lore1  =   new  ArrayList  <  String  >   (   )   ;  
lore1.  add   (   "This is just a label."   )   ;  
lore1.  add   (   "It cannot be clicked as"   )   ;  
lore1.  add   (   "It's purpose is to give"   )   ;  
lore1.  add   (   "information."   )   ;  

 // Create the first Item, which is a Label (doesn't do anything when clicked, not moveable) and set  
 // it's position in the inventory  
  Label   infoLabel  =    Label   .  create   (   new  ItemStack  (  Material.  WOOD_SPADE   )  ,  "Info Label"  , lore1  )   ;  
infoLabel.  setCoords   (   3  ,  2   )   ;  

 // Create Lore for the second Item  
ArrayList  <  String  >  lore2  =   new  ArrayList  <  String  >   (   )   ;  
lore2.  add   (   "This however is a button."   )   ;  
lore2.  add   (   "It cancels the click event"   )   ;  
lore2.  add   (   "and sends you a chat message."   )   ;  

 // Create the second Item, which is Button and set it's position in the inventory  
  Button   messageButton  =    Button   .  create   (   new  ItemStack  (  Material.  GOLD_NUGGET   )  ,  "Message Button"  , lore2  )   ;  
messageButton.  setCoords   (   5  ,  2   )   ;  
 // Now assign a Click Event to the Button  
messageButton.  setOnClick   (   (  event  )   ->   {  
    e.  getPlayer   (   )  .  sendMessage   (   "Hey there. How are you? You clicked me, right?"   )   ;  
    event.  setCancelled   (   true   )   ;  
 }   )   ;  

 // And now the same for the third Item  
ArrayList  <  String  >  lore3  =   new  ArrayList  <  String  >   (   )   ;  
lore3.  add   (   "This is another button."   )   ;  
lore3.  add   (   "It cancels the click event"   )   ;  
lore3.  add   (   "and kicks you!"   )   ;  
  Button   kickButton  =    Button   .  create   (   new  ItemStack  (  Material.  DIAMOND_AXE   )  ,  "Kick Button"  , lore3  )   ;  
kickButton.  setCoords   (   7  ,  2   )   ;  
kickButton.  setOnClick   (   (  event  )   ->   {  
    e.  getPlayer   (   )  .  kickPlayer   (   "You clicked me. I hate being clicked."   )   ;  
    event.  setCancelled   (   true   )   ;  
 }   )   ;  

 // And at last add the Components to the Window and show the Window to the player  
window.  addComponent   (  infoLabel  )   ;  
window.  addComponent   (  messageButton  )   ;  
window.  addComponent   (  kickButton  )   ;  
window.  show   (  e.  getPlayer   (   )   )   ;

This isn't all however. You can also for example assign an onClose Event to a Window.

What State is invi currently in?
Invi is currently usable, but still pretty unfinished and may contain some bugs, which is why we're always happy about Pull Requests and Issues on GitHub!

Documentation

Similar projects

Plugin →