Skip to content

Ariouz/BarBuilder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 

Repository files navigation

BarBuilder

Last updates:

v1.0.1 Update:

added invert(), switchColors() and switchSense() methods.

What is that ?

BarBuilder is a class that help you to make bars, looking like XP bars. Example: 10% of 20 = 2 are green and 18 are red -> in code this is:

new BarBuilder(10, 20).build();

How to make a basic XP bar ?

Create a String wich the bar you want to have.

String myXpBar;

Initialize it with the bar you want. For example, if I want a bar that shows 12% with 50 caracters (default is '|')

myXpBar = new BarBuilder(12, 50).build;

Preview: Image of result

Don't forget to use build() methods at the end. You can also change the colors, the caracter, the size of bar.

Methods and Build details

If you want to customize you bar, you can change the colors, the size of the bar (how many '|' there are) and the caracter (change '|' with another thing).

The setFullColor Method:

This methods will change the green bars to another color, exemple in code:

myXpBar = new BarBuilder(12, 50).setFullColor(ChatColor.BLUE).build;

Preview: Image of result

The setEmptyColor Method:

This method will change you the red bars to another color, exemple in code:

myXpBar = new BarBuilder(12, 50).setEmptyColor(ChatColor.GOLD).build;

Preview: Image of result

The setSize Method:

This method will change you the bar size (default is 100), exemple in code:

myXpBar = new BarBuilder(12, 150).build;
myXpBar = new BarBuilder(12).setSize(150).build;

(These methods do the same thing) Preview: Image of result

The setCaracter Method:

This method will change you the bar caracter (default is '|'), exemple in code:

myXpBar = new BarBuilder(12, 50).setCaracter('x').build;

Preview: Image of result

You can superpose methods in one line of code, exemple in code:

myXpBar = new BarBuilder(12).setCaracter(':').setFullColor(ChatColor.YELLOW).setEmptyColor(ChatColor.GOLD).setSize(50).build;

Preview: Image of result

The switchColors() method:

This method will switch the fullColor with the emptyColor, exemple in code:

myXpBar = new BarBuilder(80).switchColors().build();

Preview: Image of result

The switchSense(Sense) method:

This method will change the sense of the bazar (default is Sense.NORMAL), exemple in code with Sense.REVERSE:

myXpBar = new BarBuilder(80).switchSense(BarBuilder.Sense.REVERSE).build();

Preview: Image of result

The invert() method:

This method will invert the Sense and the colors of the bar, nice if you want to make a countdown:

myXpBar = new BarBuilder(80).invert().build();
OR
myXpBar = new BarBuilder(80).switchColors().switchSense(BarBuilder.Sense.REVERSE).build();

Preview: Image of result

As you can see, the two differents line of code do the same thing.

Getters

getPercent()

Return the percent of completed.

getFullColor()

Return the "completed" color (default is Green).

getEmptyColor()

Return the "non-completed" color (default is Red).

getCharacter()

Return the character of the bar (default is '|').

getSize()

Return the size of the bar (number of characters).

Hope you enjoy my class, if you have any request or idea ask me.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages