Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Spigot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>net.goldtreeservers</groupId>
<artifactId>worldguardextraflags</artifactId>
<version>4.2.5-SNAPSHOT</version>
<version>4.2.6-SNAPSHOT</version>
</parent>

<groupId>net.goldtreeservers.worldguardextraflags</groupId>
Expand Down Expand Up @@ -105,12 +105,12 @@
<version>7.0.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.5.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.dmulloy2</groupId>
<artifactId>ProtocolLib</artifactId>
<version>5.4.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion Spigot/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: WorldGuardExtraFlags
description: Adds more flags to WorldGuard to help manage your server easily!

version: 4.2.5-SNAPSHOT
version: 4.2.6-SNAPSHOT
api-version: 1.13

author: isokissa3
Expand Down
128 changes: 78 additions & 50 deletions WG/pom.xml
Original file line number Diff line number Diff line change
@@ -1,55 +1,83 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.goldtreeservers</groupId>
<artifactId>worldguardextraflags</artifactId>
<version>4.2.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.goldtreeservers</groupId>
<artifactId>worldguardextraflags</artifactId>
<version>4.2.6-SNAPSHOT</version>
</parent>

<groupId>net.goldtreeservers.worldguardextraflags</groupId>
<artifactId>wg</artifactId>
<groupId>net.goldtreeservers.worldguardextraflags</groupId>
<artifactId>wg</artifactId>

<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sk89q-repo</id>
<url>https://maven.enginehub.org/repo/</url>
</repository>
</repositories>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sk89q-repo</id>
<url>https://maven.enginehub.org/repo/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.6-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-core</artifactId>
<version>7.2.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>7.2.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-core</artifactId>
<version>7.0.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId>
<version>7.0.6</version>
<scope>provided</scope>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.42</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.6-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-core</artifactId>
<version>7.2.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>7.2.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-core</artifactId>
<version>7.0.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId>
<version>7.0.6</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>21</source>
<target>21</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.42</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.session.handler.Handler;
import org.bukkit.Bukkit;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;

import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
Expand Down Expand Up @@ -49,13 +52,68 @@ public boolean onCrossBoundary(LocalPlayer player, Location from, Location to, A

if (!this.getSession().getManager().hasBypass(player, (World) to.getExtent()))
{
for(Set<String> commands_ : commands)
for (Set<String> commands_ : commands)
{
if (!this.lastCommands.contains(commands_))
{
for(String command : commands_)
Plugin plugin;
try
{
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command.substring(1).replace("%username%", player.getName())); //TODO: Make this better
plugin = JavaPlugin.getProvidingPlugin(this.getClass());
}
catch (IllegalArgumentException | IllegalStateException e)
{
plugin = Bukkit.getPluginManager().getPlugin("WorldGuardExtraFlags");
}

if (plugin == null)
{
Bukkit.getLogger().severe("[WGEF-DEBUG] CRITICAL: Plugin instance is NULL! Commands cannot run.");
break;
}

if (!plugin.isEnabled())
{
Bukkit.getLogger().warning("[WGEF-DEBUG] Plugin is disabled, skipping commands.");
break;
}

final Set<String> commandsToRun = commands_;
final String playerName = player.getName();
final Plugin pluginFinal = plugin;

Runnable commandTask = () ->
{
ConsoleCommandSender console = Bukkit.getConsoleSender();
for (String command : commandsToRun)
{
try
{
if (command == null || command.trim().isEmpty()) continue;

String cmdToRun = command.replace("%username%", playerName).trim();
if (cmdToRun.startsWith("/"))
{
cmdToRun = cmdToRun.substring(1);
}

Bukkit.dispatchCommand(console, cmdToRun);
}
catch (Throwable t)
{
pluginFinal.getLogger().warning("[WGEF-Error] Failed to execute command '" + command + "' for " + playerName);
t.printStackTrace();
}
}
};

if (Bukkit.isPrimaryThread())
{
commandTask.run();
}
else
{
Bukkit.getScheduler().runTask(pluginFinal, commandTask);
}

break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.session.handler.Handler;
import org.bukkit.Bukkit;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.plugin.Plugin;

import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
Expand Down Expand Up @@ -76,9 +78,47 @@ public boolean onCrossBoundary(LocalPlayer player, Location from, Location to, A
{
if (!commands.contains(commands_))
{
for (String command : commands_)
final Plugin plugin = Bukkit.getPluginManager().getPlugin("WorldGuardExtraFlags");
if (plugin == null || !plugin.isEnabled())
{
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command.substring(1).replace("%username%", player.getName())); //TODO: Make this better
break;
}

final Set<String> commandsToRun = commands_;
final String playerName = player.getName();

Runnable commandTask = () ->
{
ConsoleCommandSender console = Bukkit.getConsoleSender();
for (String command : commandsToRun)
{
try
{
if (command == null || command.trim().isEmpty()) continue;

String cmdToRun = command.replace("%username%", playerName).trim();
if (cmdToRun.startsWith("/"))
{
cmdToRun = cmdToRun.substring(1);
}

Bukkit.dispatchCommand(console, cmdToRun);
}
catch (Throwable t)
{
plugin.getLogger().warning("Error executing console command '" + command + "' for player " + playerName);
t.printStackTrace();
}
}
};

if (Bukkit.isPrimaryThread())
{
commandTask.run();
}
else
{
Bukkit.getScheduler().runTask(plugin, commandTask);
}

break;
Expand Down
Loading