Skip to content

Commit

Permalink
"Fix" tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JRoy committed May 13, 2024
1 parent 26d4dcd commit 3961e12
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
private static final Logger BUKKIT_LOGGER = Logger.getLogger("Essentials");
private static Logger LOGGER = null;
public static boolean TESTING = false;
private final transient TNTExplodeListener tntListener = new TNTExplodeListener();
private final transient Set<String> vanishedPlayers = new LinkedHashSet<>();
private final transient Map<String, IEssentialsCommand> commandMap = new HashMap<>();
Expand Down Expand Up @@ -231,6 +232,7 @@ public ISettings getSettings() {
}

public void setupForTesting(final Server server) throws IOException, InvalidDescriptionException {
TESTING = true;
LOGGER = new BaseLoggerProvider(this, BUKKIT_LOGGER);
final File dataFolder = File.createTempFile("essentialstest", "");
if (!dataFolder.delete()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.earth2me.essentials.utils;

import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.IEssentials;
import net.ess3.api.IUser;
import net.ess3.api.TranslatableException;
Expand Down Expand Up @@ -40,10 +41,14 @@ public final class LocationUtil {
private static final Set<Material> TRANSPARENT_MATERIALS = EnumSet.noneOf(Material.class);

static {
// Materials from Material.isTransparent()
for (final Material mat : Material.values()) {
if (mat.isTransparent()) {
HOLLOW_MATERIALS.add(mat);
// If the server is running in a test environment, the isTransparent() method will blow up since
// it requires the registry to be initialized. This is a workaround to prevent that from happening.
if (!Essentials.TESTING) {
// Materials from Material.isTransparent()
for (final Material mat : Material.values()) {
if (mat.isTransparent()) {
HOLLOW_MATERIALS.add(mat);
}
}
}

Expand Down

0 comments on commit 3961e12

Please sign in to comment.