Skip to content

Commit

Permalink
Fixed IllegalStateException error on some servers during server shutd…
Browse files Browse the repository at this point in the history
…owns.
  • Loading branch information
Intelli committed Jul 6, 2024
1 parent ce8c194 commit c67e697
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;
import java.util.Locale;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;

Expand Down Expand Up @@ -54,7 +55,7 @@ else if (checkType == Material.PAINTING || BukkitAdapter.ADAPTER.isItemFrame(che
}

CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
if (Config.getGlobal().API_ENABLED) {
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;
import java.util.Locale;

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.BlockState;

Expand Down Expand Up @@ -84,7 +85,7 @@ else if (type == Material.WATER || type == Material.LAVA) {
}

CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
if (Config.getGlobal().API_ENABLED) {
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.sql.PreparedStatement;
import java.util.Locale;

import org.bukkit.Bukkit;
import org.bukkit.Location;

import net.coreprotect.CoreProtect;
Expand All @@ -29,7 +30,7 @@ public static void log(PreparedStatement preparedStmt, int batchCount, long time
}

CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
if (Config.getGlobal().API_ENABLED) {
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.Locale;
import java.util.Map;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
Expand Down Expand Up @@ -173,7 +174,7 @@ protected static void logTransaction(PreparedStatement preparedStmt, int batchCo
}

CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
if (Config.getGlobal().API_ENABLED) {
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;
import java.util.Locale;

import org.bukkit.Bukkit;
import org.bukkit.block.BlockState;

import net.coreprotect.CoreProtect;
Expand All @@ -30,7 +31,7 @@ public static void log(PreparedStatement preparedStmt, PreparedStatement prepare
}

CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
if (Config.getGlobal().API_ENABLED) {
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Locale;
import java.util.Map;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.inventory.ItemStack;

Expand Down Expand Up @@ -126,7 +127,7 @@ protected static void logTransaction(PreparedStatement preparedStmt, int batchCo
}

CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
if (Config.getGlobal().API_ENABLED) {
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.sql.PreparedStatement;
import java.util.Locale;

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.BlockState;

Expand All @@ -28,7 +29,7 @@ public static void log(PreparedStatement preparedStmt, int batchCount, String us
}

CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
if (Config.getGlobal().API_ENABLED) {
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.sql.PreparedStatement;
import java.util.Locale;

import org.bukkit.Bukkit;
import org.bukkit.block.BlockState;

import net.coreprotect.CoreProtect;
Expand Down Expand Up @@ -30,7 +31,7 @@ public static void log(PreparedStatement preparedStmt, int batchCount, String us
}

CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
if (Config.getGlobal().API_ENABLED) {
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.sql.PreparedStatement;
import java.util.Locale;

import org.bukkit.Bukkit;
import org.bukkit.Location;

import net.coreprotect.CoreProtect;
Expand All @@ -26,7 +27,7 @@ public static void log(PreparedStatement preparedStmt, int batchCount, String us
}

CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
if (Config.getGlobal().API_ENABLED) {
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
}

Expand Down

0 comments on commit c67e697

Please sign in to comment.