Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-24 18:10:08 +01:00
Fixed /butcher. (I also added necessary methods to Bukkit.)
Dieser Commit ist enthalten in:
Ursprung
26e72abc3e
Commit
5e01f50d93
53
src/com/sk89q/worldedit/bukkit/BukkitUtil.java
Normale Datei
53
src/com/sk89q/worldedit/bukkit/BukkitUtil.java
Normale Datei
@ -0,0 +1,53 @@
|
|||||||
|
// $Id$
|
||||||
|
/*
|
||||||
|
* WorldEdit
|
||||||
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||||
|
*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import com.sk89q.worldedit.BlockVector;
|
||||||
|
import com.sk89q.worldedit.Vector;
|
||||||
|
|
||||||
|
public class BukkitUtil {
|
||||||
|
private BukkitUtil() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockVector toVector(Block block) {
|
||||||
|
return new BlockVector(block.getX(), block.getY(), block.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector toVector(Location loc) {
|
||||||
|
return new Vector(loc.getX(), loc.getY(), loc.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector toVector(org.bukkit.util.Vector vector) {
|
||||||
|
return new Vector(vector.getX(), vector.getY(), vector.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Player matchSinglePlayer(Server server, String name) {
|
||||||
|
List<Player> players = server.matchPlayer(name);
|
||||||
|
if (players.size() == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return players.get(0);
|
||||||
|
}
|
||||||
|
}
|
@ -26,6 +26,8 @@ import org.bukkit.block.BlockState;
|
|||||||
import org.bukkit.block.Furnace;
|
import org.bukkit.block.Furnace;
|
||||||
import org.bukkit.block.MobSpawner;
|
import org.bukkit.block.MobSpawner;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.entity.Creature;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -298,13 +300,25 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
* Kill mobs in an area.
|
* Kill mobs in an area.
|
||||||
*
|
*
|
||||||
* @param origin
|
* @param origin
|
||||||
* @param radius
|
* @param radius -1 for all mobs
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int killMobs(Vector origin, int radius) {
|
public int killMobs(Vector origin, int radius) {
|
||||||
// TODO Auto-generated method stub
|
int num = 0;
|
||||||
return 0;
|
double radiusSq = Math.pow(radius, 2);
|
||||||
|
|
||||||
|
for (LivingEntity ent : world.getLivingEntities()) {
|
||||||
|
if (ent instanceof Creature) {
|
||||||
|
if (radius == -1
|
||||||
|
|| origin.distanceSq(BukkitUtil.toVector(ent.getLocation())) <= radiusSq) {
|
||||||
|
ent.setHealth(0);
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Location toLocation(Vector pt) {
|
private Location toLocation(Vector pt) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren