# SagaLib API Simplified Usage Examples
## Core API
// Get API instance
SagaLibAPI sagaLib = SagaLibAPI. getInstance ( ) ;
## GUI System
### Creating GUI
// Create basic GUI
GuiHolder gui = sagaLib. createGui (player, "Main Menu", 54 ) ;
// Create pagination GUI
GuiHolder paginationGui = sagaLib. createPaginationGui (player, "Pagination Menu", 45 ) ;
// Create dynamic size GUI
GuiHolder dynamicGui = sagaLib. createDynamicGui (player, "Dynamic Menu", 27, 54, 45 ) ;
### Button Operations
// Create button
GuiButton button = new SimpleButton (Material. DIAMOND, "Diamond Button" ) ;
button. setClickHandler (event -> {
// Handle click event
} ) ;
// Add button
sagaLib. addButton (gui, 0, button ) ;
// Batch add buttons
Map < Integer, GuiButton > buttons = new HashMap <> ( ) ;
buttons. put ( 0, button1 ) ;
buttons. put ( 1, button2 ) ;
sagaLib. addButtons (gui, buttons ) ;
### Pagination Operations
// Get current page number
int currentPage = sagaLib. getCurrentPage (gui ) ;
// Set page number
sagaLib. setPage (gui, 0 ) ;
// Add navigation buttons
GuiButton prevButton = new SimpleButton (Material. ARROW, "Previous Page" ) ;
prevButton. setClickHandler (event -> {
int current = sagaLib. getCurrentPage (gui ) ;
if (current > 0 ) {
sagaLib. setPage (gui, current - 1 ) ;
}
} ) ;
GuiButton nextButton = new SimpleButton (Material. ARROW, "Next Page" ) ;
nextButton. setClickHandler (event -> {
int current = sagaLib. getCurrentPage (gui ) ;
int maxPage = (totalItems - 1 ) / itemsPerPage ;
if (current < maxPage ) {
sagaLib. setPage (gui, current + 1 ) ;
}
} ) ;
### Layout and Style
// Create layout
GuiLayout layout = sagaLib. createCustomLayout ( 6, 9, 1, 1 ) ;
sagaLib. setLayout (gui, layout ) ;
// Create style
GuiStyle style = sagaLib. createDefaultStyle ( ) ;
GuiStyle customStyle = sagaLib. createCustomStyle (
Material. BLACK_STAINED_GLASS_PANE, // Border material
Material. GRAY_STAINED_GLASS_PANE, // Background material
Material. WHITE_STAINED_GLASS_PANE // Button material
) ;
// Apply style
sagaLib. applyStyle (gui, style ) ;
### Animation Control
// Create animation
GuiAnimation animation = new FadeAnimation ( ) ;
// Add animation
sagaLib. addAnimation (gui, animation ) ;
// Control animation
sagaLib. startAnimation (gui, animation ) ;
sagaLib. stopAnimation (gui, animation ) ;
// Get animation status
String status = sagaLib. getAnimationStatus (gui, animation ) ;
### Item Operations
// Add item
sagaLib. addItem (gui, 0, item ) ;
// Batch add items
Map < Integer, ItemStack > items = new HashMap <> ( ) ;
items. put ( 0, item1 ) ;
items. put ( 1, item2 ) ;
sagaLib. addItems (gui, items ) ;
// Set item lore
List <String > lore = Arrays. asList ( "First line", "Second line" ) ;
sagaLib. setItemLore (item, lore ) ;
## Configuration System
// Get config manager
ConfigManager config = sagaLib. getConfigManager ( ) ;
config. loadConfig ( ) ;
// Get language manager
LanguageManager lang = sagaLib. getLanguageManager ( ) ;
lang. loadMessages ( ) ;
// Reload configuration
sagaLib. reloadConfig ( ) ;
// Get message configuration
FileConfiguration messageConfig = sagaLib. getMessageConfig ( ) ;
String message = messageConfig. getString ( "message.key" ) ;
// Get debug message configuration
FileConfiguration debugConfig = sagaLib. getDebugMessageConfig ( ) ;
## Utility Classes
// Parse color codes
String colored = sagaLib. parseColor ( "&aGreen text" ) ;
// Parse placeholders
String parsed = sagaLib. parsePlaceholders (player, "Player name: %player_name%" ) ;
// Check PlaceholderAPI
boolean hasPlaceholderAPI = sagaLib. hasPlaceholderAPI ( ) ;
// Register custom placeholder
sagaLib. registerPlaceholder ( "custom", player -> "Custom value" ) ;
// Get other utility classes
ColorUtil colorUtil = sagaLib. getColorUtil ( ) ;
TextUtil textUtil = sagaLib. getTextUtil ( ) ;
GuiUtil guiUtil = sagaLib. getGuiUtil ( ) ;
## Button Update Techniques
// Create new button to replace existing button
SimpleButton newButton = new SimpleButton (Material. DIAMOND, "New Button Name" ) ;
newButton. setLore ( Arrays. asList ( "&7New description text" ) ) ;
newButton. setClickHandler (event -> {
// New click handler
} ) ;
sagaLib. addButton (gui, slot, newButton ) ;
// Button update helper method
private void updateButton (GuiHolder gui, int slot, boolean state ) {
SimpleButton button = new SimpleButton (
state ? Material. EMERALD : Material. REDSTONE,
state ? "Active State" : "Disabled State"
) ;
button. setLore ( Arrays. asList (
"&7Click to " + (state ? "disable" : "activate" )
) ) ;
button. setClickHandler (e -> {
updateButton (gui, slot, !state ) ;
} ) ;
sagaLib. addButton (gui, slot, button ) ;
}
## Pagination Data Loading
// Load data for specific page
private void loadItemsForPage (GuiHolder gui, int page, int itemsPerPage, int totalItems ) {
int startIndex = page * itemsPerPage ;
int endIndex = Math. min (startIndex + itemsPerPage, totalItems ) ;
for ( int i = startIndex ; i < endIndex ; i ++ ) {
int slotIndex = i - startIndex ;
ItemStack item = createItem (i ) ;
sagaLib. addItem (gui, slotIndex, item ) ;
}
}
## Custom Animation
// Implement custom animation
public class CustomAnimation implements GuiAnimation {
private boolean running = false ;
@Override
public void start (GuiHolder holder ) {
running = true ;
// Animation start logic
}
@Override
public void stop ( ) {
running = false ;
// Animation stop logic
}
@Override
public boolean isRunning ( ) {
return running ;
}
@Override
public String getName ( ) {
return "custom" ;
}
@Override
public String getDescription ( ) {
return "Custom animation effect" ;
}
@Override
public String getStatus ( ) {
return running ? "START" : "STOP" ;
}
}
// Or using anonymous inner class
GuiAnimation animation = new GuiAnimation ( ) {
private boolean running = false ;
@Override
public void start (GuiHolder holder ) {
running = true ;
// Implement animation logic
}
@Override
public void stop ( ) {
running = false ;
}
@Override
public boolean isRunning ( ) {
return running ;
}
@Override
public String getName ( ) {
return "anonymous" ;
}
@Override
public String getDescription ( ) {
return "Anonymous animation" ;
}
@Override
public String getStatus ( ) {
return running ? "START" : "STOP" ;
}
} ;
## Core API
Code (Java):
// Get API instance
SagaLibAPI sagaLib = SagaLibAPI. getInstance ( ) ;
### Creating GUI
Code (Java):
// Create basic GUI
GuiHolder gui = sagaLib. createGui (player, "Main Menu", 54 ) ;
// Create pagination GUI
GuiHolder paginationGui = sagaLib. createPaginationGui (player, "Pagination Menu", 45 ) ;
// Create dynamic size GUI
GuiHolder dynamicGui = sagaLib. createDynamicGui (player, "Dynamic Menu", 27, 54, 45 ) ;
Code (Java):
// Create button
GuiButton button = new SimpleButton (Material. DIAMOND, "Diamond Button" ) ;
button. setClickHandler (event -> {
// Handle click event
} ) ;
// Add button
sagaLib. addButton (gui, 0, button ) ;
// Batch add buttons
Map < Integer, GuiButton > buttons = new HashMap <> ( ) ;
buttons. put ( 0, button1 ) ;
buttons. put ( 1, button2 ) ;
sagaLib. addButtons (gui, buttons ) ;
Code (Java):
// Get current page number
int currentPage = sagaLib. getCurrentPage (gui ) ;
// Set page number
sagaLib. setPage (gui, 0 ) ;
// Add navigation buttons
GuiButton prevButton = new SimpleButton (Material. ARROW, "Previous Page" ) ;
prevButton. setClickHandler (event -> {
int current = sagaLib. getCurrentPage (gui ) ;
if (current > 0 ) {
sagaLib. setPage (gui, current - 1 ) ;
}
} ) ;
GuiButton nextButton = new SimpleButton (Material. ARROW, "Next Page" ) ;
nextButton. setClickHandler (event -> {
int current = sagaLib. getCurrentPage (gui ) ;
int maxPage = (totalItems - 1 ) / itemsPerPage ;
if (current < maxPage ) {
sagaLib. setPage (gui, current + 1 ) ;
}
} ) ;
Code (Java):
// Create layout
GuiLayout layout = sagaLib. createCustomLayout ( 6, 9, 1, 1 ) ;
sagaLib. setLayout (gui, layout ) ;
// Create style
GuiStyle style = sagaLib. createDefaultStyle ( ) ;
GuiStyle customStyle = sagaLib. createCustomStyle (
Material. BLACK_STAINED_GLASS_PANE, // Border material
Material. GRAY_STAINED_GLASS_PANE, // Background material
Material. WHITE_STAINED_GLASS_PANE // Button material
) ;
// Apply style
sagaLib. applyStyle (gui, style ) ;
Code (Java):
// Create animation
GuiAnimation animation = new FadeAnimation ( ) ;
// Add animation
sagaLib. addAnimation (gui, animation ) ;
// Control animation
sagaLib. startAnimation (gui, animation ) ;
sagaLib. stopAnimation (gui, animation ) ;
// Get animation status
String status = sagaLib. getAnimationStatus (gui, animation ) ;
Code (Java):
// Add item
sagaLib. addItem (gui, 0, item ) ;
// Batch add items
Map < Integer, ItemStack > items = new HashMap <> ( ) ;
items. put ( 0, item1 ) ;
items. put ( 1, item2 ) ;
sagaLib. addItems (gui, items ) ;
// Set item lore
List <String > lore = Arrays. asList ( "First line", "Second line" ) ;
sagaLib. setItemLore (item, lore ) ;
Code (Java):
// Get config manager
ConfigManager config = sagaLib. getConfigManager ( ) ;
config. loadConfig ( ) ;
// Get language manager
LanguageManager lang = sagaLib. getLanguageManager ( ) ;
lang. loadMessages ( ) ;
// Reload configuration
sagaLib. reloadConfig ( ) ;
// Get message configuration
FileConfiguration messageConfig = sagaLib. getMessageConfig ( ) ;
String message = messageConfig. getString ( "message.key" ) ;
// Get debug message configuration
FileConfiguration debugConfig = sagaLib. getDebugMessageConfig ( ) ;
Code (Java):
// Parse color codes
String colored = sagaLib. parseColor ( "&aGreen text" ) ;
// Parse placeholders
String parsed = sagaLib. parsePlaceholders (player, "Player name: %player_name%" ) ;
// Check PlaceholderAPI
boolean hasPlaceholderAPI = sagaLib. hasPlaceholderAPI ( ) ;
// Register custom placeholder
sagaLib. registerPlaceholder ( "custom", player -> "Custom value" ) ;
// Get other utility classes
ColorUtil colorUtil = sagaLib. getColorUtil ( ) ;
TextUtil textUtil = sagaLib. getTextUtil ( ) ;
GuiUtil guiUtil = sagaLib. getGuiUtil ( ) ;
Code (Java):
// Create new button to replace existing button
SimpleButton newButton = new SimpleButton (Material. DIAMOND, "New Button Name" ) ;
newButton. setLore ( Arrays. asList ( "&7New description text" ) ) ;
newButton. setClickHandler (event -> {
// New click handler
} ) ;
sagaLib. addButton (gui, slot, newButton ) ;
// Button update helper method
private void updateButton (GuiHolder gui, int slot, boolean state ) {
SimpleButton button = new SimpleButton (
state ? Material. EMERALD : Material. REDSTONE,
state ? "Active State" : "Disabled State"
) ;
button. setLore ( Arrays. asList (
"&7Click to " + (state ? "disable" : "activate" )
) ) ;
button. setClickHandler (e -> {
updateButton (gui, slot, !state ) ;
} ) ;
sagaLib. addButton (gui, slot, button ) ;
}
Code (Java):
// Load data for specific page
private void loadItemsForPage (GuiHolder gui, int page, int itemsPerPage, int totalItems ) {
int startIndex = page * itemsPerPage ;
int endIndex = Math. min (startIndex + itemsPerPage, totalItems ) ;
for ( int i = startIndex ; i < endIndex ; i ++ ) {
int slotIndex = i - startIndex ;
ItemStack item = createItem (i ) ;
sagaLib. addItem (gui, slotIndex, item ) ;
}
}
Code (Java):
// Implement custom animation
public class CustomAnimation implements GuiAnimation {
private boolean running = false ;
@Override
public void start (GuiHolder holder ) {
running = true ;
// Animation start logic
}
@Override
public void stop ( ) {
running = false ;
// Animation stop logic
}
@Override
public boolean isRunning ( ) {
return running ;
}
@Override
public String getName ( ) {
return "custom" ;
}
@Override
public String getDescription ( ) {
return "Custom animation effect" ;
}
@Override
public String getStatus ( ) {
return running ? "START" : "STOP" ;
}
}
// Or using anonymous inner class
GuiAnimation animation = new GuiAnimation ( ) {
private boolean running = false ;
@Override
public void start (GuiHolder holder ) {
running = true ;
// Implement animation logic
}
@Override
public void stop ( ) {
running = false ;
}
@Override
public boolean isRunning ( ) {
return running ;
}
@Override
public String getName ( ) {
return "anonymous" ;
}
@Override
public String getDescription ( ) {
return "Anonymous animation" ;
}
@Override
public String getStatus ( ) {
return running ? "START" : "STOP" ;
}
} ;
Quick facts
- Edition: Minecraft Java
- File type: .jar
- Minecraft version listed: 1.21
- How to install: Install the matching mod loader (Forge, Fabric or NeoForge) for your Minecraft version. → Download the .jar. → Put it in the .minecraft/mods folder and launch that loader profile.
- Where to get it: Opens on Spigot — not every file is mirrored on our own servers.
Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.
del is a free Minecraft Java mod. Compatible with Minecraft 1.21. Downloaded 357 times (via Spigot). Download it and open it directly in the game.