Made BukkitEntity keep a weak ref to the entity and cleaned up code.

This commit is contained in:
sk89q
2014-07-18 11:43:18 -07:00
parent 781fc31d6f
commit 70f05c950a
6 changed files with 52 additions and 163 deletions

View File

@ -190,7 +190,7 @@ public class EditSession implements Extent {
this.bypassNone = extent;
} else {
Extent extent = new NullExtent();
extent = survivalExtent = new SurvivalModeExtent(extent, new NullWorld());
extent = survivalExtent = new SurvivalModeExtent(extent, NullWorld.getInstance());
extent = blockBagExtent = new BlockBagExtent(extent, blockBag);
extent = reorderExtent = new MultiStageReorder(extent, false);
extent = maskingExtent = new MaskingExtent(extent, Masks.alwaysTrue());

View File

@ -1,56 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.entity.metadata;
/**
* Describes a creature.
*/
public interface Creature {
/**
* Returns whether the creature is a non-player character, such as
* a NPC human or a villager.
*
* @return true if the creature is an NPC
*/
boolean isNpc();
/**
* Returns whether the creature can be tamed.
*
* @return true if the creature can be tamed
*/
boolean isTameable();
/**
* Returns whether the creature is hostile.
*
* @return true if the creature is hostile
*/
boolean isHostile();
/**
* Returns whether the creature is passive.
*
* @return true if the creature is passive
*/
boolean isPassive();
}

View File

@ -1,34 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.entity.metadata;
/**
* Indicates a creature that can be tamed.
*/
public interface Tameable {
/**
* Returns whether the creature is tamed.
*
* @return true if the creature is tamed
*/
boolean isTamed();
}

View File

@ -46,6 +46,11 @@ import java.util.List;
*/
public class NullWorld extends AbstractWorld {
private static final NullWorld INSTANCE = new NullWorld();
protected NullWorld() {
}
@Override
public String getName() {
return "null";
@ -120,4 +125,14 @@ public class NullWorld extends AbstractWorld {
public Entity createEntity(Location location, BaseEntity entity) {
return null;
}
/**
* Return an instance of this null world.
*
* @return a null world
*/
public static NullWorld getInstance() {
return INSTANCE;
}
}