Fix /u ncolor (#118)
This commit is contained in:
parent
7448eb7e3a
commit
ce4f40c2c4
4 changed files with 21 additions and 13 deletions
4
pom.xml
4
pom.xml
|
@ -211,10 +211,10 @@
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.palmergames.bukkit.towny</groupId>
|
<groupId>com.github.TownyAdvanced</groupId>
|
||||||
<artifactId>Towny</artifactId>
|
<artifactId>Towny</artifactId>
|
||||||
<!-- <version>8d3b6b6</version> ButtonCore repo -->
|
<!-- <version>8d3b6b6</version> ButtonCore repo -->
|
||||||
<version>0.96.1.0</version>
|
<version>0.96.2.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- <dependency> <groupId>au.com.mineauz</groupId> <artifactId>Minigames</artifactId>
|
<!-- <dependency> <groupId>au.com.mineauz</groupId> <artifactId>Minigames</artifactId>
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class NColorCommand extends UCommandBase {
|
||||||
//Don't add ~ for nicknames
|
//Don't add ~ for nicknames
|
||||||
if (!nameWithLines.replace("|", "").replace(":", "").equalsIgnoreCase(name)) {
|
if (!nameWithLines.replace("|", "").replace(":", "").equalsIgnoreCase(name)) {
|
||||||
player.sendMessage("§cThe name you gave doesn't match your name. Make sure to use "
|
player.sendMessage("§cThe name you gave doesn't match your name. Make sure to use "
|
||||||
+ name + "§c with added vertical lines (|) or colons (:).");
|
+ name + "§c with added vertical lines (|) or colons (:).");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
String[] nameparts = nameWithLines.split("[|:]");
|
String[] nameparts = nameWithLines.split("[|:]");
|
||||||
|
@ -50,22 +50,30 @@ public class NColorCommand extends UCommandBase {
|
||||||
player.sendMessage("§cYour town doesn't have a color set. The town mayor can set it using /u towncolor.");
|
player.sendMessage("§cYour town doesn't have a color set. The town mayor can set it using /u towncolor.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (nameparts.length < towncolors.length + 1) { //+1: Nation color
|
var component = TownColorComponent.getComponent();
|
||||||
|
byte nationColors = (byte) (component.useNationColors().get() ? 1 : 0);
|
||||||
|
if (nameparts.length < towncolors.length + nationColors) { //+1: Nation color
|
||||||
player.sendMessage("§cYou need more vertical lines (|) or colons (:) in your name. (Should have " + (towncolors.length - 1 + 1) + ")"); //Nation color
|
player.sendMessage("§cYou need more vertical lines (|) or colons (:) in your name. (Should have " + (towncolors.length - 1 + 1) + ")"); //Nation color
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (nameparts.length > (towncolors.length + 1) * 2) {
|
if (nameparts.length > (towncolors.length + nationColors) * 2) {
|
||||||
player.sendMessage("§cYou have waay too many vertical lines (|) or colons (:) in your name. (Should have " + (towncolors.length - 1 + 1) + ")");
|
player.sendMessage("§cYou have waay too many vertical lines (|) or colons (:) in your name. (Should have " + (towncolors.length - 1 + 1) + ")");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (nameparts.length > towncolors.length + 1) {
|
if (nameparts.length > towncolors.length + nationColors) {
|
||||||
player.sendMessage("§cYou have too many vertical lines (|) or colons (:) in your name. (Should have " + (towncolors.length - 1 + 1) + ")");
|
player.sendMessage("§cYou have too many vertical lines (|) or colons (:) in your name. (Should have " + (towncolors.length - 1 + 1) + ")");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ChatPlayer.getPlayer(player.getUniqueId(), ChatPlayer.class).NameColorLocations()
|
var cp = ChatPlayer.getPlayer(player.getUniqueId(), ChatPlayer.class);
|
||||||
.set(new ArrayList<>(Arrays.stream(nameparts).map(String::length).collect(Collectors.toList()))); // No byte[], no TIntArrayList
|
var list = Arrays.stream(nameparts).map(String::length).collect(Collectors.toList());
|
||||||
TownColorComponent.updatePlayerColors(player);
|
if (list.contains(0)) {
|
||||||
player.sendMessage("§bName colors set: " + player.getDisplayName());
|
player.sendMessage("§cAll colors need to be represented in your name. (Use as Test|name|123 instead of |Testname123|)");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
cp.NameColorLocations().set(new ArrayList<>(list)); // No byte[], no TIntArrayList
|
||||||
|
TownColorComponent.updatePlayerColors(player, cp);
|
||||||
|
cp.save();
|
||||||
|
player.sendMessage("§bName colors set: " + player.getDisplayName());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,14 +207,14 @@ public class TownColorComponent extends Component<PluginMain> implements Listene
|
||||||
/**
|
/**
|
||||||
* Checks if the component is enabled
|
* Checks if the component is enabled
|
||||||
*/
|
*/
|
||||||
public static void updatePlayerColors(Player player) { //Probably while ingame (/u ncolor)
|
public static void updatePlayerColors(Player player) { //Probably while ingame (/u ncolor - not anymore)
|
||||||
updatePlayerColors(player, ChatPlayer.getPlayer(player.getUniqueId(), ChatPlayer.class));
|
updatePlayerColors(player, ChatPlayer.getPlayer(player.getUniqueId(), ChatPlayer.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the component is enabled
|
* Checks if the component is enabled
|
||||||
*/
|
*/
|
||||||
private static void updatePlayerColors(Player player, ChatPlayer cp) { //Probably at join - nop, nicknames
|
public static void updatePlayerColors(Player player, ChatPlayer cp) { //Probably at join - nop, nicknames
|
||||||
if (!ComponentManager.isEnabled(TownColorComponent.class))
|
if (!ComponentManager.isEnabled(TownColorComponent.class))
|
||||||
return;
|
return;
|
||||||
User user = PluginMain.essentials.getUser(player);
|
User user = PluginMain.essentials.getUser(player);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: Chroma-Chat
|
name: Chroma-Chat
|
||||||
main: buttondevteam.chat.PluginMain
|
main: buttondevteam.chat.PluginMain
|
||||||
version: '4.0'
|
version: '1.0'
|
||||||
commands:
|
commands:
|
||||||
u:
|
u:
|
||||||
description: Auto-flair system. Accept or ignore flair.
|
description: Auto-flair system. Accept or ignore flair.
|
||||||
|
|
Loading…
Reference in a new issue