Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 18:40:05 +01:00
Using trove collections for most internal stuff, using array access in BlockType and ItemType
Dieser Commit ist enthalten in:
Ursprung
31bd786fdf
Commit
410ac65c6a
10
pom.xml
10
pom.xml
@ -90,6 +90,14 @@
|
|||||||
<artifactId>spoutapi</artifactId>
|
<artifactId>spoutapi</artifactId>
|
||||||
<version>dev-SNAPSHOT</version>
|
<version>dev-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.sf.trove4j</groupId>
|
||||||
|
<artifactId>trove4j</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
<type>jar</type>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -173,8 +181,10 @@
|
|||||||
<!-- We want to bundle in the modified jchronic library -->
|
<!-- We want to bundle in the modified jchronic library -->
|
||||||
<includes>
|
<includes>
|
||||||
<include>com.sk89q:jchronic</include>
|
<include>com.sk89q:jchronic</include>
|
||||||
|
<include>net.sf.trove4j:trove4j</include>
|
||||||
</includes>
|
</includes>
|
||||||
</artifactSet>
|
</artifactSet>
|
||||||
|
<minimizeJar>true</minimizeJar>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
@ -39,6 +39,8 @@ import com.sk89q.worldedit.expression.ExpressionException;
|
|||||||
import com.sk89q.worldedit.expression.runtime.RValue;
|
import com.sk89q.worldedit.expression.runtime.RValue;
|
||||||
import com.sk89q.worldedit.masks.Mask;
|
import com.sk89q.worldedit.masks.Mask;
|
||||||
import com.sk89q.worldedit.patterns.*;
|
import com.sk89q.worldedit.patterns.*;
|
||||||
|
import gnu.trove.set.TIntSet;
|
||||||
|
import gnu.trove.set.hash.TIntHashSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class can wrap all block editing operations into one "edit session" that
|
* This class can wrap all block editing operations into one "edit session" that
|
||||||
@ -118,7 +120,7 @@ public class EditSession {
|
|||||||
/**
|
/**
|
||||||
* List of missing blocks;
|
* List of missing blocks;
|
||||||
*/
|
*/
|
||||||
private Set<Integer> missingBlocks = new HashSet<Integer>();
|
private TIntSet missingBlocks = new TIntHashSet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mask to cover operations.
|
* Mask to cover operations.
|
||||||
@ -660,9 +662,9 @@ public class EditSession {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Set<Integer> popMissingBlocks() {
|
public TIntSet popMissingBlocks() {
|
||||||
Set<Integer> missingBlocks = this.missingBlocks;
|
TIntSet missingBlocks = this.missingBlocks;
|
||||||
this.missingBlocks = new HashSet<Integer>();
|
this.missingBlocks = new TIntHashSet();
|
||||||
return missingBlocks;
|
return missingBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ import com.sk89q.worldedit.scripting.*;
|
|||||||
import com.sk89q.worldedit.tools.*;
|
import com.sk89q.worldedit.tools.*;
|
||||||
import com.sk89q.worldedit.masks.*;
|
import com.sk89q.worldedit.masks.*;
|
||||||
import com.sk89q.worldedit.patterns.*;
|
import com.sk89q.worldedit.patterns.*;
|
||||||
|
import gnu.trove.set.TIntSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is the main entry point for WorldEdit. All events are routed
|
* This class is the main entry point for WorldEdit. All events are routed
|
||||||
@ -974,7 +975,7 @@ public class WorldEdit {
|
|||||||
blockBag.flushChanges();
|
blockBag.flushChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<Integer> missingBlocks = editSession.popMissingBlocks();
|
TIntSet missingBlocks = editSession.popMissingBlocks();
|
||||||
|
|
||||||
if (missingBlocks.size() > 0) {
|
if (missingBlocks.size() > 0) {
|
||||||
StringBuilder str = new StringBuilder();
|
StringBuilder str = new StringBuilder();
|
||||||
@ -982,12 +983,12 @@ public class WorldEdit {
|
|||||||
int size = missingBlocks.size();
|
int size = missingBlocks.size();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (Integer id : missingBlocks) {
|
for (int id : missingBlocks.toArray()) {
|
||||||
BlockType type = BlockType.fromID(id);
|
BlockType type = BlockType.fromID(id);
|
||||||
|
|
||||||
str.append(type != null
|
str.append(type != null
|
||||||
? type.getName() + " (" + id + ")"
|
? type.getName() + " (" + id + ")"
|
||||||
: id.toString());
|
: id);
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.blocks;
|
package com.sk89q.worldedit.blocks;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import gnu.trove.map.TIntIntMap;
|
||||||
import java.util.Map;
|
import gnu.trove.map.hash.TIntIntHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an item.
|
* Represents an item.
|
||||||
@ -37,7 +37,7 @@ public class BaseItem {
|
|||||||
*/
|
*/
|
||||||
private short damage;
|
private short damage;
|
||||||
|
|
||||||
private Map<Integer, Integer> enchantments = new HashMap<Integer, Integer>();
|
private TIntIntMap enchantments = new TIntIntHashMap();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the object.
|
* Construct the object.
|
||||||
@ -88,7 +88,7 @@ public class BaseItem {
|
|||||||
this.damage = damage;
|
this.damage = damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, Integer> getEnchantments() {
|
public TIntIntMap getEnchantments() {
|
||||||
return enchantments;
|
return enchantments;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,15 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.blocks;
|
package com.sk89q.worldedit.blocks;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import gnu.trove.map.TIntObjectMap;
|
||||||
|
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||||
|
import gnu.trove.set.TIntSet;
|
||||||
|
import gnu.trove.set.hash.TIntHashSet;
|
||||||
|
|
||||||
import com.sk89q.util.StringUtil;
|
import com.sk89q.util.StringUtil;
|
||||||
import com.sk89q.worldedit.PlayerDirection;
|
import com.sk89q.worldedit.PlayerDirection;
|
||||||
@ -163,7 +165,7 @@ public enum BlockType {
|
|||||||
/**
|
/**
|
||||||
* Stores a map of the IDs for fast access.
|
* Stores a map of the IDs for fast access.
|
||||||
*/
|
*/
|
||||||
private static final Map<Integer, BlockType> ids = new HashMap<Integer, BlockType>();
|
private static BlockType[] ids = new BlockType[256];
|
||||||
/**
|
/**
|
||||||
* Stores a map of the names for fast access.
|
* Stores a map of the names for fast access.
|
||||||
*/
|
*/
|
||||||
@ -174,8 +176,13 @@ public enum BlockType {
|
|||||||
private final String[] lookupKeys;
|
private final String[] lookupKeys;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
for (BlockType type : EnumSet.allOf(BlockType.class)) {
|
for (BlockType type : values()) {
|
||||||
ids.put(type.id, type);
|
if (ids.length > type.id) {
|
||||||
|
ids[type.id] = type;
|
||||||
|
} else {
|
||||||
|
ids = Arrays.copyOf(ids, type.id + 10);
|
||||||
|
ids[type.id] = type;
|
||||||
|
}
|
||||||
for (String key : type.lookupKeys) {
|
for (String key : type.lookupKeys) {
|
||||||
lookup.put(key, type);
|
lookup.put(key, type);
|
||||||
}
|
}
|
||||||
@ -214,7 +221,11 @@ public enum BlockType {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static BlockType fromID(int id) {
|
public static BlockType fromID(int id) {
|
||||||
return ids.get(id);
|
if (id < 0 || id >= ids.length) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return ids[id];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -287,7 +298,7 @@ public enum BlockType {
|
|||||||
/**
|
/**
|
||||||
* HashSet for shouldPlaceLast.
|
* HashSet for shouldPlaceLast.
|
||||||
*/
|
*/
|
||||||
private static final Set<Integer> shouldPlaceLast = new HashSet<Integer>();
|
private static final TIntSet shouldPlaceLast = new TIntHashSet();
|
||||||
static {
|
static {
|
||||||
shouldPlaceLast.add(BlockID.SAPLING);
|
shouldPlaceLast.add(BlockID.SAPLING);
|
||||||
shouldPlaceLast.add(BlockID.BED);
|
shouldPlaceLast.add(BlockID.BED);
|
||||||
@ -348,7 +359,7 @@ public enum BlockType {
|
|||||||
/**
|
/**
|
||||||
* HashSet for shouldPlaceLast.
|
* HashSet for shouldPlaceLast.
|
||||||
*/
|
*/
|
||||||
private static final Set<Integer> shouldPlaceFinal = new HashSet<Integer>();
|
private static final TIntSet shouldPlaceFinal = new TIntHashSet();
|
||||||
static {
|
static {
|
||||||
shouldPlaceFinal.add(BlockID.SIGN_POST);
|
shouldPlaceFinal.add(BlockID.SIGN_POST);
|
||||||
shouldPlaceFinal.add(BlockID.WOODEN_DOOR);
|
shouldPlaceFinal.add(BlockID.WOODEN_DOOR);
|
||||||
@ -376,7 +387,7 @@ public enum BlockType {
|
|||||||
/**
|
/**
|
||||||
* HashSet for canPassThrough.
|
* HashSet for canPassThrough.
|
||||||
*/
|
*/
|
||||||
private static final Set<Integer> canPassThrough = new HashSet<Integer>();
|
private static final TIntSet canPassThrough = new TIntHashSet();
|
||||||
static {
|
static {
|
||||||
canPassThrough.add(BlockID.AIR);
|
canPassThrough.add(BlockID.AIR);
|
||||||
canPassThrough.add(BlockID.WATER);
|
canPassThrough.add(BlockID.WATER);
|
||||||
@ -440,7 +451,7 @@ public enum BlockType {
|
|||||||
/**
|
/**
|
||||||
* HashSet for usesData.
|
* HashSet for usesData.
|
||||||
*/
|
*/
|
||||||
private static final Set<Integer> usesData = new HashSet<Integer>();
|
private static final TIntSet usesData = new TIntHashSet();
|
||||||
static {
|
static {
|
||||||
usesData.add(BlockID.SAPLING);
|
usesData.add(BlockID.SAPLING);
|
||||||
usesData.add(BlockID.WATER);
|
usesData.add(BlockID.WATER);
|
||||||
@ -532,7 +543,7 @@ public enum BlockType {
|
|||||||
/**
|
/**
|
||||||
* HashSet for isContainerBlock.
|
* HashSet for isContainerBlock.
|
||||||
*/
|
*/
|
||||||
private static final Set<Integer> isContainerBlock = new HashSet<Integer>();
|
private static final TIntSet isContainerBlock = new TIntHashSet();
|
||||||
static {
|
static {
|
||||||
isContainerBlock.add(BlockID.DISPENSER);
|
isContainerBlock.add(BlockID.DISPENSER);
|
||||||
isContainerBlock.add(BlockID.FURNACE);
|
isContainerBlock.add(BlockID.FURNACE);
|
||||||
@ -563,7 +574,7 @@ public enum BlockType {
|
|||||||
/**
|
/**
|
||||||
* HashSet for isRedstoneBlock.
|
* HashSet for isRedstoneBlock.
|
||||||
*/
|
*/
|
||||||
private static final Set<Integer> isRedstoneBlock = new HashSet<Integer>();
|
private static final TIntSet isRedstoneBlock = new TIntHashSet();
|
||||||
static {
|
static {
|
||||||
isRedstoneBlock.add(BlockID.POWERED_RAIL);
|
isRedstoneBlock.add(BlockID.POWERED_RAIL);
|
||||||
isRedstoneBlock.add(BlockID.DETECTOR_RAIL);
|
isRedstoneBlock.add(BlockID.DETECTOR_RAIL);
|
||||||
@ -607,7 +618,7 @@ public enum BlockType {
|
|||||||
/**
|
/**
|
||||||
* HashSet for canTransferRedstone.
|
* HashSet for canTransferRedstone.
|
||||||
*/
|
*/
|
||||||
private static final Set<Integer> canTransferRedstone = new HashSet<Integer>();
|
private static final TIntSet canTransferRedstone = new TIntHashSet();
|
||||||
static {
|
static {
|
||||||
canTransferRedstone.add(BlockID.REDSTONE_TORCH_OFF);
|
canTransferRedstone.add(BlockID.REDSTONE_TORCH_OFF);
|
||||||
canTransferRedstone.add(BlockID.REDSTONE_TORCH_ON);
|
canTransferRedstone.add(BlockID.REDSTONE_TORCH_ON);
|
||||||
@ -640,7 +651,7 @@ public enum BlockType {
|
|||||||
/**
|
/**
|
||||||
* HashSet for isRedstoneSource.
|
* HashSet for isRedstoneSource.
|
||||||
*/
|
*/
|
||||||
private static final Set<Integer> isRedstoneSource = new HashSet<Integer>();
|
private static final TIntSet isRedstoneSource = new TIntHashSet();
|
||||||
static {
|
static {
|
||||||
isRedstoneSource.add(BlockID.DETECTOR_RAIL);
|
isRedstoneSource.add(BlockID.DETECTOR_RAIL);
|
||||||
isRedstoneSource.add(BlockID.REDSTONE_TORCH_OFF);
|
isRedstoneSource.add(BlockID.REDSTONE_TORCH_OFF);
|
||||||
@ -673,7 +684,7 @@ public enum BlockType {
|
|||||||
/**
|
/**
|
||||||
* HashSet for isRailBlock.
|
* HashSet for isRailBlock.
|
||||||
*/
|
*/
|
||||||
private static final Set<Integer> isRailBlock = new HashSet<Integer>();
|
private static final TIntSet isRailBlock = new TIntHashSet();
|
||||||
static {
|
static {
|
||||||
isRailBlock.add(BlockID.POWERED_RAIL);
|
isRailBlock.add(BlockID.POWERED_RAIL);
|
||||||
isRailBlock.add(BlockID.DETECTOR_RAIL);
|
isRailBlock.add(BlockID.DETECTOR_RAIL);
|
||||||
@ -702,7 +713,7 @@ public enum BlockType {
|
|||||||
/**
|
/**
|
||||||
* HashSet for isNaturalBlock.
|
* HashSet for isNaturalBlock.
|
||||||
*/
|
*/
|
||||||
private static final Set<Integer> isNaturalTerrainBlock = new HashSet<Integer>();
|
private static final TIntSet isNaturalTerrainBlock = new TIntHashSet();
|
||||||
static {
|
static {
|
||||||
isNaturalTerrainBlock.add(BlockID.STONE);
|
isNaturalTerrainBlock.add(BlockID.STONE);
|
||||||
isNaturalTerrainBlock.add(BlockID.GRASS);
|
isNaturalTerrainBlock.add(BlockID.GRASS);
|
||||||
@ -751,7 +762,7 @@ public enum BlockType {
|
|||||||
/**
|
/**
|
||||||
* HashSet for emitsLight.
|
* HashSet for emitsLight.
|
||||||
*/
|
*/
|
||||||
private static final Set<Integer> emitsLight = new HashSet<Integer>();
|
private static final TIntSet emitsLight = new TIntHashSet();
|
||||||
static {
|
static {
|
||||||
emitsLight.add(BlockID.LAVA);
|
emitsLight.add(BlockID.LAVA);
|
||||||
emitsLight.add(BlockID.STATIONARY_LAVA);
|
emitsLight.add(BlockID.STATIONARY_LAVA);
|
||||||
@ -785,7 +796,7 @@ public enum BlockType {
|
|||||||
/**
|
/**
|
||||||
* HashSet for isTranslucent.
|
* HashSet for isTranslucent.
|
||||||
*/
|
*/
|
||||||
private static final Set<Integer> isTranslucent = new HashSet<Integer>();
|
private static final TIntSet isTranslucent = new TIntHashSet();
|
||||||
static {
|
static {
|
||||||
isTranslucent.add(BlockID.AIR);
|
isTranslucent.add(BlockID.AIR);
|
||||||
isTranslucent.add(BlockID.SAPLING);
|
isTranslucent.add(BlockID.SAPLING);
|
||||||
@ -1244,8 +1255,8 @@ public enum BlockType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Map<Integer, PlayerDirection> dataAttachments = new HashMap<Integer, PlayerDirection>();
|
private static final TIntObjectMap<PlayerDirection> dataAttachments = new TIntObjectHashMap<PlayerDirection>();
|
||||||
private static final Map<Integer, PlayerDirection> nonDataAttachments = new HashMap<Integer, PlayerDirection>();
|
private static final TIntObjectMap<PlayerDirection> nonDataAttachments = new TIntObjectHashMap<PlayerDirection>();
|
||||||
static {
|
static {
|
||||||
nonDataAttachments.put(BlockID.SAPLING, PlayerDirection.DOWN);
|
nonDataAttachments.put(BlockID.SAPLING, PlayerDirection.DOWN);
|
||||||
nonDataAttachments.put(BlockID.POWERED_RAIL, PlayerDirection.DOWN);
|
nonDataAttachments.put(BlockID.POWERED_RAIL, PlayerDirection.DOWN);
|
||||||
|
@ -19,15 +19,14 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.blocks;
|
package com.sk89q.worldedit.blocks;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.Arrays;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import com.sk89q.util.StringUtil;
|
import com.sk89q.util.StringUtil;
|
||||||
|
import gnu.trove.set.TIntSet;
|
||||||
|
import gnu.trove.set.hash.TIntHashSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ItemType types.
|
* ItemType types.
|
||||||
@ -308,7 +307,7 @@ public enum ItemType {
|
|||||||
/**
|
/**
|
||||||
* Stores a map of the IDs for fast access.
|
* Stores a map of the IDs for fast access.
|
||||||
*/
|
*/
|
||||||
private static final Map<Integer, ItemType> ids = new HashMap<Integer, ItemType>();
|
private static ItemType[] ids = new ItemType[3200];
|
||||||
/**
|
/**
|
||||||
* Stores a map of the names for fast access.
|
* Stores a map of the names for fast access.
|
||||||
*/
|
*/
|
||||||
@ -319,8 +318,13 @@ public enum ItemType {
|
|||||||
private final String[] lookupKeys;
|
private final String[] lookupKeys;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
for (ItemType type : EnumSet.allOf(ItemType.class)) {
|
for (ItemType type : values()) {
|
||||||
ids.put(type.id, type);
|
if (ids.length > type.id) {
|
||||||
|
ids[type.id] = type;
|
||||||
|
} else {
|
||||||
|
ids = Arrays.copyOf(ids, type.id + 10);
|
||||||
|
ids[type.id] = type;
|
||||||
|
}
|
||||||
for (String key : type.lookupKeys) {
|
for (String key : type.lookupKeys) {
|
||||||
lookup.put(key, type);
|
lookup.put(key, type);
|
||||||
}
|
}
|
||||||
@ -359,7 +363,11 @@ public enum ItemType {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static ItemType fromID(int id) {
|
public static ItemType fromID(int id) {
|
||||||
return ids.get(id);
|
if (id < 0 || id >= ids.length) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return ids[id];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -369,7 +377,7 @@ public enum ItemType {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String toName(int id) {
|
public static String toName(int id) {
|
||||||
ItemType type = ids.get(id);
|
ItemType type = fromID(id);
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
return type.getName();
|
return type.getName();
|
||||||
} else {
|
} else {
|
||||||
@ -387,7 +395,7 @@ public enum ItemType {
|
|||||||
if (id == 0) {
|
if (id == 0) {
|
||||||
return "Hand";
|
return "Hand";
|
||||||
}
|
}
|
||||||
ItemType type = ids.get(id);
|
ItemType type = fromID(id);
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
return type.getName();
|
return type.getName();
|
||||||
} else {
|
} else {
|
||||||
@ -470,7 +478,7 @@ public enum ItemType {
|
|||||||
return lookupKeys;
|
return lookupKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Set<Integer> shouldNotStack = new HashSet<Integer>();
|
private static final TIntSet shouldNotStack = new TIntHashSet();
|
||||||
static {
|
static {
|
||||||
shouldNotStack.add(ItemID.IRON_SHOVEL);
|
shouldNotStack.add(ItemID.IRON_SHOVEL);
|
||||||
shouldNotStack.add(ItemID.IRON_PICK);
|
shouldNotStack.add(ItemID.IRON_PICK);
|
||||||
@ -560,7 +568,7 @@ public enum ItemType {
|
|||||||
return shouldNotStack.contains(id);
|
return shouldNotStack.contains(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Set<Integer> usesDamageValue = new HashSet<Integer>();
|
private static final TIntSet usesDamageValue = new TIntHashSet();
|
||||||
static {
|
static {
|
||||||
usesDamageValue.add(BlockID.SAPLING);
|
usesDamageValue.add(BlockID.SAPLING);
|
||||||
//usesDamageValue.add(BlockID.WATER);
|
//usesDamageValue.add(BlockID.WATER);
|
||||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.bukkit;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import gnu.trove.procedure.TIntIntProcedure;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Furnace;
|
import org.bukkit.block.Furnace;
|
||||||
@ -683,13 +684,20 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (contents[i] != null) {
|
if (contents[i] != null) {
|
||||||
ItemStack toAdd = new ItemStack(contents[i].getType(),
|
final ItemStack toAdd = new ItemStack(contents[i].getType(),
|
||||||
contents[i].getAmount(),
|
contents[i].getAmount(),
|
||||||
contents[i].getDamage());
|
contents[i].getDamage());
|
||||||
try {
|
try {
|
||||||
for (Map.Entry<Integer, Integer> entry : contents[i].getEnchantments().entrySet()) {
|
contents[i].getEnchantments().forEachEntry(new TIntIntProcedure() {
|
||||||
toAdd.addEnchantment(Enchantment.getById(entry.getKey()), entry.getValue());
|
@Override
|
||||||
}
|
public boolean execute(int key, int value) {
|
||||||
|
Enchantment ench = Enchantment.getById(key);
|
||||||
|
if (ench != null) {
|
||||||
|
toAdd.addEnchantment(ench, value);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (Throwable ignore) {}
|
} catch (Throwable ignore) {}
|
||||||
inven.setItem(i, toAdd);
|
inven.setItem(i, toAdd);
|
||||||
} else {
|
} else {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren