Sefiraat's Addons Documentation
  • Sefiraat
    • Throw me a sponsor, get some stuff!
  • Networks
    • Basics
      • What is Networks?
      • Item Deposit/Withdrawal
    • Network Nodes
      • Network Controller
      • Network Grid
      • Network Bridge
      • Network Cell
      • Network Monitor
      • Network Quantum Storage
      • Network Importer
      • Network Exporter
      • Network Grabber
      • Network Pusher
      • Network Purger
      • Network Capacitor
      • Network Power Display
      • Network Encoder
      • Network Autocrafters
      • Network Vanilla Pusher
      • Network Vanilla Grabber
      • Network Wireless Transmitter
      • Network Wireless Receiver
      • Network Control: X
      • Network Control: V
      • Network Vacuum
    • Tools
      • Network Remote
      • Crafting Blueprint
      • Network Crayon
      • Network Configurator
      • Network Wireless Configurator
      • Network Probe
  • Crystamae Historia
    • Spell Crafting
      • What is Crystamae?
      • Chronicling
      • Realisation
      • Liquefaction
      • Spell Plates
      • Stave Configurator
    • Spells
      • Abstract Void
      • Air Nova
      • Air Sprites
      • Ancient Defence
      • Animaniacs
    • Tools
      • Block Veil
      • Refracting Lens
      • Ephemeral Tables
      • Spell Plates
      • Connecting Compass
      • Displacer
      • Luminescence Scoops
      • Recalling Lattice
    • Gadgets
      • Lamps
      • Vacuums
      • Mob-spawning Dirt
      • Damage Plates
      • Experience Collectors
      • Ender Inhibitors
      • Verache Candles
      • Mysterious Items
      • Greenhouse Glass
      • Trophy Display
      • Exaltation Stand
      • Diverging Waystone
      • Angel Block
      • Philosopher's Spray
      • Glass of Milk
      • Voids
    • Artistic Items
    • Exalted Items
    • Uniques
  • Netheopoiesis
    • Overview
      • Purification
      • Growing and Breeding Plants
    • Purification
      • Sleeping in the Nether
      • Water in the Nether
      • Friendly Mobs
      • A Better-Barter
      • Mob Swapping
      • Mob Spawning
      • Purifying Aura
      • To the End!
    • Plants
      • Addon Berry Plant
      • Bartered Plant
      • Beach Plant
      • Best Friend Plant
      • Black and White Plant
      • Blob Plant
      • Busy Plant
      • Buzzing Plant
      • Chilly Plant
      • Cobbled Plant
      • Combustible Plant
      • Crystalline Plant
      • Cute Plant
      • Deepslate Plant
      • Desert Plant
      • Dusty Plant
      • Eden Plant
      • Enchanted Plant
      • Ethereal Plant
      • Feldspar Plant
      • Gateway Plant
      • Glistening Plant
      • Glowing Plant
      • Grainy Plant
      • Grass Plant
      • Hate Filled Plant
      • Hexed Plant
      • Igneous Plant
      • Ignited Plant
      • Jungle Plant
      • Learned Plant
      • Math Plant
      • Metallic Plant
      • Moldable Plant
      • Nori Plant
      • Oakendran Plant
      • Parrot Plant
      • Perfection Plant
      • Polar Plant
      • Porky Plant
      • Prismatic Plant
      • Protective Plant
      • Pulsing Plant
      • Purification Plant
      • Rainbow Plant
      • Rotten Plant
      • Saintly Plant
      • Seaside Plant
      • Seedy Plant
      • Shelled Plant
      • Shiny Plant
      • Slimy Plant
      • Smooth Plant
      • Soul Plant
      • Spindle Plant
      • Spiney Plant
      • Spirit Plant
      • Splintered Plant
      • Stoney Plant
      • Stray Plant
      • Stringy Plant
      • Swamp Plant
      • Sweet Plant
      • Tarnished Plant
      • Terrifying Plant
      • Treasured Plant
      • Valuable Plant
      • Volcanic Plant
      • Wet Plant
      • Wild Plant
  • SlimeTinker
    • Basics
    • Materials
      • Adamantite
      • Advanced Alloy
      • Aluminum Brass
      • Aluminum Bronze
      • Aluminum Singularity
      • Aluminum
      • Billon
      • Boomerite
      • Brass
      • Bronze
      • Carbon Fibre
      • Coal
      • Cobalt
      • Copper Singularity
      • Copper
      • Corinthian Bronze
      • Crimson Root
      • Cringleium
      • Damascus Steel
      • Daxi Absorption
      • Daxi Fortitude
      • Daxi Regeneration
      • Daxi Saturation
      • Daxi Strength
      • Diamond Singularity
      • Diamond
      • Duralium
      • Earth Singularity
      • Ferrosilicon
      • Fortune Singularity
      • Ghostly Essence
      • Gold Singularity
      • Gold
      • Hardened Metal
      • Infinite
      • Infinity Singularity
      • Interdimensional Presence
      • Iridium
      • Iron Singularity
      • Iron
      • Lead Singularity
      • Lead
      • Leather
      • Liquid Christmas
      • Liquid Love
      • Mag Thor
      • Magic Singularity
      • Magnesium Singularity
      • Magnesium
      • Magnonium
      • Magsteel
      • Metal Singularity
      • Mixed Metal
      • Mythril
      • Nickel
      • Osmium Superalloy
      • Osmium
      • Redstone Alloy
      • Redstone
      • Refined Iron
      • Reinforced Alloy
      • Reinforced Slime Steel
      • Remotininium
      • Rubber
      • Scrap
      • Sefirite
      • Segganesson
      • Silicon
      • Silver Singularity
      • Silver
      • Slime Steel
      • Slime
      • Solder
      • Stainless Steel
      • Star Dust
      • Steel
      • String
      • Tesseracting Material
      • Thorium
      • Tin Singularity
      • Tin
      • Titanium
      • Twisted Vine
      • Unpatentablium
      • Vex Gem
      • Vine
      • Void
      • Warped Root
      • Weeping Vine
      • Zinc Singularity
      • Zinc
    • Traits
  • Cultivation
    • Overview
      • Crop Breeding
    • Crafting Items
    • Tools
      • Crop Sticks
      • Plant Analyzer
      • Seed Pack
    • Machines
      • Garden Cloche
      • Cooking Work Stations
    • Plants
    • Developers
      • Adding Food Items via PR
        • 0: Adding new skull textures
        • 1: SlimefunItemStack
        • 2: Creating the Food SlimefunItem
  • DankTech2
    • Basics
  • Simple Storage
    • Basics
  • EMCTech
    • What is EMC?
    • EMC Calculations
  • Folio
    • Cards
      • Stone
      • Andesite
      • Basalt
  • SefiLib
    • Setup
      • Maven
    • Theme
    • SimpleFlexGroup
    • SimpleTickingBlock
    • TimePeriod
    • JavaDocs
