Skip to content

Commit c1f7f38

Browse files
committed
Compatibility for versions of spigot that don't include the Chat Component API
1 parent 6a0303c commit c1f7f38

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

Spigot Addon/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<name>PlayerBalancer Addon</name>
1313
<artifactId>playerbalancer-addon</artifactId>
14-
<version>1.0 for 2.1.2.0+</version>
14+
<version>1.1 for 2.1.2.0+</version>
1515

1616
<build>
1717
<finalName>PlayerBalancerAddon</finalName>

Spigot Addon/src/main/java/com/jaimemartz/playerbalanceraddon/MainCommand.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.jaimemartz.playerbalanceraddon;
22

33
import com.google.common.base.Strings;
4-
import net.md_5.bungee.api.ChatColor;
5-
import net.md_5.bungee.api.chat.ComponentBuilder;
4+
import org.bukkit.ChatColor;
65
import org.bukkit.command.Command;
76
import org.bukkit.command.CommandExecutor;
87
import org.bukkit.command.CommandSender;
@@ -28,17 +27,17 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
2827
if (player != null) {
2928
plugin.getManager().connectPlayer(player, input);
3029
} else {
31-
sender.spigot().sendMessage(new ComponentBuilder("There is no player with that name connected to this server").color(ChatColor.RED).create());
30+
sender.sendMessage(ChatColor.RED + "There is no player with that name connected to this server");
3231
}
3332
} else {
3433
if (sender instanceof Player) {
3534
plugin.getManager().connectPlayer((Player) sender, input);
3635
} else {
37-
sender.spigot().sendMessage(new ComponentBuilder("This command variant can only be executed by a player").color(ChatColor.RED).create());
36+
sender.sendMessage("This command variant can only be executed by a player");
3837
}
3938
}
4039
} else {
41-
sender.spigot().sendMessage(new ComponentBuilder("Usage: /section connect <section> [player]").color(ChatColor.RED).create());
40+
sender.sendMessage(ChatColor.RED + "Usage: /section connect <section> [player]");
4241
}
4342
break;
4443
}
@@ -49,13 +48,13 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
4948
if (player != null) {
5049
plugin.getManager().fallbackPlayer((Player) sender);
5150
} else {
52-
sender.spigot().sendMessage(new ComponentBuilder("There is no player with that name connected to this server").color(ChatColor.RED).create());
51+
sender.sendMessage(ChatColor.RED + "There is no player with that name connected to this server");
5352
}
5453
} else {
5554
if (sender instanceof Player) {
5655
plugin.getManager().fallbackPlayer((Player) sender);
5756
} else {
58-
sender.spigot().sendMessage(new ComponentBuilder("This command variant can only be executed by a player").color(ChatColor.RED).create());
57+
sender.sendMessage(ChatColor.RED + "This command variant can only be executed by a player");
5958
}
6059
}
6160
break;
@@ -72,11 +71,11 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
7271
*/
7372
}
7473
} else {
75-
sender.spigot().sendMessage(new ComponentBuilder(Strings.repeat("-", 53)).strikethrough(true).color(ChatColor.GRAY).create());
76-
sender.spigot().sendMessage(new ComponentBuilder("Available commands:").color(ChatColor.GRAY).create());
77-
sender.spigot().sendMessage(new ComponentBuilder("/spb connect <section> [player]").color(ChatColor.AQUA).append(" - ").color(ChatColor.GRAY).append("Connects you or the specified player to that section").color(ChatColor.RED).create());
78-
sender.spigot().sendMessage(new ComponentBuilder("/spb fallback [player]").color(ChatColor.AQUA).append(" - ").color(ChatColor.GRAY).append("Connects you or the specified player to the parent of the current section").color(ChatColor.RED).create());
79-
sender.spigot().sendMessage(new ComponentBuilder(Strings.repeat("-", 53)).strikethrough(true).color(ChatColor.GRAY).create());
74+
sender.sendMessage(ChatColor.STRIKETHROUGH + ChatColor.GRAY.toString() + Strings.repeat("-", 53));
75+
sender.sendMessage(ChatColor.GRAY + "Available commands:");
76+
sender.sendMessage(ChatColor.AQUA + "/spb connect <section> [player]" + ChatColor.GRAY + " - " + ChatColor.RED + "Connects you or the specified player to that section");
77+
sender.sendMessage(ChatColor.AQUA + "/spb fallback [player]" + ChatColor.GRAY + " - " + ChatColor.RED + "Connects you or the specified player to the parent of the current section");
78+
sender.sendMessage(ChatColor.STRIKETHROUGH + ChatColor.GRAY.toString() + Strings.repeat("-", 53));
8079
}
8180
}
8281
return false;

Spigot Addon/src/main/java/com/jaimemartz/playerbalanceraddon/PluginMessageManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public void setPlayerBypass(Player player) {
194194
player.sendPluginMessage(plugin, "PlayerBalancer", out.toByteArray());
195195
}
196196

197-
//TOODO Add this to the /balancer or some other command too
197+
//TODO Add this to the /balancer or some other command too
198198
public void bypassConnect(Player player, String server) {
199199
ByteArrayDataOutput out = ByteStreams.newDataOutput();
200200
out.writeUTF("BypassConnect");

0 commit comments

Comments
 (0)