forked from aromaa/WorldGuardExtraFlags
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
135 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|