mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-24 19:45:43 +01:00
Don't force-tie groups to colors; resolves #516
This commit is contained in:
parent
63092b6d71
commit
cb26c414bd
@ -423,7 +423,7 @@ public class Announcer {
|
||||
|
||||
boolean full = playerCount >= maxPlayersPerGroup;
|
||||
|
||||
DColor color = plugin.getMainConfig().getGroupColorPriority().get(groupCount);
|
||||
DColor color = plugin.getMainConfig().getGroupColorPriority(groupCount);
|
||||
ItemStack button = color.getWoolMaterial().toItemStack();
|
||||
ItemMeta meta = button.getItemMeta();
|
||||
meta.setDisplayName(name + (full ? ChatColor.DARK_RED : ChatColor.GREEN) + " [" + playerCount + "/" + maxPlayersPerGroup + "]");
|
||||
|
@ -254,7 +254,7 @@ public class GroupCommand extends DCommand {
|
||||
|
||||
MessageUtil.sendCenteredMessage(sender, "&4&l[ &6" + dGroup.getName() + " &4&l]");
|
||||
MessageUtil.sendMessage(sender, "&bCaptain: &e" + dGroup.getCaptain().getName());
|
||||
String players = new String();
|
||||
String players = "";
|
||||
for (String player : dGroup.getPlayers().getNames()) {
|
||||
players += (players.isEmpty() ? "" : "&b, &e") + player;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class StatusCommand extends DCommand {
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
String minecraftVersion = compat.getVersion().toString();
|
||||
String bukkitVersion = Bukkit.getName() + (compat.isSpigot() ? " (Spigot)" : new String()) + " " + Bukkit.getBukkitVersion();
|
||||
String bukkitVersion = Bukkit.getName() + (compat.isSpigot() ? " (Spigot)" : "") + " " + Bukkit.getBukkitVersion();
|
||||
String internalsVersion = compat.getInternals().toString();
|
||||
String dungeonsxlVersion = plugin.getDescription().getVersion();
|
||||
|
||||
|
@ -75,7 +75,6 @@ public class MainConfig extends DREConfig {
|
||||
LIGHT_GREEN,
|
||||
PURPLE,
|
||||
ORANGE,
|
||||
WHITE,
|
||||
BLACK,
|
||||
LIGHT_BLUE,
|
||||
DARK_GREEN,
|
||||
@ -83,7 +82,8 @@ public class MainConfig extends DREConfig {
|
||||
LIGHT_GRAY,
|
||||
CYAN,
|
||||
MAGENTA,
|
||||
DARK_GRAY
|
||||
DARK_GRAY,
|
||||
PINK
|
||||
));
|
||||
private double announcementInterval = 30;
|
||||
|
||||
@ -285,6 +285,14 @@ public class MainConfig extends DREConfig {
|
||||
return groupColorPriority;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param count the group count
|
||||
* @return the group color for the count
|
||||
*/
|
||||
public DColor getGroupColorPriority(int count) {
|
||||
return (count < groupColorPriority.size() && count >= 0) ? groupColorPriority.get(count) : DColor.WHITE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param colors the colors to set
|
||||
*/
|
||||
@ -583,24 +591,23 @@ public class MainConfig extends DREConfig {
|
||||
tutorialStartGroup = config.getString("tutorial.startgroup", tutorialStartGroup);
|
||||
tutorialEndGroup = config.getString("tutorial.endgroup", tutorialEndGroup);
|
||||
|
||||
if (config.contains("groupColorPriority")) {
|
||||
if (config.getStringList("groupColorPriority").size() < 15) {
|
||||
ArrayList<String> strings = new ArrayList<>();
|
||||
for (DColor color : groupColorPriority) {
|
||||
strings.add(color.toString());
|
||||
}
|
||||
config.set("groupColorPriority", strings);
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException exception) {
|
||||
}
|
||||
if (config.getStringList("groupColorPriority").size() < 14) {
|
||||
ArrayList<String> strings = new ArrayList<>();
|
||||
for (DColor color : groupColorPriority) {
|
||||
strings.add(color.toString());
|
||||
}
|
||||
config.set("groupColorPriority", strings);
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException exception) {
|
||||
}
|
||||
|
||||
} else {
|
||||
groupColorPriority.clear();
|
||||
for (String color : config.getStringList("groupColorPriority")) {
|
||||
if (EnumUtil.isValidEnum(DColor.class, color)) {
|
||||
groupColorPriority.add(DColor.valueOf(color));
|
||||
}
|
||||
} else {
|
||||
groupColorPriority.clear();
|
||||
for (String color : config.getStringList("groupColorPriority")) {
|
||||
DColor dColor = EnumUtil.getEnum(DColor.class, color);
|
||||
if (dColor != null && dColor != DColor.WHITE) {
|
||||
groupColorPriority.add(dColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,9 @@ public class DGroup {
|
||||
DungeonsXL plugin;
|
||||
DPlayerCache dPlayers;
|
||||
|
||||
private static int counter;
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
private Player captain;
|
||||
private PlayerCollection players = new PlayerCollection();
|
||||
@ -76,11 +79,11 @@ public class DGroup {
|
||||
private int lives = -1;
|
||||
|
||||
public DGroup(DungeonsXL plugin, Player player) {
|
||||
this(plugin, "Group " + plugin.getDGroupCache().size(), player);
|
||||
this(plugin, "Group#" + counter, player);
|
||||
}
|
||||
|
||||
public DGroup(DungeonsXL plugin, Player player, DColor color) {
|
||||
this(plugin, color.toString().replace("_", " "), player);
|
||||
this(plugin, color.toString() + "#" + counter, player);
|
||||
}
|
||||
|
||||
public DGroup(DungeonsXL plugin, String name, Player player) {
|
||||
@ -95,10 +98,12 @@ public class DGroup {
|
||||
|
||||
playing = false;
|
||||
floorCount = 0;
|
||||
|
||||
id = counter++;
|
||||
}
|
||||
|
||||
public DGroup(DungeonsXL plugin, Player player, Dungeon dungeon) {
|
||||
this(plugin, plugin.getMainConfig().getGroupColorPriority().get(plugin.getDGroupCache().size()).toString(), player, dungeon);
|
||||
this(plugin, "Group#" + counter, player, dungeon);
|
||||
}
|
||||
|
||||
public DGroup(DungeonsXL plugin, String name, Player player, Dungeon dungeon) {
|
||||
@ -129,14 +134,23 @@ public class DGroup {
|
||||
setDungeon(dungeon);
|
||||
playing = false;
|
||||
floorCount = 0;
|
||||
|
||||
id = counter++;
|
||||
}
|
||||
|
||||
// Getters and setters
|
||||
/**
|
||||
* @return the group ID
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name; formatted
|
||||
*/
|
||||
public String getName() {
|
||||
return (color != null ? color.getChatColor().toString() : new String()) + name;
|
||||
return getDColor().getChatColor() + name;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -157,7 +171,7 @@ public class DGroup {
|
||||
* @param color the color to fetch the name from
|
||||
*/
|
||||
public void setName(DColor color) {
|
||||
name = color.toString().replace("_", " ");
|
||||
name = color.toString() + "#" + id;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -520,7 +534,7 @@ public class DGroup {
|
||||
* @return if the group has been customized with a command
|
||||
*/
|
||||
public boolean isCustom() {
|
||||
return !name.matches("Group_[0-9]{1,}");
|
||||
return !name.matches("Group#[0-9]{1,}");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -544,7 +558,7 @@ public class DGroup {
|
||||
if (color != null) {
|
||||
return color;
|
||||
} else {
|
||||
return DColor.DEFAULT;
|
||||
return DColor.WHITE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -766,7 +780,9 @@ public class DGroup {
|
||||
GameRuleProvider rules = game.getRules();
|
||||
gameWorld.setWeather(rules);
|
||||
|
||||
color = plugin.getMainConfig().getGroupColorPriority().get(game.getDGroups().indexOf(this));
|
||||
if (color == null) {
|
||||
color = plugin.getMainConfig().getGroupColorPriority((game.getDGroups().indexOf(this)));
|
||||
}
|
||||
|
||||
for (DGroup dGroup : game.getDGroups()) {
|
||||
if (dGroup == null) {
|
||||
|
@ -43,7 +43,7 @@ public enum DColor {
|
||||
LIGHT_RED(ChatColor.RED, DyeColor.RED, VanillaItem.RED_WOOL),
|
||||
ORANGE(ChatColor.GOLD, DyeColor.ORANGE, VanillaItem.ORANGE_WOOL),
|
||||
YELLOW(ChatColor.YELLOW, DyeColor.YELLOW, VanillaItem.YELLOW_WOOL),
|
||||
DEFAULT(ChatColor.BLUE, DyeColor.PINK, VanillaItem.PINK_WOOL);
|
||||
PINK(ChatColor.BLUE, DyeColor.PINK, VanillaItem.PINK_WOOL);
|
||||
|
||||
private ChatColor chat;
|
||||
private DyeColor dye;
|
||||
|
Loading…
Reference in New Issue
Block a user