Powered by GitBook
On this page
  • Creating a Theme
  • ItemStacks
  • Themed Strings

Was this helpful?

  1. SefiLib

Theme

Creating a Theme

A Theme in SefiLib is a way to pre-define a style and reuse it in multi locations.

It supports basic chat messages and strings, Themed ItemStack and Themed SlimefunItemStack also.

To create a new Theme, first add the import:

import io.github.sefiraat.sefilib.string.Theme;

Then you need to choose your ChatColor for the theme.

ChatColor chatColor = ChatColor.of("#3295a8");
ChatColor chatColor = ChatColor.RED;
Color color = new Color(255, 150, 20);
ChatColor chatColor = ChatColor.of(color);

Be sure you use ChatColor from net.md_5.bungee.api.ChatColor not org.bukkit.ChatColor

Then you need a String that will be the name, lore line and tag for this Theme. This string is used in the following ways:

  • Added to the final line in the lore of an ItemStack

  • Prepends any logging message sent via the Theme

Then create a new Theme using these two arguments.

Theme TRAIT = new Theme(ChatColor.of("#3295a8"), "Trait");

I would suggest creating themes as static elements of a utility class, as per the below example:

package dev.sefiraat.slimetinker2.implementation;

import io.github.sefiraat.sefilib.string.Theme;
import net.md_5.bungee.api.ChatColor;

public final class TinkerThemes {

    private TinkerThemes() {
        throw new IllegalStateException("Utility class");
    }

