Skip to content

Commit

Permalink
Fix dispatch per player
Browse files Browse the repository at this point in the history
  • Loading branch information
Euphillya committed Dec 16, 2024
1 parent d70edfe commit 6ae1b61
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
6 changes: 3 additions & 3 deletions patches/plugins/0001-Rebrand-Folia.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
From 475e4b6e92ccf4ae502b353f968688174f56bd84 Mon Sep 17 00:00:00 2001
From 0fc8bbe2809e0d5184cd3bdb16162928ccafc50f Mon Sep 17 00:00:00 2001
From: Euphyllia Bierque <bierque.euphyllia@gmail.com>
Date: Sun, 29 Sep 2024 18:50:06 +0200
Date: Mon, 16 Dec 2024 13:59:08 +0100
Subject: [PATCH 1/3] Rebrand Folia

---
Expand Down Expand Up @@ -78,5 +78,5 @@ index 0460fa0..f68fed6 100644
</dependency>
<dependency>
--
2.45.1.windows.1
2.47.1.windows.1

8 changes: 4 additions & 4 deletions patches/plugins/0002-Replace-Scheduler-to-Folia.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
From c606db9786ce3d623a007b5c22ffc0a35cc06d2e Mon Sep 17 00:00:00 2001
From dc2dc5042dd92dbe9b993f48d8fafc71f3fe8020 Mon Sep 17 00:00:00 2001
From: Euphyllia Bierque <bierque.euphyllia@gmail.com>
Date: Sun, 29 Sep 2024 18:50:06 +0200
Date: Mon, 16 Dec 2024 13:59:09 +0100
Subject: [PATCH 2/3] Replace Scheduler to Folia

---
Expand Down Expand Up @@ -70,7 +70,7 @@ index d721e4f..56e2165 100644

diff --git a/WG/src/main/java/net/goldtreeservers/worldguardextraflags/scheduler_wg/FoliaRunnable.java b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/scheduler_wg/FoliaRunnable.java
new file mode 100644
index 0000000..81ab976
index 0000000..c3d6983
--- /dev/null
+++ b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/scheduler_wg/FoliaRunnable.java
@@ -0,0 +1,297 @@
Expand Down Expand Up @@ -454,5 +454,5 @@ index 80fa69b..ea4df8e 100644
if (value != null && value.size() > 0)
{
--
2.45.1.windows.1
2.47.1.windows.1

30 changes: 16 additions & 14 deletions patches/plugins/0003-Fix-dispatch-command.patch
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
From 81adef40685b363dd2a59783a77369e22477023c Mon Sep 17 00:00:00 2001
From 85547f73328d6a2e08253b0c82a910d96da86eb9 Mon Sep 17 00:00:00 2001
From: Euphyllia Bierque <bierque.euphyllia@gmail.com>
Date: Sun, 29 Sep 2024 18:50:06 +0200
Date: Mon, 16 Dec 2024 13:59:09 +0100
Subject: [PATCH 3/3] Fix dispatch command

---
.../wg/handlers/CommandOnEntryFlagHandler.java | 3 ++-
.../wg/handlers/CommandOnExitFlagHandler.java | 3 ++-
.../wg/handlers/ConsoleCommandOnEntryFlagHandler.java | 3 ++-
.../wg/handlers/ConsoleCommandOnExitFlagHandler.java | 3 ++-
4 files changed, 8 insertions(+), 4 deletions(-)
.../wg/handlers/CommandOnEntryFlagHandler.java | 4 +++-
.../wg/handlers/CommandOnExitFlagHandler.java | 4 +++-
.../wg/handlers/ConsoleCommandOnEntryFlagHandler.java | 3 ++-
.../wg/handlers/ConsoleCommandOnExitFlagHandler.java | 3 ++-
4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/CommandOnEntryFlagHandler.java b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/CommandOnEntryFlagHandler.java
index 8e056f0..0467473 100644
index 8e056f0..ead232f 100644
--- a/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/CommandOnEntryFlagHandler.java
+++ b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/CommandOnEntryFlagHandler.java
@@ -8,6 +8,7 @@ import com.sk89q.worldedit.bukkit.BukkitPlayer;
Expand All @@ -22,17 +22,18 @@ index 8e056f0..0467473 100644
import com.sk89q.worldguard.session.handler.Handler;
import org.bukkit.Bukkit;

@@ -56,7 +57,7 @@ public class CommandOnEntryFlagHandler extends Handler
@@ -56,7 +57,8 @@ public class CommandOnEntryFlagHandler extends Handler
{
for(String command : commands_)
{
- Bukkit.getServer().dispatchCommand(((BukkitPlayer) player).getPlayer(), command.substring(1).replace("%username%", player.getName())); //TODO: Make this better
+ Bukkit.getGlobalRegionScheduler().execute(WorldGuardPlugin.getPlugin(WorldGuardPlugin.class), () -> Bukkit.getServer().dispatchCommand(((BukkitPlayer) player).getPlayer(), command.substring(1).replace("%username%", player.getName()))); //TODO: Make this better
+ org.bukkit.entity.Player bukkitPlayer = ((BukkitPlayer) player).getPlayer();
+ bukkitPlayer.getScheduler().run(WorldGuardPlugin.getPlugin(WorldGuardPlugin.class), (pTask) -> Bukkit.getServer().dispatchCommand(bukkitPlayer, command.substring(1).replace("%username%", player.getName())), null); //TODO: Make this better
}

break;
diff --git a/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/CommandOnExitFlagHandler.java b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/CommandOnExitFlagHandler.java
index b7c8716..eb2503e 100644
index b7c8716..8d2b25d 100644
--- a/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/CommandOnExitFlagHandler.java
+++ b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/CommandOnExitFlagHandler.java
@@ -7,6 +7,7 @@ import com.sk89q.worldedit.bukkit.BukkitPlayer;
Expand All @@ -43,12 +44,13 @@ index b7c8716..eb2503e 100644
import com.sk89q.worldguard.session.handler.Handler;
import org.bukkit.Bukkit;

@@ -77,7 +78,7 @@ public class CommandOnExitFlagHandler extends Handler
@@ -77,7 +78,8 @@ public class CommandOnExitFlagHandler extends Handler
{
for (String command : commands_)
{
- Bukkit.getServer().dispatchCommand(((BukkitPlayer) player).getPlayer(), command.substring(1).replace("%username%", player.getName())); //TODO: Make this better
+ Bukkit.getGlobalRegionScheduler().execute(WorldGuardPlugin.getPlugin(WorldGuardPlugin.class), () -> Bukkit.getServer().dispatchCommand(((BukkitPlayer) player).getPlayer(), command.substring(1).replace("%username%", player.getName()))); //TODO: Make this better
+ org.bukkit.entity.Player bukkitPlayer = ((BukkitPlayer) player).getPlayer();
+ bukkitPlayer.getScheduler().run(WorldGuardPlugin.getPlugin(WorldGuardPlugin.class), (pTask) -> Bukkit.getServer().dispatchCommand(bukkitPlayer, command.substring(1).replace("%username%", player.getName())), null); //TODO: Make this better
}

break;
Expand Down Expand Up @@ -95,5 +97,5 @@ index ce09762..d182f26 100644

break;
--
2.45.1.windows.1
2.47.1.windows.1

0 comments on commit 6ae1b61

Please sign in to comment.