Fix /u ncolor (#118)

This commit is contained in:
Norbi Peti 2020-07-17 17:41:38 +02:00
parent 7448eb7e3a
commit ce4f40c2c4
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
4 changed files with 21 additions and 13 deletions

View file

@ -211,10 +211,10 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.palmergames.bukkit.towny</groupId>
<groupId>com.github.TownyAdvanced</groupId>
<artifactId>Towny</artifactId>
<!-- <version>8d3b6b6</version> ButtonCore repo -->
<version>0.96.1.0</version>
<version>0.96.2.0</version>
<scope>provided</scope>
</dependency>
<!-- <dependency> <groupId>au.com.mineauz</groupId> <artifactId>Minigames</artifactId>

View file

@ -50,21 +50,29 @@ public class NColorCommand extends UCommandBase {
player.sendMessage("§cYour town doesn't have a color set. The town mayor can set it using /u towncolor.");
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
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) + ")");
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) + ")");
return true;
}
ChatPlayer.getPlayer(player.getUniqueId(), ChatPlayer.class).NameColorLocations()
.set(new ArrayList<>(Arrays.stream(nameparts).map(String::length).collect(Collectors.toList()))); // No byte[], no TIntArrayList
TownColorComponent.updatePlayerColors(player);
var cp = ChatPlayer.getPlayer(player.getUniqueId(), ChatPlayer.class);
var list = Arrays.stream(nameparts).map(String::length).collect(Collectors.toList());
if (list.contains(0)) {
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;
}

View file

@ -207,14 +207,14 @@ public class TownColorComponent extends Component<PluginMain> implements Listene
/**
* 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));
}
/**
* 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))
return;
User user = PluginMain.essentials.getUser(player);

View file

@ -1,6 +1,6 @@
name: Chroma-Chat
main: buttondevteam.chat.PluginMain
version: '4.0'
version: '1.0'
commands:
u:
description: Auto-flair system. Accept or ignore flair.