The "spawner|mobType" syntax once again makes functional mob spawners.

Also fix block parser context not being restricted.
This commit is contained in:
wizjany
2019-05-18 09:52:24 -04:00
parent 3173e26109
commit 334d5cfaab
5 changed files with 45 additions and 32 deletions

View File

@ -81,6 +81,7 @@ public class FactoryConverter<T> implements ArgumentConverter<T> {
}
}
parserContext.setSession(session);
parserContext.setRestricted(true);
try {
return SuccessfulConversion.fromSingle(

View File

@ -46,6 +46,8 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.block.FuzzyBlockState;
import com.sk89q.worldedit.world.entity.EntityType;
import com.sk89q.worldedit.world.entity.EntityTypes;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import java.util.HashMap;
@ -323,12 +325,11 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
// Allow setting mob spawn type
if (blockAndExtraData.length > 1) {
String mobName = blockAndExtraData[1];
for (MobType mobType : MobType.values()) {
if (mobType.getName().toLowerCase(Locale.ROOT).equals(mobName.toLowerCase(Locale.ROOT))) {
mobName = mobType.getName();
break;
}
EntityType ent = EntityTypes.get(mobName.toLowerCase(Locale.ROOT));
if (ent == null) {
throw new NoMatchException("Unknown entity type '" + mobName + "'");
}
mobName = ent.getId();
if (!worldEdit.getPlatformManager().queryCapability(Capability.USER_COMMANDS).isValidMobType(mobName)) {
throw new NoMatchException("Unknown mob type '" + mobName + "'");
}

View File

@ -63,7 +63,7 @@ public interface Platform {
* Checks if a mob type is valid.
*
* @param type The mob type name to check
* @return Whether the name is a valid mod bype
* @return Whether the name is a valid mod type
*/
boolean isValidMobType(String type);