    public static final Theme MAIN = new Theme(ChatColor.of("#8a0e0e"), "SlimeTinker2");
    public static final Theme RESEARCH = new Theme(ChatColor.of("#a60e03"), "Research");
    public static final Theme CRAFTING = new Theme(ChatColor.of("#dbcea9"), "Crafting Material");
    public static final Theme RECIPE_TYPE = new Theme(ChatColor.of("#ffe89c"), "Recipe Type");
    public static final Theme MACHINE = new Theme(ChatColor.of("#3295a8"), "Machine");
    public static final Theme TOOL = new Theme(ChatColor.of("#3295a8"), "Tool");
    public static final Theme PART = new Theme(ChatColor.of("#dbcea9"), "Part");
    public static final Theme TRAIT = new Theme(ChatColor.of("#3295a8"), "Trait");
    public static final Theme MATERIAL = new Theme(ChatColor.of("#dbcea9"), "Material");
    public static final Theme ENCHANTMENT = new Theme(ChatColor.of("#ffe89c"), "Enchantment");
    public static final Theme UPGRADE = new Theme(ChatColor.of("#ea201a"), "Upgrade");
    public static final Theme ADDON = new Theme(ChatColor.of("#8a0e0e"), "Addon");
}

The Theme class comes with some default themes that can be used for common purposes (and used by Theme for item generation and certain strings).

// Yellow theme used to denote a warning of some kind
public static final Theme WARNING = new Theme(ChatColor.YELLOW, "Warning");
// Red theme used to denote an error, misuse etc.
public static final Theme ERROR = new Theme(ChatColor.RED, "Error");
// A plain white theme used for simple notices
public static final Theme NOTICE = new Theme(ChatColor.WHITE, "Notice");
// A passive light grey theme used for hints, sub-information and item lore
public static final Theme PASSIVE = new Theme(ChatColor.GRAY);
// A lime-green theme used to denote success and/or 'good' responses
public static final Theme SUCCESS = new Theme(ChatColor.GREEN, "Success");
// A bright yellow used for highlighting key word or where to click
public static final Theme CLICK_INFO = new Theme(ChatColor.of("#e4ed32"), "Click here");

ItemStacks

To create an ItemStack with the Theme applied. Simply use the static method Theme#themedItemStack() providing the Material, the Theme to be applied, the Item's name and a List<String> for the lore.

ItemStack itemStack = Theme.themedItemStack(
    Material.OAK_LOG,
    Themes.MATERIAL,
    "Testing Name",
    List.of(
        "Hello there",
        "This is some lore"
    )
);

The resulting ItemStack will have the name you provided using the Theme's color. The lore lines will follow after a single line gap using a the default Theme#PASSIVE. After all of the lore lines, there will be one last gap followed by the Theme's lore line using Theme#CLICK_INFO

SlimefunItemStack

A SlimefunItemStack is created in almost the same way, requiring an additional argument for the SlimefunItem ID as well as the List<String> being replaced with a String Array/String var-args

SlimefunItemStack slimefunItemStack = Theme.themedSlimefunItemStack(
    "ADDON_ITEM_ID",
    Material.OAK_LOG,
    Themes.MATERIAL,
    "Testing Name",
    new String[] {
        "Hello there",
        "This is some lore"
    }
);
SlimefunItemStack slimefunItemStack = Theme.themedSlimefunItemStack(
    "ADDON_ITEM_ID",
    Material.OAK_LOG,
    Themes.MATERIAL,
    "Testing Name",
    "Hello there",
    "This is some lore"
);

Themed Strings

The Theme class overrides .toString() to provide the theme's base color. This means at the most basic level, you can use your theme field directly within a string concatenation or other message formatter

String string = Themes.WARNING_THEME + "WARNING"

String string = MESSAGE_FORMAT.format(
    new Object[]{Themes.WARNING_THEME, "WARNING"}, 
    new StringBuffer(), 
    null
).toString()

You can use the .apply(Object) method which will directly return a String that is colored to match the theme. The static method Theme#applyThemeToString(Theme, String) does the same as .apply() but in a static context.

Player player = getPlayer();

player.sendMessage(Themes.WARNING_THEME.apply("This is a warning message"));

player.sendMessage(Theme.applyThemeToString(Themes.WARNING_THEME, "This is a warning mesage"));

You can use the .asTitle(Object, Object) method which will directly return a String that has the first object (as a string) in the themes color followed immedietly by a colon, a space then the second object as a string using the default Theme.PASSIVE. The static method Theme#applyThemeAsTitle(Theme, String, Object) does the same as .asTitle() but in a static context.

Player player = getPlayer();
int numberOfItems = getNumberOfItems();
String message = Theme.CLICK_INFO.asTitle("Total Items", numberOfItems);

player.sendMessage(message);
PreviousMavenNextSimpleFlexGroup

Last updated 2 years ago

Was this helpful?

An ItemStack created using Theme
A SlimefunItemStack created using a Theme
asTitle() example