Skip to content

Commit

Permalink
Fix block update command message and add permission
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yh-china committed Aug 22, 2023
1 parent e439872 commit 68a6e74
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
13 changes: 10 additions & 3 deletions patches/server/0008-Fakeplayer-support.patch
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ index 6e600f9d81178f4ad10967a1aba802c9ac853d82..9d6b1550302eb552872d91380e79ac28
}
// Water Animals
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index c5c89964d60f291a4625545bb39f314850945ae6..45e865b1e09da36830609a8a3fe10a5b20a8583a 100644
index 03f2fd1958b8f2c7d97232240f05affcc6f56b7f..ad85acbb2b6f23c12d8ca250f98b86cf168ce0d5 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -8,6 +8,9 @@ import org.bukkit.command.Command;
Expand All @@ -354,10 +354,10 @@ index c5c89964d60f291a4625545bb39f314850945ae6..45e865b1e09da36830609a8a3fe10a5b
public static void load(final YamlConfiguration config) {
diff --git a/src/main/java/top/leavesmc/leaves/bot/BotCommand.java b/src/main/java/top/leavesmc/leaves/bot/BotCommand.java
new file mode 100644
index 0000000000000000000000000000000000000000..1cd65e1249f4d8579e9bdd78d508f184fe4fb46a
index 0000000000000000000000000000000000000000..8b9c3573b8778b984135aac57c68c341b99c91c8
--- /dev/null
+++ b/src/main/java/top/leavesmc/leaves/bot/BotCommand.java
@@ -0,0 +1,254 @@
@@ -0,0 +1,261 @@
+package top.leavesmc.leaves.bot;
+
+import org.bukkit.Bukkit;
Expand All @@ -370,6 +370,9 @@ index 0000000000000000000000000000000000000000..1cd65e1249f4d8579e9bdd78d508f184
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+import org.bukkit.generator.WorldInfo;
+import org.bukkit.permissions.Permission;
+import org.bukkit.permissions.PermissionDefault;
+import org.bukkit.plugin.PluginManager;
+import org.jetbrains.annotations.NotNull;
+import top.leavesmc.leaves.bot.agent.Actions;
+import top.leavesmc.leaves.bot.agent.BotAction;
Expand All @@ -388,6 +391,10 @@ index 0000000000000000000000000000000000000000..1cd65e1249f4d8579e9bdd78d508f184
+ this.description = "FakePlayer Command";
+ this.usageMessage = "/bot [create | remove | action | list]";
+ this.setPermission("bukkit.command.bot");
+ final PluginManager pluginManager = Bukkit.getServer().getPluginManager();
+ if (pluginManager.getPermission("bukkit.command.bot") == null) {
+ pluginManager.addPermission(new Permission("bukkit.command.bot", PermissionDefault.OP));
+ }
+ }
+
+ @Override
Expand Down
22 changes: 18 additions & 4 deletions patches/server/0083-No-block-update-command.patch
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ index 2708251ebc1995e71fb0e5dca9e158a3005f8a8a..e28351b379677fec356b6efec2d882ee
}
}
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index 54d8bc4d86c78f44206aa5769b7db36e39291a98..579d06b8fd026f4a9b8c865bb8192ec7fc805fc2 100644
index 4f9b950e21f55c0f251eb15164315c8f7891b17a..e5db9559f0af53ab1dac04d570bf1c7352350121 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -11,6 +11,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
Expand All @@ -116,15 +116,21 @@ index 54d8bc4d86c78f44206aa5769b7db36e39291a98..579d06b8fd026f4a9b8c865bb8192ec7
public static void load(final YamlConfiguration config) {
diff --git a/src/main/java/top/leavesmc/leaves/command/NoBlockUpdateCommand.java b/src/main/java/top/leavesmc/leaves/command/NoBlockUpdateCommand.java
new file mode 100644
index 0000000000000000000000000000000000000000..d4b0edc241c45f14c2ce339bb70c62b2d65ac74d
index 0000000000000000000000000000000000000000..819d5a5383dc6978f53645b727722fa924b7a505
--- /dev/null
+++ b/src/main/java/top/leavesmc/leaves/command/NoBlockUpdateCommand.java
@@ -0,0 +1,38 @@
@@ -0,0 +1,52 @@
+package top.leavesmc.leaves.command;
+
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.JoinConfiguration;
+import net.kyori.adventure.text.format.NamedTextColor;
+import org.bukkit.Bukkit;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.permissions.Permission;
+import org.bukkit.permissions.PermissionDefault;
+import org.bukkit.plugin.PluginManager;
+import org.jetbrains.annotations.NotNull;
+import top.leavesmc.leaves.LeavesConfig;
+
Expand All @@ -139,6 +145,10 @@ index 0000000000000000000000000000000000000000..d4b0edc241c45f14c2ce339bb70c62b2
+ this.description = "No Block Update Command";
+ this.usageMessage = "/blockupdate";
+ this.setPermission("bukkit.command.blockupdate");
+ final PluginManager pluginManager = Bukkit.getServer().getPluginManager();
+ if (pluginManager.getPermission("bukkit.command.blockupdate") == null) {
+ pluginManager.addPermission(new Permission("bukkit.command.blockupdate", PermissionDefault.OP));
+ }
+ }
+
+ @Override
Expand All @@ -150,7 +160,11 @@ index 0000000000000000000000000000000000000000..d4b0edc241c45f14c2ce339bb70c62b2
+ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
+ if (!testPermission(sender)) return true;
+ noBlockUpdate = !noBlockUpdate;
+ Bukkit.broadcast("Block update status: " + !noBlockUpdate, "bukkit.command.blockupdate");
+ Bukkit.broadcast(Component.join(JoinConfiguration.noSeparators(),
+ Component.text("Block update status: ", NamedTextColor.GRAY),
+ Component.text(!noBlockUpdate, noBlockUpdate ? NamedTextColor.AQUA : NamedTextColor.GRAY)
+ ), "bukkit.command.blockupdate");
+
+ return true;
+ }
+
Expand Down

0 comments on commit 68a6e74

Please sign in to comment.