Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coloured brackets #20

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 28 additions & 21 deletions src/main/java/com/jewelexx/tablocation/TabLocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public final class TabLocation extends JavaPlugin implements Listener {
static final Logger log = Bukkit.getLogger();
static boolean environmentEnabled;
static boolean locationEnabled;
static boolean bracketColourEnabled;
static FileConfiguration config;
final String version = getDescription().getVersion();

Expand All @@ -38,6 +39,7 @@ public void onEnable() {

environmentEnabled = config.getBoolean("Show dimension");
locationEnabled = config.getBoolean("Show location");
bracketColourEnabled = config.getBoolean("Colour brackets");

manager.registerEvents(this, this);

Expand Down Expand Up @@ -104,27 +106,30 @@ protected static String getLoc(Player player) {

String world = "";

if (environmentEnabled) {
Environment environment = player.getWorld().getEnvironment();

switch (environment) {
case NORMAL:
world = "Overworld";
break;
case NETHER:
world = "Nether";
break;
case THE_END:
world = "End";
break;
default:
world = environment.toString();
break;
}
Environment environment = player.getWorld().getEnvironment();

switch (environment) {
case NORMAL:
world = "Overworld";
break;
case NETHER:
world = "Nether";
break;
case THE_END:
world = "End";
break;
default:
world = environment.toString();
break;
}

String colourcode = config.getString("Colour for The " + world);

String colourcode = config.getString("Colour for The " + world);
String theworld = "";

world = colourcode + "The " + world + CraftColours.RESET;
if (environmentEnabled) {

theworld = colourcode + "The " + world + CraftColours.RESET;
}

String location = "";
Expand All @@ -142,7 +147,9 @@ protected static String getLoc(Player player) {
if (locationEnabled && environmentEnabled) {
separator = ", ";
}

return " " + CraftColours.WHITE + "[" + location + separator + world + "]";
if (!bracketColourEnabled) {
colourcode = CraftColours.WHITE;
}
return " " + colourcode + "[" + CraftColours.WHITE + location + separator + theworld + colourcode + "]";
}
}
4 changes: 3 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Show the dimension player's current dimension
# Show the player's current dimension
Show dimension: true
# Show the exact coordinates of the player
Show location: true
# Colour the brackets around the coordinates depending on the player's dimension
Colour brackets: false

# The following are Minecraft colour codes from https://www.digminecraft.com/lists/color_list_pc.php
Colour for The Overworld: §a
Expand Down