Fix RegionScoreboardElement
This commit is contained in:
@@ -23,8 +23,13 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Linked
|
||||
public class RegionScoreboardElement implements ScoreboardElement {
|
||||
|
||||
@@ -41,6 +46,11 @@ public class RegionScoreboardElement implements ScoreboardElement {
|
||||
@Override
|
||||
public String get(Region region, Player p) {
|
||||
if (region.getType().isGlobal()) return null;
|
||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + region.getName();
|
||||
Optional<File> gameModeConfig = region.getGameModeConfig();
|
||||
if (gameModeConfig.isEmpty()) return null;
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(region.getGameModeConfig().get());
|
||||
List<String> names = config.getStringList("Server.ChatNames");
|
||||
if (names.isEmpty()) return null;
|
||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + names.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user