Skip to content

Commit

Permalink
Fix dispatch commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Euphillya committed Sep 29, 2024
1 parent 0b18906 commit 95ff49d
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 6 deletions.
6 changes: 3 additions & 3 deletions patches/plugins/0001-Rebrand-Folia.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 8359082574195fc03b64b89090aa60413c969359 Mon Sep 17 00:00:00 2001
From d0ebd22722da3b2d20587fd35c3f1f0fd74f6ddc Mon Sep 17 00:00:00 2001
From: Euphyllia Bierque <bierque.euphyllia@gmail.com>
Date: Sun, 29 Sep 2024 18:08:39 +0200
Subject: [PATCH 1/2] Rebrand Folia
Date: Sun, 29 Sep 2024 18:49:12 +0200
Subject: [PATCH 1/3] Rebrand Folia

---
Spigot/pom.xml | 10 +++++-----
Expand Down
6 changes: 3 additions & 3 deletions patches/plugins/0002-Replace-Scheduler-to-Folia.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 1531c320a9877717cee24cb7afb70dfefc3e1480 Mon Sep 17 00:00:00 2001
From 8695b09b9833d346568d83113f991152b6ea536a Mon Sep 17 00:00:00 2001
From: Euphyllia Bierque <bierque.euphyllia@gmail.com>
Date: Sun, 29 Sep 2024 18:08:39 +0200
Subject: [PATCH 2/2] Replace Scheduler to Folia
Date: Sun, 29 Sep 2024 18:49:12 +0200
Subject: [PATCH 2/3] Replace Scheduler to Folia

---
.../WorldGuardExtraFlagsPlugin.java | 2 +-
Expand Down
129 changes: 129 additions & 0 deletions patches/plugins/0003-Fix-dispatch-command.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
From de679996e5f2fc49c8c935916a5013f6f417bd66 Mon Sep 17 00:00:00 2001
From: Euphyllia Bierque <bierque.euphyllia@gmail.com>
Date: Sun, 29 Sep 2024 18:49:13 +0200
Subject: [PATCH 3/3] Fix dispatch command

---
.../worldguardextraflags/wg/WorldGuardUtils.java | 5 +++--
.../wg/handlers/CommandOnEntryFlagHandler.java | 3 ++-
.../wg/handlers/CommandOnExitFlagHandler.java | 3 ++-
.../wg/handlers/ConsoleCommandOnEntryFlagHandler.java | 3 ++-
.../wg/handlers/ConsoleCommandOnExitFlagHandler.java | 3 ++-
5 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/WorldGuardUtils.java b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/WorldGuardUtils.java
index 19a36df..a40d508 100644
--- a/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/WorldGuardUtils.java
+++ b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/WorldGuardUtils.java
@@ -3,6 +3,7 @@ package net.goldtreeservers.worldguardextraflags.wg;
import java.util.HashSet;
import java.util.Set;

+import net.goldtreeservers.worldguardextraflags.scheduler_wg.FoliaRunnable;
import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
@@ -27,14 +28,14 @@ public class WorldGuardUtils

player.setMetadata(WorldGuardUtils.PREVENT_TELEPORT_LOOP_META, result);

- new BukkitRunnable()
+ new FoliaRunnable(player.getScheduler(), null)
{
@Override
public void run()
{
player.removeMetadata(WorldGuardUtils.PREVENT_TELEPORT_LOOP_META, plugin);
}
- }.runTask(plugin);
+ }.run(plugin);
}

Set<Object> set = (Set<Object>)result.value();
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
--- 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;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldguard.LocalPlayer;
+import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.session.handler.Handler;
import org.bukkit.Bukkit;

@@ -56,7 +57,7 @@ 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
}

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
--- 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;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldguard.LocalPlayer;
+import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.session.handler.Handler;
import org.bukkit.Bukkit;

@@ -77,7 +78,7 @@ 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
}

break;
diff --git a/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/ConsoleCommandOnEntryFlagHandler.java b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/ConsoleCommandOnEntryFlagHandler.java
index 6fd09dc..9389656 100644
--- a/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/ConsoleCommandOnEntryFlagHandler.java
+++ b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/ConsoleCommandOnEntryFlagHandler.java
@@ -7,6 +7,7 @@ import java.util.Set;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldguard.LocalPlayer;
+import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.session.handler.Handler;
import org.bukkit.Bukkit;

@@ -55,7 +56,7 @@ public class ConsoleCommandOnEntryFlagHandler extends Handler
{
for(String command : commands_)
{
- Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command.substring(1).replace("%username%", player.getName())); //TODO: Make this better
+ Bukkit.getGlobalRegionScheduler().execute(WorldGuardPlugin.getPlugin(WorldGuardPlugin.class), () -> Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command.substring(1).replace("%username%", player.getName()))); //TODO: Make this better
}

break;
diff --git a/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/ConsoleCommandOnExitFlagHandler.java b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/ConsoleCommandOnExitFlagHandler.java
index ce09762..d182f26 100644
--- a/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/ConsoleCommandOnExitFlagHandler.java
+++ b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/ConsoleCommandOnExitFlagHandler.java
@@ -8,6 +8,7 @@ import com.google.common.collect.Lists;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldguard.LocalPlayer;
+import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.session.handler.Handler;
import org.bukkit.Bukkit;

@@ -78,7 +79,7 @@ public class ConsoleCommandOnExitFlagHandler extends Handler
{
for (String command : commands_)
{
- Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command.substring(1).replace("%username%", player.getName())); //TODO: Make this better
+ Bukkit.getGlobalRegionScheduler().execute(WorldGuardPlugin.getPlugin(WorldGuardPlugin.class), () -> Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command.substring(1).replace("%username%", player.getName()))); //TODO: Make this better
}

break;
--
2.45.1.windows.1

0 comments on commit 95ff49d

Please sign in to comment.