mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
Minor code cleanup
Plus an optimization
This commit is contained in:
parent
6007f040cd
commit
31d346a587
@ -123,7 +123,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
THIS = this;
|
BukkitMain.THIS = this;
|
||||||
new PS(this, "Bukkit");
|
new PS(this, "Bukkit");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,12 +131,12 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
PS.get().disable();
|
PS.get().disable();
|
||||||
Bukkit.getScheduler().cancelTasks(this);
|
Bukkit.getScheduler().cancelTasks(this);
|
||||||
THIS = null;
|
BukkitMain.THIS = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void log(String message) {
|
public void log(String message) {
|
||||||
if (THIS != null) {
|
if (BukkitMain.THIS != null) {
|
||||||
try {
|
try {
|
||||||
message = C.color(message);
|
message = C.color(message);
|
||||||
if (!Settings.CONSOLE_COLOR) {
|
if (!Settings.CONSOLE_COLOR) {
|
||||||
@ -153,7 +153,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable() {
|
public void disable() {
|
||||||
if (THIS != null) {
|
if (BukkitMain.THIS != null) {
|
||||||
onDisable();
|
onDisable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -224,10 +224,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
case LIGHTNING:
|
case LIGHTNING:
|
||||||
case WITHER_SKULL:
|
case WITHER_SKULL:
|
||||||
case UNKNOWN:
|
case UNKNOWN:
|
||||||
case PLAYER: {
|
case PLAYER:
|
||||||
// non moving / unmovable
|
// non moving / unmovable
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
case THROWN_EXP_BOTTLE:
|
case THROWN_EXP_BOTTLE:
|
||||||
case SPLASH_POTION:
|
case SPLASH_POTION:
|
||||||
case SNOWBALL:
|
case SNOWBALL:
|
||||||
@ -235,15 +234,13 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
case SPECTRAL_ARROW:
|
case SPECTRAL_ARROW:
|
||||||
case TIPPED_ARROW:
|
case TIPPED_ARROW:
|
||||||
case ENDER_PEARL:
|
case ENDER_PEARL:
|
||||||
case ARROW: {
|
case ARROW:
|
||||||
// managed elsewhere | projectile
|
// managed elsewhere | projectile
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
case ARMOR_STAND:
|
case ARMOR_STAND:
|
||||||
case ITEM_FRAME:
|
case ITEM_FRAME:
|
||||||
case PAINTING: {
|
case PAINTING:
|
||||||
// TEMPORARILY CLASSIFY AS VEHICLE
|
// TEMPORARILY CLASSIFY AS VEHICLE
|
||||||
}
|
|
||||||
case MINECART:
|
case MINECART:
|
||||||
case MINECART_CHEST:
|
case MINECART_CHEST:
|
||||||
case MINECART_COMMAND:
|
case MINECART_COMMAND:
|
||||||
@ -278,15 +275,13 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
case SMALL_FIREBALL:
|
case SMALL_FIREBALL:
|
||||||
case FIREBALL:
|
case FIREBALL:
|
||||||
case DRAGON_FIREBALL:
|
case DRAGON_FIREBALL:
|
||||||
case DROPPED_ITEM: {
|
case DROPPED_ITEM:
|
||||||
// dropped item
|
// dropped item
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
case PRIMED_TNT:
|
case PRIMED_TNT:
|
||||||
case FALLING_BLOCK: {
|
case FALLING_BLOCK:
|
||||||
// managed elsewhere
|
// managed elsewhere
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
case BAT:
|
case BAT:
|
||||||
case BLAZE:
|
case BLAZE:
|
||||||
case CAVE_SPIDER:
|
case CAVE_SPIDER:
|
||||||
@ -320,7 +315,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
case WOLF:
|
case WOLF:
|
||||||
case ZOMBIE:
|
case ZOMBIE:
|
||||||
case SHULKER:
|
case SHULKER:
|
||||||
default: {
|
default:
|
||||||
if (!Settings.KILL_ROAD_MOBS) {
|
if (!Settings.KILL_ROAD_MOBS) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -334,7 +329,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -383,7 +377,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
@Override
|
@Override
|
||||||
public boolean initWorldEdit() {
|
public boolean initWorldEdit() {
|
||||||
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
|
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
|
||||||
BukkitMain.worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit");
|
worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit");
|
||||||
getServer().getPluginManager().registerEvents(new WEListener(), this);
|
getServer().getPluginManager().registerEvents(new WEListener(), this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -55,16 +55,16 @@ abstract class APlotMeConnector {
|
|||||||
public Location getPlotTopLocAbs(int path, int plot, PlotId plotid) {
|
public Location getPlotTopLocAbs(int path, int plot, PlotId plotid) {
|
||||||
int px = plotid.x;
|
int px = plotid.x;
|
||||||
int pz = plotid.y;
|
int pz = plotid.y;
|
||||||
int x = (px * (path + plot)) - (int) Math.floor(path / 2) - 1;
|
int x = px * (path + plot) - (int) Math.floor(path / 2) - 1;
|
||||||
int z = (pz * (path + plot)) - (int) Math.floor(path / 2) - 1;
|
int z = pz * (path + plot) - (int) Math.floor(path / 2) - 1;
|
||||||
return new Location(null, x, 256, z);
|
return new Location(null, x, 256, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getPlotBottomLocAbs(int path, int plot, PlotId plotid) {
|
public Location getPlotBottomLocAbs(int path, int plot, PlotId plotid) {
|
||||||
int px = plotid.x;
|
int px = plotid.x;
|
||||||
int pz = plotid.y;
|
int pz = plotid.y;
|
||||||
int x = (px * (path + plot)) - plot - (int) Math.floor(path / 2) - 1;
|
int x = px * (path + plot) - plot - (int) Math.floor(path / 2) - 1;
|
||||||
int z = (pz * (path + plot)) - plot - (int) Math.floor(path / 2) - 1;
|
int z = pz * (path + plot) - plot - (int) Math.floor(path / 2) - 1;
|
||||||
return new Location(null, x, 1, z);
|
return new Location(null, x, 1, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public class EntityWrapper {
|
|||||||
private ArmorStandStats stand;
|
private ArmorStandStats stand;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public EntityWrapper(org.bukkit.entity.Entity entity, short depth) {
|
public EntityWrapper(Entity entity, short depth) {
|
||||||
this.hash = entity.getEntityId();
|
this.hash = entity.getEntityId();
|
||||||
this.depth = depth;
|
this.depth = depth;
|
||||||
Location loc = entity.getLocation();
|
Location loc = entity.getLocation();
|
||||||
@ -113,21 +113,24 @@ public class EntityWrapper {
|
|||||||
case THROWN_EXP_BOTTLE:
|
case THROWN_EXP_BOTTLE:
|
||||||
case WEATHER:
|
case WEATHER:
|
||||||
case WITHER_SKULL:
|
case WITHER_SKULL:
|
||||||
case UNKNOWN: {
|
case UNKNOWN:
|
||||||
|
case TIPPED_ARROW:
|
||||||
|
case SPECTRAL_ARROW:
|
||||||
|
case SHULKER_BULLET:
|
||||||
|
case DRAGON_FIREBALL:
|
||||||
|
case LINGERING_POTION:
|
||||||
|
case AREA_EFFECT_CLOUD:
|
||||||
// Do this stuff later
|
// Do this stuff later
|
||||||
return;
|
return;
|
||||||
}
|
default:
|
||||||
default: {
|
|
||||||
PS.debug("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType());
|
PS.debug("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType());
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
// MISC //
|
// MISC //
|
||||||
case DROPPED_ITEM: {
|
case DROPPED_ITEM:
|
||||||
Item item = (Item) entity;
|
Item item = (Item) entity;
|
||||||
this.stack = item.getItemStack();
|
this.stack = item.getItemStack();
|
||||||
return;
|
return;
|
||||||
}
|
case ITEM_FRAME:
|
||||||
case ITEM_FRAME: {
|
|
||||||
ItemFrame itemframe = (ItemFrame) entity;
|
ItemFrame itemframe = (ItemFrame) entity;
|
||||||
this.x = Math.floor(this.x);
|
this.x = Math.floor(this.x);
|
||||||
this.y = Math.floor(this.y);
|
this.y = Math.floor(this.y);
|
||||||
@ -135,8 +138,7 @@ public class EntityWrapper {
|
|||||||
this.dataByte = getOrdinal(Rotation.values(), itemframe.getRotation());
|
this.dataByte = getOrdinal(Rotation.values(), itemframe.getRotation());
|
||||||
this.stack = itemframe.getItem().clone();
|
this.stack = itemframe.getItem().clone();
|
||||||
return;
|
return;
|
||||||
}
|
case PAINTING:
|
||||||
case PAINTING: {
|
|
||||||
Painting painting = (Painting) entity;
|
Painting painting = (Painting) entity;
|
||||||
this.x = Math.floor(this.x);
|
this.x = Math.floor(this.x);
|
||||||
this.y = Math.floor(this.y);
|
this.y = Math.floor(this.y);
|
||||||
@ -144,23 +146,21 @@ public class EntityWrapper {
|
|||||||
Art a = painting.getArt();
|
Art a = painting.getArt();
|
||||||
this.dataByte = getOrdinal(BlockFace.values(), painting.getFacing());
|
this.dataByte = getOrdinal(BlockFace.values(), painting.getFacing());
|
||||||
int h = a.getBlockHeight();
|
int h = a.getBlockHeight();
|
||||||
if ((h % 2) == 0) {
|
if (h % 2 == 0) {
|
||||||
this.y -= 1;
|
this.y -= 1;
|
||||||
}
|
}
|
||||||
this.dataString = a.name();
|
this.dataString = a.name();
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
// END MISC //
|
// END MISC //
|
||||||
// INVENTORY HOLDER //
|
// INVENTORY HOLDER //
|
||||||
case MINECART_CHEST:
|
case MINECART_CHEST:
|
||||||
case MINECART_HOPPER: {
|
case MINECART_HOPPER:
|
||||||
storeInventory((InventoryHolder) entity);
|
storeInventory((InventoryHolder) entity);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
// START LIVING ENTITY //
|
// START LIVING ENTITY //
|
||||||
// START AGEABLE //
|
// START AGEABLE //
|
||||||
// START TAMEABLE //
|
// START TAMEABLE //
|
||||||
case HORSE: {
|
case HORSE:
|
||||||
Horse horse = (Horse) entity;
|
Horse horse = (Horse) entity;
|
||||||
this.horse = new HorseStats();
|
this.horse = new HorseStats();
|
||||||
this.horse.jump = horse.getJumpStrength();
|
this.horse.jump = horse.getJumpStrength();
|
||||||
@ -173,51 +173,44 @@ public class EntityWrapper {
|
|||||||
storeLiving((LivingEntity) entity);
|
storeLiving((LivingEntity) entity);
|
||||||
storeInventory((InventoryHolder) entity);
|
storeInventory((InventoryHolder) entity);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
// END INVENTORY HOLDER //
|
// END INVENTORY HOLDER //
|
||||||
case WOLF:
|
case WOLF:
|
||||||
case OCELOT: {
|
case OCELOT:
|
||||||
storeTameable((Tameable) entity);
|
storeTameable((Tameable) entity);
|
||||||
storeAgeable((Ageable) entity);
|
storeAgeable((Ageable) entity);
|
||||||
storeLiving((LivingEntity) entity);
|
storeLiving((LivingEntity) entity);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
// END TAMEABLE //
|
// END TAMEABLE //
|
||||||
case SHEEP: {
|
case SHEEP:
|
||||||
Sheep sheep = (Sheep) entity;
|
Sheep sheep = (Sheep) entity;
|
||||||
this.dataByte = (byte) (sheep.isSheared() ? 1 : 0);
|
this.dataByte = (byte) (sheep.isSheared() ? 1 : 0);
|
||||||
this.dataByte2 = sheep.getColor().getDyeData();
|
this.dataByte2 = sheep.getColor().getDyeData();
|
||||||
storeAgeable((Ageable) entity);
|
storeAgeable((Ageable) entity);
|
||||||
storeLiving((LivingEntity) entity);
|
storeLiving((LivingEntity) entity);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
case VILLAGER:
|
case VILLAGER:
|
||||||
case CHICKEN:
|
case CHICKEN:
|
||||||
case COW:
|
case COW:
|
||||||
case MUSHROOM_COW:
|
case MUSHROOM_COW:
|
||||||
case PIG: {
|
case PIG:
|
||||||
storeAgeable((Ageable) entity);
|
storeAgeable((Ageable) entity);
|
||||||
storeLiving((LivingEntity) entity);
|
storeLiving((LivingEntity) entity);
|
||||||
return;
|
return;
|
||||||
}
|
case RABBIT: // NEW
|
||||||
// END AGEABLE //
|
|
||||||
case RABBIT: { // NEW
|
|
||||||
this.dataByte = getOrdinal(Type.values(), ((Rabbit) entity).getRabbitType());
|
this.dataByte = getOrdinal(Type.values(), ((Rabbit) entity).getRabbitType());
|
||||||
storeAgeable((Ageable) entity);
|
storeAgeable((Ageable) entity);
|
||||||
storeLiving((LivingEntity) entity);
|
storeLiving((LivingEntity) entity);
|
||||||
return;
|
return;
|
||||||
}
|
// END AGEABLE //
|
||||||
case GUARDIAN: { // NEW
|
case GUARDIAN: // NEW
|
||||||
this.dataByte = (byte) (((Guardian) entity).isElder() ? 1 : 0);
|
this.dataByte = (byte) (((Guardian) entity).isElder() ? 1 : 0);
|
||||||
storeLiving((LivingEntity) entity);
|
storeLiving((LivingEntity) entity);
|
||||||
return;
|
return;
|
||||||
}
|
case SKELETON: // NEW
|
||||||
case SKELETON: { // NEW
|
|
||||||
this.dataByte = (byte) ((Skeleton) entity).getSkeletonType().getId();
|
this.dataByte = (byte) ((Skeleton) entity).getSkeletonType().getId();
|
||||||
storeLiving((LivingEntity) entity);
|
storeLiving((LivingEntity) entity);
|
||||||
return;
|
return;
|
||||||
}
|
case ARMOR_STAND: // NEW
|
||||||
case ARMOR_STAND: { // NEW
|
|
||||||
// CHECK positions
|
// CHECK positions
|
||||||
ArmorStand stand = (ArmorStand) entity;
|
ArmorStand stand = (ArmorStand) entity;
|
||||||
this.inventory = new ItemStack[]{stand.getItemInHand().clone(), stand.getHelmet().clone(), stand.getChestplate().clone(),
|
this.inventory = new ItemStack[]{stand.getItemInHand().clone(), stand.getHelmet().clone(), stand.getChestplate().clone(),
|
||||||
@ -271,7 +264,6 @@ public class EntityWrapper {
|
|||||||
this.stand.small = true;
|
this.stand.small = true;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
case ENDERMITE: // NEW
|
case ENDERMITE: // NEW
|
||||||
case BAT:
|
case BAT:
|
||||||
case ENDER_DRAGON:
|
case ENDER_DRAGON:
|
||||||
@ -289,11 +281,10 @@ public class EntityWrapper {
|
|||||||
case ENDERMAN:
|
case ENDERMAN:
|
||||||
case CREEPER:
|
case CREEPER:
|
||||||
case BLAZE:
|
case BLAZE:
|
||||||
|
case SHULKER:
|
||||||
case SNOWMAN:
|
case SNOWMAN:
|
||||||
case IRON_GOLEM: {
|
case IRON_GOLEM:
|
||||||
storeLiving((LivingEntity) entity);
|
storeLiving((LivingEntity) entity);
|
||||||
return;
|
|
||||||
}
|
|
||||||
// END LIVING //
|
// END LIVING //
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -318,7 +309,7 @@ public class EntityWrapper {
|
|||||||
entity.setCustomName(this.lived.name);
|
entity.setCustomName(this.lived.name);
|
||||||
entity.setCustomNameVisible(this.lived.visible);
|
entity.setCustomNameVisible(this.lived.visible);
|
||||||
}
|
}
|
||||||
if ((this.lived.potions != null) && !this.lived.potions.isEmpty()) {
|
if (this.lived.potions != null && !this.lived.potions.isEmpty()) {
|
||||||
entity.addPotionEffects(this.lived.potions);
|
entity.addPotionEffects(this.lived.potions);
|
||||||
}
|
}
|
||||||
entity.setRemainingAir(this.lived.air);
|
entity.setRemainingAir(this.lived.air);
|
||||||
@ -413,21 +404,17 @@ public class EntityWrapper {
|
|||||||
}
|
}
|
||||||
Entity entity;
|
Entity entity;
|
||||||
switch (this.type) {
|
switch (this.type) {
|
||||||
case DROPPED_ITEM: {
|
case DROPPED_ITEM:
|
||||||
return world.dropItem(loc, this.stack);
|
return world.dropItem(loc, this.stack);
|
||||||
}
|
|
||||||
case PLAYER:
|
case PLAYER:
|
||||||
case LEASH_HITCH: {
|
case LEASH_HITCH:
|
||||||
return null;
|
return null;
|
||||||
}
|
case ITEM_FRAME:
|
||||||
case ITEM_FRAME: {
|
|
||||||
entity = world.spawn(loc, ItemFrame.class);
|
entity = world.spawn(loc, ItemFrame.class);
|
||||||
break;
|
break;
|
||||||
}
|
case PAINTING:
|
||||||
case PAINTING: {
|
|
||||||
entity = world.spawn(loc, Painting.class);
|
entity = world.spawn(loc, Painting.class);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
entity = world.spawnEntity(loc, this.type);
|
entity = world.spawnEntity(loc, this.type);
|
||||||
break;
|
break;
|
||||||
@ -483,38 +470,33 @@ public class EntityWrapper {
|
|||||||
case WEATHER:
|
case WEATHER:
|
||||||
case WITHER_SKULL:
|
case WITHER_SKULL:
|
||||||
case MINECART_FURNACE:
|
case MINECART_FURNACE:
|
||||||
case UNKNOWN: {
|
case UNKNOWN:
|
||||||
// Do this stuff later
|
// Do this stuff later
|
||||||
return entity;
|
return entity;
|
||||||
}
|
default:
|
||||||
default: {
|
|
||||||
PS.debug("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType());
|
PS.debug("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType());
|
||||||
return entity;
|
return entity;
|
||||||
}
|
|
||||||
// MISC //
|
// MISC //
|
||||||
case ITEM_FRAME: {
|
case ITEM_FRAME:
|
||||||
ItemFrame itemframe = (ItemFrame) entity;
|
ItemFrame itemframe = (ItemFrame) entity;
|
||||||
itemframe.setRotation(Rotation.values()[this.dataByte]);
|
itemframe.setRotation(Rotation.values()[this.dataByte]);
|
||||||
itemframe.setItem(this.stack);
|
itemframe.setItem(this.stack);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
case PAINTING:
|
||||||
case PAINTING: {
|
|
||||||
Painting painting = (Painting) entity;
|
Painting painting = (Painting) entity;
|
||||||
painting.setFacingDirection(BlockFace.values()[this.dataByte], true);
|
painting.setFacingDirection(BlockFace.values()[this.dataByte], true);
|
||||||
painting.setArt(Art.getByName(this.dataString), true);
|
painting.setArt(Art.getByName(this.dataString), true);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
|
||||||
// END MISC //
|
// END MISC //
|
||||||
// INVENTORY HOLDER //
|
// INVENTORY HOLDER //
|
||||||
case MINECART_CHEST:
|
case MINECART_CHEST:
|
||||||
case MINECART_HOPPER: {
|
case MINECART_HOPPER:
|
||||||
restoreInventory((InventoryHolder) entity);
|
restoreInventory((InventoryHolder) entity);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
|
||||||
// START LIVING ENTITY //
|
// START LIVING ENTITY //
|
||||||
// START AGEABLE //
|
// START AGEABLE //
|
||||||
// START TAMEABLE //
|
// START TAMEABLE //
|
||||||
case HORSE: {
|
case HORSE:
|
||||||
Horse horse = (Horse) entity;
|
Horse horse = (Horse) entity;
|
||||||
horse.setJumpStrength(this.horse.jump);
|
horse.setJumpStrength(this.horse.jump);
|
||||||
horse.setCarryingChest(this.horse.chest);
|
horse.setCarryingChest(this.horse.chest);
|
||||||
@ -526,17 +508,15 @@ public class EntityWrapper {
|
|||||||
restoreLiving((LivingEntity) entity);
|
restoreLiving((LivingEntity) entity);
|
||||||
restoreInventory((InventoryHolder) entity);
|
restoreInventory((InventoryHolder) entity);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
|
||||||
// END INVENTORY HOLDER //
|
// END INVENTORY HOLDER //
|
||||||
case WOLF:
|
case WOLF:
|
||||||
case OCELOT: {
|
case OCELOT:
|
||||||
restoreTameable((Tameable) entity);
|
restoreTameable((Tameable) entity);
|
||||||
restoreAgeable((Ageable) entity);
|
restoreAgeable((Ageable) entity);
|
||||||
restoreLiving((LivingEntity) entity);
|
restoreLiving((LivingEntity) entity);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
|
||||||
// END AGEABLE //
|
// END AGEABLE //
|
||||||
case SHEEP: {
|
case SHEEP:
|
||||||
Sheep sheep = (Sheep) entity;
|
Sheep sheep = (Sheep) entity;
|
||||||
if (this.dataByte == 1) {
|
if (this.dataByte == 1) {
|
||||||
sheep.setSheared(true);
|
sheep.setSheared(true);
|
||||||
@ -547,40 +527,35 @@ public class EntityWrapper {
|
|||||||
restoreAgeable((Ageable) entity);
|
restoreAgeable((Ageable) entity);
|
||||||
restoreLiving((LivingEntity) entity);
|
restoreLiving((LivingEntity) entity);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
|
||||||
case VILLAGER:
|
case VILLAGER:
|
||||||
case CHICKEN:
|
case CHICKEN:
|
||||||
case COW:
|
case COW:
|
||||||
case MUSHROOM_COW:
|
case MUSHROOM_COW:
|
||||||
case PIG: {
|
case PIG:
|
||||||
restoreAgeable((Ageable) entity);
|
restoreAgeable((Ageable) entity);
|
||||||
restoreLiving((LivingEntity) entity);
|
restoreLiving((LivingEntity) entity);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
|
||||||
// END AGEABLE //
|
// END AGEABLE //
|
||||||
case RABBIT: { // NEW
|
case RABBIT: // NEW
|
||||||
if (this.dataByte != 0) {
|
if (this.dataByte != 0) {
|
||||||
((Rabbit) entity).setRabbitType(Type.values()[this.dataByte]);
|
((Rabbit) entity).setRabbitType(Type.values()[this.dataByte]);
|
||||||
}
|
}
|
||||||
restoreAgeable((Ageable) entity);
|
restoreAgeable((Ageable) entity);
|
||||||
restoreLiving((LivingEntity) entity);
|
restoreLiving((LivingEntity) entity);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
case GUARDIAN: // NEW
|
||||||
case GUARDIAN: { // NEW
|
|
||||||
if (this.dataByte != 0) {
|
if (this.dataByte != 0) {
|
||||||
((Guardian) entity).setElder(true);
|
((Guardian) entity).setElder(true);
|
||||||
}
|
}
|
||||||
restoreLiving((LivingEntity) entity);
|
restoreLiving((LivingEntity) entity);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
case SKELETON: // NEW
|
||||||
case SKELETON: { // NEW
|
|
||||||
if (this.dataByte != 0) {
|
if (this.dataByte != 0) {
|
||||||
((Skeleton) entity).setSkeletonType(SkeletonType.values()[this.dataByte]);
|
((Skeleton) entity).setSkeletonType(SkeletonType.values()[this.dataByte]);
|
||||||
}
|
}
|
||||||
storeLiving((LivingEntity) entity);
|
storeLiving((LivingEntity) entity);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
case ARMOR_STAND: // NEW
|
||||||
case ARMOR_STAND: { // NEW
|
|
||||||
// CHECK positions
|
// CHECK positions
|
||||||
ArmorStand stand = (ArmorStand) entity;
|
ArmorStand stand = (ArmorStand) entity;
|
||||||
if (this.inventory[0] != null) {
|
if (this.inventory[0] != null) {
|
||||||
@ -598,27 +573,27 @@ public class EntityWrapper {
|
|||||||
if (this.inventory[4] != null) {
|
if (this.inventory[4] != null) {
|
||||||
stand.setBoots(this.inventory[4]);
|
stand.setBoots(this.inventory[4]);
|
||||||
}
|
}
|
||||||
if ((this.stand.head[0] != 0) || (this.stand.head[1] != 0) || (this.stand.head[2] != 0)) {
|
if (this.stand.head[0] != 0 || this.stand.head[1] != 0 || this.stand.head[2] != 0) {
|
||||||
EulerAngle pose = new EulerAngle(this.stand.head[0], this.stand.head[1], this.stand.head[2]);
|
EulerAngle pose = new EulerAngle(this.stand.head[0], this.stand.head[1], this.stand.head[2]);
|
||||||
stand.setHeadPose(pose);
|
stand.setHeadPose(pose);
|
||||||
}
|
}
|
||||||
if ((this.stand.body[0] != 0) || (this.stand.body[1] != 0) || (this.stand.body[2] != 0)) {
|
if (this.stand.body[0] != 0 || this.stand.body[1] != 0 || this.stand.body[2] != 0) {
|
||||||
EulerAngle pose = new EulerAngle(this.stand.body[0], this.stand.body[1], this.stand.body[2]);
|
EulerAngle pose = new EulerAngle(this.stand.body[0], this.stand.body[1], this.stand.body[2]);
|
||||||
stand.setBodyPose(pose);
|
stand.setBodyPose(pose);
|
||||||
}
|
}
|
||||||
if ((this.stand.leftLeg[0] != 0) || (this.stand.leftLeg[1] != 0) || (this.stand.leftLeg[2] != 0)) {
|
if (this.stand.leftLeg[0] != 0 || this.stand.leftLeg[1] != 0 || this.stand.leftLeg[2] != 0) {
|
||||||
EulerAngle pose = new EulerAngle(this.stand.leftLeg[0], this.stand.leftLeg[1], this.stand.leftLeg[2]);
|
EulerAngle pose = new EulerAngle(this.stand.leftLeg[0], this.stand.leftLeg[1], this.stand.leftLeg[2]);
|
||||||
stand.setLeftLegPose(pose);
|
stand.setLeftLegPose(pose);
|
||||||
}
|
}
|
||||||
if ((this.stand.rightLeg[0] != 0) || (this.stand.rightLeg[1] != 0) || (this.stand.rightLeg[2] != 0)) {
|
if (this.stand.rightLeg[0] != 0 || this.stand.rightLeg[1] != 0 || this.stand.rightLeg[2] != 0) {
|
||||||
EulerAngle pose = new EulerAngle(this.stand.rightLeg[0], this.stand.rightLeg[1], this.stand.rightLeg[2]);
|
EulerAngle pose = new EulerAngle(this.stand.rightLeg[0], this.stand.rightLeg[1], this.stand.rightLeg[2]);
|
||||||
stand.setRightLegPose(pose);
|
stand.setRightLegPose(pose);
|
||||||
}
|
}
|
||||||
if ((this.stand.leftArm[0] != 0) || (this.stand.leftArm[1] != 0) || (this.stand.leftArm[2] != 0)) {
|
if (this.stand.leftArm[0] != 0 || this.stand.leftArm[1] != 0 || this.stand.leftArm[2] != 0) {
|
||||||
EulerAngle pose = new EulerAngle(this.stand.leftArm[0], this.stand.leftArm[1], this.stand.leftArm[2]);
|
EulerAngle pose = new EulerAngle(this.stand.leftArm[0], this.stand.leftArm[1], this.stand.leftArm[2]);
|
||||||
stand.setLeftArmPose(pose);
|
stand.setLeftArmPose(pose);
|
||||||
}
|
}
|
||||||
if ((this.stand.rightArm[0] != 0) || (this.stand.rightArm[1] != 0) || (this.stand.rightArm[2] != 0)) {
|
if (this.stand.rightArm[0] != 0 || this.stand.rightArm[1] != 0 || this.stand.rightArm[2] != 0) {
|
||||||
EulerAngle pose = new EulerAngle(this.stand.rightArm[0], this.stand.rightArm[1], this.stand.rightArm[2]);
|
EulerAngle pose = new EulerAngle(this.stand.rightArm[0], this.stand.rightArm[1], this.stand.rightArm[2]);
|
||||||
stand.setRightArmPose(pose);
|
stand.setRightArmPose(pose);
|
||||||
}
|
}
|
||||||
@ -639,7 +614,6 @@ public class EntityWrapper {
|
|||||||
}
|
}
|
||||||
restoreLiving((LivingEntity) entity);
|
restoreLiving((LivingEntity) entity);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
|
||||||
case ENDERMITE: // NEW
|
case ENDERMITE: // NEW
|
||||||
case BAT:
|
case BAT:
|
||||||
case ENDER_DRAGON:
|
case ENDER_DRAGON:
|
||||||
@ -658,10 +632,9 @@ public class EntityWrapper {
|
|||||||
case CREEPER:
|
case CREEPER:
|
||||||
case BLAZE:
|
case BLAZE:
|
||||||
case SNOWMAN:
|
case SNOWMAN:
|
||||||
case IRON_GOLEM: {
|
case IRON_GOLEM:
|
||||||
restoreLiving((LivingEntity) entity);
|
restoreLiving((LivingEntity) entity);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
|
||||||
// END LIVING //
|
// END LIVING //
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,9 +44,9 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
|||||||
final Location bot = corners[0];
|
final Location bot = corners[0];
|
||||||
Location top = corners[1];
|
Location top = corners[1];
|
||||||
|
|
||||||
final int width = (top.getX() - bot.getX()) + 1;
|
final int width = top.getX() - bot.getX() + 1;
|
||||||
int height = (top.getY() - bot.getY()) + 1;
|
int height = top.getY() - bot.getY() + 1;
|
||||||
final int length = (top.getZ() - bot.getZ()) + 1;
|
final int length = top.getZ() - bot.getZ() + 1;
|
||||||
// Main Schematic tag
|
// Main Schematic tag
|
||||||
final HashMap<String, Tag> schematic = new HashMap<>();
|
final HashMap<String, Tag> schematic = new HashMap<>();
|
||||||
schematic.put("Width", new ShortTag("Width", (short) width));
|
schematic.put("Width", new ShortTag("Width", (short) width));
|
||||||
@ -114,7 +113,7 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
while (!chunks.isEmpty() && ((System.currentTimeMillis() - start) < 20)) {
|
while (!chunks.isEmpty() && System.currentTimeMillis() - start < 20) {
|
||||||
// save schematics
|
// save schematics
|
||||||
ChunkLoc chunk = chunks.remove(0);
|
ChunkLoc chunk = chunks.remove(0);
|
||||||
Chunk bc = worldObj.getChunkAt(chunk.x, chunk.z);
|
Chunk bc = worldObj.getChunkAt(chunk.x, chunk.z);
|
||||||
@ -145,7 +144,7 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
|||||||
int i1 = ry * width * length;
|
int i1 = ry * width * length;
|
||||||
for (int z = zzb; z <= zzt; z++) {
|
for (int z = zzb; z <= zzt; z++) {
|
||||||
int rz = z - bz;
|
int rz = z - bz;
|
||||||
int i2 = i1 + (rz * width);
|
int i2 = i1 + rz * width;
|
||||||
for (int x = xxb; x <= xxt; x++) {
|
for (int x = xxb; x <= xxt; x++) {
|
||||||
int rx = x - bx;
|
int rx = x - bx;
|
||||||
int index = i2 + rx;
|
int index = i2 + rx;
|
||||||
@ -219,9 +218,8 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
|||||||
case 189:
|
case 189:
|
||||||
case 190:
|
case 190:
|
||||||
case 191:
|
case 191:
|
||||||
case 192: {
|
case 192:
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case 54:
|
case 54:
|
||||||
case 130:
|
case 130:
|
||||||
case 142:
|
case 142:
|
||||||
@ -256,17 +254,14 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
|||||||
case 29:
|
case 29:
|
||||||
case 33:
|
case 33:
|
||||||
case 151:
|
case 151:
|
||||||
case 178: {
|
case 178:
|
||||||
// TODO implement fully
|
// TODO implement fully
|
||||||
BlockState state = block.getState();
|
BlockState state = block.getState();
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
StateWrapper wrapper = new StateWrapper(state);
|
StateWrapper wrapper = new StateWrapper(state);
|
||||||
CompoundTag rawTag = wrapper.getTag();
|
CompoundTag rawTag = wrapper.getTag();
|
||||||
if (rawTag != null) {
|
if (rawTag != null) {
|
||||||
Map<String, Tag> values = new HashMap<>();
|
Map<String, Tag> values = new HashMap<>(rawTag.getValue());
|
||||||
for (Entry<String, Tag> entry : rawTag.getValue().entrySet()) {
|
|
||||||
values.put(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
values.put("id", new StringTag("id", wrapper.getId()));
|
values.put("id", new StringTag("id", wrapper.getId()));
|
||||||
values.put("x", new IntTag("x", x));
|
values.put("x", new IntTag("x", x));
|
||||||
values.put("y", new IntTag("y", y));
|
values.put("y", new IntTag("y", y));
|
||||||
@ -275,11 +270,9 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
|||||||
tileEntities.add(tileEntityTag);
|
tileEntities.add(tileEntityTag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
default:
|
||||||
default: {
|
|
||||||
blockData[index] = block.getData();
|
blockData[index] = block.getData();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// For optimization reasons, we are not supporting custom data types
|
// For optimization reasons, we are not supporting custom data types
|
||||||
// Especially since the most likely reason beyond this range is modded servers in which the blocks
|
// Especially since the most likely reason beyond this range is modded servers in which the blocks
|
||||||
// have NBT
|
// have NBT
|
||||||
|
@ -75,7 +75,7 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||||||
options.put("generator.type", object.type);
|
options.put("generator.type", object.type);
|
||||||
options.put("generator.terrain", object.terrain);
|
options.put("generator.terrain", object.terrain);
|
||||||
options.put("generator.plugin", object.plotManager);
|
options.put("generator.plugin", object.plotManager);
|
||||||
if ((object.setupGenerator != null) && !object.setupGenerator.equals(object.plotManager)) {
|
if (object.setupGenerator != null && !object.setupGenerator.equals(object.plotManager)) {
|
||||||
options.put("generator.init", object.setupGenerator);
|
options.put("generator.init", object.setupGenerator);
|
||||||
}
|
}
|
||||||
for (Entry<String, Object> entry : options.entrySet()) {
|
for (Entry<String, Object> entry : options.entrySet()) {
|
||||||
@ -91,42 +91,40 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GeneratorWrapper<?> gen = generators.get(object.setupGenerator);
|
GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);
|
||||||
if ((gen != null) && gen.isFull()) {
|
if (gen != null && gen.isFull()) {
|
||||||
object.setupGenerator = null;
|
object.setupGenerator = null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1: {
|
case 1:
|
||||||
for (ConfigurationNode step : steps) {
|
for (ConfigurationNode step : steps) {
|
||||||
worldSection.set(step.getConstant(), step.getValue());
|
worldSection.set(step.getConstant(), step.getValue());
|
||||||
}
|
}
|
||||||
PS.get().config.set("worlds." + world + "." + "generator.type", object.type);
|
PS.get().config.set("worlds." + world + "." + "generator.type", object.type);
|
||||||
PS.get().config.set("worlds." + world + "." + "generator.terrain", object.terrain);
|
PS.get().config.set("worlds." + world + "." + "generator.terrain", object.terrain);
|
||||||
PS.get().config.set("worlds." + world + "." + "generator.plugin", object.plotManager);
|
PS.get().config.set("worlds." + world + "." + "generator.plugin", object.plotManager);
|
||||||
if ((object.setupGenerator != null) && !object.setupGenerator.equals(object.plotManager)) {
|
if (object.setupGenerator != null && !object.setupGenerator.equals(object.plotManager)) {
|
||||||
PS.get().config.set("worlds." + world + "." + "generator.init", object.setupGenerator);
|
PS.get().config.set("worlds." + world + "." + "generator.init", object.setupGenerator);
|
||||||
}
|
}
|
||||||
GeneratorWrapper<?> gen = generators.get(object.setupGenerator);
|
GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);
|
||||||
if ((gen != null) && gen.isFull()) {
|
if (gen != null && gen.isFull()) {
|
||||||
object.setupGenerator = null;
|
object.setupGenerator = null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
case 0:
|
||||||
case 0: {
|
|
||||||
for (ConfigurationNode step : steps) {
|
for (ConfigurationNode step : steps) {
|
||||||
worldSection.set(step.getConstant(), step.getValue());
|
worldSection.set(step.getConstant(), step.getValue());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
PS.get().config.save(PS.get().configFile);
|
PS.get().config.save(PS.get().configFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (object.setupGenerator != null) {
|
if (object.setupGenerator != null) {
|
||||||
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core")
|
if (Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null && Bukkit.getPluginManager().getPlugin("Multiverse-Core")
|
||||||
.isEnabled()) {
|
.isEnabled()) {
|
||||||
Bukkit.getServer()
|
Bukkit.getServer()
|
||||||
.dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal -g " + object.setupGenerator);
|
.dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal -g " + object.setupGenerator);
|
||||||
@ -135,7 +133,7 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
if (Bukkit.getPluginManager().getPlugin("MultiWorld") != null && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world + " plugin:" + object.setupGenerator);
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world + " plugin:" + object.setupGenerator);
|
||||||
setGenerator(world, object.setupGenerator);
|
setGenerator(world, object.setupGenerator);
|
||||||
if (Bukkit.getWorld(world) != null) {
|
if (Bukkit.getWorld(world) != null) {
|
||||||
@ -148,14 +146,14 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||||||
Bukkit.createWorld(wc);
|
Bukkit.createWorld(wc);
|
||||||
setGenerator(world, object.setupGenerator);
|
setGenerator(world, object.setupGenerator);
|
||||||
} else {
|
} else {
|
||||||
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core")
|
if (Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null && Bukkit.getPluginManager().getPlugin("Multiverse-Core")
|
||||||
.isEnabled()) {
|
.isEnabled()) {
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal");
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal");
|
||||||
if (Bukkit.getWorld(world) != null) {
|
if (Bukkit.getWorld(world) != null) {
|
||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
if (Bukkit.getPluginManager().getPlugin("MultiWorld") != null && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world);
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world);
|
||||||
if (Bukkit.getWorld(world) != null) {
|
if (Bukkit.getWorld(world) != null) {
|
||||||
return world;
|
return world;
|
||||||
@ -193,7 +191,7 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||||||
if (!(generator instanceof BukkitPlotGenerator)) {
|
if (!(generator instanceof BukkitPlotGenerator)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
for (Entry<String, GeneratorWrapper<?>> entry : generators.entrySet()) {
|
for (Entry<String, GeneratorWrapper<?>> entry : SetupUtils.generators.entrySet()) {
|
||||||
GeneratorWrapper<?> current = entry.getValue();
|
GeneratorWrapper<?> current = entry.getValue();
|
||||||
if (current.equals(generator)) {
|
if (current.equals(generator)) {
|
||||||
return entry.getKey();
|
return entry.getKey();
|
||||||
|
@ -59,7 +59,7 @@ public class FastQueue_1_8 extends SlowQueue {
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
ArrayList<Chunk> chunks = new ArrayList<Chunk>();
|
ArrayList<Chunk> chunks = new ArrayList<Chunk>();
|
||||||
Iterator<Entry<ChunkWrapper, Chunk>> i = FastQueue_1_8.this.toUpdate.entrySet().iterator();
|
Iterator<Entry<ChunkWrapper, Chunk>> i = FastQueue_1_8.this.toUpdate.entrySet().iterator();
|
||||||
while (i.hasNext() && (count < 128)) {
|
while (i.hasNext() && count < 128) {
|
||||||
chunks.add(i.next().getValue());
|
chunks.add(i.next().getValue());
|
||||||
i.remove();
|
i.remove();
|
||||||
count++;
|
count++;
|
||||||
@ -161,7 +161,7 @@ public class FastQueue_1_8 extends SlowQueue {
|
|||||||
case 29:
|
case 29:
|
||||||
case 33:
|
case 33:
|
||||||
case 151:
|
case 151:
|
||||||
case 178: {
|
case 178:
|
||||||
Block block = world.getBlockAt(x, y, z);
|
Block block = world.getBlockAt(x, y, z);
|
||||||
if (block.getData() == newBlock.data) {
|
if (block.getData() == newBlock.data) {
|
||||||
if (block.getTypeId() != newBlock.id) {
|
if (block.getTypeId() != newBlock.id) {
|
||||||
@ -176,7 +176,6 @@ public class FastQueue_1_8 extends SlowQueue {
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Start data value shortcut
|
// Start data value shortcut
|
||||||
Block block = world.getBlockAt(x, y, z);
|
Block block = world.getBlockAt(x, y, z);
|
||||||
@ -263,10 +262,9 @@ public class FastQueue_1_8 extends SlowQueue {
|
|||||||
case 189:
|
case 189:
|
||||||
case 190:
|
case 190:
|
||||||
case 191:
|
case 191:
|
||||||
case 192: {
|
case 192:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (block.getData() == newBlock.data) {
|
if (block.getData() == newBlock.data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -311,7 +309,7 @@ public class FastQueue_1_8 extends SlowQueue {
|
|||||||
case 29:
|
case 29:
|
||||||
case 33:
|
case 33:
|
||||||
case 151:
|
case 151:
|
||||||
case 178: {
|
case 178:
|
||||||
if (block.getData() == newBlock.data) {
|
if (block.getData() == newBlock.data) {
|
||||||
block.setTypeId(newBlock.id, false);
|
block.setTypeId(newBlock.id, false);
|
||||||
} else {
|
} else {
|
||||||
@ -319,7 +317,6 @@ public class FastQueue_1_8 extends SlowQueue {
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// End blockstate workaround //
|
// End blockstate workaround //
|
||||||
|
|
||||||
// check sign
|
// check sign
|
||||||
|
@ -230,7 +230,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
|||||||
setType.call(x, y & 15, z, this.air);
|
setType.call(x, y & 15, z, this.air);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
default: {
|
default:
|
||||||
int x = MainUtil.x_loc[j][k];
|
int x = MainUtil.x_loc[j][k];
|
||||||
int y = MainUtil.y_loc[j][k];
|
int y = MainUtil.y_loc[j][k];
|
||||||
int z = MainUtil.z_loc[j][k];
|
int z = MainUtil.z_loc[j][k];
|
||||||
@ -238,7 +238,6 @@ public class FastQueue_1_9 extends SlowQueue {
|
|||||||
setType.call(x, y & 15, z, iBlock);
|
setType.call(x, y & 15, z, iBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (fill) {
|
if (fill) {
|
||||||
fs.setCount(j, Short.MAX_VALUE);
|
fs.setCount(j, Short.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
* Creates an empty {@link FileConfiguration} with no default values.
|
* Creates an empty {@link FileConfiguration} with no default values.
|
||||||
*/
|
*/
|
||||||
public FileConfiguration() {
|
public FileConfiguration() {
|
||||||
super();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,7 +34,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
*
|
*
|
||||||
* @param defaults Default value provider
|
* @param defaults Default value provider
|
||||||
*/
|
*/
|
||||||
public FileConfiguration(final Configuration defaults) {
|
public FileConfiguration(Configuration defaults) {
|
||||||
super(defaults);
|
super(defaults);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,13 +53,13 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
* any reason.
|
* any reason.
|
||||||
* @throws IllegalArgumentException Thrown when file is null.
|
* @throws IllegalArgumentException Thrown when file is null.
|
||||||
*/
|
*/
|
||||||
public void save(final File file) throws IOException {
|
public void save(File file) throws IOException {
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
throw new NullPointerException("File cannot be null");
|
throw new NullPointerException("File cannot be null");
|
||||||
}
|
}
|
||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
|
|
||||||
final String data = saveToString();
|
String data = saveToString();
|
||||||
|
|
||||||
try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) {
|
try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) {
|
||||||
writer.write(data);
|
writer.write(data);
|
||||||
@ -82,7 +81,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
* any reason.
|
* any reason.
|
||||||
* @throws IllegalArgumentException Thrown when file is null.
|
* @throws IllegalArgumentException Thrown when file is null.
|
||||||
*/
|
*/
|
||||||
public void save(final String file) throws IOException {
|
public void save(String file) throws IOException {
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
throw new NullPointerException("File cannot be null");
|
throw new NullPointerException("File cannot be null");
|
||||||
}
|
}
|
||||||
@ -116,12 +115,12 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
* a valid Configuration.
|
* a valid Configuration.
|
||||||
* @throws IllegalArgumentException Thrown when file is null.
|
* @throws IllegalArgumentException Thrown when file is null.
|
||||||
*/
|
*/
|
||||||
public void load(final File file) throws IOException, InvalidConfigurationException {
|
public void load(File file) throws IOException, InvalidConfigurationException {
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
throw new NullPointerException("File cannot be null");
|
throw new NullPointerException("File cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
final FileInputStream stream = new FileInputStream(file);
|
FileInputStream stream = new FileInputStream(file);
|
||||||
|
|
||||||
load(new InputStreamReader(stream, StandardCharsets.UTF_8));
|
load(new InputStreamReader(stream, StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
@ -139,9 +138,9 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
* represent a valid Configuration
|
* represent a valid Configuration
|
||||||
* @throws IllegalArgumentException thrown when reader is null
|
* @throws IllegalArgumentException thrown when reader is null
|
||||||
*/
|
*/
|
||||||
public void load(final Reader reader) throws IOException, InvalidConfigurationException {
|
public void load(Reader reader) throws IOException, InvalidConfigurationException {
|
||||||
|
|
||||||
final StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
try (BufferedReader input = reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader)) {
|
try (BufferedReader input = reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader)) {
|
||||||
String line;
|
String line;
|
||||||
@ -173,7 +172,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
* a valid Configuration.
|
* a valid Configuration.
|
||||||
* @throws IllegalArgumentException Thrown when file is null.
|
* @throws IllegalArgumentException Thrown when file is null.
|
||||||
*/
|
*/
|
||||||
public void load(final String file) throws IOException, InvalidConfigurationException {
|
public void load(String file) throws IOException, InvalidConfigurationException {
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
throw new NullPointerException("File cannot be null");
|
throw new NullPointerException("File cannot be null");
|
||||||
}
|
}
|
||||||
@ -196,7 +195,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
* invalid.
|
* invalid.
|
||||||
* @throws IllegalArgumentException Thrown if contents is null.
|
* @throws IllegalArgumentException Thrown if contents is null.
|
||||||
*/
|
*/
|
||||||
public abstract void loadFromString(final String contents) throws InvalidConfigurationException;
|
public abstract void loadFromString(String contents) throws InvalidConfigurationException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles the header for this {@link FileConfiguration} and returns the
|
* Compiles the header for this {@link FileConfiguration} and returns the
|
||||||
@ -212,10 +211,10 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileConfigurationOptions options() {
|
public FileConfigurationOptions options() {
|
||||||
if (options == null) {
|
if (this.options == null) {
|
||||||
options = new FileConfigurationOptions(this);
|
this.options = new FileConfigurationOptions(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (FileConfigurationOptions) options;
|
return (FileConfigurationOptions) this.options;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ package com.intellectualcrafters.jnbt;
|
|||||||
* The {@code TAG_Byte_Array} tag.
|
* The {@code TAG_Byte_Array} tag.
|
||||||
*/
|
*/
|
||||||
public final class ByteArrayTag extends Tag {
|
public final class ByteArrayTag extends Tag {
|
||||||
|
|
||||||
private final byte[] value;
|
private final byte[] value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11,8 +12,7 @@ public final class ByteArrayTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @param value the value of the tag
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public ByteArrayTag(final byte[] value) {
|
public ByteArrayTag(byte[] value) {
|
||||||
super();
|
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,29 +22,29 @@ public final class ByteArrayTag extends Tag {
|
|||||||
* @param name the name of the tag
|
* @param name the name of the tag
|
||||||
* @param value the value of the tag
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public ByteArrayTag(final String name, final byte[] value) {
|
public ByteArrayTag(String name, byte[] value) {
|
||||||
super(name);
|
super(name);
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] getValue() {
|
public byte[] getValue() {
|
||||||
return value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final StringBuilder hex = new StringBuilder();
|
StringBuilder hex = new StringBuilder();
|
||||||
for (final byte b : value) {
|
for (byte b : this.value) {
|
||||||
final String hexDigits = Integer.toHexString(b).toUpperCase();
|
String hexDigits = Integer.toHexString(b).toUpperCase();
|
||||||
if (hexDigits.length() == 1) {
|
if (hexDigits.length() == 1) {
|
||||||
hex.append("0");
|
hex.append("0");
|
||||||
}
|
}
|
||||||
hex.append(hexDigits).append(" ");
|
hex.append(hexDigits).append(" ");
|
||||||
}
|
}
|
||||||
final String name = getName();
|
String name = getName();
|
||||||
String append = "";
|
String append = "";
|
||||||
if ((name != null) && !name.equals("")) {
|
if (name != null && !name.equals("")) {
|
||||||
append = "(\"" + getName() + "\")";
|
append = "(\"" + getName() + "\")";
|
||||||
}
|
}
|
||||||
return "TAG_Byte_Array" + append + ": " + hex;
|
return "TAG_Byte_Array" + append + ": " + hex;
|
||||||
|
@ -4,6 +4,7 @@ package com.intellectualcrafters.jnbt;
|
|||||||
* The {@code TAG_Byte} tag.
|
* The {@code TAG_Byte} tag.
|
||||||
*/
|
*/
|
||||||
public final class ByteTag extends Tag {
|
public final class ByteTag extends Tag {
|
||||||
|
|
||||||
private final byte value;
|
private final byte value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11,8 +12,7 @@ public final class ByteTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @param value the value of the tag
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public ByteTag(final byte value) {
|
public ByteTag(byte value) {
|
||||||
super();
|
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,23 +22,23 @@ public final class ByteTag extends Tag {
|
|||||||
* @param name the name of the tag
|
* @param name the name of the tag
|
||||||
* @param value the value of the tag
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public ByteTag(final String name, final byte value) {
|
public ByteTag(String name, byte value) {
|
||||||
super(name);
|
super(name);
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Byte getValue() {
|
public Byte getValue() {
|
||||||
return value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final String name = getName();
|
String name = getName();
|
||||||
String append = "";
|
String append = "";
|
||||||
if ((name != null) && !name.equals("")) {
|
if (name != null && !name.equals("")) {
|
||||||
append = "(\"" + getName() + "\")";
|
append = "(\"" + getName() + "\")";
|
||||||
}
|
}
|
||||||
return "TAG_Byte" + append + ": " + value;
|
return "TAG_Byte" + append + ": " + this.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ public final class CompoundTag extends Tag {
|
|||||||
* @param value the value of the tag
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public CompoundTag(Map<String, Tag> value) {
|
public CompoundTag(Map<String, Tag> value) {
|
||||||
super();
|
|
||||||
this.value = Collections.unmodifiableMap(value);
|
this.value = Collections.unmodifiableMap(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,7 +373,7 @@ public final class CompoundTag extends Tag {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
String name = getName();
|
String name = getName();
|
||||||
String append = "";
|
String append = "";
|
||||||
if ((name != null) && !name.equals("")) {
|
if (name != null && !name.equals("")) {
|
||||||
append = "(\"" + getName() + "\")";
|
append = "(\"" + getName() + "\")";
|
||||||
}
|
}
|
||||||
StringBuilder bldr = new StringBuilder();
|
StringBuilder bldr = new StringBuilder();
|
||||||
|
@ -9,13 +9,14 @@ import java.util.Map;
|
|||||||
* Helps create compound tags.
|
* Helps create compound tags.
|
||||||
*/
|
*/
|
||||||
public class CompoundTagBuilder {
|
public class CompoundTagBuilder {
|
||||||
|
|
||||||
private final Map<String, Tag> entries;
|
private final Map<String, Tag> entries;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
*/
|
*/
|
||||||
CompoundTagBuilder() {
|
CompoundTagBuilder() {
|
||||||
entries = new HashMap<String, Tag>();
|
this.entries = new HashMap<String, Tag>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,9 +24,9 @@ public class CompoundTagBuilder {
|
|||||||
*
|
*
|
||||||
* @param value the value
|
* @param value the value
|
||||||
*/
|
*/
|
||||||
CompoundTagBuilder(final Map<String, Tag> value) {
|
CompoundTagBuilder(Map<String, Tag> value) {
|
||||||
checkNotNull(value);
|
checkNotNull(value);
|
||||||
entries = value;
|
this.entries = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,10 +46,10 @@ public class CompoundTagBuilder {
|
|||||||
*
|
*
|
||||||
* @return this object
|
* @return this object
|
||||||
*/
|
*/
|
||||||
public CompoundTagBuilder put(final String key, final Tag value) {
|
public CompoundTagBuilder put(String key, Tag value) {
|
||||||
checkNotNull(key);
|
checkNotNull(key);
|
||||||
checkNotNull(value);
|
checkNotNull(value);
|
||||||
entries.put(key, value);
|
this.entries.put(key, value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ public class CompoundTagBuilder {
|
|||||||
*
|
*
|
||||||
* @return this object
|
* @return this object
|
||||||
*/
|
*/
|
||||||
public CompoundTagBuilder putByteArray(final String key, final byte[] value) {
|
public CompoundTagBuilder putByteArray(String key, byte[] value) {
|
||||||
return put(key, new ByteArrayTag(key, value));
|
return put(key, new ByteArrayTag(key, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +73,7 @@ public class CompoundTagBuilder {
|
|||||||
*
|
*
|
||||||
* @return this object
|
* @return this object
|
||||||
*/
|
*/
|
||||||
public CompoundTagBuilder putByte(final String key, final byte value) {
|
public CompoundTagBuilder putByte(String key, byte value) {
|
||||||
return put(key, new ByteTag(key, value));
|
return put(key, new ByteTag(key, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +85,7 @@ public class CompoundTagBuilder {
|
|||||||
*
|
*
|
||||||
* @return this object
|
* @return this object
|
||||||
*/
|
*/
|
||||||
public CompoundTagBuilder putDouble(final String key, final double value) {
|
public CompoundTagBuilder putDouble(String key, double value) {
|
||||||
return put(key, new DoubleTag(key, value));
|
return put(key, new DoubleTag(key, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +97,7 @@ public class CompoundTagBuilder {
|
|||||||
*
|
*
|
||||||
* @return this object
|
* @return this object
|
||||||
*/
|
*/
|
||||||
public CompoundTagBuilder putFloat(final String key, final float value) {
|
public CompoundTagBuilder putFloat(String key, float value) {
|
||||||
return put(key, new FloatTag(key, value));
|
return put(key, new FloatTag(key, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +109,7 @@ public class CompoundTagBuilder {
|
|||||||
*
|
*
|
||||||
* @return this object
|
* @return this object
|
||||||
*/
|
*/
|
||||||
public CompoundTagBuilder putIntArray(final String key, final int[] value) {
|
public CompoundTagBuilder putIntArray(String key, int[] value) {
|
||||||
return put(key, new IntArrayTag(key, value));
|
return put(key, new IntArrayTag(key, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +121,7 @@ public class CompoundTagBuilder {
|
|||||||
*
|
*
|
||||||
* @return this object
|
* @return this object
|
||||||
*/
|
*/
|
||||||
public CompoundTagBuilder putInt(final String key, final int value) {
|
public CompoundTagBuilder putInt(String key, int value) {
|
||||||
return put(key, new IntTag(key, value));
|
return put(key, new IntTag(key, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +133,7 @@ public class CompoundTagBuilder {
|
|||||||
*
|
*
|
||||||
* @return this object
|
* @return this object
|
||||||
*/
|
*/
|
||||||
public CompoundTagBuilder putLong(final String key, final long value) {
|
public CompoundTagBuilder putLong(String key, long value) {
|
||||||
return put(key, new LongTag(key, value));
|
return put(key, new LongTag(key, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +145,7 @@ public class CompoundTagBuilder {
|
|||||||
*
|
*
|
||||||
* @return this object
|
* @return this object
|
||||||
*/
|
*/
|
||||||
public CompoundTagBuilder putShort(final String key, final short value) {
|
public CompoundTagBuilder putShort(String key, short value) {
|
||||||
return put(key, new ShortTag(key, value));
|
return put(key, new ShortTag(key, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +157,7 @@ public class CompoundTagBuilder {
|
|||||||
*
|
*
|
||||||
* @return this object
|
* @return this object
|
||||||
*/
|
*/
|
||||||
public CompoundTagBuilder putString(final String key, final String value) {
|
public CompoundTagBuilder putString(String key, String value) {
|
||||||
return put(key, new StringTag(key, value));
|
return put(key, new StringTag(key, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,9 +168,9 @@ public class CompoundTagBuilder {
|
|||||||
*
|
*
|
||||||
* @return this object
|
* @return this object
|
||||||
*/
|
*/
|
||||||
public CompoundTagBuilder putAll(final Map<String, ? extends Tag> value) {
|
public CompoundTagBuilder putAll(Map<String, ? extends Tag> value) {
|
||||||
checkNotNull(value);
|
checkNotNull(value);
|
||||||
for (final Map.Entry<String, ? extends Tag> entry : value.entrySet()) {
|
for (Map.Entry<String, ? extends Tag> entry : value.entrySet()) {
|
||||||
put(entry.getKey(), entry.getValue());
|
put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
@ -181,7 +182,7 @@ public class CompoundTagBuilder {
|
|||||||
* @return the new compound tag
|
* @return the new compound tag
|
||||||
*/
|
*/
|
||||||
public CompoundTag build() {
|
public CompoundTag build() {
|
||||||
return new CompoundTag(new HashMap<String, Tag>(entries));
|
return new CompoundTag(new HashMap<String, Tag>(this.entries));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -191,7 +192,7 @@ public class CompoundTagBuilder {
|
|||||||
*
|
*
|
||||||
* @return the created compound tag
|
* @return the created compound tag
|
||||||
*/
|
*/
|
||||||
public CompoundTag build(final String name) {
|
public CompoundTag build(String name) {
|
||||||
return new CompoundTag(name, new HashMap<String, Tag>(entries));
|
return new CompoundTag(name, new HashMap<String, Tag>(this.entries));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ package com.intellectualcrafters.jnbt;
|
|||||||
* The {@code TAG_Double} tag.
|
* The {@code TAG_Double} tag.
|
||||||
*/
|
*/
|
||||||
public final class DoubleTag extends Tag {
|
public final class DoubleTag extends Tag {
|
||||||
|
|
||||||
private final double value;
|
private final double value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11,8 +12,7 @@ public final class DoubleTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @param value the value of the tag
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public DoubleTag(final double value) {
|
public DoubleTag(double value) {
|
||||||
super();
|
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,23 +22,23 @@ public final class DoubleTag extends Tag {
|
|||||||
* @param name the name of the tag
|
* @param name the name of the tag
|
||||||
* @param value the value of the tag
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public DoubleTag(final String name, final double value) {
|
public DoubleTag(String name, double value) {
|
||||||
super(name);
|
super(name);
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Double getValue() {
|
public Double getValue() {
|
||||||
return value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final String name = getName();
|
String name = getName();
|
||||||
String append = "";
|
String append = "";
|
||||||
if ((name != null) && !name.equals("")) {
|
if (name != null && !name.equals("")) {
|
||||||
append = "(\"" + getName() + "\")";
|
append = "(\"" + getName() + "\")";
|
||||||
}
|
}
|
||||||
return "TAG_Double" + append + ": " + value;
|
return "TAG_Double" + append + ": " + this.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,11 @@ package com.intellectualcrafters.jnbt;
|
|||||||
* The {@code TAG_End} tag.
|
* The {@code TAG_End} tag.
|
||||||
*/
|
*/
|
||||||
public final class EndTag extends Tag {
|
public final class EndTag extends Tag {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the tag.
|
* Creates the tag.
|
||||||
*/
|
*/
|
||||||
public EndTag() {
|
public EndTag() {
|
||||||
super();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,6 +4,7 @@ package com.intellectualcrafters.jnbt;
|
|||||||
* The {@code TAG_Float} tag.
|
* The {@code TAG_Float} tag.
|
||||||
*/
|
*/
|
||||||
public final class FloatTag extends Tag {
|
public final class FloatTag extends Tag {
|
||||||
|
|
||||||
private final float value;
|
private final float value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11,8 +12,7 @@ public final class FloatTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @param value the value of the tag
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public FloatTag(final float value) {
|
public FloatTag(float value) {
|
||||||
super();
|
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,23 +22,23 @@ public final class FloatTag extends Tag {
|
|||||||
* @param name the name of the tag
|
* @param name the name of the tag
|
||||||
* @param value the value of the tag
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public FloatTag(final String name, final float value) {
|
public FloatTag(String name, float value) {
|
||||||
super(name);
|
super(name);
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Float getValue() {
|
public Float getValue() {
|
||||||
return value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final String name = getName();
|
String name = getName();
|
||||||
String append = "";
|
String append = "";
|
||||||
if ((name != null) && !name.equals("")) {
|
if (name != null && !name.equals("")) {
|
||||||
append = "(\"" + getName() + "\")";
|
append = "(\"" + getName() + "\")";
|
||||||
}
|
}
|
||||||
return "TAG_Float" + append + ": " + value;
|
return "TAG_Float" + append + ": " + this.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
* The {@code TAG_Int_Array} tag.
|
* The {@code TAG_Int_Array} tag.
|
||||||
*/
|
*/
|
||||||
public final class IntArrayTag extends Tag {
|
public final class IntArrayTag extends Tag {
|
||||||
|
|
||||||
private final int[] value;
|
private final int[] value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -13,8 +14,7 @@ public final class IntArrayTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @param value the value of the tag
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public IntArrayTag(final int[] value) {
|
public IntArrayTag(int[] value) {
|
||||||
super();
|
|
||||||
checkNotNull(value);
|
checkNotNull(value);
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
@ -25,7 +25,7 @@ public final class IntArrayTag extends Tag {
|
|||||||
* @param name the name of the tag
|
* @param name the name of the tag
|
||||||
* @param value the value of the tag
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public IntArrayTag(final String name, final int[] value) {
|
public IntArrayTag(String name, int[] value) {
|
||||||
super(name);
|
super(name);
|
||||||
checkNotNull(value);
|
checkNotNull(value);
|
||||||
this.value = value;
|
this.value = value;
|
||||||
@ -33,22 +33,22 @@ public final class IntArrayTag extends Tag {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getValue() {
|
public int[] getValue() {
|
||||||
return value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final StringBuilder hex = new StringBuilder();
|
StringBuilder hex = new StringBuilder();
|
||||||
for (final int b : value) {
|
for (int b : this.value) {
|
||||||
final String hexDigits = Integer.toHexString(b).toUpperCase();
|
String hexDigits = Integer.toHexString(b).toUpperCase();
|
||||||
if (hexDigits.length() == 1) {
|
if (hexDigits.length() == 1) {
|
||||||
hex.append("0");
|
hex.append("0");
|
||||||
}
|
}
|
||||||
hex.append(hexDigits).append(" ");
|
hex.append(hexDigits).append(" ");
|
||||||
}
|
}
|
||||||
final String name = getName();
|
String name = getName();
|
||||||
String append = "";
|
String append = "";
|
||||||
if ((name != null) && !name.equals("")) {
|
if (name != null && !name.equals("")) {
|
||||||
append = "(\"" + getName() + "\")";
|
append = "(\"" + getName() + "\")";
|
||||||
}
|
}
|
||||||
return "TAG_Int_Array" + append + ": " + hex;
|
return "TAG_Int_Array" + append + ": " + hex;
|
||||||
|
@ -4,6 +4,7 @@ package com.intellectualcrafters.jnbt;
|
|||||||
* The {@code TAG_Int} tag.
|
* The {@code TAG_Int} tag.
|
||||||
*/
|
*/
|
||||||
public final class IntTag extends Tag {
|
public final class IntTag extends Tag {
|
||||||
|
|
||||||
private final int value;
|
private final int value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11,8 +12,7 @@ public final class IntTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @param value the value of the tag
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public IntTag(final int value) {
|
public IntTag(int value) {
|
||||||
super();
|
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,23 +22,23 @@ public final class IntTag extends Tag {
|
|||||||
* @param name the name of the tag
|
* @param name the name of the tag
|
||||||
* @param value the value of the tag
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public IntTag(final String name, final int value) {
|
public IntTag(String name, int value) {
|
||||||
super(name);
|
super(name);
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getValue() {
|
public Integer getValue() {
|
||||||
return value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final String name = getName();
|
String name = getName();
|
||||||
String append = "";
|
String append = "";
|
||||||
if ((name != null) && !name.equals("")) {
|
if (name != null && !name.equals("")) {
|
||||||
append = "(\"" + getName() + "\")";
|
append = "(\"" + getName() + "\")";
|
||||||
}
|
}
|
||||||
return "TAG_Int" + append + ": " + value;
|
return "TAG_Int" + append + ": " + this.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import java.util.NoSuchElementException;
|
|||||||
* The {@code TAG_List} tag.
|
* The {@code TAG_List} tag.
|
||||||
*/
|
*/
|
||||||
public final class ListTag extends Tag {
|
public final class ListTag extends Tag {
|
||||||
|
|
||||||
private final Class<? extends Tag> type;
|
private final Class<? extends Tag> type;
|
||||||
private final List<Tag> value;
|
private final List<Tag> value;
|
||||||
|
|
||||||
@ -19,8 +20,7 @@ public final class ListTag extends Tag {
|
|||||||
* @param type the type of tag
|
* @param type the type of tag
|
||||||
* @param value the value of the tag
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public ListTag(final Class<? extends Tag> type, final List<? extends Tag> value) {
|
public ListTag(Class<? extends Tag> type, List<? extends Tag> value) {
|
||||||
super();
|
|
||||||
checkNotNull(value);
|
checkNotNull(value);
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.value = Collections.unmodifiableList(value);
|
this.value = Collections.unmodifiableList(value);
|
||||||
@ -33,7 +33,7 @@ public final class ListTag extends Tag {
|
|||||||
* @param type the type of tag
|
* @param type the type of tag
|
||||||
* @param value the value of the tag
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public ListTag(final String name, final Class<? extends Tag> type, final List<? extends Tag> value) {
|
public ListTag(String name, Class<? extends Tag> type, List<? extends Tag> value) {
|
||||||
super(name);
|
super(name);
|
||||||
checkNotNull(value);
|
checkNotNull(value);
|
||||||
this.type = type;
|
this.type = type;
|
||||||
@ -46,12 +46,12 @@ public final class ListTag extends Tag {
|
|||||||
* @return The type of item in this list.
|
* @return The type of item in this list.
|
||||||
*/
|
*/
|
||||||
public Class<? extends Tag> getType() {
|
public Class<? extends Tag> getType() {
|
||||||
return type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Tag> getValue() {
|
public List<Tag> getValue() {
|
||||||
return value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,7 +61,7 @@ public final class ListTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @return a new list tag
|
* @return a new list tag
|
||||||
*/
|
*/
|
||||||
public ListTag setValue(final List<Tag> list) {
|
public ListTag setValue(List<Tag> list) {
|
||||||
return new ListTag(getName(), getType(), list);
|
return new ListTag(getName(), getType(), list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,10 +72,10 @@ public final class ListTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @return the tag or null
|
* @return the tag or null
|
||||||
*/
|
*/
|
||||||
public Tag getIfExists(final int index) {
|
public Tag getIfExists(int index) {
|
||||||
try {
|
try {
|
||||||
return value.get(index);
|
return this.value.get(index);
|
||||||
} catch (final NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,8 +88,8 @@ public final class ListTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @return a byte array
|
* @return a byte array
|
||||||
*/
|
*/
|
||||||
public byte[] getByteArray(final int index) {
|
public byte[] getByteArray(int index) {
|
||||||
final Tag tag = getIfExists(index);
|
Tag tag = getIfExists(index);
|
||||||
if (tag instanceof ByteArrayTag) {
|
if (tag instanceof ByteArrayTag) {
|
||||||
return ((ByteArrayTag) tag).getValue();
|
return ((ByteArrayTag) tag).getValue();
|
||||||
} else {
|
} else {
|
||||||
@ -105,8 +105,8 @@ public final class ListTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @return a byte
|
* @return a byte
|
||||||
*/
|
*/
|
||||||
public byte getByte(final int index) {
|
public byte getByte(int index) {
|
||||||
final Tag tag = getIfExists(index);
|
Tag tag = getIfExists(index);
|
||||||
if (tag instanceof ByteTag) {
|
if (tag instanceof ByteTag) {
|
||||||
return ((ByteTag) tag).getValue();
|
return ((ByteTag) tag).getValue();
|
||||||
} else {
|
} else {
|
||||||
@ -122,8 +122,8 @@ public final class ListTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @return a double
|
* @return a double
|
||||||
*/
|
*/
|
||||||
public double getDouble(final int index) {
|
public double getDouble(int index) {
|
||||||
final Tag tag = getIfExists(index);
|
Tag tag = getIfExists(index);
|
||||||
if (tag instanceof DoubleTag) {
|
if (tag instanceof DoubleTag) {
|
||||||
return ((DoubleTag) tag).getValue();
|
return ((DoubleTag) tag).getValue();
|
||||||
} else {
|
} else {
|
||||||
@ -139,8 +139,8 @@ public final class ListTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @return a double
|
* @return a double
|
||||||
*/
|
*/
|
||||||
public double asDouble(final int index) {
|
public double asDouble(int index) {
|
||||||
final Tag tag = getIfExists(index);
|
Tag tag = getIfExists(index);
|
||||||
if (tag instanceof ByteTag) {
|
if (tag instanceof ByteTag) {
|
||||||
return ((ByteTag) tag).getValue();
|
return ((ByteTag) tag).getValue();
|
||||||
} else if (tag instanceof ShortTag) {
|
} else if (tag instanceof ShortTag) {
|
||||||
@ -166,8 +166,8 @@ public final class ListTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @return a float
|
* @return a float
|
||||||
*/
|
*/
|
||||||
public float getFloat(final int index) {
|
public float getFloat(int index) {
|
||||||
final Tag tag = getIfExists(index);
|
Tag tag = getIfExists(index);
|
||||||
if (tag instanceof FloatTag) {
|
if (tag instanceof FloatTag) {
|
||||||
return ((FloatTag) tag).getValue();
|
return ((FloatTag) tag).getValue();
|
||||||
} else {
|
} else {
|
||||||
@ -183,8 +183,8 @@ public final class ListTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @return an int array
|
* @return an int array
|
||||||
*/
|
*/
|
||||||
public int[] getIntArray(final int index) {
|
public int[] getIntArray(int index) {
|
||||||
final Tag tag = getIfExists(index);
|
Tag tag = getIfExists(index);
|
||||||
if (tag instanceof IntArrayTag) {
|
if (tag instanceof IntArrayTag) {
|
||||||
return ((IntArrayTag) tag).getValue();
|
return ((IntArrayTag) tag).getValue();
|
||||||
} else {
|
} else {
|
||||||
@ -200,8 +200,8 @@ public final class ListTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @return an int
|
* @return an int
|
||||||
*/
|
*/
|
||||||
public int getInt(final int index) {
|
public int getInt(int index) {
|
||||||
final Tag tag = getIfExists(index);
|
Tag tag = getIfExists(index);
|
||||||
if (tag instanceof IntTag) {
|
if (tag instanceof IntTag) {
|
||||||
return ((IntTag) tag).getValue();
|
return ((IntTag) tag).getValue();
|
||||||
} else {
|
} else {
|
||||||
@ -217,8 +217,8 @@ public final class ListTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @return an int
|
* @return an int
|
||||||
*/
|
*/
|
||||||
public int asInt(final int index) {
|
public int asInt(int index) {
|
||||||
final Tag tag = getIfExists(index);
|
Tag tag = getIfExists(index);
|
||||||
if (tag instanceof ByteTag) {
|
if (tag instanceof ByteTag) {
|
||||||
return ((ByteTag) tag).getValue();
|
return ((ByteTag) tag).getValue();
|
||||||
} else if (tag instanceof ShortTag) {
|
} else if (tag instanceof ShortTag) {
|
||||||
@ -244,8 +244,8 @@ public final class ListTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @return a list of tags
|
* @return a list of tags
|
||||||
*/
|
*/
|
||||||
public List<Tag> getList(final int index) {
|
public List<Tag> getList(int index) {
|
||||||
final Tag tag = getIfExists(index);
|
Tag tag = getIfExists(index);
|
||||||
if (tag instanceof ListTag) {
|
if (tag instanceof ListTag) {
|
||||||
return ((ListTag) tag).getValue();
|
return ((ListTag) tag).getValue();
|
||||||
} else {
|
} else {
|
||||||
@ -261,12 +261,12 @@ public final class ListTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @return a tag list instance
|
* @return a tag list instance
|
||||||
*/
|
*/
|
||||||
public ListTag getListTag(final int index) {
|
public ListTag getListTag(int index) {
|
||||||
final Tag tag = getIfExists(index);
|
Tag tag = getIfExists(index);
|
||||||
if (tag instanceof ListTag) {
|
if (tag instanceof ListTag) {
|
||||||
return (ListTag) tag;
|
return (ListTag) tag;
|
||||||
} else {
|
} else {
|
||||||
return new ListTag(StringTag.class, Collections.<Tag> emptyList());
|
return new ListTag(StringTag.class, Collections.<Tag>emptyList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,10 +282,10 @@ public final class ListTag extends Tag {
|
|||||||
* @return a list of tags
|
* @return a list of tags
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T extends Tag> List<T> getList(final int index, final Class<T> listType) {
|
public <T extends Tag> List<T> getList(int index, Class<T> listType) {
|
||||||
final Tag tag = getIfExists(index);
|
Tag tag = getIfExists(index);
|
||||||
if (tag instanceof ListTag) {
|
if (tag instanceof ListTag) {
|
||||||
final ListTag listTag = (ListTag) tag;
|
ListTag listTag = (ListTag) tag;
|
||||||
if (listTag.getType().equals(listType)) {
|
if (listTag.getType().equals(listType)) {
|
||||||
return (List<T>) listTag.getValue();
|
return (List<T>) listTag.getValue();
|
||||||
} else {
|
} else {
|
||||||
@ -304,8 +304,8 @@ public final class ListTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @return a long
|
* @return a long
|
||||||
*/
|
*/
|
||||||
public long getLong(final int index) {
|
public long getLong(int index) {
|
||||||
final Tag tag = getIfExists(index);
|
Tag tag = getIfExists(index);
|
||||||
if (tag instanceof LongTag) {
|
if (tag instanceof LongTag) {
|
||||||
return ((LongTag) tag).getValue();
|
return ((LongTag) tag).getValue();
|
||||||
} else {
|
} else {
|
||||||
@ -321,8 +321,8 @@ public final class ListTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @return a long
|
* @return a long
|
||||||
*/
|
*/
|
||||||
public long asLong(final int index) {
|
public long asLong(int index) {
|
||||||
final Tag tag = getIfExists(index);
|
Tag tag = getIfExists(index);
|
||||||
if (tag instanceof ByteTag) {
|
if (tag instanceof ByteTag) {
|
||||||
return ((ByteTag) tag).getValue();
|
return ((ByteTag) tag).getValue();
|
||||||
} else if (tag instanceof ShortTag) {
|
} else if (tag instanceof ShortTag) {
|
||||||
@ -348,8 +348,8 @@ public final class ListTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @return a short
|
* @return a short
|
||||||
*/
|
*/
|
||||||
public short getShort(final int index) {
|
public short getShort(int index) {
|
||||||
final Tag tag = getIfExists(index);
|
Tag tag = getIfExists(index);
|
||||||
if (tag instanceof ShortTag) {
|
if (tag instanceof ShortTag) {
|
||||||
return ((ShortTag) tag).getValue();
|
return ((ShortTag) tag).getValue();
|
||||||
} else {
|
} else {
|
||||||
@ -365,8 +365,8 @@ public final class ListTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @return a string
|
* @return a string
|
||||||
*/
|
*/
|
||||||
public String getString(final int index) {
|
public String getString(int index) {
|
||||||
final Tag tag = getIfExists(index);
|
Tag tag = getIfExists(index);
|
||||||
if (tag instanceof StringTag) {
|
if (tag instanceof StringTag) {
|
||||||
return ((StringTag) tag).getValue();
|
return ((StringTag) tag).getValue();
|
||||||
} else {
|
} else {
|
||||||
@ -376,14 +376,16 @@ public final class ListTag extends Tag {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final String name = getName();
|
String name = getName();
|
||||||
String append = "";
|
String append = "";
|
||||||
if ((name != null) && !name.equals("")) {
|
if (name != null && !name.equals("")) {
|
||||||
append = "(\"" + getName() + "\")";
|
append = "(\"" + getName() + "\")";
|
||||||
}
|
}
|
||||||
final StringBuilder bldr = new StringBuilder();
|
StringBuilder bldr = new StringBuilder();
|
||||||
bldr.append("TAG_List").append(append).append(": ").append(value.size()).append(" entries of type ").append(NBTUtils.getTypeName(type)).append("\r\n{\r\n");
|
bldr.append("TAG_List").append(append).append(": ").append(this.value.size()).append(" entries of type ")
|
||||||
for (final Tag t : value) {
|
.append(NBTUtils.getTypeName(this.type))
|
||||||
|
.append("\r\n{\r\n");
|
||||||
|
for (Tag t : this.value) {
|
||||||
bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
|
bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
|
||||||
}
|
}
|
||||||
bldr.append("}");
|
bldr.append("}");
|
||||||
|
@ -11,6 +11,7 @@ import java.util.List;
|
|||||||
* Helps create list tags.
|
* Helps create list tags.
|
||||||
*/
|
*/
|
||||||
public class ListTagBuilder {
|
public class ListTagBuilder {
|
||||||
|
|
||||||
private final Class<? extends Tag> type;
|
private final Class<? extends Tag> type;
|
||||||
private final List<Tag> entries;
|
private final List<Tag> entries;
|
||||||
|
|
||||||
@ -19,10 +20,10 @@ public class ListTagBuilder {
|
|||||||
*
|
*
|
||||||
* @param type of tag contained in this list
|
* @param type of tag contained in this list
|
||||||
*/
|
*/
|
||||||
ListTagBuilder(final Class<? extends Tag> type) {
|
ListTagBuilder(Class<? extends Tag> type) {
|
||||||
checkNotNull(type);
|
checkNotNull(type);
|
||||||
this.type = type;
|
this.type = type;
|
||||||
entries = new ArrayList<Tag>();
|
this.entries = new ArrayList<Tag>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,7 +33,7 @@ public class ListTagBuilder {
|
|||||||
*
|
*
|
||||||
* @return a new builder
|
* @return a new builder
|
||||||
*/
|
*/
|
||||||
public static ListTagBuilder create(final Class<? extends Tag> type) {
|
public static ListTagBuilder create(Class<? extends Tag> type) {
|
||||||
return new ListTagBuilder(type);
|
return new ListTagBuilder(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,18 +46,18 @@ public class ListTagBuilder {
|
|||||||
* @return a new builder
|
* @return a new builder
|
||||||
*/
|
*/
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public static <T extends Tag> ListTagBuilder createWith(final T... entries) {
|
public static <T extends Tag> ListTagBuilder createWith(T... entries) {
|
||||||
checkNotNull(entries);
|
checkNotNull(entries);
|
||||||
if (entries.length == 0) {
|
if (entries.length == 0) {
|
||||||
throw new IllegalArgumentException("This method needs an array of at least one entry");
|
throw new IllegalArgumentException("This method needs an array of at least one entry");
|
||||||
}
|
}
|
||||||
final Class<? extends Tag> type = entries[0].getClass();
|
Class<? extends Tag> type = entries[0].getClass();
|
||||||
for (int i = 1; i < entries.length; i++) {
|
for (int i = 1; i < entries.length; i++) {
|
||||||
if (!type.isInstance(entries[i])) {
|
if (!type.isInstance(entries[i])) {
|
||||||
throw new IllegalArgumentException("An array of different tag types was provided");
|
throw new IllegalArgumentException("An array of different tag types was provided");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final ListTagBuilder builder = new ListTagBuilder(type);
|
ListTagBuilder builder = new ListTagBuilder(type);
|
||||||
builder.addAll(Arrays.asList(entries));
|
builder.addAll(Arrays.asList(entries));
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
@ -68,12 +69,12 @@ public class ListTagBuilder {
|
|||||||
*
|
*
|
||||||
* @return this object
|
* @return this object
|
||||||
*/
|
*/
|
||||||
public ListTagBuilder add(final Tag value) {
|
public ListTagBuilder add(Tag value) {
|
||||||
checkNotNull(value);
|
checkNotNull(value);
|
||||||
if (!type.isInstance(value)) {
|
if (!this.type.isInstance(value)) {
|
||||||
throw new IllegalArgumentException(value.getClass().getCanonicalName() + " is not of expected type " + type.getCanonicalName());
|
throw new IllegalArgumentException(value.getClass().getCanonicalName() + " is not of expected type " + this.type.getCanonicalName());
|
||||||
}
|
}
|
||||||
entries.add(value);
|
this.entries.add(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,9 +85,9 @@ public class ListTagBuilder {
|
|||||||
*
|
*
|
||||||
* @return this object
|
* @return this object
|
||||||
*/
|
*/
|
||||||
public ListTagBuilder addAll(final Collection<? extends Tag> value) {
|
public ListTagBuilder addAll(Collection<? extends Tag> value) {
|
||||||
checkNotNull(value);
|
checkNotNull(value);
|
||||||
for (final Tag v : value) {
|
for (Tag v : value) {
|
||||||
add(v);
|
add(v);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
@ -98,7 +99,7 @@ public class ListTagBuilder {
|
|||||||
* @return the new list tag
|
* @return the new list tag
|
||||||
*/
|
*/
|
||||||
public ListTag build() {
|
public ListTag build() {
|
||||||
return new ListTag(type, new ArrayList<Tag>(entries));
|
return new ListTag(this.type, new ArrayList<Tag>(this.entries));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,7 +109,7 @@ public class ListTagBuilder {
|
|||||||
*
|
*
|
||||||
* @return the created list tag
|
* @return the created list tag
|
||||||
*/
|
*/
|
||||||
public ListTag build(final String name) {
|
public ListTag build(String name) {
|
||||||
return new ListTag(name, type, new ArrayList<Tag>(entries));
|
return new ListTag(name, this.type, new ArrayList<Tag>(this.entries));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ package com.intellectualcrafters.jnbt;
|
|||||||
* The {@code TAG_Long} tag.
|
* The {@code TAG_Long} tag.
|
||||||
*/
|
*/
|
||||||
public final class LongTag extends Tag {
|
public final class LongTag extends Tag {
|
||||||
|
|
||||||
private final long value;
|
private final long value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11,8 +12,7 @@ public final class LongTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @param value the value of the tag
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public LongTag(final long value) {
|
public LongTag(long value) {
|
||||||
super();
|
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,23 +22,23 @@ public final class LongTag extends Tag {
|
|||||||
* @param name the name of the tag
|
* @param name the name of the tag
|
||||||
* @param value the value of the tag
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public LongTag(final String name, final long value) {
|
public LongTag(String name, long value) {
|
||||||
super(name);
|
super(name);
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getValue() {
|
public Long getValue() {
|
||||||
return value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final String name = getName();
|
String name = getName();
|
||||||
String append = "";
|
String append = "";
|
||||||
if ((name != null) && !name.equals("")) {
|
if (name != null && !name.equals("")) {
|
||||||
append = "(\"" + getName() + "\")";
|
append = "(\"" + getName() + "\")";
|
||||||
}
|
}
|
||||||
return "TAG_Long" + append + ": " + value;
|
return "TAG_Long" + append + ": " + this.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,13 +9,15 @@ import java.nio.charset.StandardCharsets;
|
|||||||
public final class NBTConstants {
|
public final class NBTConstants {
|
||||||
|
|
||||||
public static final Charset CHARSET = StandardCharsets.UTF_8;
|
public static final Charset CHARSET = StandardCharsets.UTF_8;
|
||||||
public static final int TYPE_END = 0, TYPE_BYTE = 1, TYPE_SHORT = 2, TYPE_INT = 3, TYPE_LONG = 4, TYPE_FLOAT = 5, TYPE_DOUBLE = 6, TYPE_BYTE_ARRAY = 7, TYPE_STRING = 8, TYPE_LIST = 9,
|
public static final int TYPE_END = 0, TYPE_BYTE = 1, TYPE_SHORT = 2, TYPE_INT = 3, TYPE_LONG = 4, TYPE_FLOAT = 5, TYPE_DOUBLE = 6,
|
||||||
|
TYPE_BYTE_ARRAY = 7, TYPE_STRING = 8, TYPE_LIST = 9,
|
||||||
TYPE_COMPOUND = 10, TYPE_INT_ARRAY = 11;
|
TYPE_COMPOUND = 10, TYPE_INT_ARRAY = 11;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default private constructor.
|
* Default private constructor.
|
||||||
*/
|
*/
|
||||||
private NBTConstants() {}
|
private NBTConstants() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a type ID to its corresponding {@link Tag} class.
|
* Convert a type ID to its corresponding {@link Tag} class.
|
||||||
@ -26,7 +28,7 @@ public final class NBTConstants {
|
|||||||
*
|
*
|
||||||
* @throws IllegalArgumentException thrown if the tag ID is not valid
|
* @throws IllegalArgumentException thrown if the tag ID is not valid
|
||||||
*/
|
*/
|
||||||
public static Class<? extends Tag> getClassFromType(final int id) {
|
public static Class<? extends Tag> getClassFromType(int id) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case TYPE_END:
|
case TYPE_END:
|
||||||
return EndTag.class;
|
return EndTag.class;
|
||||||
|
@ -15,6 +15,7 @@ import java.util.Map;
|
|||||||
* may be found at @linktourl http://www.minecraft.net/docs/NBT.txt"> http://www.minecraft.net/docs/NBT.txt.
|
* may be found at @linktourl http://www.minecraft.net/docs/NBT.txt"> http://www.minecraft.net/docs/NBT.txt.
|
||||||
*/
|
*/
|
||||||
public final class NBTInputStream implements Closeable {
|
public final class NBTInputStream implements Closeable {
|
||||||
|
|
||||||
private final DataInputStream is;
|
private final DataInputStream is;
|
||||||
|
|
||||||
private int count;
|
private int count;
|
||||||
@ -26,7 +27,7 @@ public final class NBTInputStream implements Closeable {
|
|||||||
*
|
*
|
||||||
* @throws IOException if an I/O error occurs
|
* @throws IOException if an I/O error occurs
|
||||||
*/
|
*/
|
||||||
public NBTInputStream(final InputStream is) {
|
public NBTInputStream(InputStream is) {
|
||||||
this.is = new DataInputStream(is);
|
this.is = new DataInputStream(is);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +49,7 @@ public final class NBTInputStream implements Closeable {
|
|||||||
*
|
*
|
||||||
* @throws IOException if an I/O error occurs.
|
* @throws IOException if an I/O error occurs.
|
||||||
*/
|
*/
|
||||||
public Tag readTag(final int maxDepth) throws IOException {
|
public Tag readTag(int maxDepth) throws IOException {
|
||||||
return readTag(0, maxDepth);
|
return readTag(0, maxDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,16 +62,16 @@ public final class NBTInputStream implements Closeable {
|
|||||||
*
|
*
|
||||||
* @throws IOException if an I/O error occurs.
|
* @throws IOException if an I/O error occurs.
|
||||||
*/
|
*/
|
||||||
private Tag readTag(final int depth, final int maxDepth) throws IOException {
|
private Tag readTag(int depth, int maxDepth) throws IOException {
|
||||||
if ((count++) > maxDepth) {
|
if (this.count++ > maxDepth) {
|
||||||
throw new IOException("Exceeds max depth: " + count);
|
throw new IOException("Exceeds max depth: " + this.count);
|
||||||
}
|
}
|
||||||
final int type = is.readByte() & 0xFF;
|
int type = this.is.readByte() & 0xFF;
|
||||||
String name;
|
String name;
|
||||||
if (type != NBTConstants.TYPE_END) {
|
if (type != NBTConstants.TYPE_END) {
|
||||||
final int nameLength = is.readShort() & 0xFFFF;
|
int nameLength = this.is.readShort() & 0xFFFF;
|
||||||
final byte[] nameBytes = new byte[nameLength];
|
byte[] nameBytes = new byte[nameLength];
|
||||||
is.readFully(nameBytes);
|
this.is.readFully(nameBytes);
|
||||||
name = new String(nameBytes, NBTConstants.CHARSET);
|
name = new String(nameBytes, NBTConstants.CHARSET);
|
||||||
} else {
|
} else {
|
||||||
name = "";
|
name = "";
|
||||||
@ -89,11 +90,11 @@ public final class NBTInputStream implements Closeable {
|
|||||||
*
|
*
|
||||||
* @throws IOException if an I/O error occurs.
|
* @throws IOException if an I/O error occurs.
|
||||||
*/
|
*/
|
||||||
private Tag readTagPayload(final int type, final String name, final int depth, final int maxDepth) throws IOException {
|
private Tag readTagPayload(int type, String name, int depth, int maxDepth) throws IOException {
|
||||||
if ((count++) > maxDepth) {
|
if (this.count++ > maxDepth) {
|
||||||
throw new IOException("Exceeds max depth: " + count);
|
throw new IOException("Exceeds max depth: " + this.count);
|
||||||
}
|
}
|
||||||
count++;
|
this.count++;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NBTConstants.TYPE_END:
|
case NBTConstants.TYPE_END:
|
||||||
if (depth == 0) {
|
if (depth == 0) {
|
||||||
@ -102,54 +103,54 @@ public final class NBTInputStream implements Closeable {
|
|||||||
return new EndTag();
|
return new EndTag();
|
||||||
}
|
}
|
||||||
case NBTConstants.TYPE_BYTE:
|
case NBTConstants.TYPE_BYTE:
|
||||||
return new ByteTag(name, is.readByte());
|
return new ByteTag(name, this.is.readByte());
|
||||||
case NBTConstants.TYPE_SHORT:
|
case NBTConstants.TYPE_SHORT:
|
||||||
return new ShortTag(name, is.readShort());
|
return new ShortTag(name, this.is.readShort());
|
||||||
case NBTConstants.TYPE_INT:
|
case NBTConstants.TYPE_INT:
|
||||||
return new IntTag(name, is.readInt());
|
return new IntTag(name, this.is.readInt());
|
||||||
case NBTConstants.TYPE_LONG:
|
case NBTConstants.TYPE_LONG:
|
||||||
return new LongTag(name, is.readLong());
|
return new LongTag(name, this.is.readLong());
|
||||||
case NBTConstants.TYPE_FLOAT:
|
case NBTConstants.TYPE_FLOAT:
|
||||||
return new FloatTag(name, is.readFloat());
|
return new FloatTag(name, this.is.readFloat());
|
||||||
case NBTConstants.TYPE_DOUBLE:
|
case NBTConstants.TYPE_DOUBLE:
|
||||||
return new DoubleTag(name, is.readDouble());
|
return new DoubleTag(name, this.is.readDouble());
|
||||||
case NBTConstants.TYPE_BYTE_ARRAY:
|
case NBTConstants.TYPE_BYTE_ARRAY:
|
||||||
int length = is.readInt();
|
int length = this.is.readInt();
|
||||||
|
|
||||||
// Max depth
|
// Max depth
|
||||||
if ((count += length) > maxDepth) {
|
if ((this.count += length) > maxDepth) {
|
||||||
throw new IOException("Exceeds max depth: " + count);
|
throw new IOException("Exceeds max depth: " + this.count);
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] bytes = new byte[length];
|
byte[] bytes = new byte[length];
|
||||||
is.readFully(bytes);
|
this.is.readFully(bytes);
|
||||||
return new ByteArrayTag(name, bytes);
|
return new ByteArrayTag(name, bytes);
|
||||||
case NBTConstants.TYPE_STRING:
|
case NBTConstants.TYPE_STRING:
|
||||||
length = is.readShort();
|
length = this.is.readShort();
|
||||||
|
|
||||||
// Max depth
|
// Max depth
|
||||||
if ((count += length) > maxDepth) {
|
if ((this.count += length) > maxDepth) {
|
||||||
throw new IOException("Exceeds max depth: " + count);
|
throw new IOException("Exceeds max depth: " + this.count);
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes = new byte[length];
|
bytes = new byte[length];
|
||||||
is.readFully(bytes);
|
this.is.readFully(bytes);
|
||||||
return new StringTag(name, new String(bytes, NBTConstants.CHARSET));
|
return new StringTag(name, new String(bytes, NBTConstants.CHARSET));
|
||||||
case NBTConstants.TYPE_LIST:
|
case NBTConstants.TYPE_LIST:
|
||||||
final int childType = is.readByte();
|
int childType = this.is.readByte();
|
||||||
length = is.readInt();
|
length = this.is.readInt();
|
||||||
|
|
||||||
// Max depth
|
// Max depth
|
||||||
if ((count += length) > maxDepth) {
|
if ((this.count += length) > maxDepth) {
|
||||||
throw new IOException("Exceeds max depth: " + count);
|
throw new IOException("Exceeds max depth: " + this.count);
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Tag> tagList = new ArrayList<Tag>();
|
List<Tag> tagList = new ArrayList<Tag>();
|
||||||
for (int i = 0; i < length; ++i) {
|
for (int i = 0; i < length; ++i) {
|
||||||
final Tag tag = readTagPayload(childType, "", depth + 1, maxDepth);
|
Tag tag = readTagPayload(childType, "", depth + 1, maxDepth);
|
||||||
if (tag instanceof EndTag) {
|
if (tag instanceof EndTag) {
|
||||||
throw new IOException("TAG_End not permitted in a list.");
|
throw new IOException("TAG_End not permitted in a list.");
|
||||||
}
|
}
|
||||||
@ -157,9 +158,9 @@ public final class NBTInputStream implements Closeable {
|
|||||||
}
|
}
|
||||||
return new ListTag(name, NBTUtils.getTypeClass(childType), tagList);
|
return new ListTag(name, NBTUtils.getTypeClass(childType), tagList);
|
||||||
case NBTConstants.TYPE_COMPOUND:
|
case NBTConstants.TYPE_COMPOUND:
|
||||||
final Map<String, Tag> tagMap = new HashMap<String, Tag>();
|
Map<String, Tag> tagMap = new HashMap<String, Tag>();
|
||||||
while (true) {
|
while (true) {
|
||||||
final Tag tag = readTag(depth + 1, maxDepth);
|
Tag tag = readTag(depth + 1, maxDepth);
|
||||||
if (tag instanceof EndTag) {
|
if (tag instanceof EndTag) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
@ -168,15 +169,15 @@ public final class NBTInputStream implements Closeable {
|
|||||||
}
|
}
|
||||||
return new CompoundTag(name, tagMap);
|
return new CompoundTag(name, tagMap);
|
||||||
case NBTConstants.TYPE_INT_ARRAY:
|
case NBTConstants.TYPE_INT_ARRAY:
|
||||||
length = is.readInt();
|
length = this.is.readInt();
|
||||||
// Max depth
|
// Max depth
|
||||||
if ((count += length) > maxDepth) {
|
if ((this.count += length) > maxDepth) {
|
||||||
throw new IOException("Exceeds max depth: " + count);
|
throw new IOException("Exceeds max depth: " + this.count);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
final int[] data = new int[length];
|
int[] data = new int[length];
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
data[i] = is.readInt();
|
data[i] = this.is.readInt();
|
||||||
}
|
}
|
||||||
return new IntArrayTag(name, data);
|
return new IntArrayTag(name, data);
|
||||||
default:
|
default:
|
||||||
@ -186,6 +187,6 @@ public final class NBTInputStream implements Closeable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
is.close();
|
this.is.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import java.util.List;
|
|||||||
* @author Graham Edgecombe
|
* @author Graham Edgecombe
|
||||||
*/
|
*/
|
||||||
public final class NBTOutputStream implements Closeable {
|
public final class NBTOutputStream implements Closeable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The output stream.
|
* The output stream.
|
||||||
*/
|
*/
|
||||||
|
@ -6,10 +6,12 @@ import java.util.Map;
|
|||||||
* A class which contains NBT-related utility methods.
|
* A class which contains NBT-related utility methods.
|
||||||
*/
|
*/
|
||||||
public final class NBTUtils {
|
public final class NBTUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default private constructor.
|
* Default private constructor.
|
||||||
*/
|
*/
|
||||||
private NBTUtils() {}
|
private NBTUtils() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the type name of a tag.
|
* Gets the type name of a tag.
|
||||||
@ -18,7 +20,7 @@ public final class NBTUtils {
|
|||||||
*
|
*
|
||||||
* @return The type name.
|
* @return The type name.
|
||||||
*/
|
*/
|
||||||
public static String getTypeName(final Class<? extends Tag> clazz) {
|
public static String getTypeName(Class<? extends Tag> clazz) {
|
||||||
if (clazz.equals(ByteArrayTag.class)) {
|
if (clazz.equals(ByteArrayTag.class)) {
|
||||||
return "TAG_Byte_Array";
|
return "TAG_Byte_Array";
|
||||||
} else if (clazz.equals(ByteTag.class)) {
|
} else if (clazz.equals(ByteTag.class)) {
|
||||||
@ -57,7 +59,7 @@ public final class NBTUtils {
|
|||||||
*
|
*
|
||||||
* @throws IllegalArgumentException if the tag class is invalid.
|
* @throws IllegalArgumentException if the tag class is invalid.
|
||||||
*/
|
*/
|
||||||
public static int getTypeCode(final Class<? extends Tag> clazz) {
|
public static int getTypeCode(Class<? extends Tag> clazz) {
|
||||||
if (clazz.equals(ByteArrayTag.class)) {
|
if (clazz.equals(ByteArrayTag.class)) {
|
||||||
return NBTConstants.TYPE_BYTE_ARRAY;
|
return NBTConstants.TYPE_BYTE_ARRAY;
|
||||||
} else if (clazz.equals(ByteTag.class)) {
|
} else if (clazz.equals(ByteTag.class)) {
|
||||||
@ -96,7 +98,7 @@ public final class NBTUtils {
|
|||||||
*
|
*
|
||||||
* @throws IllegalArgumentException if the tag type is invalid.
|
* @throws IllegalArgumentException if the tag type is invalid.
|
||||||
*/
|
*/
|
||||||
public static Class<? extends Tag> getTypeClass(final int type) {
|
public static Class<? extends Tag> getTypeClass(int type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NBTConstants.TYPE_END:
|
case NBTConstants.TYPE_END:
|
||||||
return EndTag.class;
|
return EndTag.class;
|
||||||
@ -137,11 +139,12 @@ public final class NBTUtils {
|
|||||||
*
|
*
|
||||||
* @return child tag
|
* @return child tag
|
||||||
*/
|
*/
|
||||||
public static <T extends Tag> T getChildTag(final Map<String, Tag> items, final String key, final Class<T> expected) throws IllegalArgumentException {
|
public static <T extends Tag> T getChildTag(Map<String, Tag> items, String key, Class<T> expected)
|
||||||
|
throws IllegalArgumentException {
|
||||||
if (!items.containsKey(key)) {
|
if (!items.containsKey(key)) {
|
||||||
throw new IllegalArgumentException("Missing a \"" + key + "\" tag");
|
throw new IllegalArgumentException("Missing a \"" + key + "\" tag");
|
||||||
}
|
}
|
||||||
final Tag tag = items.get(key);
|
Tag tag = items.get(key);
|
||||||
if (!expected.isInstance(tag)) {
|
if (!expected.isInstance(tag)) {
|
||||||
throw new IllegalArgumentException(key + " tag is not of tag type " + expected.getName());
|
throw new IllegalArgumentException(key + " tag is not of tag type " + expected.getName());
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ package com.intellectualcrafters.jnbt;
|
|||||||
* The {@code TAG_Short} tag.
|
* The {@code TAG_Short} tag.
|
||||||
*/
|
*/
|
||||||
public final class ShortTag extends Tag {
|
public final class ShortTag extends Tag {
|
||||||
|
|
||||||
private final short value;
|
private final short value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11,8 +12,7 @@ public final class ShortTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @param value the value of the tag
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public ShortTag(final short value) {
|
public ShortTag(short value) {
|
||||||
super();
|
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,23 +22,23 @@ public final class ShortTag extends Tag {
|
|||||||
* @param name the name of the tag
|
* @param name the name of the tag
|
||||||
* @param value the value of the tag
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public ShortTag(final String name, final short value) {
|
public ShortTag(String name, short value) {
|
||||||
super(name);
|
super(name);
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Short getValue() {
|
public Short getValue() {
|
||||||
return value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final String name = getName();
|
String name = getName();
|
||||||
String append = "";
|
String append = "";
|
||||||
if ((name != null) && !name.equals("")) {
|
if (name != null && !name.equals("")) {
|
||||||
append = "(\"" + getName() + "\")";
|
append = "(\"" + getName() + "\")";
|
||||||
}
|
}
|
||||||
return "TAG_Short" + append + ": " + value;
|
return "TAG_Short" + append + ": " + this.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
* The {@code TAG_String} tag.
|
* The {@code TAG_String} tag.
|
||||||
*/
|
*/
|
||||||
public final class StringTag extends Tag {
|
public final class StringTag extends Tag {
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -13,8 +14,7 @@ public final class StringTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @param value the value of the tag
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public StringTag(final String value) {
|
public StringTag(String value) {
|
||||||
super();
|
|
||||||
checkNotNull(value);
|
checkNotNull(value);
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
@ -25,7 +25,7 @@ public final class StringTag extends Tag {
|
|||||||
* @param name the name of the tag
|
* @param name the name of the tag
|
||||||
* @param value the value of the tag
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public StringTag(final String name, final String value) {
|
public StringTag(String name, String value) {
|
||||||
super(name);
|
super(name);
|
||||||
checkNotNull(value);
|
checkNotNull(value);
|
||||||
this.value = value;
|
this.value = value;
|
||||||
@ -33,16 +33,16 @@ public final class StringTag extends Tag {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final String name = getName();
|
String name = getName();
|
||||||
String append = "";
|
String append = "";
|
||||||
if ((name != null) && !name.equals("")) {
|
if (name != null && !name.equals("")) {
|
||||||
append = "(\"" + getName() + "\")";
|
append = "(\"" + getName() + "\")";
|
||||||
}
|
}
|
||||||
return "TAG_String" + append + ": " + value;
|
return "TAG_String" + append + ": " + this.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ package com.intellectualcrafters.jnbt;
|
|||||||
* Represents a NBT tag.
|
* Represents a NBT tag.
|
||||||
*/
|
*/
|
||||||
public abstract class Tag {
|
public abstract class Tag {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,7 +32,7 @@ public abstract class Tag {
|
|||||||
* @return the name of this tag
|
* @return the name of this tag
|
||||||
*/
|
*/
|
||||||
public final String getName() {
|
public final String getName() {
|
||||||
return name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,7 +133,7 @@ public class PS {
|
|||||||
*/
|
*/
|
||||||
public PS(IPlotMain imp_class, String platform) {
|
public PS(IPlotMain imp_class, String platform) {
|
||||||
try {
|
try {
|
||||||
instance = this;
|
PS.instance = this;
|
||||||
this.thread = Thread.currentThread();
|
this.thread = Thread.currentThread();
|
||||||
SetupUtils.generators = new HashMap<>();
|
SetupUtils.generators = new HashMap<>();
|
||||||
this.IMP = imp_class;
|
this.IMP = imp_class;
|
||||||
@ -151,16 +151,16 @@ public class PS {
|
|||||||
this.version = this.IMP.getPluginVersion();
|
this.version = this.IMP.getPluginVersion();
|
||||||
this.platform = platform;
|
this.platform = platform;
|
||||||
if (getJavaVersion() < 1.7) {
|
if (getJavaVersion() < 1.7) {
|
||||||
log(C.CONSOLE_JAVA_OUTDATED_1_7);
|
PS.log(C.CONSOLE_JAVA_OUTDATED_1_7);
|
||||||
this.IMP.disable();
|
this.IMP.disable();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (getJavaVersion() < 1.8) {
|
if (getJavaVersion() < 1.8) {
|
||||||
log(C.CONSOLE_JAVA_OUTDATED_1_8);
|
PS.log(C.CONSOLE_JAVA_OUTDATED_1_8);
|
||||||
}
|
}
|
||||||
this.TASK = this.IMP.getTaskManager();
|
this.TASK = this.IMP.getTaskManager();
|
||||||
if (!C.ENABLED.s().isEmpty()) {
|
if (!C.ENABLED.s().isEmpty()) {
|
||||||
log(C.ENABLED);
|
PS.log(C.ENABLED);
|
||||||
}
|
}
|
||||||
setupConfigs();
|
setupConfigs();
|
||||||
this.translationFile = new File(this.IMP.getDirectory() + File.separator + "translations" + File.separator + "PlotSquared.use_THIS.yml");
|
this.translationFile = new File(this.IMP.getDirectory() + File.separator + "translations" + File.separator + "PlotSquared.use_THIS.yml");
|
||||||
@ -188,7 +188,7 @@ public class PS {
|
|||||||
if (Settings.METRICS) {
|
if (Settings.METRICS) {
|
||||||
this.IMP.startMetrics();
|
this.IMP.startMetrics();
|
||||||
} else {
|
} else {
|
||||||
log(C.CONSOLE_PLEASE_ENABLE_METRICS);
|
PS.log(C.CONSOLE_PLEASE_ENABLE_METRICS);
|
||||||
}
|
}
|
||||||
if (Settings.CHUNK_PROCESSOR) {
|
if (Settings.CHUNK_PROCESSOR) {
|
||||||
this.IMP.registerChunkProcessor();
|
this.IMP.registerChunkProcessor();
|
||||||
@ -198,7 +198,7 @@ public class PS {
|
|||||||
TaskManager.runTaskLater(new Runnable() {
|
TaskManager.runTaskLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PS.debug("Starting UUID caching");
|
debug("Starting UUID caching");
|
||||||
UUIDHandler.startCaching(new Runnable() {
|
UUIDHandler.startCaching(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -225,11 +225,11 @@ public class PS {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (PS.this.IMP.initPlotMeConverter()) {
|
if (PS.this.IMP.initPlotMeConverter()) {
|
||||||
log("&c=== IMPORTANT ===");
|
PS.log("&c=== IMPORTANT ===");
|
||||||
log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!");
|
PS.log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!");
|
||||||
log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!");
|
PS.log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!");
|
||||||
log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!");
|
PS.log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!");
|
||||||
log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the "
|
PS.log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the "
|
||||||
+ "'settings.yml'");
|
+ "'settings.yml'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -275,9 +275,10 @@ public class PS {
|
|||||||
if (url != null) {
|
if (url != null) {
|
||||||
PS.this.update = url;
|
PS.this.update = url;
|
||||||
} else if (PS.this.lastVersion == null) {
|
} else if (PS.this.lastVersion == null) {
|
||||||
log("&aThanks for installing PlotSquared!");
|
PS.log("&aThanks for installing PlotSquared!");
|
||||||
} else if (!PS.get().checkVersion(PS.this.lastVersion, PS.this.version)) {
|
} else if (!get().checkVersion(PS.this.lastVersion, PS.this.version)) {
|
||||||
log("&aThanks for updating from " + StringMan.join(PS.this.lastVersion, ".") + " to " + StringMan.join(PS.this.version, ".")
|
PS.log("&aThanks for updating from " + StringMan.join(PS.this.lastVersion, ".") + " to " + StringMan
|
||||||
|
.join(PS.this.version, ".")
|
||||||
+ "!");
|
+ "!");
|
||||||
DBFunc.dbManager.updateTables(PS.this.lastVersion);
|
DBFunc.dbManager.updateTables(PS.this.lastVersion);
|
||||||
}
|
}
|
||||||
@ -303,11 +304,11 @@ public class PS {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!WorldUtil.IMP.isWorld(world)) {
|
if (!WorldUtil.IMP.isWorld(world)) {
|
||||||
PS.debug("&c`" + world + "` was not properly loaded - PlotSquared will now try to load it properly: ");
|
debug("&c`" + world + "` was not properly loaded - PlotSquared will now try to load it properly: ");
|
||||||
PS.debug(
|
debug(
|
||||||
"&8 - &7Are you trying to delete this world? Remember to remove it from the settings.yml, bukkit.yml and "
|
"&8 - &7Are you trying to delete this world? Remember to remove it from the settings.yml, bukkit.yml and "
|
||||||
+ "multiverse worlds.yml");
|
+ "multiverse worlds.yml");
|
||||||
PS.debug("&8 - &7Your world management plugin may be faulty (or non existent)");
|
debug("&8 - &7Your world management plugin may be faulty (or non existent)");
|
||||||
PS.this.IMP.setGenerator(world);
|
PS.this.IMP.setGenerator(world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -335,7 +336,7 @@ public class PS {
|
|||||||
* @return the instance created by IPlotMain
|
* @return the instance created by IPlotMain
|
||||||
*/
|
*/
|
||||||
public static PS get() {
|
public static PS get() {
|
||||||
return instance;
|
return PS.instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -345,7 +346,7 @@ public class PS {
|
|||||||
* @see IPlotMain#log(String)
|
* @see IPlotMain#log(String)
|
||||||
*/
|
*/
|
||||||
public static void log(Object message) {
|
public static void log(Object message) {
|
||||||
get().IMP.log(StringMan.getString(message));
|
PS.get().IMP.log(StringMan.getString(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void stacktrace() {
|
public static void stacktrace() {
|
||||||
@ -360,7 +361,7 @@ public class PS {
|
|||||||
*/
|
*/
|
||||||
public static void debug(Object message) {
|
public static void debug(Object message) {
|
||||||
if (Settings.DEBUG) {
|
if (Settings.DEBUG) {
|
||||||
log(message);
|
PS.log(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1342,7 +1343,7 @@ public class PS {
|
|||||||
int type = worldSection != null ? worldSection.getInt("generator.type") : 0;
|
int type = worldSection != null ? worldSection.getInt("generator.type") : 0;
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
if (this.plotAreaMap.containsKey(world)) {
|
if (this.plotAreaMap.containsKey(world)) {
|
||||||
PS.debug("World possibly already loaded: " + world);
|
debug("World possibly already loaded: " + world);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IndependentPlotGenerator pg;
|
IndependentPlotGenerator pg;
|
||||||
@ -1368,10 +1369,10 @@ public class PS {
|
|||||||
// Conventional plot generator
|
// Conventional plot generator
|
||||||
PlotArea plotArea = pg.getNewPlotArea(world, null, null, null);
|
PlotArea plotArea = pg.getNewPlotArea(world, null, null, null);
|
||||||
PlotManager plotManager = pg.getNewPlotManager();
|
PlotManager plotManager = pg.getNewPlotManager();
|
||||||
log(C.PREFIX + "&aDetected world load for '" + world + "'");
|
PS.log(C.PREFIX + "&aDetected world load for '" + world + "'");
|
||||||
log(C.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + pg);
|
PS.log(C.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + pg);
|
||||||
log(C.PREFIX + "&3 - plotworld: &7" + plotArea.getClass().getName());
|
PS.log(C.PREFIX + "&3 - plotworld: &7" + plotArea.getClass().getName());
|
||||||
log(C.PREFIX + "&3 - manager: &7" + plotManager.getClass().getName());
|
PS.log(C.PREFIX + "&3 - manager: &7" + plotManager.getClass().getName());
|
||||||
if (!this.config.contains(path)) {
|
if (!this.config.contains(path)) {
|
||||||
this.config.createSection(path);
|
this.config.createSection(path);
|
||||||
worldSection = this.config.getConfigurationSection(path);
|
worldSection = this.config.getConfigurationSection(path);
|
||||||
@ -1394,10 +1395,10 @@ public class PS {
|
|||||||
ConfigurationSection areasSection = worldSection.getConfigurationSection("areas");
|
ConfigurationSection areasSection = worldSection.getConfigurationSection("areas");
|
||||||
if (areasSection == null) {
|
if (areasSection == null) {
|
||||||
if (this.plotAreaMap.containsKey(world)) {
|
if (this.plotAreaMap.containsKey(world)) {
|
||||||
PS.debug("World possibly already loaded: " + world);
|
debug("World possibly already loaded: " + world);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log(C.PREFIX + "&aDetected world load for '" + world + "'");
|
PS.log(C.PREFIX + "&aDetected world load for '" + world + "'");
|
||||||
String gen_string = worldSection.getString("generator.plugin", "PlotSquared");
|
String gen_string = worldSection.getString("generator.plugin", "PlotSquared");
|
||||||
if (type == 2) {
|
if (type == 2) {
|
||||||
Set<PlotCluster> clusters = this.clusters_tmp != null ? this.clusters_tmp.get(world) : new HashSet<PlotCluster>();
|
Set<PlotCluster> clusters = this.clusters_tmp != null ? this.clusters_tmp.get(world) : new HashSet<PlotCluster>();
|
||||||
@ -1413,7 +1414,7 @@ public class PS {
|
|||||||
worldSection.createSection("areas." + fullId);
|
worldSection.createSection("areas." + fullId);
|
||||||
DBFunc.replaceWorld(world, world + ";" + name, pos1, pos2); // NPE
|
DBFunc.replaceWorld(world, world + ";" + name, pos1, pos2); // NPE
|
||||||
|
|
||||||
log(C.PREFIX + "&3 - " + name + "-" + pos1 + "-" + pos2);
|
PS.log(C.PREFIX + "&3 - " + name + "-" + pos1 + "-" + pos2);
|
||||||
GeneratorWrapper<?> areaGen = this.IMP.getGenerator(world, gen_string);
|
GeneratorWrapper<?> areaGen = this.IMP.getGenerator(world, gen_string);
|
||||||
if (areaGen == null) {
|
if (areaGen == null) {
|
||||||
throw new IllegalArgumentException("Invalid Generator: " + gen_string);
|
throw new IllegalArgumentException("Invalid Generator: " + gen_string);
|
||||||
@ -1426,10 +1427,10 @@ public class PS {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
log(C.PREFIX + "&c | &9generator: &7" + baseGenerator + ">" + areaGen);
|
PS.log(C.PREFIX + "&c | &9generator: &7" + baseGenerator + ">" + areaGen);
|
||||||
log(C.PREFIX + "&c | &9plotworld: &7" + pa);
|
PS.log(C.PREFIX + "&c | &9plotworld: &7" + pa);
|
||||||
log(C.PREFIX + "&c | &9manager: &7" + pa);
|
PS.log(C.PREFIX + "&c | &9manager: &7" + pa);
|
||||||
log(C.PREFIX + "&cNote: &7Area created for cluster:" + name + " (invalid or old configuration?)");
|
PS.log(C.PREFIX + "&cNote: &7Area created for cluster:" + name + " (invalid or old configuration?)");
|
||||||
areaGen.getPlotGenerator().initialize(pa);
|
areaGen.getPlotGenerator().initialize(pa);
|
||||||
areaGen.augment(pa);
|
areaGen.augment(pa);
|
||||||
toLoad.add(pa);
|
toLoad.add(pa);
|
||||||
@ -1451,9 +1452,9 @@ public class PS {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
log(C.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + areaGen);
|
PS.log(C.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + areaGen);
|
||||||
log(C.PREFIX + "&3 - plotworld: &7" + pa);
|
PS.log(C.PREFIX + "&3 - plotworld: &7" + pa);
|
||||||
log(C.PREFIX + "&3 - manager: &7" + pa.getPlotManager());
|
PS.log(C.PREFIX + "&3 - manager: &7" + pa.getPlotManager());
|
||||||
areaGen.getPlotGenerator().initialize(pa);
|
areaGen.getPlotGenerator().initialize(pa);
|
||||||
areaGen.augment(pa);
|
areaGen.augment(pa);
|
||||||
addPlotArea(pa);
|
addPlotArea(pa);
|
||||||
@ -1463,7 +1464,7 @@ public class PS {
|
|||||||
throw new IllegalArgumentException("Invalid type for multi-area world. Expected `2`, got `" + type + "`");
|
throw new IllegalArgumentException("Invalid type for multi-area world. Expected `2`, got `" + type + "`");
|
||||||
}
|
}
|
||||||
for (String areaId : areasSection.getKeys(false)) {
|
for (String areaId : areasSection.getKeys(false)) {
|
||||||
log(C.PREFIX + "&3 - " + areaId);
|
PS.log(C.PREFIX + "&3 - " + areaId);
|
||||||
int i1 = areaId.indexOf("-");
|
int i1 = areaId.indexOf("-");
|
||||||
int i2 = areaId.indexOf(";");
|
int i2 = areaId.indexOf(";");
|
||||||
if (i1 == -1 || i2 == -1) {
|
if (i1 == -1 || i2 == -1) {
|
||||||
@ -1525,10 +1526,10 @@ public class PS {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
log(C.PREFIX + "&aDetected area load for '" + world + "'");
|
PS.log(C.PREFIX + "&aDetected area load for '" + world + "'");
|
||||||
log(C.PREFIX + "&c | &9generator: &7" + baseGenerator + ">" + areaGen);
|
PS.log(C.PREFIX + "&c | &9generator: &7" + baseGenerator + ">" + areaGen);
|
||||||
log(C.PREFIX + "&c | &9plotworld: &7" + pa);
|
PS.log(C.PREFIX + "&c | &9plotworld: &7" + pa);
|
||||||
log(C.PREFIX + "&c | &9manager: &7" + pa.getPlotManager());
|
PS.log(C.PREFIX + "&c | &9manager: &7" + pa.getPlotManager());
|
||||||
areaGen.getPlotGenerator().initialize(pa);
|
areaGen.getPlotGenerator().initialize(pa);
|
||||||
areaGen.augment(pa);
|
areaGen.augment(pa);
|
||||||
addPlotArea(pa);
|
addPlotArea(pa);
|
||||||
@ -1551,7 +1552,7 @@ public class PS {
|
|||||||
for (String element : split) {
|
for (String element : split) {
|
||||||
String[] pair = element.split("=");
|
String[] pair = element.split("=");
|
||||||
if (pair.length != 2) {
|
if (pair.length != 2) {
|
||||||
log("&cNo value provided for: &7" + element);
|
PS.log("&cNo value provided for: &7" + element);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String key = pair[0].toLowerCase();
|
String key = pair[0].toLowerCase();
|
||||||
@ -1560,52 +1561,44 @@ public class PS {
|
|||||||
try {
|
try {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "s":
|
case "s":
|
||||||
case "size": {
|
case "size":
|
||||||
this.config.set(base + "plot.size", Configuration.INTEGER.parseString(value).shortValue());
|
this.config.set(base + "plot.size", Configuration.INTEGER.parseString(value).shortValue());
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case "g":
|
case "g":
|
||||||
case "gap": {
|
case "gap":
|
||||||
this.config.set(base + "road.width", Configuration.INTEGER.parseString(value).shortValue());
|
this.config.set(base + "road.width", Configuration.INTEGER.parseString(value).shortValue());
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case "h":
|
case "h":
|
||||||
case "height": {
|
case "height":
|
||||||
this.config.set(base + "road.height", Configuration.INTEGER.parseString(value).shortValue());
|
this.config.set(base + "road.height", Configuration.INTEGER.parseString(value).shortValue());
|
||||||
this.config.set(base + "plot.height", Configuration.INTEGER.parseString(value).shortValue());
|
this.config.set(base + "plot.height", Configuration.INTEGER.parseString(value).shortValue());
|
||||||
this.config.set(base + "wall.height", Configuration.INTEGER.parseString(value).shortValue());
|
this.config.set(base + "wall.height", Configuration.INTEGER.parseString(value).shortValue());
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case "f":
|
case "f":
|
||||||
case "floor": {
|
case "floor":
|
||||||
this.config.set(base + "plot.floor",
|
this.config.set(base + "plot.floor",
|
||||||
new ArrayList<>(Arrays.asList(StringMan.join(Configuration.BLOCKLIST.parseString(value), ",").split(","))));
|
new ArrayList<>(Arrays.asList(StringMan.join(Configuration.BLOCKLIST.parseString(value), ",").split(","))));
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case "m":
|
case "m":
|
||||||
case "main": {
|
case "main":
|
||||||
this.config.set(base + "plot.filling",
|
this.config.set(base + "plot.filling",
|
||||||
new ArrayList<>(Arrays.asList(StringMan.join(Configuration.BLOCKLIST.parseString(value), ",").split(","))));
|
new ArrayList<>(Arrays.asList(StringMan.join(Configuration.BLOCKLIST.parseString(value), ",").split(","))));
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case "w":
|
case "w":
|
||||||
case "wall": {
|
case "wall":
|
||||||
this.config.set(base + "wall.filling", Configuration.BLOCK.parseString(value).toString());
|
this.config.set(base + "wall.filling", Configuration.BLOCK.parseString(value).toString());
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case "b":
|
case "b":
|
||||||
case "border": {
|
case "border":
|
||||||
this.config.set(base + "wall.block", Configuration.BLOCK.parseString(value).toString());
|
this.config.set(base + "wall.block", Configuration.BLOCK.parseString(value).toString());
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
default: {
|
PS.log("&cKey not found: &7" + element);
|
||||||
log("&cKey not found: &7" + element);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
log("&cInvalid value: &7" + value + " in arg " + element);
|
PS.log("&cInvalid value: &7" + value + " in arg " + element);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1661,9 +1654,9 @@ public class PS {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
MainUtil.sendMessage(sender, "Failed to update PlotSquared");
|
MainUtil.sendMessage(sender, "Failed to update PlotSquared");
|
||||||
MainUtil.sendMessage(sender, " - Please update manually");
|
MainUtil.sendMessage(sender, " - Please update manually");
|
||||||
log("============ Stacktrace ============");
|
PS.log("============ Stacktrace ============");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
log("====================================");
|
PS.log("====================================");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1717,7 +1710,7 @@ public class PS {
|
|||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
log("&cCould not save " + file);
|
PS.log("&cCould not save " + file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1755,7 +1748,7 @@ public class PS {
|
|||||||
DBFunc.close();
|
DBFunc.close();
|
||||||
UUIDHandler.handleShutdown();
|
UUIDHandler.handleShutdown();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
log("&cCould not close database connection!");
|
PS.log("&cCould not close database connection!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1765,8 +1758,8 @@ public class PS {
|
|||||||
public void setupDatabase() {
|
public void setupDatabase() {
|
||||||
try {
|
try {
|
||||||
if (Settings.DB.USE_MONGO) {
|
if (Settings.DB.USE_MONGO) {
|
||||||
log(C.PREFIX + "MongoDB is not yet implemented");
|
PS.log(C.PREFIX + "MongoDB is not yet implemented");
|
||||||
log(C.PREFIX + "&cNo storage type is set!");
|
PS.log(C.PREFIX + "&cNo storage type is set!");
|
||||||
this.IMP.disable();
|
this.IMP.disable();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1776,7 +1769,7 @@ public class PS {
|
|||||||
} else if (Settings.DB.USE_SQLITE) {
|
} else if (Settings.DB.USE_SQLITE) {
|
||||||
this.database = new SQLite(this.IMP.getDirectory() + File.separator + Settings.DB.SQLITE_DB + ".db");
|
this.database = new SQLite(this.IMP.getDirectory() + File.separator + Settings.DB.SQLITE_DB + ".db");
|
||||||
} else {
|
} else {
|
||||||
log(C.PREFIX + "&cNo storage type is set!");
|
PS.log(C.PREFIX + "&cNo storage type is set!");
|
||||||
this.IMP.disable();
|
this.IMP.disable();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1785,18 +1778,18 @@ public class PS {
|
|||||||
this.plots_tmp = DBFunc.getPlots();
|
this.plots_tmp = DBFunc.getPlots();
|
||||||
this.clusters_tmp = DBFunc.getClusters();
|
this.clusters_tmp = DBFunc.getClusters();
|
||||||
} catch (ClassNotFoundException | SQLException e) {
|
} catch (ClassNotFoundException | SQLException e) {
|
||||||
log(C.PREFIX + "&cFailed to open DATABASE connection. The plugin will disable itself.");
|
PS.log(C.PREFIX + "&cFailed to open DATABASE connection. The plugin will disable itself.");
|
||||||
if (Settings.DB.USE_MONGO) {
|
if (Settings.DB.USE_MONGO) {
|
||||||
log("$4MONGO");
|
PS.log("$4MONGO");
|
||||||
} else if (Settings.DB.USE_MYSQL) {
|
} else if (Settings.DB.USE_MYSQL) {
|
||||||
log("$4MYSQL");
|
PS.log("$4MYSQL");
|
||||||
} else if (Settings.DB.USE_SQLITE) {
|
} else if (Settings.DB.USE_SQLITE) {
|
||||||
log("$4SQLITE");
|
PS.log("$4SQLITE");
|
||||||
}
|
}
|
||||||
log("&d==== Here is an ugly stacktrace, if you are interested in those things ===");
|
PS.log("&d==== Here is an ugly stacktrace, if you are interested in those things ===");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
log("&d==== End of stacktrace ====");
|
PS.log("&d==== End of stacktrace ====");
|
||||||
log("&6Please go to the PlotSquared 'storage.yml' and configure the database correctly.");
|
PS.log("&6Please go to the PlotSquared 'storage.yml' and configure the database correctly.");
|
||||||
this.IMP.disable();
|
this.IMP.disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1996,15 +1989,15 @@ public class PS {
|
|||||||
if (keep > 0 || ignore > 0) {
|
if (keep > 0 || ignore > 0) {
|
||||||
options.put("clear.auto.threshold", 1);
|
options.put("clear.auto.threshold", 1);
|
||||||
options.put("clear.auto.enabled", false);
|
options.put("clear.auto.enabled", false);
|
||||||
log("&cIMPORTANT MESSAGE ABOUT THIS UPDATE!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
PS.log("&cIMPORTANT MESSAGE ABOUT THIS UPDATE!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||||
log("&cSorry for all the exclamation marks, but this could be important.");
|
PS.log("&cSorry for all the exclamation marks, but this could be important.");
|
||||||
log("&cPlot clearing has changed to a new system that requires calibration.");
|
PS.log("&cPlot clearing has changed to a new system that requires calibration.");
|
||||||
log("&cThis is how it will work: ");
|
PS.log("&cThis is how it will work: ");
|
||||||
log("&c - Players will rate plots");
|
PS.log("&c - Players will rate plots");
|
||||||
log("&c - When enough plots are rated, you can run /plot debugexec calibrate-analysis");
|
PS.log("&c - When enough plots are rated, you can run /plot debugexec calibrate-analysis");
|
||||||
log("&c - You can decide the (rough) percentage of expired plots to clear");
|
PS.log("&c - You can decide the (rough) percentage of expired plots to clear");
|
||||||
log("&c - To just clear all expired plot, ignore this and set: &7threshold: -1");
|
PS.log("&c - To just clear all expired plot, ignore this and set: &7threshold: -1");
|
||||||
log("&cMore information:&7 https://github.com/IntellectualSites/PlotSquared/wiki/Plot-analysis:");
|
PS.log("&cMore information:&7 https://github.com/IntellectualSites/PlotSquared/wiki/Plot-analysis:");
|
||||||
} else {
|
} else {
|
||||||
options.put("clear.auto.threshold", Settings.CLEAR_THRESHOLD);
|
options.put("clear.auto.threshold", Settings.CLEAR_THRESHOLD);
|
||||||
}
|
}
|
||||||
@ -2172,7 +2165,7 @@ public class PS {
|
|||||||
Settings.MAX_AUTO_SIZE = this.config.getInt("claim.max-auto-area");
|
Settings.MAX_AUTO_SIZE = this.config.getInt("claim.max-auto-area");
|
||||||
Settings.MAX_PLOTS = this.config.getInt("max_plots");
|
Settings.MAX_PLOTS = this.config.getInt("max_plots");
|
||||||
if (Settings.MAX_PLOTS > 32767) {
|
if (Settings.MAX_PLOTS > 32767) {
|
||||||
log("&c`max_plots` Is set too high! This is a per player setting and does not need to be very large.");
|
PS.log("&c`max_plots` Is set too high! This is a per player setting and does not need to be very large.");
|
||||||
Settings.MAX_PLOTS = 32767;
|
Settings.MAX_PLOTS = 32767;
|
||||||
}
|
}
|
||||||
Settings.GLOBAL_LIMIT = this.config.getBoolean("global_limit");
|
Settings.GLOBAL_LIMIT = this.config.getBoolean("global_limit");
|
||||||
@ -2180,7 +2173,7 @@ public class PS {
|
|||||||
// Misc
|
// Misc
|
||||||
Settings.DEBUG = this.config.getBoolean("debug");
|
Settings.DEBUG = this.config.getBoolean("debug");
|
||||||
if (Settings.DEBUG) {
|
if (Settings.DEBUG) {
|
||||||
log(C.PREFIX + "&6Debug Mode Enabled (Default). Edit the config to turn this off.");
|
PS.log(C.PREFIX + "&6Debug Mode Enabled (Default). Edit the config to turn this off.");
|
||||||
}
|
}
|
||||||
Settings.CONSOLE_COLOR = this.config.getBoolean("console.color");
|
Settings.CONSOLE_COLOR = this.config.getBoolean("console.color");
|
||||||
if (!this.config.getBoolean("chat.fancy") || !checkVersion(this.IMP.getServerVersion(), 1, 8, 0)) {
|
if (!this.config.getBoolean("chat.fancy") || !checkVersion(this.IMP.getServerVersion(), 1, 8, 0)) {
|
||||||
@ -2201,7 +2194,7 @@ public class PS {
|
|||||||
public void setupConfigs() {
|
public void setupConfigs() {
|
||||||
File folder = new File(this.IMP.getDirectory() + File.separator + "config");
|
File folder = new File(this.IMP.getDirectory() + File.separator + "config");
|
||||||
if (!folder.exists() && !folder.mkdirs()) {
|
if (!folder.exists() && !folder.mkdirs()) {
|
||||||
log(C.PREFIX + "&cFailed to create the /plugins/config folder. Please create it manually.");
|
PS.log(C.PREFIX + "&cFailed to create the /plugins/config folder. Please create it manually.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.styleFile = new File(this.IMP.getDirectory() + File.separator + "translations" + File.separator + "style.yml");
|
this.styleFile = new File(this.IMP.getDirectory() + File.separator + "translations" + File.separator + "style.yml");
|
||||||
@ -2210,50 +2203,50 @@ public class PS {
|
|||||||
this.styleFile.getParentFile().mkdirs();
|
this.styleFile.getParentFile().mkdirs();
|
||||||
}
|
}
|
||||||
if (!this.styleFile.createNewFile()) {
|
if (!this.styleFile.createNewFile()) {
|
||||||
log("Could not create the style file, please create \"translations/style.yml\" manually");
|
PS.log("Could not create the style file, please create \"translations/style.yml\" manually");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.style = YamlConfiguration.loadConfiguration(this.styleFile);
|
this.style = YamlConfiguration.loadConfiguration(this.styleFile);
|
||||||
setupStyle();
|
setupStyle();
|
||||||
} catch (IOException err) {
|
} catch (IOException err) {
|
||||||
err.printStackTrace();
|
err.printStackTrace();
|
||||||
log("failed to save style.yml");
|
PS.log("failed to save style.yml");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.configFile = new File(this.IMP.getDirectory() + File.separator + "config" + File.separator + "settings.yml");
|
this.configFile = new File(this.IMP.getDirectory() + File.separator + "config" + File.separator + "settings.yml");
|
||||||
if (!this.configFile.exists()) {
|
if (!this.configFile.exists()) {
|
||||||
if (!this.configFile.createNewFile()) {
|
if (!this.configFile.createNewFile()) {
|
||||||
log("Could not create the settings file, please create \"settings.yml\" manually.");
|
PS.log("Could not create the settings file, please create \"settings.yml\" manually.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.config = YamlConfiguration.loadConfiguration(this.configFile);
|
this.config = YamlConfiguration.loadConfiguration(this.configFile);
|
||||||
setupConfig();
|
setupConfig();
|
||||||
} catch (IOException err_trans) {
|
} catch (IOException err_trans) {
|
||||||
log("Failed to save settings.yml");
|
PS.log("Failed to save settings.yml");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.storageFile = new File(this.IMP.getDirectory() + File.separator + "config" + File.separator + "storage.yml");
|
this.storageFile = new File(this.IMP.getDirectory() + File.separator + "config" + File.separator + "storage.yml");
|
||||||
if (!this.storageFile.exists()) {
|
if (!this.storageFile.exists()) {
|
||||||
if (!this.storageFile.createNewFile()) {
|
if (!this.storageFile.createNewFile()) {
|
||||||
log("Could not the storage settings file, please create \"storage.yml\" manually.");
|
PS.log("Could not the storage settings file, please create \"storage.yml\" manually.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.storage = YamlConfiguration.loadConfiguration(this.storageFile);
|
this.storage = YamlConfiguration.loadConfiguration(this.storageFile);
|
||||||
setupStorage();
|
setupStorage();
|
||||||
} catch (IOException err_trans) {
|
} catch (IOException err_trans) {
|
||||||
log("Failed to save storage.yml");
|
PS.log("Failed to save storage.yml");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.commandsFile = new File(this.IMP.getDirectory() + File.separator + "config" + File.separator + "commands.yml");
|
this.commandsFile = new File(this.IMP.getDirectory() + File.separator + "config" + File.separator + "commands.yml");
|
||||||
if (!this.commandsFile.exists()) {
|
if (!this.commandsFile.exists()) {
|
||||||
if (!this.commandsFile.createNewFile()) {
|
if (!this.commandsFile.createNewFile()) {
|
||||||
log("Could not the storage settings file, please create \"commands.yml\" manually.");
|
PS.log("Could not the storage settings file, please create \"commands.yml\" manually.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.commands = YamlConfiguration.loadConfiguration(this.commandsFile);
|
this.commands = YamlConfiguration.loadConfiguration(this.commandsFile);
|
||||||
setupStorage();
|
setupStorage();
|
||||||
} catch (IOException err_trans) {
|
} catch (IOException err_trans) {
|
||||||
log("Failed to save commands.yml");
|
PS.log("Failed to save commands.yml");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.style.save(this.styleFile);
|
this.style.save(this.styleFile);
|
||||||
@ -2261,7 +2254,7 @@ public class PS {
|
|||||||
this.storage.save(this.storageFile);
|
this.storage.save(this.storageFile);
|
||||||
this.commands.save(this.commandsFile);
|
this.commands.save(this.commandsFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log("Configuration file saving failed");
|
PS.log("Configuration file saving failed");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2313,7 +2306,7 @@ public class PS {
|
|||||||
settings.put("Schematics Save Path", "" + Settings.SCHEMATIC_SAVE_PATH);
|
settings.put("Schematics Save Path", "" + Settings.SCHEMATIC_SAVE_PATH);
|
||||||
settings.put("API Location", "" + Settings.API_URL);
|
settings.put("API Location", "" + Settings.API_URL);
|
||||||
for (Entry<String, String> setting : settings.entrySet()) {
|
for (Entry<String, String> setting : settings.entrySet()) {
|
||||||
log(C.PREFIX + String.format("&cKey: &6%s&c, Value: &6%s", setting.getKey(), setting.getValue()));
|
PS.log(C.PREFIX + String.format("&cKey: &6%s&c, Value: &6%s", setting.getKey(), setting.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,17 +51,16 @@ public class Area extends SubCommand {
|
|||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
case "c":
|
case "c":
|
||||||
case "setup":
|
case "setup":
|
||||||
case "create": {
|
case "create":
|
||||||
if (!Permissions.hasPermission(plr, "plots.area.create")) {
|
if (!Permissions.hasPermission(plr, "plots.area.create")) {
|
||||||
C.NO_PERMISSION.send(plr, "plots.area.create");
|
C.NO_PERMISSION.send(plr, "plots.area.create");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1: {
|
case 1:
|
||||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||||
return false;
|
return false;
|
||||||
}
|
case 2:
|
||||||
case 2: {
|
|
||||||
switch (args[1].toLowerCase()) {
|
switch (args[1].toLowerCase()) {
|
||||||
case "pos1": { // Set position 1
|
case "pos1": { // Set position 1
|
||||||
HybridPlotWorld area = plr.getMeta("area_create_area");
|
HybridPlotWorld area = plr.getMeta("area_create_area");
|
||||||
@ -69,14 +68,14 @@ public class Area extends SubCommand {
|
|||||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Location loc = plr.getLocation();
|
Location location = plr.getLocation();
|
||||||
plr.setMeta("area_pos1", loc);
|
plr.setMeta("area_pos1", location);
|
||||||
C.SET_ATTRIBUTE.send(plr, "area_pos1", loc.getX() + "," + loc.getZ());
|
C.SET_ATTRIBUTE.send(plr, "area_pos1", location.getX() + "," + location.getZ());
|
||||||
MainUtil.sendMessage(plr, "You will now set pos2: /plot area create pos2"
|
MainUtil.sendMessage(plr, "You will now set pos2: /plot area create pos2"
|
||||||
+ "\nNote: The chosen plot size may result in the created area not exactly matching your second position.");
|
+ "\nNote: The chosen plot size may result in the created area not exactly matching your second position.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "pos2": { // Set position 2 and finish creation for type=2 (partial)
|
case "pos2": // Set position 2 and finish creation for type=2 (partial)
|
||||||
final HybridPlotWorld area = plr.getMeta("area_create_area");
|
final HybridPlotWorld area = plr.getMeta("area_create_area");
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||||
@ -148,8 +147,6 @@ public class Area extends SubCommand {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
default: // Start creation
|
default: // Start creation
|
||||||
final SetupObject object = new SetupObject();
|
final SetupObject object = new SetupObject();
|
||||||
String[] split = args[1].split(":");
|
String[] split = args[1].split(":");
|
||||||
@ -180,61 +177,51 @@ public class Area extends SubCommand {
|
|||||||
}
|
}
|
||||||
switch (pair[0].toLowerCase()) {
|
switch (pair[0].toLowerCase()) {
|
||||||
case "s":
|
case "s":
|
||||||
case "size": {
|
case "size":
|
||||||
pa.PLOT_WIDTH = Integer.parseInt(pair[1]);
|
pa.PLOT_WIDTH = Integer.parseInt(pair[1]);
|
||||||
pa.SIZE = (short) (pa.PLOT_WIDTH + pa.ROAD_WIDTH);
|
pa.SIZE = (short) (pa.PLOT_WIDTH + pa.ROAD_WIDTH);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case "g":
|
case "g":
|
||||||
case "gap": {
|
case "gap":
|
||||||
pa.ROAD_WIDTH = Integer.parseInt(pair[1]);
|
pa.ROAD_WIDTH = Integer.parseInt(pair[1]);
|
||||||
pa.SIZE = (short) (pa.PLOT_WIDTH + pa.ROAD_WIDTH);
|
pa.SIZE = (short) (pa.PLOT_WIDTH + pa.ROAD_WIDTH);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case "h":
|
case "h":
|
||||||
case "height": {
|
case "height":
|
||||||
int value = Integer.parseInt(pair[1]);
|
int value = Integer.parseInt(pair[1]);
|
||||||
pa.PLOT_HEIGHT = value;
|
pa.PLOT_HEIGHT = value;
|
||||||
pa.ROAD_HEIGHT = value;
|
pa.ROAD_HEIGHT = value;
|
||||||
pa.WALL_HEIGHT = value;
|
pa.WALL_HEIGHT = value;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case "f":
|
case "f":
|
||||||
case "floor": {
|
case "floor":
|
||||||
pa.TOP_BLOCK = Configuration.BLOCKLIST.parseString(pair[1]);
|
pa.TOP_BLOCK = Configuration.BLOCKLIST.parseString(pair[1]);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case "m":
|
case "m":
|
||||||
case "main": {
|
case "main":
|
||||||
pa.MAIN_BLOCK = Configuration.BLOCKLIST.parseString(pair[1]);
|
pa.MAIN_BLOCK = Configuration.BLOCKLIST.parseString(pair[1]);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case "w":
|
case "w":
|
||||||
case "wall": {
|
case "wall":
|
||||||
pa.WALL_FILLING = Configuration.BLOCK.parseString(pair[1]);
|
pa.WALL_FILLING = Configuration.BLOCK.parseString(pair[1]);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case "b":
|
case "b":
|
||||||
case "border": {
|
case "border":
|
||||||
pa.WALL_BLOCK = Configuration.BLOCK.parseString(pair[1]);
|
pa.WALL_BLOCK = Configuration.BLOCK.parseString(pair[1]);
|
||||||
break;
|
break;
|
||||||
}
|
case "terrain":
|
||||||
case "terrain": {
|
|
||||||
pa.TERRAIN = Integer.parseInt(pair[1]);
|
pa.TERRAIN = Integer.parseInt(pair[1]);
|
||||||
object.terrain = pa.TERRAIN;
|
object.terrain = pa.TERRAIN;
|
||||||
break;
|
break;
|
||||||
}
|
case "type":
|
||||||
case "type": {
|
|
||||||
pa.TYPE = Integer.parseInt(pair[1]);
|
pa.TYPE = Integer.parseInt(pair[1]);
|
||||||
object.type = pa.TYPE;
|
object.type = pa.TYPE;
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
default: {
|
|
||||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (pa.TYPE != 2) {
|
if (pa.TYPE != 2) {
|
||||||
if (WorldUtil.IMP.isWorld(pa.worldname)) {
|
if (WorldUtil.IMP.isWorld(pa.worldname)) {
|
||||||
C.SETUP_WORLD_TAKEN.send(plr, pa.worldname);
|
C.SETUP_WORLD_TAKEN.send(plr, pa.worldname);
|
||||||
@ -292,7 +279,6 @@ public class Area extends SubCommand {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
case "i":
|
case "i":
|
||||||
case "info": {
|
case "info": {
|
||||||
if (!Permissions.hasPermission(plr, "plots.area.info")) {
|
if (!Permissions.hasPermission(plr, "plots.area.info")) {
|
||||||
@ -349,7 +335,7 @@ public class Area extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "l":
|
case "l":
|
||||||
case "list": {
|
case "list":
|
||||||
if (!Permissions.hasPermission(plr, "plots.area.list")) {
|
if (!Permissions.hasPermission(plr, "plots.area.list")) {
|
||||||
C.NO_PERMISSION.send(plr, "plots.area.list");
|
C.NO_PERMISSION.send(plr, "plots.area.list");
|
||||||
return false;
|
return false;
|
||||||
@ -407,7 +393,6 @@ public class Area extends SubCommand {
|
|||||||
}
|
}
|
||||||
}, "/plot area list", C.AREA_LIST_HEADER_PAGED.s());
|
}, "/plot area list", C.AREA_LIST_HEADER_PAGED.s());
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
case "regen":
|
case "regen":
|
||||||
case "regenerate": {
|
case "regenerate": {
|
||||||
if (!Permissions.hasPermission(plr, "plots.area.regen")) {
|
if (!Permissions.hasPermission(plr, "plots.area.regen")) {
|
||||||
@ -435,7 +420,7 @@ public class Area extends SubCommand {
|
|||||||
case "v":
|
case "v":
|
||||||
case "teleport":
|
case "teleport":
|
||||||
case "visit":
|
case "visit":
|
||||||
case "tp": {
|
case "tp":
|
||||||
if (!Permissions.hasPermission(plr, "plots.area.tp")) {
|
if (!Permissions.hasPermission(plr, "plots.area.tp")) {
|
||||||
C.NO_PERMISSION.send(plr, "plots.area.tp");
|
C.NO_PERMISSION.send(plr, "plots.area.tp");
|
||||||
return false;
|
return false;
|
||||||
@ -460,9 +445,8 @@ public class Area extends SubCommand {
|
|||||||
}
|
}
|
||||||
plr.teleport(center);
|
plr.teleport(center);
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
case "delete":
|
case "delete":
|
||||||
case "remove": {
|
case "remove":
|
||||||
MainUtil.sendMessage(plr, "$1World creation settings may be stored in multiple locations:"
|
MainUtil.sendMessage(plr, "$1World creation settings may be stored in multiple locations:"
|
||||||
+ "\n$3 - $2Bukkit bukkit.yml"
|
+ "\n$3 - $2Bukkit bukkit.yml"
|
||||||
+ "\n$3 - $2PlotSquared settings.yml"
|
+ "\n$3 - $2PlotSquared settings.yml"
|
||||||
@ -470,7 +454,6 @@ public class Area extends SubCommand {
|
|||||||
+ "\n$1Stop the server and delete it from these locations.");
|
+ "\n$1Stop the server and delete it from these locations.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ public class BO3 extends SubCommand {
|
|||||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||||
Location loc = plr.getLocation();
|
Location loc = plr.getLocation();
|
||||||
Plot plot = loc.getPlotAbs();
|
Plot plot = loc.getPlotAbs();
|
||||||
if ((plot == null) || !plot.hasOwner()) {
|
if (plot == null || !plot.hasOwner()) {
|
||||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
}
|
}
|
||||||
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.bo3")) {
|
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.bo3")) {
|
||||||
@ -40,21 +40,18 @@ public class BO3 extends SubCommand {
|
|||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
case "output":
|
case "output":
|
||||||
case "save":
|
case "save":
|
||||||
case "export": {
|
case "export":
|
||||||
return BO3Handler.saveBO3(plr, plot);
|
return BO3Handler.saveBO3(plr, plot);
|
||||||
}
|
|
||||||
case "paste":
|
case "paste":
|
||||||
case "load":
|
case "load":
|
||||||
case "import":
|
case "import":
|
||||||
case "input": {
|
case "input":
|
||||||
// TODO NOT IMPLEMENTED YET
|
// TODO NOT IMPLEMENTED YET
|
||||||
MainUtil.sendMessage(plr, "NOT IMPLEMENTED YET!!!");
|
MainUtil.sendMessage(plr, "NOT IMPLEMENTED YET!!!");
|
||||||
return false;
|
return false;
|
||||||
}
|
default:
|
||||||
default: {
|
|
||||||
noArgs(plr);
|
noArgs(plr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -545,7 +545,7 @@ public class Cluster extends SubCommand {
|
|||||||
}
|
}
|
||||||
case "sh":
|
case "sh":
|
||||||
case "setspawn":
|
case "setspawn":
|
||||||
case "sethome": {
|
case "sethome":
|
||||||
if (!Permissions.hasPermission(plr, "plots.cluster.sethome")) {
|
if (!Permissions.hasPermission(plr, "plots.cluster.sethome")) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome");
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome");
|
||||||
return false;
|
return false;
|
||||||
@ -576,7 +576,6 @@ public class Cluster extends SubCommand {
|
|||||||
DBFunc.setPosition(cluster, relative.getX() + "," + relative.getY() + "," + relative.getZ());
|
DBFunc.setPosition(cluster, relative.getX() + "," + relative.getY() + "," + relative.getZ());
|
||||||
return MainUtil.sendMessage(plr, C.POSITION_SET);
|
return MainUtil.sendMessage(plr, C.POSITION_SET);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
MainUtil.sendMessage(plr, C.CLUSTER_AVAILABLE_ARGS);
|
MainUtil.sendMessage(plr, C.CLUSTER_AVAILABLE_ARGS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class Condense extends SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||||
if ((args.length != 2) && (args.length != 3)) {
|
if (args.length != 2 && args.length != 3) {
|
||||||
MainUtil.sendMessage(plr, "/plot condense <area> <start|stop|info> [radius]");
|
MainUtil.sendMessage(plr, "/plot condense <area> <start|stop|info> [radius]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ public class Condense extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, "/plot condense " + area.toString() + " start <radius>");
|
MainUtil.sendMessage(plr, "/plot condense " + area.toString() + " start <radius>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (TASK) {
|
if (Condense.TASK) {
|
||||||
MainUtil.sendMessage(plr, "TASK ALREADY STARTED");
|
MainUtil.sendMessage(plr, "TASK ALREADY STARTED");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ public class Condense extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
int size = allPlots.size();
|
int size = allPlots.size();
|
||||||
int minimumRadius = (int) Math.ceil((Math.sqrt(size) / 2) + 1);
|
int minimumRadius = (int) Math.ceil(Math.sqrt(size) / 2 + 1);
|
||||||
if (radius < minimumRadius) {
|
if (radius < minimumRadius) {
|
||||||
MainUtil.sendMessage(plr, "RADIUS TOO SMALL");
|
MainUtil.sendMessage(plr, "RADIUS TOO SMALL");
|
||||||
return false;
|
return false;
|
||||||
@ -99,7 +99,7 @@ public class Condense extends SubCommand {
|
|||||||
List<PlotId> toMove = new ArrayList<>(getPlots(allPlots, radius));
|
List<PlotId> toMove = new ArrayList<>(getPlots(allPlots, radius));
|
||||||
final List<PlotId> free = new ArrayList<>();
|
final List<PlotId> free = new ArrayList<>();
|
||||||
PlotId start = new PlotId(0, 0);
|
PlotId start = new PlotId(0, 0);
|
||||||
while ((start.x <= minimumRadius) && (start.y <= minimumRadius)) {
|
while (start.x <= minimumRadius && start.y <= minimumRadius) {
|
||||||
Plot plot = area.getPlotAbs(start);
|
Plot plot = area.getPlotAbs(start);
|
||||||
if (plot != null && !plot.hasOwner()) {
|
if (plot != null && !plot.hasOwner()) {
|
||||||
free.add(plot.getId());
|
free.add(plot.getId());
|
||||||
@ -114,11 +114,11 @@ public class Condense extends SubCommand {
|
|||||||
Runnable run = new Runnable() {
|
Runnable run = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!TASK) {
|
if (!Condense.TASK) {
|
||||||
MainUtil.sendMessage(plr, "TASK CANCELLED.");
|
MainUtil.sendMessage(plr, "TASK CANCELLED.");
|
||||||
}
|
}
|
||||||
if (allPlots.isEmpty()) {
|
if (allPlots.isEmpty()) {
|
||||||
TASK = false;
|
Condense.TASK = false;
|
||||||
MainUtil.sendMessage(plr, "TASK COMPLETE. PLEASE VERIFY THAT NO NEW PLOTS HAVE BEEN CLAIMED DURING TASK.");
|
MainUtil.sendMessage(plr, "TASK COMPLETE. PLEASE VERIFY THAT NO NEW PLOTS HAVE BEEN CLAIMED DURING TASK.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ public class Condense extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (free.isEmpty()) {
|
if (free.isEmpty()) {
|
||||||
TASK = false;
|
Condense.TASK = false;
|
||||||
MainUtil.sendMessage(plr, "TASK FAILED. NO FREE PLOTS FOUND!");
|
MainUtil.sendMessage(plr, "TASK FAILED. NO FREE PLOTS FOUND!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -156,20 +156,19 @@ public class Condense extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
TASK = true;
|
Condense.TASK = true;
|
||||||
TaskManager.runTaskAsync(run);
|
TaskManager.runTaskAsync(run);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "stop": {
|
case "stop":
|
||||||
if (!TASK) {
|
if (!Condense.TASK) {
|
||||||
MainUtil.sendMessage(plr, "TASK ALREADY STOPPED");
|
MainUtil.sendMessage(plr, "TASK ALREADY STOPPED");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
TASK = false;
|
Condense.TASK = false;
|
||||||
MainUtil.sendMessage(plr, "TASK STOPPED");
|
MainUtil.sendMessage(plr, "TASK STOPPED");
|
||||||
return true;
|
return true;
|
||||||
}
|
case "info":
|
||||||
case "info": {
|
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
MainUtil.sendMessage(plr, "/plot condense " + area.toString() + " info <radius>");
|
MainUtil.sendMessage(plr, "/plot condense " + area.toString() + " info <radius>");
|
||||||
return false;
|
return false;
|
||||||
@ -181,7 +180,7 @@ public class Condense extends SubCommand {
|
|||||||
int radius = Integer.parseInt(args[2]);
|
int radius = Integer.parseInt(args[2]);
|
||||||
Collection<Plot> plots = area.getPlots();
|
Collection<Plot> plots = area.getPlots();
|
||||||
int size = plots.size();
|
int size = plots.size();
|
||||||
int minimumRadius = (int) Math.ceil((Math.sqrt(size) / 2) + 1);
|
int minimumRadius = (int) Math.ceil(Math.sqrt(size) / 2 + 1);
|
||||||
if (radius < minimumRadius) {
|
if (radius < minimumRadius) {
|
||||||
MainUtil.sendMessage(plr, "RADIUS TOO SMALL");
|
MainUtil.sendMessage(plr, "RADIUS TOO SMALL");
|
||||||
return false;
|
return false;
|
||||||
@ -198,7 +197,6 @@ public class Condense extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, "&e - Radius is measured in plot width");
|
MainUtil.sendMessage(plr, "&e - Radius is measured in plot width");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
MainUtil.sendMessage(plr, "/plot condense " + area.worldname + " <start|stop|info> [radius]");
|
MainUtil.sendMessage(plr, "/plot condense " + area.worldname + " <start|stop|info> [radius]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -206,7 +204,7 @@ public class Condense extends SubCommand {
|
|||||||
public Set<PlotId> getPlots(Collection<Plot> plots, int radius) {
|
public Set<PlotId> getPlots(Collection<Plot> plots, int radius) {
|
||||||
HashSet<PlotId> outside = new HashSet<>();
|
HashSet<PlotId> outside = new HashSet<>();
|
||||||
for (Plot plot : plots) {
|
for (Plot plot : plots) {
|
||||||
if ((plot.getId().x > radius) || (plot.getId().x < -radius) || (plot.getId().y > radius) || (plot.getId().y < -radius)) {
|
if (plot.getId().x > radius || plot.getId().x < -radius || plot.getId().y > radius || plot.getId().y < -radius) {
|
||||||
outside.add(plot.getId());
|
outside.add(plot.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ public class Database extends SubCommand {
|
|||||||
com.intellectualcrafters.plot.database.Database implementation;
|
com.intellectualcrafters.plot.database.Database implementation;
|
||||||
String prefix = "";
|
String prefix = "";
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
case "import": {
|
case "import":
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
MainUtil.sendMessage(player, "/plot database import [sqlite file] [prefix]");
|
MainUtil.sendMessage(player, "/plot database import [sqlite file] [prefix]");
|
||||||
return false;
|
return false;
|
||||||
@ -90,7 +90,7 @@ public class Database extends SubCommand {
|
|||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, "&6Starting...");
|
MainUtil.sendMessage(player, "&6Starting...");
|
||||||
implementation = new SQLite(file.getPath());
|
implementation = new SQLite(file.getPath());
|
||||||
SQLManager manager = new SQLManager(implementation, (args.length == 3) ? args[2] : "", true);
|
SQLManager manager = new SQLManager(implementation, args.length == 3 ? args[2] : "", true);
|
||||||
HashMap<String, HashMap<PlotId, Plot>> map = manager.getPlots();
|
HashMap<String, HashMap<PlotId, Plot>> map = manager.getPlots();
|
||||||
plots = new ArrayList<>();
|
plots = new ArrayList<>();
|
||||||
for (Entry<String, HashMap<PlotId, Plot>> entry : map.entrySet()) {
|
for (Entry<String, HashMap<PlotId, Plot>> entry : map.entrySet()) {
|
||||||
@ -122,7 +122,6 @@ public class Database extends SubCommand {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
case "mysql":
|
case "mysql":
|
||||||
if (args.length < 6) {
|
if (args.length < 6) {
|
||||||
return MainUtil.sendMessage(player, "/plot database mysql [host] [port] [username] [password] [database] {prefix}");
|
return MainUtil.sendMessage(player, "/plot database mysql [host] [port] [username] [password] [database] {prefix}");
|
||||||
@ -148,7 +147,7 @@ public class Database extends SubCommand {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
SQLManager manager = new SQLManager(implementation, prefix, true);
|
SQLManager manager = new SQLManager(implementation, prefix, true);
|
||||||
insertPlots(manager, plots, player);
|
Database.insertPlots(manager, plots, player);
|
||||||
return true;
|
return true;
|
||||||
} catch (ClassNotFoundException | SQLException e) {
|
} catch (ClassNotFoundException | SQLException e) {
|
||||||
MainUtil.sendMessage(player, "$1Failed to save plots, read stacktrace for info");
|
MainUtil.sendMessage(player, "$1Failed to save plots, read stacktrace for info");
|
||||||
|
@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.commands;
|
|||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.util.StringMan;
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
import com.plotsquared.general.commands.Command;
|
import com.plotsquared.general.commands.Command;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@ -18,22 +19,24 @@ public class GenerateDocs {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new WE_Anywhere();
|
new WE_Anywhere();
|
||||||
List<Command> commands = MainCommand.getInstance().getCommands();
|
List<Command> commands = MainCommand.getInstance().getCommands();
|
||||||
log("### Want to document some commands?");
|
GenerateDocs.log("### Want to document some commands?");
|
||||||
log(" - This page is automatically generated");
|
GenerateDocs.log(" - This page is automatically generated");
|
||||||
log(" - Fork the project and add a javadoc comment to one of the command classes");
|
GenerateDocs.log(" - Fork the project and add a javadoc comment to one of the command classes");
|
||||||
log(" - Then do a pull request and it will be added to this page");
|
GenerateDocs.log(" - Then do a pull request and it will be added to this page");
|
||||||
log("");
|
GenerateDocs.log("");
|
||||||
log("# Contents");
|
GenerateDocs.log("# Contents");
|
||||||
for (CommandCategory category : CommandCategory.values()) {
|
for (CommandCategory category : CommandCategory.values()) {
|
||||||
log("###### " + category.name());
|
GenerateDocs.log("###### " + category.name());
|
||||||
for (Command command : MainCommand.getInstance().getCommands(category, null)) {
|
for (Command command : MainCommand.getInstance().getCommands(category, null)) {
|
||||||
log(" - [/plot " + command.getId() + "](https://github.com/IntellectualSites/PlotSquared/wiki/Commands#" + command.getId() + ") ");
|
GenerateDocs
|
||||||
|
.log(" - [/plot " + command.getId() + "](https://github.com/IntellectualSites/PlotSquared/wiki/Commands#" + command.getId()
|
||||||
|
+ ") ");
|
||||||
}
|
}
|
||||||
log("");
|
GenerateDocs.log("");
|
||||||
}
|
}
|
||||||
log("# Commands");
|
GenerateDocs.log("# Commands");
|
||||||
for (Command command : commands) {
|
for (Command command : commands) {
|
||||||
printCommand(command);
|
GenerateDocs.printCommand(command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,62 +49,60 @@ public class GenerateDocs {
|
|||||||
String source =
|
String source =
|
||||||
"https://github.com/IntellectualSites/PlotSquared/tree/master/Core/src/main/java/com/intellectualcrafters/plot/commands/" + clazz
|
"https://github.com/IntellectualSites/PlotSquared/tree/master/Core/src/main/java/com/intellectualcrafters/plot/commands/" + clazz
|
||||||
+ ".java";
|
+ ".java";
|
||||||
log("## [" + name.toUpperCase() + "](" + source + ") ");
|
GenerateDocs.log("## [" + name.toUpperCase() + "](" + source + ") ");
|
||||||
|
|
||||||
File file = new File("Core/src/main/java/com/intellectualcrafters/plot/commands/" + clazz + ".java");
|
File file = new File("Core/src/main/java/com/intellectualcrafters/plot/commands/" + clazz + ".java");
|
||||||
List<String> lines = Files.readAllLines(file.toPath(), StandardCharsets.UTF_8);
|
List<String> lines = Files.readAllLines(file.toPath(), StandardCharsets.UTF_8);
|
||||||
List<String> perms = getPerms(name, lines);
|
List<String> perms = GenerateDocs.getPerms(name, lines);
|
||||||
List<String> usages = getUsage(name, lines);
|
List<String> usages = GenerateDocs.getUsage(name, lines);
|
||||||
String comment = getComments(lines);
|
String comment = GenerateDocs.getComments(lines);
|
||||||
|
|
||||||
log("#### Description");
|
GenerateDocs.log("#### Description");
|
||||||
log("`" + command.getDescription() + "`");
|
GenerateDocs.log("`" + command.getDescription() + "`");
|
||||||
if (!comment.isEmpty()) {
|
if (!comment.isEmpty()) {
|
||||||
log("##### Comments");
|
GenerateDocs.log("##### Comments");
|
||||||
log("``` java");
|
GenerateDocs.log("``` java");
|
||||||
log(comment);
|
GenerateDocs.log(comment);
|
||||||
log("```");
|
GenerateDocs.log("```");
|
||||||
}
|
}
|
||||||
|
|
||||||
log("#### Usage ");
|
GenerateDocs.log("#### Usage ");
|
||||||
{
|
|
||||||
String mainUsage = command.getUsage().replaceAll("\\{label\\}", "plot");
|
String mainUsage = command.getUsage().replaceAll("\\{label\\}", "plot");
|
||||||
if (!usages.isEmpty() && !usages.get(0).equalsIgnoreCase(mainUsage)) {
|
if (!usages.isEmpty() && !usages.get(0).equalsIgnoreCase(mainUsage)) {
|
||||||
log("##### Primary ");
|
GenerateDocs.log("##### Primary ");
|
||||||
log(" - `" + mainUsage + "` ");
|
GenerateDocs.log(" - `" + mainUsage + "` ");
|
||||||
log("");
|
GenerateDocs.log("");
|
||||||
log("##### Other ");
|
GenerateDocs.log("##### Other ");
|
||||||
log(" - `" + StringMan.join(usages, "`\n - `") + "` ");
|
GenerateDocs.log(" - `" + StringMan.join(usages, "`\n - `") + "` ");
|
||||||
log("");
|
GenerateDocs.log("");
|
||||||
} else {
|
} else {
|
||||||
log("`" + mainUsage + "` ");
|
GenerateDocs.log("`" + mainUsage + "` ");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.getRequiredType() != RequiredType.NONE) {
|
if (command.getRequiredType() != RequiredType.NONE) {
|
||||||
log("#### Required callers");
|
GenerateDocs.log("#### Required callers");
|
||||||
log("`" + command.getRequiredType().name() + "`");
|
GenerateDocs.log("`" + command.getRequiredType().name() + "`");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> aliases = command.getAliases();
|
List<String> aliases = command.getAliases();
|
||||||
if (!aliases.isEmpty()) {
|
if (!aliases.isEmpty()) {
|
||||||
log("#### Aliases");
|
GenerateDocs.log("#### Aliases");
|
||||||
log("`" + StringMan.getString(command.getAliases()) + "`");
|
GenerateDocs.log("`" + StringMan.getString(command.getAliases()) + "`");
|
||||||
}
|
}
|
||||||
|
|
||||||
log("#### Permissions");
|
GenerateDocs.log("#### Permissions");
|
||||||
if (!perms.isEmpty()) {
|
if (!perms.isEmpty()) {
|
||||||
log("##### Primary");
|
GenerateDocs.log("##### Primary");
|
||||||
log(" - `" + command.getPermission() + "` ");
|
GenerateDocs.log(" - `" + command.getPermission() + "` ");
|
||||||
log("");
|
GenerateDocs.log("");
|
||||||
log("##### Other");
|
GenerateDocs.log("##### Other");
|
||||||
log(" - `" + StringMan.join(perms, "`\n - `") + "`");
|
GenerateDocs.log(" - `" + StringMan.join(perms, "`\n - `") + "`");
|
||||||
log("");
|
GenerateDocs.log("");
|
||||||
} else {
|
} else {
|
||||||
log("`" + command.getPermission() + "` ");
|
GenerateDocs.log("`" + command.getPermission() + "` ");
|
||||||
}
|
}
|
||||||
log("***");
|
GenerateDocs.log("***");
|
||||||
log("");
|
GenerateDocs.log("");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -189,11 +190,10 @@ public class GenerateDocs {
|
|||||||
}
|
}
|
||||||
switch (cmd.toLowerCase()) {
|
switch (cmd.toLowerCase()) {
|
||||||
case "auto":
|
case "auto":
|
||||||
case "claim": {
|
case "claim":
|
||||||
perms.add("plots.plot.<#>");
|
perms.add("plots.plot.<#>");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return new ArrayList<>(perms);
|
return new ArrayList<>(perms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,11 +30,10 @@ public class Help extends Command {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
|
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0: {
|
case 0:
|
||||||
displayHelp(player, null, 0);
|
displayHelp(player, null, 0);
|
||||||
return;
|
return;
|
||||||
}
|
case 1:
|
||||||
case 1: {
|
|
||||||
if (MathMan.isInteger(args[0])) {
|
if (MathMan.isInteger(args[0])) {
|
||||||
try {
|
try {
|
||||||
displayHelp(player, null, Integer.parseInt(args[0]));
|
displayHelp(player, null, Integer.parseInt(args[0]));
|
||||||
@ -45,8 +44,7 @@ public class Help extends Command {
|
|||||||
displayHelp(player, args[0], 1);
|
displayHelp(player, args[0], 1);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
case 2:
|
||||||
case 2: {
|
|
||||||
if (MathMan.isInteger(args[1])) {
|
if (MathMan.isInteger(args[1])) {
|
||||||
try {
|
try {
|
||||||
displayHelp(player, args[1], Integer.parseInt(args[1]));
|
displayHelp(player, args[1], Integer.parseInt(args[1]));
|
||||||
@ -55,12 +53,10 @@ public class Help extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
default:
|
||||||
default: {
|
|
||||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void displayHelp(PlotPlayer player, String cat, int page) {
|
public void displayHelp(PlotPlayer player, String cat, int page) {
|
||||||
CommandCategory catEnum = null;
|
CommandCategory catEnum = null;
|
||||||
|
@ -10,6 +10,7 @@ import com.intellectualcrafters.plot.util.CommentManager;
|
|||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.StringMan;
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ import java.util.List;
|
|||||||
public class Inbox extends SubCommand {
|
public class Inbox extends SubCommand {
|
||||||
|
|
||||||
public void displayComments(PlotPlayer player, List<PlotComment> oldComments, int page) {
|
public void displayComments(PlotPlayer player, List<PlotComment> oldComments, int page) {
|
||||||
if ((oldComments == null) || oldComments.isEmpty()) {
|
if (oldComments == null || oldComments.isEmpty()) {
|
||||||
MainUtil.sendMessage(player, C.INBOX_EMPTY);
|
MainUtil.sendMessage(player, C.INBOX_EMPTY);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -38,7 +39,7 @@ public class Inbox extends SubCommand {
|
|||||||
page = totalPages;
|
page = totalPages;
|
||||||
}
|
}
|
||||||
// Only display 12 per page
|
// Only display 12 per page
|
||||||
int max = (page * 12) + 12;
|
int max = page * 12 + 12;
|
||||||
if (max > comments.length) {
|
if (max > comments.length) {
|
||||||
max = comments.length;
|
max = comments.length;
|
||||||
}
|
}
|
||||||
@ -112,7 +113,7 @@ public class Inbox extends SubCommand {
|
|||||||
final int page;
|
final int page;
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
switch (args[1].toLowerCase()) {
|
switch (args[1].toLowerCase()) {
|
||||||
case "delete": {
|
case "delete":
|
||||||
if (!inbox.canModify(plot, player)) {
|
if (!inbox.canModify(plot, player)) {
|
||||||
sendMessage(player, C.NO_PERM_INBOX_MODIFY);
|
sendMessage(player, C.NO_PERM_INBOX_MODIFY);
|
||||||
return false;
|
return false;
|
||||||
@ -149,8 +150,7 @@ public class Inbox extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
case "clear":
|
||||||
case "clear": {
|
|
||||||
if (!inbox.canModify(plot, player)) {
|
if (!inbox.canModify(plot, player)) {
|
||||||
sendMessage(player, C.NO_PERM_INBOX_MODIFY);
|
sendMessage(player, C.NO_PERM_INBOX_MODIFY);
|
||||||
}
|
}
|
||||||
@ -161,8 +161,7 @@ public class Inbox extends SubCommand {
|
|||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, C.COMMENT_REMOVED, "*");
|
MainUtil.sendMessage(player, C.COMMENT_REMOVED, "*");
|
||||||
return true;
|
return true;
|
||||||
}
|
default:
|
||||||
default: {
|
|
||||||
try {
|
try {
|
||||||
page = Integer.parseInt(args[1]);
|
page = Integer.parseInt(args[1]);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
@ -170,7 +169,6 @@ public class Inbox extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
page = 1;
|
page = 1;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public class Info extends SubCommand {
|
|||||||
args = new String[]{args[1]};
|
args = new String[]{args[1]};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((args.length == 1) && args[0].equalsIgnoreCase("inv")) {
|
if (args.length == 1 && args[0].equalsIgnoreCase("inv")) {
|
||||||
PlotInventory inv = new PlotInventory(player) {
|
PlotInventory inv = new PlotInventory(player) {
|
||||||
@Override
|
@Override
|
||||||
public boolean onClick(int index) {
|
public boolean onClick(int index) {
|
||||||
@ -95,13 +95,9 @@ public class Info extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
boolean hasOwner = plot.hasOwner();
|
boolean hasOwner = plot.hasOwner();
|
||||||
boolean containsEveryone;
|
|
||||||
boolean trustedEveryone;
|
|
||||||
// Wildcard player {added}
|
// Wildcard player {added}
|
||||||
{
|
boolean containsEveryone = plot.getTrusted().contains(DBFunc.everyone);
|
||||||
containsEveryone = plot.getTrusted().contains(DBFunc.everyone);
|
boolean trustedEveryone = plot.getMembers().contains(DBFunc.everyone);
|
||||||
trustedEveryone = plot.getMembers().contains(DBFunc.everyone);
|
|
||||||
}
|
|
||||||
// Unclaimed?
|
// Unclaimed?
|
||||||
if (!hasOwner && !containsEveryone && !trustedEveryone) {
|
if (!hasOwner && !containsEveryone && !trustedEveryone) {
|
||||||
MainUtil.sendMessage(player, C.PLOT_INFO_UNCLAIMED, plot.getId().x + ";" + plot.getId().y);
|
MainUtil.sendMessage(player, C.PLOT_INFO_UNCLAIMED, plot.getId().x + ";" + plot.getId().y);
|
||||||
|
@ -26,6 +26,7 @@ import java.util.Arrays;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -39,8 +40,8 @@ import java.util.UUID;
|
|||||||
public class ListCmd extends SubCommand {
|
public class ListCmd extends SubCommand {
|
||||||
|
|
||||||
private String[] getArgumentList(PlotPlayer player) {
|
private String[] getArgumentList(PlotPlayer player) {
|
||||||
java.util.List<String> args = new ArrayList<>();
|
List<String> args = new ArrayList<>();
|
||||||
if ((EconHandler.manager != null) && Permissions.hasPermission(player, "plots.list.forsale")) {
|
if (EconHandler.manager != null && Permissions.hasPermission(player, "plots.list.forsale")) {
|
||||||
args.add("forsale");
|
args.add("forsale");
|
||||||
}
|
}
|
||||||
if (Permissions.hasPermission(player, "plots.list.mine")) {
|
if (Permissions.hasPermission(player, "plots.list.mine")) {
|
||||||
@ -105,14 +106,14 @@ public class ListCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
java.util.List<Plot> plots = null;
|
List<Plot> plots = null;
|
||||||
|
|
||||||
String world = plr.getLocation().getWorld();
|
String world = plr.getLocation().getWorld();
|
||||||
PlotArea area = plr.getApplicablePlotArea();
|
PlotArea area = plr.getApplicablePlotArea();
|
||||||
String arg = args[0].toLowerCase();
|
String arg = args[0].toLowerCase();
|
||||||
boolean sort = true;
|
boolean sort = true;
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
case "mine": {
|
case "mine":
|
||||||
if (!Permissions.hasPermission(plr, "plots.list.mine")) {
|
if (!Permissions.hasPermission(plr, "plots.list.mine")) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.mine");
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.mine");
|
||||||
return false;
|
return false;
|
||||||
@ -120,8 +121,7 @@ public class ListCmd extends SubCommand {
|
|||||||
sort = false;
|
sort = false;
|
||||||
plots = PS.get().sortPlotsByTemp(PS.get().getBasePlots(plr));
|
plots = PS.get().sortPlotsByTemp(PS.get().getBasePlots(plr));
|
||||||
break;
|
break;
|
||||||
}
|
case "shared":
|
||||||
case "shared": {
|
|
||||||
if (!Permissions.hasPermission(plr, "plots.list.shared")) {
|
if (!Permissions.hasPermission(plr, "plots.list.shared")) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.shared");
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.shared");
|
||||||
return false;
|
return false;
|
||||||
@ -133,8 +133,7 @@ public class ListCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
case "world":
|
||||||
case "world": {
|
|
||||||
if (!Permissions.hasPermission(plr, "plots.list.world")) {
|
if (!Permissions.hasPermission(plr, "plots.list.world")) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world");
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world");
|
||||||
return false;
|
return false;
|
||||||
@ -145,16 +144,14 @@ public class ListCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
plots = new ArrayList<>(PS.get().getPlots(world));
|
plots = new ArrayList<>(PS.get().getPlots(world));
|
||||||
break;
|
break;
|
||||||
}
|
case "expired":
|
||||||
case "expired": {
|
|
||||||
if (!Permissions.hasPermission(plr, "plots.list.expired")) {
|
if (!Permissions.hasPermission(plr, "plots.list.expired")) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.expired");
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.expired");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
plots = ExpireManager.IMP == null ? new ArrayList<Plot>() : new ArrayList<>(ExpireManager.IMP.getPendingExpired());
|
plots = ExpireManager.IMP == null ? new ArrayList<Plot>() : new ArrayList<>(ExpireManager.IMP.getPendingExpired());
|
||||||
break;
|
break;
|
||||||
}
|
case "area":
|
||||||
case "area": {
|
|
||||||
if (!Permissions.hasPermission(plr, "plots.list.area")) {
|
if (!Permissions.hasPermission(plr, "plots.list.area")) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.area");
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.area");
|
||||||
return false;
|
return false;
|
||||||
@ -165,16 +162,14 @@ public class ListCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
plots = area == null ? new ArrayList<Plot>() : new ArrayList<>(area.getPlots());
|
plots = area == null ? new ArrayList<Plot>() : new ArrayList<>(area.getPlots());
|
||||||
break;
|
break;
|
||||||
}
|
case "all":
|
||||||
case "all": {
|
|
||||||
if (!Permissions.hasPermission(plr, "plots.list.all")) {
|
if (!Permissions.hasPermission(plr, "plots.list.all")) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.all");
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.all");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
plots = new ArrayList<>(PS.get().getPlots());
|
plots = new ArrayList<>(PS.get().getPlots());
|
||||||
break;
|
break;
|
||||||
}
|
case "done":
|
||||||
case "done": {
|
|
||||||
if (!Permissions.hasPermission(plr, "plots.list.done")) {
|
if (!Permissions.hasPermission(plr, "plots.list.done")) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.done");
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.done");
|
||||||
return false;
|
return false;
|
||||||
@ -203,8 +198,7 @@ public class ListCmd extends SubCommand {
|
|||||||
});
|
});
|
||||||
sort = false;
|
sort = false;
|
||||||
break;
|
break;
|
||||||
}
|
case "top":
|
||||||
case "top": {
|
|
||||||
if (!Permissions.hasPermission(plr, "plots.list.top")) {
|
if (!Permissions.hasPermission(plr, "plots.list.top")) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.top");
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.top");
|
||||||
return false;
|
return false;
|
||||||
@ -233,7 +227,7 @@ public class ListCmd extends SubCommand {
|
|||||||
v2 /= p2s;
|
v2 /= p2s;
|
||||||
v2 += p2s;
|
v2 += p2s;
|
||||||
}
|
}
|
||||||
if ((v2 == v1) && (v2 != 0)) {
|
if (v2 == v1 && v2 != 0) {
|
||||||
return p2s - p1s;
|
return p2s - p1s;
|
||||||
}
|
}
|
||||||
return (int) Math.signum(v2 - v1);
|
return (int) Math.signum(v2 - v1);
|
||||||
@ -241,8 +235,7 @@ public class ListCmd extends SubCommand {
|
|||||||
});
|
});
|
||||||
sort = false;
|
sort = false;
|
||||||
break;
|
break;
|
||||||
}
|
case "forsale":
|
||||||
case "forsale": {
|
|
||||||
if (!Permissions.hasPermission(plr, "plots.list.forsale")) {
|
if (!Permissions.hasPermission(plr, "plots.list.forsale")) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.forsale");
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.forsale");
|
||||||
return false;
|
return false;
|
||||||
@ -258,8 +251,7 @@ public class ListCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
case "unowned":
|
||||||
case "unowned": {
|
|
||||||
if (!Permissions.hasPermission(plr, "plots.list.unowned")) {
|
if (!Permissions.hasPermission(plr, "plots.list.unowned")) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.unowned");
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.unowned");
|
||||||
return false;
|
return false;
|
||||||
@ -271,8 +263,7 @@ public class ListCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
case "unknown":
|
||||||
case "unknown": {
|
|
||||||
if (!Permissions.hasPermission(plr, "plots.list.unknown")) {
|
if (!Permissions.hasPermission(plr, "plots.list.unknown")) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.unknown");
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.unknown");
|
||||||
return false;
|
return false;
|
||||||
@ -287,8 +278,7 @@ public class ListCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
case "fuzzy":
|
||||||
case "fuzzy": {
|
|
||||||
if (!Permissions.hasPermission(plr, "plots.list.fuzzy")) {
|
if (!Permissions.hasPermission(plr, "plots.list.fuzzy")) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.fuzzy");
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.fuzzy");
|
||||||
return false;
|
return false;
|
||||||
@ -301,8 +291,7 @@ public class ListCmd extends SubCommand {
|
|||||||
plots = MainUtil.getPlotsBySearch(term);
|
plots = MainUtil.getPlotsBySearch(term);
|
||||||
sort = false;
|
sort = false;
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
default: {
|
|
||||||
if (PS.get().hasPlotArea(args[0])) {
|
if (PS.get().hasPlotArea(args[0])) {
|
||||||
if (!Permissions.hasPermission(plr, "plots.list.world")) {
|
if (!Permissions.hasPermission(plr, "plots.list.world")) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world");
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world");
|
||||||
@ -332,7 +321,6 @@ public class ListCmd extends SubCommand {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (plots == null) {
|
if (plots == null) {
|
||||||
sendMessage(plr, C.DID_YOU_MEAN, new StringComparison<>(args[0], new String[]{"mine", "shared", "world", "all"}).getBestMatch());
|
sendMessage(plr, C.DID_YOU_MEAN, new StringComparison<>(args[0], new String[]{"mine", "shared", "world", "all"}).getBestMatch());
|
||||||
@ -347,7 +335,7 @@ public class ListCmd extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayPlots(final PlotPlayer player, java.util.List<Plot> plots, int pageSize, int page, PlotArea area,
|
public void displayPlots(final PlotPlayer player, List<Plot> plots, int pageSize, int page, PlotArea area,
|
||||||
String[] args, boolean sort) {
|
String[] args, boolean sort) {
|
||||||
// Header
|
// Header
|
||||||
Iterator<Plot> iterator = plots.iterator();
|
Iterator<Plot> iterator = plots.iterator();
|
||||||
|
@ -47,54 +47,48 @@ public class Purge extends SubCommand {
|
|||||||
}
|
}
|
||||||
switch (split[0].toLowerCase()) {
|
switch (split[0].toLowerCase()) {
|
||||||
case "world":
|
case "world":
|
||||||
case "w": {
|
case "w":
|
||||||
world = split[1];
|
world = split[1];
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case "area":
|
case "area":
|
||||||
case "a": {
|
case "a":
|
||||||
area = PS.get().getPlotAreaByString(split[1]);
|
area = PS.get().getPlotAreaByString(split[1]);
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
C.NOT_VALID_PLOT_WORLD.send(plr, split[1]);
|
C.NOT_VALID_PLOT_WORLD.send(plr, split[1]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case "plotid":
|
case "plotid":
|
||||||
case "id": {
|
case "id":
|
||||||
id = PlotId.fromString(split[1]);
|
id = PlotId.fromString(split[1]);
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
C.NOT_VALID_PLOT_ID.send(plr, split[1]);
|
C.NOT_VALID_PLOT_ID.send(plr, split[1]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case "owner":
|
case "owner":
|
||||||
case "o": {
|
case "o":
|
||||||
owner = UUIDHandler.getUUID(split[1], null);
|
owner = UUIDHandler.getUUID(split[1], null);
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
C.INVALID_PLAYER.send(plr, split[1]);
|
C.INVALID_PLAYER.send(plr, split[1]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case "shared":
|
case "shared":
|
||||||
case "s": {
|
case "s":
|
||||||
added = UUIDHandler.getUUID(split[1], null);
|
added = UUIDHandler.getUUID(split[1], null);
|
||||||
if (added == null) {
|
if (added == null) {
|
||||||
C.INVALID_PLAYER.send(plr, split[1]);
|
C.INVALID_PLAYER.send(plr, split[1]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case "unknown":
|
case "unknown":
|
||||||
case "?":
|
case "?":
|
||||||
case "u": {
|
case "u":
|
||||||
unknown = Boolean.parseBoolean(split[1]);
|
unknown = Boolean.parseBoolean(split[1]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
final HashSet<Plot> toDelete = new HashSet<>();
|
final HashSet<Plot> toDelete = new HashSet<>();
|
||||||
for (Plot plot : PS.get().getBasePlots()) {
|
for (Plot plot : PS.get().getBasePlots()) {
|
||||||
if (world != null && !plot.getArea().worldname.equalsIgnoreCase(world)) {
|
if (world != null && !plot.getArea().worldname.equalsIgnoreCase(world)) {
|
||||||
|
@ -16,6 +16,7 @@ import com.intellectualcrafters.plot.util.Permissions;
|
|||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.plotsquared.general.commands.Command;
|
import com.plotsquared.general.commands.Command;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -87,7 +88,7 @@ public class Rate extends SubCommand {
|
|||||||
sendMessage(player, C.RATING_NOT_DONE);
|
sendMessage(player, C.RATING_NOT_DONE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((Settings.RATING_CATEGORIES != null) && !Settings.RATING_CATEGORIES.isEmpty()) {
|
if (Settings.RATING_CATEGORIES != null && !Settings.RATING_CATEGORIES.isEmpty()) {
|
||||||
final Runnable run = new Runnable() {
|
final Runnable run = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -154,7 +155,7 @@ public class Rate extends SubCommand {
|
|||||||
}
|
}
|
||||||
String arg = args[0];
|
String arg = args[0];
|
||||||
final int rating;
|
final int rating;
|
||||||
if (MathMan.isInteger(arg) && (arg.length() < 3) && !arg.isEmpty()) {
|
if (MathMan.isInteger(arg) && arg.length() < 3 && !arg.isEmpty()) {
|
||||||
rating = Integer.parseInt(arg);
|
rating = Integer.parseInt(arg);
|
||||||
if (rating > 10 || rating < 1) {
|
if (rating > 10 || rating < 1) {
|
||||||
sendMessage(player, C.RATING_NOT_VALID);
|
sendMessage(player, C.RATING_NOT_VALID);
|
||||||
|
@ -9,6 +9,7 @@ import com.intellectualcrafters.plot.util.Permissions;
|
|||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.plotsquared.general.commands.Argument;
|
import com.plotsquared.general.commands.Argument;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -63,7 +64,7 @@ public class Remove extends SubCommand {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "*": {
|
case "*":
|
||||||
ArrayList<UUID> toRemove = new ArrayList<>();
|
ArrayList<UUID> toRemove = new ArrayList<>();
|
||||||
HashSet<UUID> all = new HashSet<>();
|
HashSet<UUID> all = new HashSet<>();
|
||||||
all.addAll(plot.getMembers());
|
all.addAll(plot.getMembers());
|
||||||
@ -79,7 +80,6 @@ public class Remove extends SubCommand {
|
|||||||
plot.removeMember(uuid);
|
plot.removeMember(uuid);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
UUID uuid = UUIDHandler.getUUID(args[0], null);
|
UUID uuid = UUIDHandler.getUUID(args[0], null);
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
|
@ -15,6 +15,7 @@ import com.intellectualcrafters.plot.util.SchematicHandler;
|
|||||||
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -174,7 +175,7 @@ public class SchematicCmd extends SubCommand {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "export":
|
case "export":
|
||||||
case "save": {
|
case "save":
|
||||||
if (!Permissions.hasPermission(plr, "plots.schematic.save")) {
|
if (!Permissions.hasPermission(plr, "plots.schematic.save")) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.save");
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.save");
|
||||||
return false;
|
return false;
|
||||||
@ -214,12 +215,10 @@ public class SchematicCmd extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, "&7Starting export...");
|
MainUtil.sendMessage(plr, "&7Starting export...");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
default: {
|
|
||||||
sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
|
sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import com.intellectualcrafters.plot.util.StringMan;
|
|||||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||||
import com.plotsquared.general.commands.Command;
|
import com.plotsquared.general.commands.Command;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -159,7 +160,6 @@ public class Set extends SubCommand {
|
|||||||
return this.component.onCommand(plr, Arrays.copyOfRange(args, 0, args.length));
|
return this.component.onCommand(plr, Arrays.copyOfRange(args, 0, args.length));
|
||||||
}
|
}
|
||||||
// flag
|
// flag
|
||||||
{
|
|
||||||
AbstractFlag af;
|
AbstractFlag af;
|
||||||
try {
|
try {
|
||||||
af = new AbstractFlag(args[0].toLowerCase());
|
af = new AbstractFlag(args[0].toLowerCase());
|
||||||
@ -176,7 +176,6 @@ public class Set extends SubCommand {
|
|||||||
MainCommand.onCommand(plr, ("flag set " + args[0] + a.toString()).split(" "));
|
MainCommand.onCommand(plr, ("flag set " + args[0] + a.toString()).split(" "));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return noArgs(plr);
|
return noArgs(plr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,18 +28,16 @@ public class SetHome extends SetCommand {
|
|||||||
base.setHome(null);
|
base.setHome(null);
|
||||||
return MainUtil.sendMessage(plr, C.POSITION_UNSET);
|
return MainUtil.sendMessage(plr, C.POSITION_UNSET);
|
||||||
}
|
}
|
||||||
case "": {
|
case "":
|
||||||
Plot base = plot.getBasePlot(false);
|
Plot base = plot.getBasePlot(false);
|
||||||
Location bot = base.getBottomAbs();
|
Location bot = base.getBottomAbs();
|
||||||
Location loc = plr.getLocationFull();
|
Location loc = plr.getLocationFull();
|
||||||
BlockLoc rel = new BlockLoc(loc.getX() - bot.getX(), loc.getY(), loc.getZ() - bot.getZ(), loc.getYaw(), loc.getPitch());
|
BlockLoc rel = new BlockLoc(loc.getX() - bot.getX(), loc.getY(), loc.getZ() - bot.getZ(), loc.getYaw(), loc.getPitch());
|
||||||
base.setHome(rel);
|
base.setHome(rel);
|
||||||
return MainUtil.sendMessage(plr, C.POSITION_SET);
|
return MainUtil.sendMessage(plr, C.POSITION_SET);
|
||||||
}
|
default:
|
||||||
default: {
|
|
||||||
MainUtil.sendMessage(plr, C.HOME_ARGUMENT);
|
MainUtil.sendMessage(plr, C.HOME_ARGUMENT);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -75,8 +75,8 @@ public class Setup extends SubCommand {
|
|||||||
}
|
}
|
||||||
int index = object.current;
|
int index = object.current;
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0: { // choose generator
|
case 0: // choose generator
|
||||||
if ((args.length != 1) || !SetupUtils.generators.containsKey(args[0])) {
|
if (args.length != 1 || !SetupUtils.generators.containsKey(args[0])) {
|
||||||
String prefix = "\n&8 - &7";
|
String prefix = "\n&8 - &7";
|
||||||
MainUtil.sendMessage(plr, "&cYou must choose a generator!" + prefix + StringMan.join(SetupUtils.generators.keySet(), prefix)
|
MainUtil.sendMessage(plr, "&cYou must choose a generator!" + prefix + StringMan.join(SetupUtils.generators.keySet(), prefix)
|
||||||
.replaceAll("PlotSquared", "&2PlotSquared"));
|
.replaceAll("PlotSquared", "&2PlotSquared"));
|
||||||
@ -89,8 +89,7 @@ public class Setup extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, "&6What world type do you want?" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation"
|
MainUtil.sendMessage(plr, "&6What world type do you want?" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation"
|
||||||
+ "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + partial);
|
+ "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + partial);
|
||||||
break;
|
break;
|
||||||
}
|
case 1: // choose world type
|
||||||
case 1: { // choose world type
|
|
||||||
List<String> allTypes = Arrays.asList("default", "augmented", "partial");
|
List<String> allTypes = Arrays.asList("default", "augmented", "partial");
|
||||||
List<String> allDesc = Arrays.asList("Standard plot generation", "Plot generation with vanilla terrain",
|
List<String> allDesc = Arrays.asList("Standard plot generation", "Plot generation with vanilla terrain",
|
||||||
"Vanilla with clusters of plots");
|
"Vanilla with clusters of plots");
|
||||||
@ -100,7 +99,7 @@ public class Setup extends SubCommand {
|
|||||||
}
|
}
|
||||||
types.add("augmented");
|
types.add("augmented");
|
||||||
types.add("partial");
|
types.add("partial");
|
||||||
if ((args.length != 1) || !types.contains(args[0].toLowerCase())) {
|
if (args.length != 1 || !types.contains(args[0].toLowerCase())) {
|
||||||
MainUtil.sendMessage(plr, "&cYou must choose a world type!");
|
MainUtil.sendMessage(plr, "&cYou must choose a world type!");
|
||||||
for (String type : types) {
|
for (String type : types) {
|
||||||
int i = allTypes.indexOf(type);
|
int i = allTypes.indexOf(type);
|
||||||
@ -157,8 +156,7 @@ public class Setup extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
case 2: // area id
|
||||||
case 2: { // area id
|
|
||||||
if (!StringMan.isAlphanumericUnd(args[0])) {
|
if (!StringMan.isAlphanumericUnd(args[0])) {
|
||||||
MainUtil.sendMessage(plr, "&cThe area id must be alphanumerical!");
|
MainUtil.sendMessage(plr, "&cThe area id must be alphanumerical!");
|
||||||
return false;
|
return false;
|
||||||
@ -173,8 +171,7 @@ public class Setup extends SubCommand {
|
|||||||
object.current++;
|
object.current++;
|
||||||
MainUtil.sendMessage(plr, "&6What should be the minimum Plot Id?");
|
MainUtil.sendMessage(plr, "&6What should be the minimum Plot Id?");
|
||||||
break;
|
break;
|
||||||
}
|
case 3: // min
|
||||||
case 3: { // min
|
|
||||||
object.min = PlotId.fromString(args[0]);
|
object.min = PlotId.fromString(args[0]);
|
||||||
if (object.min == null) {
|
if (object.min == null) {
|
||||||
MainUtil.sendMessage(plr, "&cYou must choose a valid minimum PlotId!");
|
MainUtil.sendMessage(plr, "&cYou must choose a valid minimum PlotId!");
|
||||||
@ -183,8 +180,7 @@ public class Setup extends SubCommand {
|
|||||||
object.current++;
|
object.current++;
|
||||||
MainUtil.sendMessage(plr, "&6What should be the maximum Plot Id?");
|
MainUtil.sendMessage(plr, "&6What should be the maximum Plot Id?");
|
||||||
break;
|
break;
|
||||||
}
|
case 4:
|
||||||
case 4: {
|
|
||||||
// max
|
// max
|
||||||
PlotId id = PlotId.fromString(args[0]);
|
PlotId id = PlotId.fromString(args[0]);
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
@ -203,10 +199,9 @@ public class Setup extends SubCommand {
|
|||||||
+ "\n&8 - &7ROAD&8 - &7Terrain separated by roads"
|
+ "\n&8 - &7ROAD&8 - &7Terrain separated by roads"
|
||||||
+ "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
+ "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case 5: { // Choose terrain
|
case 5: { // Choose terrain
|
||||||
List<String> terrain = Arrays.asList("none", "ore", "road", "all");
|
List<String> terrain = Arrays.asList("none", "ore", "road", "all");
|
||||||
if ((args.length != 1) || !terrain.contains(args[0].toLowerCase())) {
|
if (args.length != 1 || !terrain.contains(args[0].toLowerCase())) {
|
||||||
MainUtil.sendMessage(plr, "&cYou must choose the terrain!"
|
MainUtil.sendMessage(plr, "&cYou must choose the terrain!"
|
||||||
+ "\n&8 - &2NONE&8 - &7No terrain at all"
|
+ "\n&8 - &2NONE&8 - &7No terrain at all"
|
||||||
+ "\n&8 - &7ORE&8 - &7Just some ore veins and trees"
|
+ "\n&8 - &7ORE&8 - &7Just some ore veins and trees"
|
||||||
@ -225,7 +220,7 @@ public class Setup extends SubCommand {
|
|||||||
step.getDefaultValue() + "");
|
step.getDefaultValue() + "");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 6: { // world setup
|
case 6: // world setup
|
||||||
if (object.setup_index == object.step.length) {
|
if (object.setup_index == object.step.length) {
|
||||||
MainUtil.sendMessage(plr, "&6What do you want your world to be called?");
|
MainUtil.sendMessage(plr, "&6What do you want your world to be called?");
|
||||||
object.setup_index = 0;
|
object.setup_index = 0;
|
||||||
@ -257,8 +252,7 @@ public class Setup extends SubCommand {
|
|||||||
step.getDefaultValue() + "");
|
step.getDefaultValue() + "");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
case 7:
|
||||||
case 7: {
|
|
||||||
if (args.length != 1) {
|
if (args.length != 1) {
|
||||||
MainUtil.sendMessage(plr, "&cYou need to choose a world name!");
|
MainUtil.sendMessage(plr, "&cYou need to choose a world name!");
|
||||||
return false;
|
return false;
|
||||||
@ -288,7 +282,6 @@ public class Setup extends SubCommand {
|
|||||||
}
|
}
|
||||||
sendMessage(plr, C.SETUP_FINISHED, object.world);
|
sendMessage(plr, C.SETUP_FINISHED, object.world);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,15 +45,14 @@ public class Visit extends SubCommand {
|
|||||||
int page = Integer.MIN_VALUE;
|
int page = Integer.MIN_VALUE;
|
||||||
Collection<Plot> unsorted = null;
|
Collection<Plot> unsorted = null;
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2: {
|
case 2:
|
||||||
if (!MathMan.isInteger(args[1])) {
|
if (!MathMan.isInteger(args[1])) {
|
||||||
sendMessage(player, C.NOT_VALID_NUMBER, "(1, ∞)");
|
sendMessage(player, C.NOT_VALID_NUMBER, "(1, ∞)");
|
||||||
sendMessage(player, C.COMMAND_SYNTAX, "/plot visit " + args[0] + " [#]");
|
sendMessage(player, C.COMMAND_SYNTAX, "/plot visit " + args[0] + " [#]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
page = Integer.parseInt(args[1]);
|
page = Integer.parseInt(args[1]);
|
||||||
}
|
case 1:
|
||||||
case 1: {
|
|
||||||
UUID user = UUIDHandler.getCachedUUID(args[0], null);
|
UUID user = UUIDHandler.getCachedUUID(args[0], null);
|
||||||
if (page == Integer.MIN_VALUE && user == null && MathMan.isInteger(args[0])) {
|
if (page == Integer.MIN_VALUE && user == null && MathMan.isInteger(args[0])) {
|
||||||
page = Integer.parseInt(args[0]);
|
page = Integer.parseInt(args[0]);
|
||||||
@ -69,16 +68,13 @@ public class Visit extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
case 0:
|
||||||
case 0: {
|
|
||||||
page = 1;
|
page = 1;
|
||||||
unsorted = PS.get().getPlots(player);
|
unsorted = PS.get().getPlots(player);
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
default: {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (page == Integer.MIN_VALUE) {
|
if (page == Integer.MIN_VALUE) {
|
||||||
page = 1;
|
page = 1;
|
||||||
}
|
}
|
||||||
|
@ -33,14 +33,14 @@ public class DBFunc {
|
|||||||
public static AbstractDB dbManager;
|
public static AbstractDB dbManager;
|
||||||
|
|
||||||
public static void movePlot(Plot originalPlot, Plot newPlot) {
|
public static void movePlot(Plot originalPlot, Plot newPlot) {
|
||||||
if ((originalPlot.temp == -1) || (newPlot.temp == -1)) {
|
if (originalPlot.temp == -1 || newPlot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.movePlot(originalPlot, newPlot);
|
DBFunc.dbManager.movePlot(originalPlot, newPlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void validatePlots(Set<Plot> plots) {
|
public static void validatePlots(Set<Plot> plots) {
|
||||||
dbManager.validateAllPlots(plots);
|
DBFunc.dbManager.validateAllPlots(plots);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,7 +74,7 @@ public class DBFunc {
|
|||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.setOwner(plot, uuid);
|
DBFunc.dbManager.setOwner(plot, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,7 +83,7 @@ public class DBFunc {
|
|||||||
* @param plots List containing all plot objects
|
* @param plots List containing all plot objects
|
||||||
*/
|
*/
|
||||||
public static void createPlotsAndData(ArrayList<Plot> plots, Runnable whenDone) {
|
public static void createPlotsAndData(ArrayList<Plot> plots, Runnable whenDone) {
|
||||||
dbManager.createPlotsAndData(plots, whenDone);
|
DBFunc.dbManager.createPlotsAndData(plots, whenDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,7 +95,7 @@ public class DBFunc {
|
|||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.createPlot(plot);
|
DBFunc.dbManager.createPlot(plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,7 +107,7 @@ public class DBFunc {
|
|||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.createPlotAndSettings(plot, whenDone);
|
DBFunc.dbManager.createPlotAndSettings(plot, whenDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,7 +116,7 @@ public class DBFunc {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static void createTables(String database) throws Exception {
|
public static void createTables(String database) throws Exception {
|
||||||
dbManager.createTables();
|
DBFunc.dbManager.createTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -128,7 +128,7 @@ public class DBFunc {
|
|||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.delete(plot);
|
DBFunc.dbManager.delete(plot);
|
||||||
plot.temp = -1;
|
plot.temp = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ public class DBFunc {
|
|||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.deleteRatings(plot);
|
DBFunc.dbManager.deleteRatings(plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -151,7 +151,7 @@ public class DBFunc {
|
|||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.deleteHelpers(plot);
|
DBFunc.dbManager.deleteHelpers(plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -162,7 +162,7 @@ public class DBFunc {
|
|||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.deleteTrusted(plot);
|
DBFunc.dbManager.deleteTrusted(plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -173,7 +173,7 @@ public class DBFunc {
|
|||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.deleteDenied(plot);
|
DBFunc.dbManager.deleteDenied(plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -184,7 +184,7 @@ public class DBFunc {
|
|||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.deleteComments(plot);
|
DBFunc.dbManager.deleteComments(plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -199,11 +199,11 @@ public class DBFunc {
|
|||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.deleteSettings(plot);
|
DBFunc.dbManager.deleteSettings(plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void delete(PlotCluster toDelete) {
|
public static void delete(PlotCluster toDelete) {
|
||||||
dbManager.delete(toDelete);
|
DBFunc.dbManager.delete(toDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -216,7 +216,7 @@ public class DBFunc {
|
|||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.createPlotSettings(id, plot);
|
DBFunc.dbManager.createPlotSettings(id, plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -227,32 +227,32 @@ public class DBFunc {
|
|||||||
* @return ID
|
* @return ID
|
||||||
*/
|
*/
|
||||||
public static int getId(Plot plot) {
|
public static int getId(Plot plot) {
|
||||||
return dbManager.getId(plot);
|
return DBFunc.dbManager.getId(plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Plots
|
* @return Plots
|
||||||
*/
|
*/
|
||||||
public static HashMap<String, HashMap<PlotId, Plot>> getPlots() {
|
public static HashMap<String, HashMap<PlotId, Plot>> getPlots() {
|
||||||
return dbManager.getPlots();
|
return DBFunc.dbManager.getPlots();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setMerged(Plot plot, boolean[] merged) {
|
public static void setMerged(Plot plot, boolean[] merged) {
|
||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.setMerged(plot, merged);
|
DBFunc.dbManager.setMerged(plot, merged);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setFlags(Plot plot, Collection<Flag> flags) {
|
public static void setFlags(Plot plot, Collection<Flag> flags) {
|
||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.setFlags(plot, flags);
|
DBFunc.dbManager.setFlags(plot, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setFlags(PlotCluster cluster, Collection<Flag> flags) {
|
public static void setFlags(PlotCluster cluster, Collection<Flag> flags) {
|
||||||
dbManager.setFlags(cluster, flags);
|
DBFunc.dbManager.setFlags(cluster, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -263,15 +263,15 @@ public class DBFunc {
|
|||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.setAlias(plot, alias);
|
DBFunc.dbManager.setAlias(plot, alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void purgeIds(Set<Integer> uniqueIds) {
|
public static void purgeIds(Set<Integer> uniqueIds) {
|
||||||
dbManager.purgeIds(uniqueIds);
|
DBFunc.dbManager.purgeIds(uniqueIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void purge(PlotArea area, Set<PlotId> plotIds) {
|
public static void purge(PlotArea area, Set<PlotId> plotIds) {
|
||||||
dbManager.purge(area, plotIds);
|
DBFunc.dbManager.purge(area, plotIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -282,7 +282,7 @@ public class DBFunc {
|
|||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.setPosition(plot, position);
|
DBFunc.dbManager.setPosition(plot, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -290,17 +290,17 @@ public class DBFunc {
|
|||||||
* @param comment
|
* @param comment
|
||||||
*/
|
*/
|
||||||
public static void removeComment(Plot plot, PlotComment comment) {
|
public static void removeComment(Plot plot, PlotComment comment) {
|
||||||
if ((plot != null) && (plot.temp == -1)) {
|
if (plot != null && plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.removeComment(plot, comment);
|
DBFunc.dbManager.removeComment(plot, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearInbox(Plot plot, String inbox) {
|
public static void clearInbox(Plot plot, String inbox) {
|
||||||
if ((plot != null) && (plot.temp == -1)) {
|
if (plot != null && plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.clearInbox(plot, inbox);
|
DBFunc.dbManager.clearInbox(plot, inbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -308,20 +308,20 @@ public class DBFunc {
|
|||||||
* @param comment
|
* @param comment
|
||||||
*/
|
*/
|
||||||
public static void setComment(Plot plot, PlotComment comment) {
|
public static void setComment(Plot plot, PlotComment comment) {
|
||||||
if ((plot != null) && (plot.temp == -1)) {
|
if (plot != null && plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.setComment(plot, comment);
|
DBFunc.dbManager.setComment(plot, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param plot
|
* @param plot
|
||||||
*/
|
*/
|
||||||
public static void getComments(Plot plot, String inbox, RunnableVal<List<PlotComment>> whenDone) {
|
public static void getComments(Plot plot, String inbox, RunnableVal<List<PlotComment>> whenDone) {
|
||||||
if ((plot != null) && (plot.temp == -1)) {
|
if (plot != null && plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.getComments(plot, inbox, whenDone);
|
DBFunc.dbManager.getComments(plot, inbox, whenDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -332,7 +332,7 @@ public class DBFunc {
|
|||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.removeTrusted(plot, uuid);
|
DBFunc.dbManager.removeTrusted(plot, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -340,14 +340,14 @@ public class DBFunc {
|
|||||||
* @param uuid
|
* @param uuid
|
||||||
*/
|
*/
|
||||||
public static void removeHelper(PlotCluster cluster, UUID uuid) {
|
public static void removeHelper(PlotCluster cluster, UUID uuid) {
|
||||||
dbManager.removeHelper(cluster, uuid);
|
DBFunc.dbManager.removeHelper(cluster, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param cluster
|
* @param cluster
|
||||||
*/
|
*/
|
||||||
public static void createCluster(PlotCluster cluster) {
|
public static void createCluster(PlotCluster cluster) {
|
||||||
dbManager.createCluster(cluster);
|
DBFunc.dbManager.createCluster(cluster);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -356,7 +356,7 @@ public class DBFunc {
|
|||||||
* @param max
|
* @param max
|
||||||
*/
|
*/
|
||||||
public static void resizeCluster(PlotCluster current, PlotId min, PlotId max) {
|
public static void resizeCluster(PlotCluster current, PlotId min, PlotId max) {
|
||||||
dbManager.resizeCluster(current, min, max);
|
DBFunc.dbManager.resizeCluster(current, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -367,7 +367,7 @@ public class DBFunc {
|
|||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.removeMember(plot, uuid);
|
DBFunc.dbManager.removeMember(plot, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -376,7 +376,7 @@ public class DBFunc {
|
|||||||
* @param uuid
|
* @param uuid
|
||||||
*/
|
*/
|
||||||
public static void removeInvited(PlotCluster cluster, UUID uuid) {
|
public static void removeInvited(PlotCluster cluster, UUID uuid) {
|
||||||
dbManager.removeInvited(cluster, uuid);
|
DBFunc.dbManager.removeInvited(cluster, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -387,11 +387,11 @@ public class DBFunc {
|
|||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.setTrusted(plot, uuid);
|
DBFunc.dbManager.setTrusted(plot, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setHelper(PlotCluster cluster, UUID uuid) {
|
public static void setHelper(PlotCluster cluster, UUID uuid) {
|
||||||
dbManager.setHelper(cluster, uuid);
|
DBFunc.dbManager.setHelper(cluster, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -402,11 +402,11 @@ public class DBFunc {
|
|||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.setMember(plot, uuid);
|
DBFunc.dbManager.setMember(plot, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setInvited(PlotCluster cluster, UUID uuid) {
|
public static void setInvited(PlotCluster cluster, UUID uuid) {
|
||||||
dbManager.setInvited(cluster, uuid);
|
DBFunc.dbManager.setInvited(cluster, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -417,7 +417,7 @@ public class DBFunc {
|
|||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.removeDenied(plot, uuid);
|
DBFunc.dbManager.removeDenied(plot, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -428,33 +428,33 @@ public class DBFunc {
|
|||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.setDenied(plot, uuid);
|
DBFunc.dbManager.setDenied(plot, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<UUID, Integer> getRatings(Plot plot) {
|
public static HashMap<UUID, Integer> getRatings(Plot plot) {
|
||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return new HashMap<>(0);
|
return new HashMap<>(0);
|
||||||
}
|
}
|
||||||
return dbManager.getRatings(plot);
|
return DBFunc.dbManager.getRatings(plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setRating(Plot plot, UUID rater, int value) {
|
public static void setRating(Plot plot, UUID rater, int value) {
|
||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbManager.setRating(plot, rater, value);
|
DBFunc.dbManager.setRating(plot, rater, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<String, Set<PlotCluster>> getClusters() {
|
public static HashMap<String, Set<PlotCluster>> getClusters() {
|
||||||
return dbManager.getClusters();
|
return DBFunc.dbManager.getClusters();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPosition(PlotCluster cluster, String position) {
|
public static void setPosition(PlotCluster cluster, String position) {
|
||||||
dbManager.setPosition(cluster, position);
|
DBFunc.dbManager.setPosition(cluster, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void replaceWorld(String oldWorld, String newWorld, PlotId min, PlotId max) {
|
public static void replaceWorld(String oldWorld, String newWorld, PlotId min, PlotId max) {
|
||||||
dbManager.replaceWorld(oldWorld, newWorld, min, max);
|
DBFunc.dbManager.replaceWorld(oldWorld, newWorld, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -463,10 +463,10 @@ public class DBFunc {
|
|||||||
* @param now
|
* @param now
|
||||||
*/
|
*/
|
||||||
public static void replaceUUID(UUID old, UUID now) {
|
public static void replaceUUID(UUID old, UUID now) {
|
||||||
dbManager.replaceUUID(old, now);
|
DBFunc.dbManager.replaceUUID(old, now);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void close() {
|
public static void close() {
|
||||||
dbManager.close();
|
DBFunc.dbManager.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,9 +40,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
*/
|
|
||||||
public class SQLManager implements AbstractDB {
|
public class SQLManager implements AbstractDB {
|
||||||
// Public final
|
// Public final
|
||||||
public final String SET_OWNER;
|
public final String SET_OWNER;
|
||||||
@ -187,11 +185,11 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBatch(PreparedStatement stmt) {
|
public void addBatch(PreparedStatement statement) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(PreparedStatement stmt) {
|
public void execute(PreparedStatement statement) {
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -221,11 +219,11 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBatch(PreparedStatement stmt) {
|
public void addBatch(PreparedStatement statement) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(PreparedStatement stmt) {
|
public void execute(PreparedStatement statement) {
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -252,11 +250,11 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBatch(PreparedStatement stmt) {
|
public void addBatch(PreparedStatement statement) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(PreparedStatement stmt) {
|
public void execute(PreparedStatement statement) {
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -294,7 +292,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
this.connection.setAutoCommit(false);
|
this.connection.setAutoCommit(false);
|
||||||
}
|
}
|
||||||
String method = null;
|
String method = null;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement statement = null;
|
||||||
UniqueStatement task = null;
|
UniqueStatement task = null;
|
||||||
UniqueStatement lastTask = null;
|
UniqueStatement lastTask = null;
|
||||||
for (Entry<Plot, Queue<UniqueStatement>> entry : this.plotTasks.entrySet()) {
|
for (Entry<Plot, Queue<UniqueStatement>> entry : this.plotTasks.entrySet()) {
|
||||||
@ -306,22 +304,22 @@ public class SQLManager implements AbstractDB {
|
|||||||
task = this.plotTasks.get(plot).remove();
|
task = this.plotTasks.get(plot).remove();
|
||||||
count++;
|
count++;
|
||||||
if (task != null) {
|
if (task != null) {
|
||||||
if (task._method == null || !task._method.equals(method)) {
|
if (task.method == null || !task.method.equals(method)) {
|
||||||
if (stmt != null) {
|
if (statement != null) {
|
||||||
lastTask.execute(stmt);
|
lastTask.execute(statement);
|
||||||
stmt.close();
|
statement.close();
|
||||||
}
|
}
|
||||||
method = task._method;
|
method = task.method;
|
||||||
stmt = task.get();
|
statement = task.get();
|
||||||
}
|
}
|
||||||
task.set(stmt);
|
task.set(statement);
|
||||||
task.addBatch(stmt);
|
task.addBatch(statement);
|
||||||
}
|
}
|
||||||
lastTask = task;
|
lastTask = task;
|
||||||
}
|
}
|
||||||
if (stmt != null && task != null) {
|
if (statement != null && task != null) {
|
||||||
task.execute(stmt);
|
task.execute(statement);
|
||||||
stmt.close();
|
statement.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!this.playerTasks.isEmpty()) {
|
if (!this.playerTasks.isEmpty()) {
|
||||||
@ -330,7 +328,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
this.connection.setAutoCommit(false);
|
this.connection.setAutoCommit(false);
|
||||||
}
|
}
|
||||||
String method = null;
|
String method = null;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement statement = null;
|
||||||
UniqueStatement task = null;
|
UniqueStatement task = null;
|
||||||
UniqueStatement lastTask = null;
|
UniqueStatement lastTask = null;
|
||||||
for (Entry<UUID, Queue<UniqueStatement>> entry : this.playerTasks.entrySet()) {
|
for (Entry<UUID, Queue<UniqueStatement>> entry : this.playerTasks.entrySet()) {
|
||||||
@ -342,22 +340,22 @@ public class SQLManager implements AbstractDB {
|
|||||||
task = this.playerTasks.get(uuid).remove();
|
task = this.playerTasks.get(uuid).remove();
|
||||||
count++;
|
count++;
|
||||||
if (task != null) {
|
if (task != null) {
|
||||||
if (task._method == null || !task._method.equals(method)) {
|
if (task.method == null || !task.method.equals(method)) {
|
||||||
if (stmt != null) {
|
if (statement != null) {
|
||||||
lastTask.execute(stmt);
|
lastTask.execute(statement);
|
||||||
stmt.close();
|
statement.close();
|
||||||
}
|
}
|
||||||
method = task._method;
|
method = task.method;
|
||||||
stmt = task.get();
|
statement = task.get();
|
||||||
}
|
}
|
||||||
task.set(stmt);
|
task.set(statement);
|
||||||
task.addBatch(stmt);
|
task.addBatch(statement);
|
||||||
}
|
}
|
||||||
lastTask = task;
|
lastTask = task;
|
||||||
}
|
}
|
||||||
if (stmt != null && task != null) {
|
if (statement != null && task != null) {
|
||||||
task.execute(stmt);
|
task.execute(statement);
|
||||||
stmt.close();
|
statement.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!this.clusterTasks.isEmpty()) {
|
if (!this.clusterTasks.isEmpty()) {
|
||||||
@ -366,7 +364,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
this.connection.setAutoCommit(false);
|
this.connection.setAutoCommit(false);
|
||||||
}
|
}
|
||||||
String method = null;
|
String method = null;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement statement = null;
|
||||||
UniqueStatement task = null;
|
UniqueStatement task = null;
|
||||||
UniqueStatement lastTask = null;
|
UniqueStatement lastTask = null;
|
||||||
for (Entry<PlotCluster, Queue<UniqueStatement>> entry : this.clusterTasks.entrySet()) {
|
for (Entry<PlotCluster, Queue<UniqueStatement>> entry : this.clusterTasks.entrySet()) {
|
||||||
@ -378,22 +376,22 @@ public class SQLManager implements AbstractDB {
|
|||||||
task = this.clusterTasks.get(cluster).remove();
|
task = this.clusterTasks.get(cluster).remove();
|
||||||
count++;
|
count++;
|
||||||
if (task != null) {
|
if (task != null) {
|
||||||
if (task._method == null || !task._method.equals(method)) {
|
if (task.method == null || !task.method.equals(method)) {
|
||||||
if (stmt != null) {
|
if (statement != null) {
|
||||||
lastTask.execute(stmt);
|
lastTask.execute(statement);
|
||||||
stmt.close();
|
statement.close();
|
||||||
}
|
}
|
||||||
method = task._method;
|
method = task.method;
|
||||||
stmt = task.get();
|
statement = task.get();
|
||||||
}
|
}
|
||||||
task.set(stmt);
|
task.set(statement);
|
||||||
task.addBatch(stmt);
|
task.addBatch(statement);
|
||||||
}
|
}
|
||||||
lastTask = task;
|
lastTask = task;
|
||||||
}
|
}
|
||||||
if (stmt != null && task != null) {
|
if (statement != null && task != null) {
|
||||||
task.execute(stmt);
|
task.execute(statement);
|
||||||
stmt.close();
|
statement.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
@ -614,7 +612,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
try {
|
try {
|
||||||
stmt.setString(i * 5 + 3, plot.owner.toString());
|
stmt.setString(i * 5 + 3, plot.owner.toString());
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
stmt.setString(i * 5 + 3, everyone.toString());
|
stmt.setString(i * 5 + 3, AbstractDB.everyone.toString());
|
||||||
}
|
}
|
||||||
stmt.setString(i * 5 + 4, plot.getArea().toString());
|
stmt.setString(i * 5 + 4, plot.getArea().toString());
|
||||||
stmt.setTimestamp(i * 5 + 5, new Timestamp(plot.getTimestamp()));
|
stmt.setTimestamp(i * 5 + 5, new Timestamp(plot.getTimestamp()));
|
||||||
@ -628,7 +626,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
try {
|
try {
|
||||||
stmt.setString(i * 6 + 4, plot.owner.toString());
|
stmt.setString(i * 6 + 4, plot.owner.toString());
|
||||||
} catch (SQLException e1) {
|
} catch (SQLException e1) {
|
||||||
stmt.setString(i * 6 + 4, everyone.toString());
|
stmt.setString(i * 6 + 4, AbstractDB.everyone.toString());
|
||||||
}
|
}
|
||||||
stmt.setString(i * 6 + 5, plot.getArea().toString());
|
stmt.setString(i * 6 + 5, plot.getArea().toString());
|
||||||
stmt.setTimestamp(i * 6 + 6, new Timestamp(plot.getTimestamp()));
|
stmt.setTimestamp(i * 6 + 6, new Timestamp(plot.getTimestamp()));
|
||||||
@ -989,14 +987,14 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(PreparedStatement stmt) {
|
public void execute(PreparedStatement statement) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBatch(PreparedStatement stmt) throws SQLException {
|
public void addBatch(PreparedStatement statement) throws SQLException {
|
||||||
stmt.executeUpdate();
|
statement.executeUpdate();
|
||||||
ResultSet keys = stmt.getGeneratedKeys();
|
ResultSet keys = statement.getGeneratedKeys();
|
||||||
if (keys.next()) {
|
if (keys.next()) {
|
||||||
plot.temp = keys.getInt(1);
|
plot.temp = keys.getInt(1);
|
||||||
}
|
}
|
||||||
@ -1476,8 +1474,9 @@ public class SQLManager implements AbstractDB {
|
|||||||
if (this.mySQL && !PS.get().checkVersion(oldVersion, 3, 3, 2)) {
|
if (this.mySQL && !PS.get().checkVersion(oldVersion, 3, 3, 2)) {
|
||||||
try (Statement stmt = this.connection.createStatement()) {
|
try (Statement stmt = this.connection.createStatement()) {
|
||||||
stmt.executeUpdate("ALTER TABLE `" + this.prefix + "plots` DROP INDEX `unique_alias`");
|
stmt.executeUpdate("ALTER TABLE `" + this.prefix + "plots` DROP INDEX `unique_alias`");
|
||||||
|
} catch (SQLException ignore) {
|
||||||
|
//ignored
|
||||||
}
|
}
|
||||||
catch (SQLException ignore) {}
|
|
||||||
}
|
}
|
||||||
DatabaseMetaData data = this.connection.getMetaData();
|
DatabaseMetaData data = this.connection.getMetaData();
|
||||||
ResultSet rs = data.getColumns(null, null, this.prefix + "plot_comments", "plot_plot_id");
|
ResultSet rs = data.getColumns(null, null, this.prefix + "plot_comments", "plot_plot_id");
|
||||||
@ -2178,7 +2177,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(PreparedStatement stmt) {
|
public void execute(PreparedStatement statement) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2480,11 +2479,12 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(PreparedStatement stmt) {}
|
public void execute(PreparedStatement statement) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBatch(PreparedStatement stmt) throws SQLException {
|
public void addBatch(PreparedStatement statement) throws SQLException {
|
||||||
ResultSet resultSet = stmt.executeQuery();
|
ResultSet resultSet = statement.executeQuery();
|
||||||
|
|
||||||
Map<String, byte[]> metaMap = new HashMap<>();
|
Map<String, byte[]> metaMap = new HashMap<>();
|
||||||
|
|
||||||
@ -2782,14 +2782,14 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(PreparedStatement stmt) {
|
public void execute(PreparedStatement statement) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBatch(PreparedStatement stmt) throws SQLException {
|
public void addBatch(PreparedStatement statement) throws SQLException {
|
||||||
stmt.executeUpdate();
|
statement.executeUpdate();
|
||||||
ResultSet keys = stmt.getGeneratedKeys();
|
ResultSet keys = statement.getGeneratedKeys();
|
||||||
if (keys.next()) {
|
if (keys.next()) {
|
||||||
cluster.temp = keys.getInt(1);
|
cluster.temp = keys.getInt(1);
|
||||||
}
|
}
|
||||||
@ -3146,18 +3146,18 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
public abstract class UniqueStatement {
|
public abstract class UniqueStatement {
|
||||||
|
|
||||||
public String _method;
|
public String method;
|
||||||
|
|
||||||
public UniqueStatement(String method) {
|
public UniqueStatement(String method) {
|
||||||
this._method = method;
|
this.method = method;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBatch(PreparedStatement stmt) throws SQLException {
|
public void addBatch(PreparedStatement statement) throws SQLException {
|
||||||
stmt.addBatch();
|
statement.addBatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute(PreparedStatement stmt) throws SQLException {
|
public void execute(PreparedStatement statement) throws SQLException {
|
||||||
stmt.executeBatch();
|
statement.executeBatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract PreparedStatement get() throws SQLException;
|
public abstract PreparedStatement get() throws SQLException;
|
||||||
|
@ -11,7 +11,7 @@ public abstract class StmtMod<T> {
|
|||||||
|
|
||||||
public String getCreateMySQL(int size, String query, int params) {
|
public String getCreateMySQL(int size, String query, int params) {
|
||||||
StringBuilder statement = new StringBuilder(query);
|
StringBuilder statement = new StringBuilder(query);
|
||||||
for (int i = 0; i < (size - 1); i++) {
|
for (int i = 0; i < size - 1; i++) {
|
||||||
statement.append("(" + StringMan.repeat(",?", params).substring(1) + "),");
|
statement.append("(" + StringMan.repeat(",?", params).substring(1) + "),");
|
||||||
}
|
}
|
||||||
statement.append("(" + StringMan.repeat(",?", params).substring(1) + ")");
|
statement.append("(" + StringMan.repeat(",?", params).substring(1) + ")");
|
||||||
@ -21,7 +21,7 @@ public abstract class StmtMod<T> {
|
|||||||
public String getCreateSQLite(int size, String query, int params) {
|
public String getCreateSQLite(int size, String query, int params) {
|
||||||
StringBuilder statement = new StringBuilder(query);
|
StringBuilder statement = new StringBuilder(query);
|
||||||
String modParams = StringMan.repeat(",?", params).substring(1);
|
String modParams = StringMan.repeat(",?", params).substring(1);
|
||||||
for (int i = 0; i < (size - 1); i++) {
|
for (int i = 0; i < size - 1; i++) {
|
||||||
statement.append("UNION SELECT " + modParams + " ");
|
statement.append("UNION SELECT " + modParams + " ");
|
||||||
}
|
}
|
||||||
return statement.toString();
|
return statement.toString();
|
||||||
|
@ -12,7 +12,7 @@ public class AbstractFlag {
|
|||||||
public final String key;
|
public final String key;
|
||||||
public final FlagValue<?> value;
|
public final FlagValue<?> value;
|
||||||
|
|
||||||
public AbstractFlag(final String key) {
|
public AbstractFlag(String key) {
|
||||||
this(key, new FlagValue.StringValue());
|
this(key, new FlagValue.StringValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ public class AbstractFlag {
|
|||||||
* The key must be alphabetical characters and <= 16 characters in length
|
* The key must be alphabetical characters and <= 16 characters in length
|
||||||
* @param key
|
* @param key
|
||||||
*/
|
*/
|
||||||
public AbstractFlag(final String key, final FlagValue<?> value) {
|
public AbstractFlag(String key, FlagValue<?> value) {
|
||||||
if (!StringMan.isAlpha(key.replaceAll("_", "").replaceAll("-", ""))) {
|
if (!StringMan.isAlpha(key.replaceAll("_", "").replaceAll("-", ""))) {
|
||||||
throw new IllegalArgumentException("Flag must be alphabetic characters");
|
throw new IllegalArgumentException("Flag must be alphabetic characters");
|
||||||
}
|
}
|
||||||
@ -37,23 +37,23 @@ public class AbstractFlag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isList() {
|
public boolean isList() {
|
||||||
return value instanceof FlagValue.ListValue;
|
return this.value instanceof FlagValue.ListValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object parseValueRaw(final String value) {
|
public Object parseValueRaw(String value) {
|
||||||
try {
|
try {
|
||||||
return this.value.parse(value);
|
return this.value.parse(value);
|
||||||
} catch (final Exception e) {
|
} catch (Exception e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString(final Object t) {
|
public String toString(Object t) {
|
||||||
return value.toString(t);
|
return this.value.toString(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValueDesc() {
|
public String getValueDesc() {
|
||||||
return value.getDescription();
|
return this.value.getDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,28 +62,28 @@ public class AbstractFlag {
|
|||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
public String getKey() {
|
public String getKey() {
|
||||||
return key;
|
return this.key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return key;
|
return this.key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return key.hashCode();
|
return this.key.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object other) {
|
public boolean equals(Object other) {
|
||||||
if (other == this) {
|
if (other == this) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(other instanceof AbstractFlag)) {
|
if (!(other instanceof AbstractFlag)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final AbstractFlag otherObj = (AbstractFlag) other;
|
AbstractFlag otherObj = (AbstractFlag) other;
|
||||||
return otherObj.key.equals(key);
|
return otherObj.key.equals(this.key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
|||||||
import com.intellectualcrafters.plot.util.StringComparison;
|
import com.intellectualcrafters.plot.util.StringComparison;
|
||||||
import com.intellectualcrafters.plot.util.StringMan;
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -26,7 +27,7 @@ public abstract class FlagValue<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean validValue(Object value) {
|
public boolean validValue(Object value) {
|
||||||
return (value != null) && (value.getClass() == this.clazz);
|
return value != null && value.getClass() == this.clazz;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString(Object t) {
|
public String toString(Object t) {
|
||||||
@ -59,20 +60,17 @@ public abstract class FlagValue<T> {
|
|||||||
case "1":
|
case "1":
|
||||||
case "yes":
|
case "yes":
|
||||||
case "allow":
|
case "allow":
|
||||||
case "true": {
|
case "true":
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
case "0":
|
case "0":
|
||||||
case "no":
|
case "no":
|
||||||
case "deny":
|
case "deny":
|
||||||
case "false": {
|
case "false":
|
||||||
return false;
|
return false;
|
||||||
}
|
default:
|
||||||
default: {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
@ -291,7 +289,7 @@ public abstract class FlagValue<T> {
|
|||||||
return new PlotBlock(id, data);
|
return new PlotBlock(id, data);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
StringComparison<PlotBlock>.ComparisonResult value = WorldUtil.IMP.getClosestBlock(t);
|
StringComparison<PlotBlock>.ComparisonResult value = WorldUtil.IMP.getClosestBlock(t);
|
||||||
if ((value == null) || (value.match > 1)) {
|
if (value == null || value.match > 1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return value.best;
|
return value.best;
|
||||||
@ -339,7 +337,7 @@ public abstract class FlagValue<T> {
|
|||||||
block = new PlotBlock(id, data);
|
block = new PlotBlock(id, data);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
StringComparison<PlotBlock>.ComparisonResult value = WorldUtil.IMP.getClosestBlock(t);
|
StringComparison<PlotBlock>.ComparisonResult value = WorldUtil.IMP.getClosestBlock(t);
|
||||||
if ((value == null) || (value.match > 1)) {
|
if (value == null || value.match > 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
block = value.best;
|
block = value.best;
|
||||||
|
@ -20,39 +20,31 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
@Override
|
@Override
|
||||||
public boolean setComponent(PlotArea plotworld, PlotId plotid, String component, PlotBlock[] blocks) {
|
public boolean setComponent(PlotArea plotworld, PlotId plotid, String component, PlotBlock[] blocks) {
|
||||||
switch (component) {
|
switch (component) {
|
||||||
case "floor": {
|
case "floor":
|
||||||
setFloor(plotworld, plotid, blocks);
|
setFloor(plotworld, plotid, blocks);
|
||||||
return true;
|
return true;
|
||||||
}
|
case "wall":
|
||||||
case "wall": {
|
|
||||||
setWallFilling(plotworld, plotid, blocks);
|
setWallFilling(plotworld, plotid, blocks);
|
||||||
return true;
|
return true;
|
||||||
}
|
case "all":
|
||||||
case "all": {
|
|
||||||
setAll(plotworld, plotid, blocks);
|
setAll(plotworld, plotid, blocks);
|
||||||
return true;
|
return true;
|
||||||
}
|
case "air":
|
||||||
case "air": {
|
|
||||||
setAir(plotworld, plotid, blocks);
|
setAir(plotworld, plotid, blocks);
|
||||||
return true;
|
return true;
|
||||||
}
|
case "main":
|
||||||
case "main": {
|
|
||||||
setMain(plotworld, plotid, blocks);
|
setMain(plotworld, plotid, blocks);
|
||||||
return true;
|
return true;
|
||||||
}
|
case "middle":
|
||||||
case "middle": {
|
|
||||||
setMiddle(plotworld, plotid, blocks);
|
setMiddle(plotworld, plotid, blocks);
|
||||||
return true;
|
return true;
|
||||||
}
|
case "outline":
|
||||||
case "outline": {
|
|
||||||
setOutline(plotworld, plotid, blocks);
|
setOutline(plotworld, plotid, blocks);
|
||||||
return true;
|
return true;
|
||||||
}
|
case "border":
|
||||||
case "border": {
|
|
||||||
setWall(plotworld, plotid, blocks);
|
setWall(plotworld, plotid, blocks);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,6 +451,6 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||||
plot = plot.getBasePlot(false);
|
plot = plot.getBasePlot(false);
|
||||||
Location bot = plot.getBottomAbs();
|
Location bot = plot.getBottomAbs();
|
||||||
return new com.intellectualcrafters.plot.object.Location(plotworld.worldname, bot.getX() - 1, dpw.ROAD_HEIGHT + 1, bot.getZ() - 2);
|
return new Location(plotworld.worldname, bot.getX() - 1, dpw.ROAD_HEIGHT + 1, bot.getZ() - 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ public class Rating {
|
|||||||
public Rating(int value) {
|
public Rating(int value) {
|
||||||
this.initial = value;
|
this.initial = value;
|
||||||
this.ratingMap = new HashMap<>();
|
this.ratingMap = new HashMap<>();
|
||||||
if ((Settings.RATING_CATEGORIES != null) && (Settings.RATING_CATEGORIES.size() > 1)) {
|
if (Settings.RATING_CATEGORIES != null && Settings.RATING_CATEGORIES.size() > 1) {
|
||||||
if (value < 10) {
|
if (value < 10) {
|
||||||
for (String ratingCategory : Settings.RATING_CATEGORIES) {
|
for (String ratingCategory : Settings.RATING_CATEGORIES) {
|
||||||
this.ratingMap.put(ratingCategory, value);
|
this.ratingMap.put(ratingCategory, value);
|
||||||
@ -27,7 +27,7 @@ public class Rating {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (String ratingCategory : Settings.RATING_CATEGORIES) {
|
for (String ratingCategory : Settings.RATING_CATEGORIES) {
|
||||||
this.ratingMap.put(ratingCategory, (value % 10) - 1);
|
this.ratingMap.put(ratingCategory, value % 10 - 1);
|
||||||
value = value / 10;
|
value = value / 10;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -66,7 +66,7 @@ public class Rating {
|
|||||||
if (!this.changed) {
|
if (!this.changed) {
|
||||||
return this.initial;
|
return this.initial;
|
||||||
}
|
}
|
||||||
if ((Settings.RATING_CATEGORIES != null) && (Settings.RATING_CATEGORIES.size() > 1)) {
|
if (Settings.RATING_CATEGORIES != null && Settings.RATING_CATEGORIES.size() > 1) {
|
||||||
int val = 0;
|
int val = 0;
|
||||||
for (int i = 0; i < Settings.RATING_CATEGORIES.size(); i++) {
|
for (int i = 0; i < Settings.RATING_CATEGORIES.size(); i++) {
|
||||||
val += (i + 1) * Math.pow(10, this.ratingMap.get(Settings.RATING_CATEGORIES.get(i)));
|
val += (i + 1) * Math.pow(10, this.ratingMap.get(Settings.RATING_CATEGORIES.get(i)));
|
||||||
|
@ -8,16 +8,16 @@ public class RegionWrapper {
|
|||||||
public final int minZ;
|
public final int minZ;
|
||||||
public final int maxZ;
|
public final int maxZ;
|
||||||
|
|
||||||
public RegionWrapper(final int minX, final int maxX, final int minZ, final int maxZ) {
|
public RegionWrapper(int minX, int maxX, int minZ, int maxZ) {
|
||||||
this.maxX = maxX;
|
this.maxX = maxX;
|
||||||
this.minX = minX;
|
this.minX = minX;
|
||||||
this.maxZ = maxZ;
|
this.maxZ = maxZ;
|
||||||
this.minZ = minZ;
|
this.minZ = minZ;
|
||||||
minY = 0;
|
this.minY = 0;
|
||||||
maxY = 256;
|
this.maxY = 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RegionWrapper(final int minX, final int maxX, final int minY, final int maxY, final int minZ, final int maxZ) {
|
public RegionWrapper(int minX, int maxX, int minY, int maxY, int minZ, int maxZ) {
|
||||||
this.maxX = maxX;
|
this.maxX = maxX;
|
||||||
this.minX = minX;
|
this.minX = minX;
|
||||||
this.maxZ = maxZ;
|
this.maxZ = maxZ;
|
||||||
@ -26,12 +26,12 @@ public class RegionWrapper {
|
|||||||
this.maxY = maxY;
|
this.maxY = maxY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIn(final int x, final int y, final int z) {
|
public boolean isIn(int x, int y, int z) {
|
||||||
return x >= minX && x <= maxX && z >= minZ && z <= maxZ && y >= minY && y <= maxY;
|
return x >= this.minX && x <= this.maxX && z >= this.minZ && z <= this.maxZ && y >= this.minY && y <= this.maxY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIn(final int x, final int z) {
|
public boolean isIn(int x, int z) {
|
||||||
return x >= minX && x <= maxX && z >= minZ && z <= maxZ;
|
return x >= this.minX && x <= this.maxX && z >= this.minZ && z <= this.maxZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean intersects(RegionWrapper other) {
|
public boolean intersects(RegionWrapper other) {
|
||||||
@ -40,7 +40,7 @@ public class RegionWrapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return minX + 13 * maxX + 23 * minZ + 39 * maxZ;
|
return this.minX + 13 * this.maxX + 23 * this.minZ + 39 * this.maxZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -53,19 +53,20 @@ public class RegionWrapper {
|
|||||||
}
|
}
|
||||||
if (obj instanceof RegionWrapper) {
|
if (obj instanceof RegionWrapper) {
|
||||||
RegionWrapper other = (RegionWrapper) obj;
|
RegionWrapper other = (RegionWrapper) obj;
|
||||||
return minX == other.minX && minZ == other.minZ && minY == other.minY && maxX == other.maxX && maxZ == other.maxZ && maxY == other.maxY;
|
return this.minX == other.minX && this.minZ == other.minZ && this.minY == other.minY && this.maxX == other.maxX && this.maxZ == other.maxZ
|
||||||
|
&& this.maxY == other.maxY;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return minX + "->" + maxX + "," + minZ + "->" + maxZ;
|
return this.minX + "->" + this.maxX + "," + this.minZ + "->" + this.maxZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location[] getCorners(String world) {
|
public Location[] getCorners(String world) {
|
||||||
Location pos1 = new Location(world, minX, minY, minZ);
|
Location pos1 = new Location(world, this.minX, this.minY, this.minZ);
|
||||||
Location pos2 = new Location(world, maxX, maxY, maxZ);
|
Location pos2 = new Location(world, this.maxX, this.maxY, this.maxZ);
|
||||||
return new Location[] { pos1, pos2 };
|
return new Location[] { pos1, pos2 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ public abstract class RunnableVal<T> implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
run(value);
|
run(this.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void run(T value);
|
public abstract void run(T value);
|
||||||
|
@ -13,7 +13,7 @@ public abstract class RunnableVal2<T, U> implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
run(value1, value2);
|
run(this.value1, this.value2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void run(T value1, U value2);
|
public abstract void run(T value1, U value2);
|
||||||
|
@ -222,37 +222,33 @@ public class MainUtil {
|
|||||||
case "week":
|
case "week":
|
||||||
case "weeks":
|
case "weeks":
|
||||||
case "wks":
|
case "wks":
|
||||||
case "w": {
|
case "w":
|
||||||
|
|
||||||
time += 604800 * nums;
|
time += 604800 * nums;
|
||||||
}
|
|
||||||
case "days":
|
case "days":
|
||||||
case "day":
|
case "day":
|
||||||
case "d": {
|
case "d":
|
||||||
time += 86400 * nums;
|
time += 86400 * nums;
|
||||||
}
|
|
||||||
case "hour":
|
case "hour":
|
||||||
case "hr":
|
case "hr":
|
||||||
case "hrs":
|
case "hrs":
|
||||||
case "hours":
|
case "hours":
|
||||||
case "h": {
|
case "h":
|
||||||
time += 3600 * nums;
|
time += 3600 * nums;
|
||||||
}
|
|
||||||
case "minutes":
|
case "minutes":
|
||||||
case "minute":
|
case "minute":
|
||||||
case "mins":
|
case "mins":
|
||||||
case "min":
|
case "min":
|
||||||
case "m": {
|
case "m":
|
||||||
time += 60 * nums;
|
time += 60 * nums;
|
||||||
}
|
|
||||||
case "seconds":
|
case "seconds":
|
||||||
case "second":
|
case "second":
|
||||||
case "secs":
|
case "secs":
|
||||||
case "sec":
|
case "sec":
|
||||||
case "s": {
|
case "s":
|
||||||
time += nums;
|
time += nums;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,7 +302,6 @@ public abstract class Command {
|
|||||||
}
|
}
|
||||||
// Command recommendation
|
// Command recommendation
|
||||||
MainUtil.sendMessage(player, C.NOT_VALID_SUBCOMMAND);
|
MainUtil.sendMessage(player, C.NOT_VALID_SUBCOMMAND);
|
||||||
{
|
|
||||||
List<Command> commands = getCommands(player);
|
List<Command> commands = getCommands(player);
|
||||||
if (commands.isEmpty()) {
|
if (commands.isEmpty()) {
|
||||||
MainUtil.sendMessage(player, C.DID_YOU_MEAN, MainCommand.getInstance().help.getUsage());
|
MainUtil.sendMessage(player, C.DID_YOU_MEAN, MainCommand.getInstance().help.getUsage());
|
||||||
@ -324,7 +323,6 @@ public abstract class Command {
|
|||||||
cmd = new StringComparison<>(args[0], this.allCommands).getMatchObject();
|
cmd = new StringComparison<>(args[0], this.allCommands).getMatchObject();
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, C.DID_YOU_MEAN, cmd.getUsage());
|
MainUtil.sendMessage(player, C.DID_YOU_MEAN, cmd.getUsage());
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String[] newArgs = Arrays.copyOfRange(args, 1, args.length);
|
String[] newArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||||
@ -336,7 +334,7 @@ public abstract class Command {
|
|||||||
|
|
||||||
public boolean checkArgs(PlotPlayer player, String[] args) {
|
public boolean checkArgs(PlotPlayer player, String[] args) {
|
||||||
Argument<?>[] reqArgs = getRequiredArguments();
|
Argument<?>[] reqArgs = getRequiredArguments();
|
||||||
if ((reqArgs != null) && (reqArgs.length > 0)) {
|
if (reqArgs != null && reqArgs.length > 0) {
|
||||||
boolean failed = args.length < reqArgs.length;
|
boolean failed = args.length < reqArgs.length;
|
||||||
String[] baseSplit = getCommandString().split(" ");
|
String[] baseSplit = getCommandString().split(" ");
|
||||||
String[] fullSplit = getUsage().split(" ");
|
String[] fullSplit = getUsage().split(" ");
|
||||||
|
@ -13,6 +13,7 @@ import com.sk89q.worldedit.entity.BaseEntity;
|
|||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.extent.NullExtent;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
|
|
||||||
@ -81,7 +82,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
case 29:
|
case 29:
|
||||||
case 33:
|
case 33:
|
||||||
case 151:
|
case 151:
|
||||||
case 178: {
|
case 178:
|
||||||
if (this.BSblocked) {
|
if (this.BSblocked) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -96,7 +97,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
try {
|
try {
|
||||||
Field field = AbstractDelegateExtent.class.getDeclaredField("extent");
|
Field field = AbstractDelegateExtent.class.getDeclaredField("extent");
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
field.set(this.parent, new com.sk89q.worldedit.extent.NullExtent());
|
field.set(this.parent, new NullExtent());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -107,8 +108,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
return super.setBlock(location, block);
|
return super.setBlock(location, block);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
default: {
|
|
||||||
int x = location.getBlockX();
|
int x = location.getBlockX();
|
||||||
int y = location.getBlockY();
|
int y = location.getBlockY();
|
||||||
int z = location.getBlockZ();
|
int z = location.getBlockZ();
|
||||||
@ -118,7 +118,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
try {
|
try {
|
||||||
Field field = AbstractDelegateExtent.class.getDeclaredField("extent");
|
Field field = AbstractDelegateExtent.class.getDeclaredField("extent");
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
field.set(this.parent, new com.sk89q.worldedit.extent.NullExtent());
|
field.set(this.parent, new NullExtent());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -208,15 +208,14 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
case 189:
|
case 189:
|
||||||
case 190:
|
case 190:
|
||||||
case 191:
|
case 191:
|
||||||
case 192: {
|
case 192:
|
||||||
if (Settings.EXPERIMENTAL_FAST_ASYNC_WORLDEDIT) {
|
if (Settings.EXPERIMENTAL_FAST_ASYNC_WORLDEDIT) {
|
||||||
SetQueue.IMP.setBlock(this.world, x, y, z, id);
|
SetQueue.IMP.setBlock(this.world, x, y, z, id);
|
||||||
} else {
|
} else {
|
||||||
super.setBlock(location, block);
|
super.setBlock(location, block);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
default: {
|
|
||||||
if (Settings.EXPERIMENTAL_FAST_ASYNC_WORLDEDIT) {
|
if (Settings.EXPERIMENTAL_FAST_ASYNC_WORLDEDIT) {
|
||||||
SetQueue.IMP.setBlock(this.world, x, y, z, new PlotBlock((short) id, (byte) block.getData()));
|
SetQueue.IMP.setBlock(this.world, x, y, z, new PlotBlock((short) id, (byte) block.getData()));
|
||||||
} else {
|
} else {
|
||||||
@ -224,10 +223,8 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -91,7 +91,7 @@ public class MainListener {
|
|||||||
@Listener
|
@Listener
|
||||||
public void onCommand(SendCommandEvent event) {
|
public void onCommand(SendCommandEvent event) {
|
||||||
switch (event.getCommand().toLowerCase()) {
|
switch (event.getCommand().toLowerCase()) {
|
||||||
case "plotme": {
|
case "plotme":
|
||||||
Player source = SpongeUtil.getCause(event.getCause(), Player.class);
|
Player source = SpongeUtil.getCause(event.getCause(), Player.class);
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
return;
|
return;
|
||||||
@ -104,7 +104,6 @@ public class MainListener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void onChat(MessageEvent event) {
|
public void onChat(MessageEvent event) {
|
||||||
@ -119,7 +118,7 @@ public class MainListener {
|
|||||||
}
|
}
|
||||||
PlotArea plotworld = PS.get().getPlotAreaByString(world);
|
PlotArea plotworld = PS.get().getPlotAreaByString(world);
|
||||||
PlotPlayer plr = SpongeUtil.getPlayer(player);
|
PlotPlayer plr = SpongeUtil.getPlayer(player);
|
||||||
if (!plotworld.PLOT_CHAT && ((plr.getMeta("chat") == null) || !(Boolean) plr.getMeta("chat"))) {
|
if (!plotworld.PLOT_CHAT && (plr.getMeta("chat") == null || !(Boolean) plr.getMeta("chat"))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location loc = SpongeUtil.getLocation(player);
|
Location loc = SpongeUtil.getLocation(player);
|
||||||
@ -222,7 +221,7 @@ public class MainListener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((entity instanceof Ambient) || (entity instanceof Animal)) {
|
if (entity instanceof Ambient || entity instanceof Animal) {
|
||||||
Flag animalFlag = FlagManager.getPlotFlagRaw(plot, "animal-cap");
|
Flag animalFlag = FlagManager.getPlotFlagRaw(plot, "animal-cap");
|
||||||
if (animalFlag != null) {
|
if (animalFlag != null) {
|
||||||
int cap = (Integer) animalFlag.getValue();
|
int cap = (Integer) animalFlag.getValue();
|
||||||
@ -252,7 +251,7 @@ public class MainListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if ((entity instanceof Minecart) || (entity instanceof Boat)) {
|
} else if (entity instanceof Minecart || entity instanceof Boat) {
|
||||||
Flag vehicleFlag = FlagManager.getPlotFlagRaw(plot, "vehicle-cap");
|
Flag vehicleFlag = FlagManager.getPlotFlagRaw(plot, "vehicle-cap");
|
||||||
if (vehicleFlag != null) {
|
if (vehicleFlag != null) {
|
||||||
int cap = (Integer) vehicleFlag.getValue();
|
int cap = (Integer) vehicleFlag.getValue();
|
||||||
@ -358,7 +357,7 @@ public class MainListener {
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
|
Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
|
||||||
if ((flag != null) && ((HashSet<PlotBlock>) flag.getValue()).contains(SpongeUtil.getPlotBlock(l.getBlock()))) {
|
if (flag != null && ((HashSet<PlotBlock>) flag.getValue()).contains(SpongeUtil.getPlotBlock(l.getBlock()))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_OTHER);
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_OTHER);
|
||||||
@ -497,7 +496,7 @@ public class MainListener {
|
|||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
|
||||||
Flag destroy = FlagManager.getPlotFlagRaw(plot, "break");
|
Flag destroy = FlagManager.getPlotFlagRaw(plot, "break");
|
||||||
BlockState state = pos.getState();
|
BlockState state = pos.getState();
|
||||||
if ((destroy == null) || !((HashSet<PlotBlock>) destroy.getValue()).contains(SpongeUtil.getPlotBlock(state))) {
|
if (destroy == null || !((HashSet<PlotBlock>) destroy.getValue()).contains(SpongeUtil.getPlotBlock(state))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -527,7 +526,7 @@ public class MainListener {
|
|||||||
} else {
|
} else {
|
||||||
Flag destroy = FlagManager.getPlotFlagRaw(plot, "break");
|
Flag destroy = FlagManager.getPlotFlagRaw(plot, "break");
|
||||||
BlockState state = l.getBlock();
|
BlockState state = l.getBlock();
|
||||||
if ((destroy != null) && ((HashSet<PlotBlock>) destroy.getValue()).contains(SpongeUtil.getPlotBlock(state))) {
|
if (destroy != null && ((HashSet<PlotBlock>) destroy.getValue()).contains(SpongeUtil.getPlotBlock(state))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
|
||||||
@ -578,7 +577,7 @@ public class MainListener {
|
|||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
||||||
Flag BUILD = FlagManager.getPlotFlagRaw(plot, C.FLAG_PLACE.s());
|
Flag BUILD = FlagManager.getPlotFlagRaw(plot, C.FLAG_PLACE.s());
|
||||||
BlockState state = pos.getState();
|
BlockState state = pos.getState();
|
||||||
if ((BUILD == null) || !((HashSet<PlotBlock>) BUILD.getValue()).contains(SpongeUtil.getPlotBlock(state))) {
|
if (BUILD == null || !((HashSet<PlotBlock>) BUILD.getValue()).contains(SpongeUtil.getPlotBlock(state))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -608,7 +607,7 @@ public class MainListener {
|
|||||||
} else {
|
} else {
|
||||||
Flag build = FlagManager.getPlotFlagRaw(plot, C.FLAG_PLACE.s());
|
Flag build = FlagManager.getPlotFlagRaw(plot, C.FLAG_PLACE.s());
|
||||||
BlockState state = l.getBlock();
|
BlockState state = l.getBlock();
|
||||||
if ((build != null) && ((HashSet<PlotBlock>) build.getValue()).contains(SpongeUtil.getPlotBlock(state))) {
|
if (build != null && ((HashSet<PlotBlock>) build.getValue()).contains(SpongeUtil.getPlotBlock(state))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
||||||
|
@ -41,9 +41,9 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
|||||||
Location bot = corners[0];
|
Location bot = corners[0];
|
||||||
Location top = corners[1];
|
Location top = corners[1];
|
||||||
|
|
||||||
int width = (top.getX() - bot.getX()) + 1;
|
int width = top.getX() - bot.getX() + 1;
|
||||||
int height = (top.getY() - bot.getY()) + 1;
|
int height = top.getY() - bot.getY() + 1;
|
||||||
int length = (top.getZ() - bot.getZ()) + 1;
|
int length = top.getZ() - bot.getZ() + 1;
|
||||||
// Main Schematic tag
|
// Main Schematic tag
|
||||||
HashMap<String, Tag> schematic = new HashMap<>();
|
HashMap<String, Tag> schematic = new HashMap<>();
|
||||||
schematic.put("Width", new ShortTag("Width", (short) width));
|
schematic.put("Width", new ShortTag("Width", (short) width));
|
||||||
@ -110,7 +110,7 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
while (!chunks.isEmpty() && ((System.currentTimeMillis() - start) < 20)) {
|
while (!chunks.isEmpty() && System.currentTimeMillis() - start < 20) {
|
||||||
// save schematics
|
// save schematics
|
||||||
ChunkLoc chunk = chunks.remove(0);
|
ChunkLoc chunk = chunks.remove(0);
|
||||||
int X = chunk.x;
|
int X = chunk.x;
|
||||||
@ -140,7 +140,7 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
|||||||
int i1 = ry * width * length;
|
int i1 = ry * width * length;
|
||||||
for (int z = zzb; z <= zzt; z++) {
|
for (int z = zzb; z <= zzt; z++) {
|
||||||
int rz = z - p1z;
|
int rz = z - p1z;
|
||||||
int i2 = i1 + (rz * width);
|
int i2 = i1 + rz * width;
|
||||||
for (int x = xxb; x <= xxt; x++) {
|
for (int x = xxb; x <= xxt; x++) {
|
||||||
int rx = x - p1x;
|
int rx = x - p1x;
|
||||||
int index = i2 + rx;
|
int index = i2 + rx;
|
||||||
@ -216,9 +216,8 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
|||||||
case 189:
|
case 189:
|
||||||
case 190:
|
case 190:
|
||||||
case 191:
|
case 191:
|
||||||
case 192: {
|
case 192:
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case 54:
|
case 54:
|
||||||
case 130:
|
case 130:
|
||||||
case 142:
|
case 142:
|
||||||
@ -253,7 +252,7 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
|||||||
case 29:
|
case 29:
|
||||||
case 33:
|
case 33:
|
||||||
case 151:
|
case 151:
|
||||||
case 178: {
|
case 178:
|
||||||
CompoundTag rawTag;
|
CompoundTag rawTag;
|
||||||
if (state instanceof Carrier) {
|
if (state instanceof Carrier) {
|
||||||
Carrier chest = (Carrier) state;
|
Carrier chest = (Carrier) state;
|
||||||
@ -275,11 +274,9 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
|||||||
CompoundTag tileEntityTag = new CompoundTag(values);
|
CompoundTag tileEntityTag = new CompoundTag(values);
|
||||||
tileEntities.add(tileEntityTag);
|
tileEntities.add(tileEntityTag);
|
||||||
}
|
}
|
||||||
}
|
default:
|
||||||
default: {
|
|
||||||
blockData[index] = block.data;
|
blockData[index] = block.data;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
blocks[index] = (byte) id;
|
blocks[index] = (byte) id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,12 +39,12 @@ public class SpongeSetupUtils extends SetupUtils {
|
|||||||
String id = wgm.getId();
|
String id = wgm.getId();
|
||||||
String name = wgm.getName();
|
String name = wgm.getName();
|
||||||
if (wgm instanceof GeneratorWrapper<?>) {
|
if (wgm instanceof GeneratorWrapper<?>) {
|
||||||
generators.put(id, (GeneratorWrapper<?>) wgm);
|
SetupUtils.generators.put(id, (GeneratorWrapper<?>) wgm);
|
||||||
generators.put(name, (GeneratorWrapper<?>) wgm);
|
SetupUtils.generators.put(name, (GeneratorWrapper<?>) wgm);
|
||||||
} else {
|
} else {
|
||||||
SpongePlotGenerator wrap = new SpongePlotGenerator(wgm);
|
SpongePlotGenerator wrap = new SpongePlotGenerator(wgm);
|
||||||
generators.put(id, wrap);
|
SetupUtils.generators.put(id, wrap);
|
||||||
generators.put(name, wrap);
|
SetupUtils.generators.put(name, wrap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ public class SpongeSetupUtils extends SetupUtils {
|
|||||||
options.put("generator.type", object.type);
|
options.put("generator.type", object.type);
|
||||||
options.put("generator.terrain", object.terrain);
|
options.put("generator.terrain", object.terrain);
|
||||||
options.put("generator.plugin", object.plotManager);
|
options.put("generator.plugin", object.plotManager);
|
||||||
if ((object.setupGenerator != null) && !object.setupGenerator.equals(object.plotManager)) {
|
if (object.setupGenerator != null && !object.setupGenerator.equals(object.plotManager)) {
|
||||||
options.put("generator.init", object.setupGenerator);
|
options.put("generator.init", object.setupGenerator);
|
||||||
}
|
}
|
||||||
for (Entry<String, Object> entry : options.entrySet()) {
|
for (Entry<String, Object> entry : options.entrySet()) {
|
||||||
@ -105,35 +105,33 @@ public class SpongeSetupUtils extends SetupUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GeneratorWrapper<?> gen = generators.get(object.setupGenerator);
|
GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);
|
||||||
if ((gen != null) && gen.isFull()) {
|
if (gen != null && gen.isFull()) {
|
||||||
object.setupGenerator = null;
|
object.setupGenerator = null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1: {
|
case 1:
|
||||||
for (ConfigurationNode step : steps) {
|
for (ConfigurationNode step : steps) {
|
||||||
worldSection.set(step.getConstant(), step.getValue());
|
worldSection.set(step.getConstant(), step.getValue());
|
||||||
}
|
}
|
||||||
PS.get().config.set("worlds." + world + "." + "generator.type", object.type);
|
PS.get().config.set("worlds." + world + "." + "generator.type", object.type);
|
||||||
PS.get().config.set("worlds." + world + "." + "generator.terrain", object.terrain);
|
PS.get().config.set("worlds." + world + "." + "generator.terrain", object.terrain);
|
||||||
PS.get().config.set("worlds." + world + "." + "generator.plugin", object.plotManager);
|
PS.get().config.set("worlds." + world + "." + "generator.plugin", object.plotManager);
|
||||||
if ((object.setupGenerator != null) && !object.setupGenerator.equals(object.plotManager)) {
|
if (object.setupGenerator != null && !object.setupGenerator.equals(object.plotManager)) {
|
||||||
PS.get().config.set("worlds." + world + "." + "generator.init", object.setupGenerator);
|
PS.get().config.set("worlds." + world + "." + "generator.init", object.setupGenerator);
|
||||||
}
|
}
|
||||||
GeneratorWrapper<?> gen = generators.get(object.setupGenerator);
|
GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);
|
||||||
if ((gen != null) && gen.isFull()) {
|
if (gen != null && gen.isFull()) {
|
||||||
object.setupGenerator = null;
|
object.setupGenerator = null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
case 0:
|
||||||
case 0: {
|
|
||||||
for (ConfigurationNode step : steps) {
|
for (ConfigurationNode step : steps) {
|
||||||
worldSection.set(step.getConstant(), step.getValue());
|
worldSection.set(step.getConstant(), step.getValue());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
PS.get().config.save(PS.get().configFile);
|
PS.get().config.save(PS.get().configFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -141,7 +139,7 @@ public class SpongeSetupUtils extends SetupUtils {
|
|||||||
}
|
}
|
||||||
if (object.setupGenerator != null) {
|
if (object.setupGenerator != null) {
|
||||||
// create world with generator
|
// create world with generator
|
||||||
GeneratorWrapper<?> gw = generators.get(object.setupGenerator);
|
GeneratorWrapper<?> gw = SetupUtils.generators.get(object.setupGenerator);
|
||||||
WorldGeneratorModifier wgm = (WorldGeneratorModifier) gw.getPlatformGenerator();
|
WorldGeneratorModifier wgm = (WorldGeneratorModifier) gw.getPlatformGenerator();
|
||||||
|
|
||||||
WorldCreationSettings settings = Sponge.getRegistry().createBuilder(Builder.class)
|
WorldCreationSettings settings = Sponge.getRegistry().createBuilder(Builder.class)
|
||||||
|
@ -19,30 +19,30 @@ public class SpongeLowerOfflineUUIDWrapper extends UUIDWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getUUID(final PlotPlayer player) {
|
public UUID getUUID(PlotPlayer player) {
|
||||||
return getUUID(player.getName());
|
return getUUID(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getUUID(final OfflinePlotPlayer player) {
|
public UUID getUUID(OfflinePlotPlayer player) {
|
||||||
return getUUID(player.getName());
|
return getUUID(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OfflinePlotPlayer getOfflinePlayer(final UUID uuid) {
|
public OfflinePlotPlayer getOfflinePlayer(UUID uuid) {
|
||||||
String name = UUIDHandler.getName(uuid);
|
String name = UUIDHandler.getName(uuid);
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
try {
|
try {
|
||||||
final GameProfile profile = SpongeMain.THIS.getResolver().get(uuid).get();
|
GameProfile profile = SpongeMain.THIS.getResolver().get(uuid).get();
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
name = profile.getName().orElse(null);
|
name = profile.getName().orElse(null);
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
for (final GameProfile profile : SpongeMain.THIS.getResolver().getCachedProfiles()) {
|
for (GameProfile profile : SpongeMain.THIS.getResolver().getCachedProfiles()) {
|
||||||
String tmp = profile.getName().orElse(null);
|
String tmp = profile.getName().orElse(null);
|
||||||
if (tmp != null) {
|
if (tmp != null) {
|
||||||
if (getUUID(name).equals(uuid)) {
|
if (getUUID(name).equals(uuid)) {
|
||||||
@ -52,7 +52,7 @@ public class SpongeLowerOfflineUUIDWrapper extends UUIDWrapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final String username = name;
|
String username = name;
|
||||||
return new OfflinePlotPlayer() {
|
return new OfflinePlotPlayer() {
|
||||||
@Override
|
@Override
|
||||||
public boolean isOnline() {
|
public boolean isOnline() {
|
||||||
@ -83,7 +83,7 @@ public class SpongeLowerOfflineUUIDWrapper extends UUIDWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getUUID(final String name) {
|
public UUID getUUID(String name) {
|
||||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
|
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user