mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-05 20:36:42 +00:00
Added basic entity handling with copy and paste.
Paintings do not currently respawn properly, entity pastes cannot be undone yet, and schematics do not yet store entities @celticminstrel needs to fix painting spawning
This commit is contained in:
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.bukkit.entity;
|
||||
|
||||
import com.sk89q.worldedit.LocalEntity;
|
||||
import com.sk89q.worldedit.Location;
|
||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class BukkitEntity extends LocalEntity {
|
||||
private final EntityType type;
|
||||
private final UUID entityId;
|
||||
|
||||
public BukkitEntity(Location loc, EntityType type, UUID entityId) {
|
||||
super(loc);
|
||||
this.type = type;
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
public UUID getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean spawn(Location weLoc) {
|
||||
org.bukkit.Location loc = BukkitUtil.toLocation(weLoc);
|
||||
return loc.getWorld().spawnCreature(loc, type) != null;
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.bukkit.entity;
|
||||
|
||||
import com.sk89q.worldedit.Location;
|
||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class BukkitExpOrb extends BukkitEntity {
|
||||
private final int amount;
|
||||
|
||||
public BukkitExpOrb(Location loc, UUID entityId, int amount) {
|
||||
super(loc, EntityType.EXPERIENCE_ORB, entityId);
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean spawn(Location weLoc) {
|
||||
org.bukkit.Location loc = BukkitUtil.toLocation(weLoc);
|
||||
ExperienceOrb orb = loc.getWorld().spawn(loc, ExperienceOrb.class);
|
||||
if (orb != null) {
|
||||
orb.setExperience(amount);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.bukkit.entity;
|
||||
|
||||
import com.sk89q.worldedit.Location;
|
||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class BukkitItem extends BukkitEntity {
|
||||
private final ItemStack stack;
|
||||
public BukkitItem(Location loc, ItemStack stack, UUID entityId) {
|
||||
super(loc, EntityType.DROPPED_ITEM, entityId);
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean spawn(Location weLoc) {
|
||||
org.bukkit.Location loc = BukkitUtil.toLocation(weLoc);
|
||||
return loc.getWorld().dropItem(loc, stack) != null;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.bukkit.entity;
|
||||
|
||||
import com.sk89q.worldedit.Location;
|
||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||
import org.bukkit.Art;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Painting;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class BukkitPainting extends BukkitEntity {
|
||||
private final Art art;
|
||||
private final BlockFace facingDirection;
|
||||
public BukkitPainting(Location loc, Art art, BlockFace facingDirection, UUID entityId) {
|
||||
super(loc, EntityType.PAINTING, entityId);
|
||||
this.art = art;
|
||||
this.facingDirection = facingDirection;
|
||||
}
|
||||
|
||||
public boolean spawn(Location weLoc) {
|
||||
org.bukkit.Location loc = BukkitUtil.toLocation(weLoc);
|
||||
Painting paint = loc.getWorld().spawn(loc, Painting.class);
|
||||
if (paint != null) {
|
||||
paint.setFacingDirection(facingDirection);
|
||||
paint.setArt(art);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user