Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Player: add custom world prefix support
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFaser committed Jul 16, 2023
1 parent 6d5f25e commit c5a6f67
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/java/net/flectone/custom/FPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,18 @@ public void setPlayerListHeaderFooter() {

public void setWorldPrefix(World world) {
if (Main.getInstance().getConfig().getBoolean("player.world.prefix.enable")) {
this.worldPrefix = Main.locale.getFormatString("player.world.prefix." + world.getEnvironment().toString().toLowerCase(), player);

String worldType = Main.config.getString("player.world.mode").equals("type")
? world.getEnvironment().toString().toLowerCase()
: world.getName().toLowerCase();

this.worldPrefix = Main.locale.getString("player.world.prefix." + worldType);
if(this.worldPrefix == null){
Main.warning("The prefix for " + worldType + " could not be determined");
this.worldPrefix = Main.locale.getString("player.world.prefix.normal");
}

this.worldPrefix = ObjectUtil.formatString(this.worldPrefix, player);
}

setDisplayName();
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ player:
name: "<world_prefix><vault_prefix><stream_prefix><player><afk_suffix><vault_suffix>"

world:
# type or name
# if mode=name the language file should contain lines with names of the worlds
mode: "type"
prefix:
enable: true

Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/language/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,18 @@ player:

world:
prefix:
# mode can be changed in config.yml (default=type)
# mode=type
normal: "#4eff52● &f"
nether: "#ff4e4e● &f"
the_end: "#834eff● &f"
custom: "#1abaf0● &f"

# mode=name
world: "#4eff52● &f"
world_nether: "#ff4e4e● &f"
world_the_end: "#834eff● &f"

chat:
bubble:
color: "#999999"
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/language/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,18 @@ player:

world:
prefix:
# режим можно изменить в config.yml (по умолчанию=type)
# режим=type
normal: "#4eff52● &f"
nether: "#ff4e4e● &f"
the_end: "#834eff● &f"
custom: "#1abaf0● &f"

# режим=name
world: "#4eff52● &f"
world_nether: "#ff4e4e● &f"
world_the_end: "#834eff● &f"

chat:
bubble:
color: "#999999"
Expand Down

0 comments on commit c5a6f67

Please sign in to comment.