forked from LogBlock/LogBlock
Merge branch 'master' into 1.14pre
This commit is contained in:
@ -74,6 +74,9 @@ public class BlockChange implements LookupCacheElement {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
BlockData type = getBlockSet();
|
BlockData type = getBlockSet();
|
||||||
BlockData replaced = getBlockReplaced();
|
BlockData replaced = getBlockReplaced();
|
||||||
|
if (type == null || replaced == null) {
|
||||||
|
return "Unknown block modification";
|
||||||
|
}
|
||||||
String typeDetails = null;
|
String typeDetails = null;
|
||||||
if (BlockStateCodecs.hasCodec(type.getMaterial())) {
|
if (BlockStateCodecs.hasCodec(type.getMaterial())) {
|
||||||
try {
|
try {
|
||||||
|
@ -55,7 +55,7 @@ public class EntityTypeConverter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static EntityType getEntityType(int entityTypeId) {
|
public static EntityType getEntityType(int entityTypeId) {
|
||||||
return idToEntityType[entityTypeId];
|
return entityTypeId >= 0 && entityTypeId < idToEntityType.length ? idToEntityType[entityTypeId] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void reinitializeEntityTypesCatchException() {
|
private static void reinitializeEntityTypesCatchException() {
|
||||||
@ -78,8 +78,15 @@ public class EntityTypeConverter {
|
|||||||
ResultSet rs = smt.executeQuery("SELECT id, name FROM `lb-entitytypes`");
|
ResultSet rs = smt.executeQuery("SELECT id, name FROM `lb-entitytypes`");
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
int key = rs.getInt(1);
|
int key = rs.getInt(1);
|
||||||
EntityType entityType = EntityType.valueOf(rs.getString(2));
|
try {
|
||||||
internalAddEntityType(key, entityType);
|
EntityType entityType = EntityType.valueOf(rs.getString(2));
|
||||||
|
internalAddEntityType(key, entityType);
|
||||||
|
} catch (IllegalArgumentException ignored) {
|
||||||
|
// the key is used, but not available in this version
|
||||||
|
if (nextEntityTypeId <= key) {
|
||||||
|
nextEntityTypeId = key + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
smt.close();
|
smt.close();
|
||||||
|
@ -122,15 +122,27 @@ public class MaterialConverter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static BlockData getBlockData(int materialId, int blockStateId) {
|
public static BlockData getBlockData(int materialId, int blockStateId) {
|
||||||
String material = idToMaterial[materialId];
|
String material = materialId >= 0 && materialId < idToMaterial.length ? idToMaterial[materialId] : null;
|
||||||
if (blockStateId >= 0) {
|
if (material == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (blockStateId >= 0 && blockStateId < idToBlockState.length && idToBlockState[blockStateId] != null) {
|
||||||
material = material + idToBlockState[blockStateId];
|
material = material + idToBlockState[blockStateId];
|
||||||
}
|
}
|
||||||
return Bukkit.createBlockData(material);
|
try {
|
||||||
|
return Bukkit.createBlockData(material);
|
||||||
|
} catch (IllegalArgumentException ignored) {
|
||||||
|
// fall back to create the default block data for the material
|
||||||
|
try {
|
||||||
|
return Bukkit.createBlockData(idToMaterial[materialId]);
|
||||||
|
} catch (IllegalArgumentException ignored2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Material getMaterial(int materialId) {
|
public static Material getMaterial(int materialId) {
|
||||||
return materialKeyToMaterial.get(idToMaterial[materialId]);
|
return materialId >= 0 && materialId < idToMaterial.length ? materialKeyToMaterial.get(idToMaterial[materialId]) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void reinitializeMaterialsCatchException() {
|
private static void reinitializeMaterialsCatchException() {
|
||||||
|
@ -5,6 +5,7 @@ import org.bukkit.Location;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import static de.diddiz.util.Utils.spaces;
|
import static de.diddiz.util.Utils.spaces;
|
||||||
|
|
||||||
@ -30,6 +31,6 @@ public class SummedEntityChanges implements LookupCacheElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return created + spaces((int) ((10 - String.valueOf(created).length()) / spaceFactor)) + destroyed + spaces((int) ((10 - String.valueOf(destroyed).length()) / spaceFactor)) + (actor != null ? actor.getName() : EntityTypeConverter.getEntityType(type).toString());
|
return created + spaces((int) ((10 - String.valueOf(created).length()) / spaceFactor)) + destroyed + spaces((int) ((10 - String.valueOf(destroyed).length()) / spaceFactor)) + (actor != null ? actor.getName() : Objects.toString(EntityTypeConverter.getEntityType(type)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -226,6 +226,9 @@ public class WorldEditor implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PerformResult perform() throws WorldEditorException {
|
public PerformResult perform() throws WorldEditorException {
|
||||||
|
if (type == null) {
|
||||||
|
throw new WorldEditorException("Unkown entity type for entity " + entityUUID, loc);
|
||||||
|
}
|
||||||
if (changeType == (rollback ? EntityChangeType.KILL : EntityChangeType.CREATE)) {
|
if (changeType == (rollback ? EntityChangeType.KILL : EntityChangeType.CREATE)) {
|
||||||
// spawn entity
|
// spawn entity
|
||||||
UUID uuid = getReplacedUUID(entityId, entityUUID);
|
UUID uuid = getReplacedUUID(entityId, entityUUID);
|
||||||
|
Reference in New Issue
Block a user