Multiverse-Core/src/old-test/java/com/onarandombox/MultiverseCore/utils/WorldCreatorMatcher.java

55 lines
2.3 KiB
Java
Raw Normal View History

2011-10-21 02:36:33 +02:00
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
2011-10-21 02:36:33 +02:00
import org.bukkit.WorldCreator;
import org.mockito.ArgumentMatcher;
public class WorldCreatorMatcher implements ArgumentMatcher<WorldCreator> {
2021-07-18 19:51:53 +02:00
private final WorldCreator worldCreator;
2011-10-22 02:37:18 +02:00
private boolean careAboutSeeds = false;
private boolean careAboutGenerators = false;
2011-10-21 02:36:33 +02:00
public WorldCreatorMatcher(WorldCreator creator) {
2011-11-25 18:02:41 +01:00
Util.log("Creating NEW world matcher.(" + creator.name() + ")");
2011-10-21 02:36:33 +02:00
this.worldCreator = creator;
}
2011-10-22 02:37:18 +02:00
public void careAboutSeeds(boolean doICare) {
this.careAboutSeeds = doICare;
}
public void careAboutGenerators(boolean doICare) {
this.careAboutGenerators = doICare;
}
2011-10-22 01:48:28 +02:00
public boolean matches(WorldCreator creator) {
2011-11-25 18:02:41 +01:00
Util.log("Checking world creators.");
2011-10-22 01:48:28 +02:00
if (creator == null) {
2011-11-25 18:02:41 +01:00
Util.log("The given creator was null, but I was checking: " + this.worldCreator.name());
2011-10-22 01:48:28 +02:00
return false;
}
Util.log("Checking Names...(" + creator.name() + ") vs (" + this.worldCreator.name() + ")");
Util.log("Checking Envs...(" + creator.environment() + ") vs (" + this.worldCreator.environment() + ")");
if (!creator.name().equals(this.worldCreator.name())) {
2011-10-21 02:36:33 +02:00
return false;
} else if (!creator.environment().equals(this.worldCreator.environment())) {
2011-11-25 18:02:41 +01:00
Util.log("Checking Environments...");
2011-10-21 02:36:33 +02:00
return false;
} else if (careAboutSeeds && creator.seed() != this.worldCreator.seed()) {
Util.log("Checking Seeds...");
2011-10-22 02:37:18 +02:00
return false;
} else if (careAboutGenerators && !creator.generator().equals(this.worldCreator.generator())) {
Util.log("Checking Gens...");
2011-10-22 02:37:18 +02:00
return false;
2011-10-21 02:36:33 +02:00
}
2011-11-25 18:02:41 +01:00
Util.log("Creators matched!!!");
2011-10-21 02:36:33 +02:00
return true;
}
}