|
13 | 13 | import java.util.Map;
|
14 | 14 | import java.util.logging.Level;
|
15 | 15 |
|
16 |
| -import org.apache.commons.lang.StringUtils; |
17 | 16 | import org.bstats.bukkit.Metrics;
|
18 | 17 | import org.bukkit.Bukkit;
|
19 | 18 | import org.bukkit.Material;
|
@@ -62,11 +61,12 @@ public class SilkSpawners extends JavaPlugin {
|
62 | 61 | private static final int BSTATS_PLUGIN_ID = 273;
|
63 | 62 | private static final String[] COMPATIBLE_MINECRAFT_VERSIONS = { "v1_8_R3", "v1_11_R1", "v1_12_R1", "v1_13_R2", "v1_14_R1", "v1_15_R1",
|
64 | 63 | "v1_16_R1", "v1_16_R2", "v1_16_R3", "v1_17_R1", "v1_18_R1", "v1_18_R2", "v1_19_R1", "v1_19_R2", "v1_19_R3", "v1_20_R1",
|
65 |
| - "v1_20_R2", "v1_20_R3", "v1_20_R4" }; |
| 64 | + "v1_20_R2", "v1_20_R3", "v1_20_R4", "v1_21_R1" }; |
66 | 65 | public static final Map<Integer, String> PROTOCOL_VERSION_PACKAGE_MAP = new HashMap<Integer, String>() {
|
67 | 66 | private static final long serialVersionUID = -5188779509588704507L;
|
68 | 67 | {
|
69 | 68 | put(766, "v1_20_R4");
|
| 69 | + put(767, "v1_21_R1"); |
70 | 70 | }
|
71 | 71 | };
|
72 | 72 | public CommentedConfiguration config;
|
@@ -94,11 +94,12 @@ public void onEnable() {
|
94 | 94 | String _nmsVersion = packageName.substring(packageName.lastIndexOf('.') + 1);
|
95 | 95 | if (_nmsVersion.equals("craftbukkit")) {
|
96 | 96 | try {
|
97 |
| - String minecraftVersion = (String) Server.class.getDeclaredMethod("getMinecraftVersion").invoke(Bukkit.getServer()); |
98 |
| - Semver semver = new Semver(minecraftVersion); |
| 97 | + final String minecraftVersion = (String) Server.class.getDeclaredMethod("getMinecraftVersion").invoke(Bukkit.getServer()); |
| 98 | + final Semver semver = new Semver(minecraftVersion); |
99 | 99 | if (semver.isGreaterThanOrEqualTo("1.20.5")) {
|
100 | 100 | @SuppressWarnings("deprecation")
|
101 |
| - int protocolVersion = (Integer) UnsafeValues.class.getDeclaredMethod("getProtocolVersion").invoke(Bukkit.getUnsafe()); |
| 101 | + final int protocolVersion = (Integer) UnsafeValues.class.getDeclaredMethod("getProtocolVersion") |
| 102 | + .invoke(Bukkit.getUnsafe()); |
102 | 103 | _nmsVersion = PROTOCOL_VERSION_PACKAGE_MAP.get(protocolVersion);
|
103 | 104 | }
|
104 | 105 | } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
@@ -556,18 +557,31 @@ private boolean shapeContainsIngredient(final List<String> shape, final char c)
|
556 | 557 | /**
|
557 | 558 | * Sends a message to the player if the 'silkspawners.info' permission is granted. Empty messages are ignored and not are not sent.
|
558 | 559 | *
|
559 |
| - * @param player the player to message |
| 560 | + * @param player the player to message |
560 | 561 | * @param message the message to send
|
561 | 562 | */
|
562 | 563 | public void informPlayer(final Player player, final String message) {
|
563 |
| - if (StringUtils.isBlank(message)) { |
| 564 | + if (isBlank(message)) { |
564 | 565 | return;
|
565 | 566 | }
|
566 | 567 | if (player.hasPermission("silkspawners.info")) {
|
567 | 568 | su.sendMessage(player, message);
|
568 | 569 | }
|
569 | 570 | }
|
570 | 571 |
|
| 572 | + public boolean isBlank(final CharSequence cs) { |
| 573 | + final int strLen = cs == null ? 0 : cs.length(); |
| 574 | + if (strLen == 0) { |
| 575 | + return true; |
| 576 | + } |
| 577 | + for (int i = 0; i < strLen; i++) { |
| 578 | + if (!Character.isWhitespace(cs.charAt(i))) { |
| 579 | + return false; |
| 580 | + } |
| 581 | + } |
| 582 | + return true; |
| 583 | + } |
| 584 | + |
571 | 585 | public void reloadConfigs() {
|
572 | 586 | config.load();
|
573 | 587 | config.save();
|
|
0 commit comments