mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 06:36:44 +01:00
Minor cleanup in favor of Java 16
- Addressing a few command deprecations during the major release superseded by toggles - Don't swallow SQL warnings in loggers behind debug, as it's often set to false - Deleted JavaVersionCheck, it's part of ServerLib.
This commit is contained in:
parent
0341111f8f
commit
3748d8e246
@ -68,7 +68,6 @@ import com.plotsquared.bukkit.uuid.SquirrelIdUUIDService;
|
|||||||
import com.plotsquared.core.PlotPlatform;
|
import com.plotsquared.core.PlotPlatform;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.backup.BackupManager;
|
import com.plotsquared.core.backup.BackupManager;
|
||||||
import com.plotsquared.core.command.WE_Anywhere;
|
|
||||||
import com.plotsquared.core.components.ComponentPresetManager;
|
import com.plotsquared.core.components.ComponentPresetManager;
|
||||||
import com.plotsquared.core.configuration.ConfigurationNode;
|
import com.plotsquared.core.configuration.ConfigurationNode;
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
@ -162,7 +161,6 @@ import java.util.concurrent.Executors;
|
|||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static com.plotsquared.bukkit.util.JavaVersionCheck.checkJvm;
|
|
||||||
import static com.plotsquared.core.util.PremiumVerification.getDownloadID;
|
import static com.plotsquared.core.util.PremiumVerification.getDownloadID;
|
||||||
import static com.plotsquared.core.util.PremiumVerification.getResourceID;
|
import static com.plotsquared.core.util.PremiumVerification.getResourceID;
|
||||||
import static com.plotsquared.core.util.PremiumVerification.getUserID;
|
import static com.plotsquared.core.util.PremiumVerification.getUserID;
|
||||||
@ -321,9 +319,6 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
try {
|
try {
|
||||||
logger.info("{} hooked into WorldEdit", this.pluginName());
|
logger.info("{} hooked into WorldEdit", this.pluginName());
|
||||||
WorldEdit.getInstance().getEventBus().register(this.injector().getInstance(WESubscriber.class));
|
WorldEdit.getInstance().getEventBus().register(this.injector().getInstance(WESubscriber.class));
|
||||||
if (Settings.Enabled_Components.COMMANDS) {
|
|
||||||
new WE_Anywhere();
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.error(
|
logger.error(
|
||||||
"Incompatible version of WorldEdit, please upgrade: https://builds.enginehub.org/job/worldedit?branch=master");
|
"Incompatible version of WorldEdit, please upgrade: https://builds.enginehub.org/job/worldedit?branch=master");
|
||||||
@ -542,10 +537,9 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
}
|
}
|
||||||
}, 100L, 100L);
|
}, 100L, 100L);
|
||||||
|
|
||||||
// Check whether the server runs on 11 or greater
|
|
||||||
checkJvm();
|
|
||||||
// Check if we are in a safe environment
|
// Check if we are in a safe environment
|
||||||
ServerLib.checkUnsafeForks();
|
ServerLib.checkUnsafeForks();
|
||||||
|
// Check whether the server runs on 16 or greater
|
||||||
ServerLib.checkJavaLTS();
|
ServerLib.checkJavaLTS();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -947,8 +941,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
|
if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
|
||||||
Location location = entity.getLocation();
|
Location location = entity.getLocation();
|
||||||
if (BukkitUtil.adapt(location).isPlotRoad()) {
|
if (BukkitUtil.adapt(location).isPlotRoad()) {
|
||||||
if (entity instanceof LivingEntity) {
|
if (entity instanceof LivingEntity livingEntity) {
|
||||||
LivingEntity livingEntity = (LivingEntity) entity;
|
|
||||||
if ((Settings.Enabled_Components.KILL_OWNED_ROAD_MOBS || !livingEntity.isLeashed())
|
if ((Settings.Enabled_Components.KILL_OWNED_ROAD_MOBS || !livingEntity.isLeashed())
|
||||||
|| !entity.hasMetadata("keep")) {
|
|| !entity.hasMetadata("keep")) {
|
||||||
Entity passenger = entity.getPassenger();
|
Entity passenger = entity.getPassenger();
|
||||||
@ -976,7 +969,6 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,8 +189,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
|||||||
AbstractHorse horse = (AbstractHorse) entity;
|
AbstractHorse horse = (AbstractHorse) entity;
|
||||||
this.horse = new HorseStats();
|
this.horse = new HorseStats();
|
||||||
this.horse.jump = horse.getJumpStrength();
|
this.horse.jump = horse.getJumpStrength();
|
||||||
if (horse instanceof ChestedHorse) {
|
if (horse instanceof ChestedHorse horse1) {
|
||||||
ChestedHorse horse1 = (ChestedHorse) horse;
|
|
||||||
this.horse.chest = horse1.isCarryingChest();
|
this.horse.chest = horse1.isCarryingChest();
|
||||||
}
|
}
|
||||||
//todo these horse features need fixing
|
//todo these horse features need fixing
|
||||||
|
@ -243,22 +243,13 @@ public class BlockEventListener implements Listener {
|
|||||||
default:
|
default:
|
||||||
if (Settings.Redstone.DETECT_INVALID_EDGE_PISTONS) {
|
if (Settings.Redstone.DETECT_INVALID_EDGE_PISTONS) {
|
||||||
switch (block.getType()) {
|
switch (block.getType()) {
|
||||||
case PISTON:
|
case PISTON, STICKY_PISTON -> {
|
||||||
case STICKY_PISTON:
|
|
||||||
org.bukkit.block.data.Directional piston = (org.bukkit.block.data.Directional) block.getBlockData();
|
org.bukkit.block.data.Directional piston = (org.bukkit.block.data.Directional) block.getBlockData();
|
||||||
switch (piston.getFacing()) {
|
switch (piston.getFacing()) {
|
||||||
case EAST:
|
case EAST -> location = location.add(1, 0, 0);
|
||||||
location = location.add(1, 0, 0);
|
case SOUTH -> location = location.add(-1, 0, 0);
|
||||||
break;
|
case WEST -> location = location.add(0, 0, 1);
|
||||||
case SOUTH:
|
case NORTH -> location = location.add(0, 0, -1);
|
||||||
location = location.add(-1, 0, 0);
|
|
||||||
break;
|
|
||||||
case WEST:
|
|
||||||
location = location.add(0, 0, 1);
|
|
||||||
break;
|
|
||||||
case NORTH:
|
|
||||||
location = location.add(0, 0, -1);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
Plot newPlot = area.getOwnedPlotAbs(location);
|
Plot newPlot = area.getOwnedPlotAbs(location);
|
||||||
if (!plot.equals(newPlot)) {
|
if (!plot.equals(newPlot)) {
|
||||||
@ -266,6 +257,7 @@ public class BlockEventListener implements Listener {
|
|||||||
plot.debug("Prevented piston update because of invalid edge piston detection");
|
plot.debug("Prevented piston update because of invalid edge piston detection");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -548,8 +540,7 @@ public class BlockEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
boolean allowed = plot.getFlag(flag);
|
boolean allowed = plot.getFlag(flag);
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
if (entity instanceof Player) {
|
if (entity instanceof Player player) {
|
||||||
Player player = (Player) entity;
|
|
||||||
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
|
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
|
||||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||||
if (allowed) {
|
if (allowed) {
|
||||||
@ -889,37 +880,7 @@ public class BlockEventListener implements Listener {
|
|||||||
public void onBlockDispense(BlockDispenseEvent event) {
|
public void onBlockDispense(BlockDispenseEvent event) {
|
||||||
Material type = event.getItem().getType();
|
Material type = event.getItem().getType();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SHULKER_BOX:
|
case SHULKER_BOX, WHITE_SHULKER_BOX, ORANGE_SHULKER_BOX, MAGENTA_SHULKER_BOX, LIGHT_BLUE_SHULKER_BOX, YELLOW_SHULKER_BOX, LIME_SHULKER_BOX, PINK_SHULKER_BOX, GRAY_SHULKER_BOX, LIGHT_GRAY_SHULKER_BOX, CYAN_SHULKER_BOX, PURPLE_SHULKER_BOX, BLUE_SHULKER_BOX, BROWN_SHULKER_BOX, GREEN_SHULKER_BOX, RED_SHULKER_BOX, BLACK_SHULKER_BOX, CARVED_PUMPKIN, WITHER_SKELETON_SKULL, FLINT_AND_STEEL, BONE_MEAL, SHEARS, GLASS_BOTTLE, GLOWSTONE, COD_BUCKET, PUFFERFISH_BUCKET, SALMON_BUCKET, TROPICAL_FISH_BUCKET, BUCKET, WATER_BUCKET, LAVA_BUCKET -> {
|
||||||
case WHITE_SHULKER_BOX:
|
|
||||||
case ORANGE_SHULKER_BOX:
|
|
||||||
case MAGENTA_SHULKER_BOX:
|
|
||||||
case LIGHT_BLUE_SHULKER_BOX:
|
|
||||||
case YELLOW_SHULKER_BOX:
|
|
||||||
case LIME_SHULKER_BOX:
|
|
||||||
case PINK_SHULKER_BOX:
|
|
||||||
case GRAY_SHULKER_BOX:
|
|
||||||
case LIGHT_GRAY_SHULKER_BOX:
|
|
||||||
case CYAN_SHULKER_BOX:
|
|
||||||
case PURPLE_SHULKER_BOX:
|
|
||||||
case BLUE_SHULKER_BOX:
|
|
||||||
case BROWN_SHULKER_BOX:
|
|
||||||
case GREEN_SHULKER_BOX:
|
|
||||||
case RED_SHULKER_BOX:
|
|
||||||
case BLACK_SHULKER_BOX:
|
|
||||||
case CARVED_PUMPKIN:
|
|
||||||
case WITHER_SKELETON_SKULL:
|
|
||||||
case FLINT_AND_STEEL:
|
|
||||||
case BONE_MEAL:
|
|
||||||
case SHEARS:
|
|
||||||
case GLASS_BOTTLE:
|
|
||||||
case GLOWSTONE:
|
|
||||||
case COD_BUCKET:
|
|
||||||
case PUFFERFISH_BUCKET:
|
|
||||||
case SALMON_BUCKET:
|
|
||||||
case TROPICAL_FISH_BUCKET:
|
|
||||||
case BUCKET:
|
|
||||||
case WATER_BUCKET:
|
|
||||||
case LAVA_BUCKET: {
|
|
||||||
if (event.getBlock().getType() == Material.DROPPER) {
|
if (event.getBlock().getType() == Material.DROPPER) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1100,8 +1061,7 @@ public class BlockEventListener implements Listener {
|
|||||||
if (ignitingEntity instanceof Fireball) {
|
if (ignitingEntity instanceof Fireball) {
|
||||||
Projectile fireball = (Projectile) ignitingEntity;
|
Projectile fireball = (Projectile) ignitingEntity;
|
||||||
Location location = null;
|
Location location = null;
|
||||||
if (fireball.getShooter() instanceof Entity) {
|
if (fireball.getShooter() instanceof Entity shooter) {
|
||||||
Entity shooter = (Entity) fireball.getShooter();
|
|
||||||
location = BukkitUtil.adapt(shooter.getLocation());
|
location = BukkitUtil.adapt(shooter.getLocation());
|
||||||
} else if (fireball.getShooter() instanceof BlockProjectileSource) {
|
} else if (fireball.getShooter() instanceof BlockProjectileSource) {
|
||||||
Block shooter =
|
Block shooter =
|
||||||
|
@ -259,7 +259,7 @@ public class ChunkListener implements Listener {
|
|||||||
|
|
||||||
private void cleanChunk(final Chunk chunk) {
|
private void cleanChunk(final Chunk chunk) {
|
||||||
TaskManager.index.incrementAndGet();
|
TaskManager.index.incrementAndGet();
|
||||||
final Integer currentIndex = TaskManager.index.get();
|
final int currentIndex = TaskManager.index.get();
|
||||||
PlotSquaredTask task = TaskManager.runTaskRepeat(() -> {
|
PlotSquaredTask task = TaskManager.runTaskRepeat(() -> {
|
||||||
if (!chunk.isLoaded()) {
|
if (!chunk.isLoaded()) {
|
||||||
Objects.requireNonNull(TaskManager.removeTask(currentIndex)).cancel();
|
Objects.requireNonNull(TaskManager.removeTask(currentIndex)).cancel();
|
||||||
|
@ -111,8 +111,7 @@ public class EntityEventListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
if (!BukkitEntityUtil.entityDamage(damager, victim, event.getCause())) {
|
if (!BukkitEntityUtil.entityDamage(damager, victim, event.getCause())) {
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
if (victim instanceof Ageable) {
|
if (victim instanceof Ageable ageable) {
|
||||||
Ageable ageable = (Ageable) victim;
|
|
||||||
if (ageable.getAge() == -24000) {
|
if (ageable.getAge() == -24000) {
|
||||||
ageable.setAge(0);
|
ageable.setAge(0);
|
||||||
ageable.setAdult();
|
ageable.setAdult();
|
||||||
|
@ -436,8 +436,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
|||||||
if (!vehicle.getPassengers().isEmpty()) {
|
if (!vehicle.getPassengers().isEmpty()) {
|
||||||
Entity passenger = vehicle.getPassengers().get(0);
|
Entity passenger = vehicle.getPassengers().get(0);
|
||||||
|
|
||||||
if (passenger instanceof Player) {
|
if (passenger instanceof final Player player) {
|
||||||
final Player player = (Player) passenger;
|
|
||||||
// reset
|
// reset
|
||||||
if (moveTmp == null) {
|
if (moveTmp == null) {
|
||||||
moveTmp = new PlayerMoveEvent(null, from, to);
|
moveTmp = new PlayerMoveEvent(null, from, to);
|
||||||
@ -778,10 +777,9 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HumanEntity clicker = event.getWhoClicked();
|
HumanEntity clicker = event.getWhoClicked();
|
||||||
if (!(clicker instanceof Player)) {
|
if (!(clicker instanceof Player player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player player = (Player) clicker;
|
|
||||||
BukkitPlayer pp = BukkitUtil.adapt(player);
|
BukkitPlayer pp = BukkitUtil.adapt(player);
|
||||||
final PlotInventory inventory = PlotInventory.getOpenPlotInventory(pp);
|
final PlotInventory inventory = PlotInventory.getOpenPlotInventory(pp);
|
||||||
if (inventory != null && event.getRawSlot() == event.getSlot()) {
|
if (inventory != null && event.getRawSlot() == event.getSlot()) {
|
||||||
@ -1029,7 +1027,6 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
|||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
Location location = BukkitUtil.adapt(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
Action action = event.getAction();
|
Action action = event.getAction();
|
||||||
outer:
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case PHYSICAL: {
|
case PHYSICAL: {
|
||||||
eventType = PlayerBlockEventType.TRIGGER_PHYSICAL;
|
eventType = PlayerBlockEventType.TRIGGER_PHYSICAL;
|
||||||
@ -1077,12 +1074,12 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
|||||||
if (PaperLib.isPaper()) {
|
if (PaperLib.isPaper()) {
|
||||||
if (MaterialTags.SPAWN_EGGS.isTagged(type) || Material.EGG.equals(type)) {
|
if (MaterialTags.SPAWN_EGGS.isTagged(type) || Material.EGG.equals(type)) {
|
||||||
eventType = PlayerBlockEventType.SPAWN_MOB;
|
eventType = PlayerBlockEventType.SPAWN_MOB;
|
||||||
break outer;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (type.toString().toLowerCase().endsWith("egg")) {
|
if (type.toString().toLowerCase().endsWith("egg")) {
|
||||||
eventType = PlayerBlockEventType.SPAWN_MOB;
|
eventType = PlayerBlockEventType.SPAWN_MOB;
|
||||||
break outer;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type.isEdible()) {
|
if (type.isEdible()) {
|
||||||
@ -1090,34 +1087,13 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ACACIA_BOAT:
|
case ACACIA_BOAT, BIRCH_BOAT, CHEST_MINECART, COMMAND_BLOCK_MINECART, DARK_OAK_BOAT, FURNACE_MINECART, HOPPER_MINECART, JUNGLE_BOAT, MINECART, OAK_BOAT, SPRUCE_BOAT, TNT_MINECART -> eventType = PlayerBlockEventType.PLACE_VEHICLE;
|
||||||
case BIRCH_BOAT:
|
case FIREWORK_ROCKET, FIREWORK_STAR -> eventType = PlayerBlockEventType.SPAWN_MOB;
|
||||||
case CHEST_MINECART:
|
case BOOK, KNOWLEDGE_BOOK, WRITABLE_BOOK, WRITTEN_BOOK -> eventType = PlayerBlockEventType.READ;
|
||||||
case COMMAND_BLOCK_MINECART:
|
case ARMOR_STAND -> {
|
||||||
case DARK_OAK_BOAT:
|
|
||||||
case FURNACE_MINECART:
|
|
||||||
case HOPPER_MINECART:
|
|
||||||
case JUNGLE_BOAT:
|
|
||||||
case MINECART:
|
|
||||||
case OAK_BOAT:
|
|
||||||
case SPRUCE_BOAT:
|
|
||||||
case TNT_MINECART:
|
|
||||||
eventType = PlayerBlockEventType.PLACE_VEHICLE;
|
|
||||||
break outer;
|
|
||||||
case FIREWORK_ROCKET:
|
|
||||||
case FIREWORK_STAR:
|
|
||||||
eventType = PlayerBlockEventType.SPAWN_MOB;
|
|
||||||
break outer;
|
|
||||||
case BOOK:
|
|
||||||
case KNOWLEDGE_BOOK:
|
|
||||||
case WRITABLE_BOOK:
|
|
||||||
case WRITTEN_BOOK:
|
|
||||||
eventType = PlayerBlockEventType.READ;
|
|
||||||
break outer;
|
|
||||||
case ARMOR_STAND:
|
|
||||||
location = BukkitUtil.adapt(block.getRelative(event.getBlockFace()).getLocation());
|
location = BukkitUtil.adapt(block.getRelative(event.getBlockFace()).getLocation());
|
||||||
eventType = PlayerBlockEventType.PLACE_MISC;
|
eventType = PlayerBlockEventType.PLACE_MISC;
|
||||||
break outer;
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1231,10 +1207,9 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onInventoryClose(InventoryCloseEvent event) {
|
public void onInventoryClose(InventoryCloseEvent event) {
|
||||||
HumanEntity closer = event.getPlayer();
|
HumanEntity closer = event.getPlayer();
|
||||||
if (!(closer instanceof Player)) {
|
if (!(closer instanceof Player player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player player = (Player) closer;
|
|
||||||
PlotInventory.removePlotInventoryOpen(BukkitUtil.adapt(player));
|
PlotInventory.removePlotInventoryOpen(BukkitUtil.adapt(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1359,8 +1334,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onHangingBreakByEntity(HangingBreakByEntityEvent event) {
|
public void onHangingBreakByEntity(HangingBreakByEntityEvent event) {
|
||||||
Entity remover = event.getRemover();
|
Entity remover = event.getRemover();
|
||||||
if (remover instanceof Player) {
|
if (remover instanceof Player p) {
|
||||||
Player p = (Player) remover;
|
|
||||||
Location location = BukkitUtil.adapt(event.getEntity().getLocation());
|
Location location = BukkitUtil.adapt(event.getEntity().getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
@ -1398,10 +1372,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
|||||||
+ " could not break hanging entity because hanging-break = false");
|
+ " could not break hanging entity because hanging-break = false");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (remover instanceof Projectile) {
|
} else if (remover instanceof Projectile p) {
|
||||||
Projectile p = (Projectile) remover;
|
if (p.getShooter() instanceof Player shooter) {
|
||||||
if (p.getShooter() instanceof Player) {
|
|
||||||
Player shooter = (Player) p.getShooter();
|
|
||||||
Location location = BukkitUtil.adapt(event.getEntity().getLocation());
|
Location location = BukkitUtil.adapt(event.getEntity().getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
@ -1535,8 +1507,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Entity attacker = event.getAttacker();
|
Entity attacker = event.getAttacker();
|
||||||
if (attacker instanceof Player) {
|
if (attacker instanceof Player p) {
|
||||||
Player p = (Player) attacker;
|
|
||||||
BukkitPlayer pp = BukkitUtil.adapt(p);
|
BukkitPlayer pp = BukkitUtil.adapt(p);
|
||||||
Plot plot = area.getPlot(location);
|
Plot plot = area.getPlot(location);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
@ -1642,8 +1613,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onItemPickup(EntityPickupItemEvent event) {
|
public void onItemPickup(EntityPickupItemEvent event) {
|
||||||
LivingEntity ent = event.getEntity();
|
LivingEntity ent = event.getEntity();
|
||||||
if (ent instanceof Player) {
|
if (ent instanceof Player player) {
|
||||||
Player player = (Player) ent;
|
|
||||||
BukkitPlayer pp = BukkitUtil.adapt(player);
|
BukkitPlayer pp = BukkitUtil.adapt(player);
|
||||||
Location location = pp.getLocation();
|
Location location = pp.getLocation();
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
|
@ -45,7 +45,7 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class SingleWorldListener implements Listener {
|
public class SingleWorldListener implements Listener {
|
||||||
|
|
||||||
private Method methodGetHandleChunk;
|
private final Method methodGetHandleChunk;
|
||||||
private Field mustSave;
|
private Field mustSave;
|
||||||
private boolean isTrueForNotSave = true;
|
private boolean isTrueForNotSave = true;
|
||||||
|
|
||||||
|
@ -53,8 +53,7 @@ public class WorldEvents implements Listener {
|
|||||||
public void onWorldInit(WorldInitEvent event) {
|
public void onWorldInit(WorldInitEvent event) {
|
||||||
World world = event.getWorld();
|
World world = event.getWorld();
|
||||||
String name = world.getName();
|
String name = world.getName();
|
||||||
if (this.plotAreaManager instanceof SinglePlotAreaManager) {
|
if (this.plotAreaManager instanceof final SinglePlotAreaManager single) {
|
||||||
final SinglePlotAreaManager single = (SinglePlotAreaManager) this.plotAreaManager;
|
|
||||||
if (single.isWorld(name)) {
|
if (single.isWorld(name)) {
|
||||||
world.setKeepSpawnInMemory(false);
|
world.setKeepSpawnInMemory(false);
|
||||||
return;
|
return;
|
||||||
|
@ -34,7 +34,10 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
/**
|
/**
|
||||||
* Multiverse specific manager that informs Multiverse of
|
* Multiverse specific manager that informs Multiverse of
|
||||||
* world creation by executing a console command
|
* world creation by executing a console command
|
||||||
|
* @deprecated Deprecated and scheduled for removal without replacement
|
||||||
|
* in favor of the build in setup wizard.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
@Singleton
|
@Singleton
|
||||||
public class MultiverseWorldManager extends BukkitWorldManager {
|
public class MultiverseWorldManager extends BukkitWorldManager {
|
||||||
|
|
||||||
|
@ -52,8 +52,7 @@ public class BukkitPermissionHandler implements PermissionHandler {
|
|||||||
public Optional<PermissionProfile> getPermissionProfile(
|
public Optional<PermissionProfile> getPermissionProfile(
|
||||||
@NonNull PlotPlayer<?> playerPlotPlayer
|
@NonNull PlotPlayer<?> playerPlotPlayer
|
||||||
) {
|
) {
|
||||||
if (playerPlotPlayer instanceof BukkitPlayer) {
|
if (playerPlotPlayer instanceof final BukkitPlayer bukkitPlayer) {
|
||||||
final BukkitPlayer bukkitPlayer = (BukkitPlayer) playerPlotPlayer;
|
|
||||||
return Optional.of(new BukkitPermissionProfile(bukkitPlayer.getPlatformPlayer()));
|
return Optional.of(new BukkitPermissionProfile(bukkitPlayer.getPlatformPlayer()));
|
||||||
} else if (playerPlotPlayer instanceof ConsolePlayer) {
|
} else if (playerPlotPlayer instanceof ConsolePlayer) {
|
||||||
return Optional.of(ConsolePermissionProfile.INSTANCE);
|
return Optional.of(ConsolePermissionProfile.INSTANCE);
|
||||||
|
@ -65,8 +65,7 @@ public class VaultPermissionHandler implements PermissionHandler {
|
|||||||
public Optional<PermissionProfile> getPermissionProfile(
|
public Optional<PermissionProfile> getPermissionProfile(
|
||||||
@NonNull PlotPlayer<?> playerPlotPlayer
|
@NonNull PlotPlayer<?> playerPlotPlayer
|
||||||
) {
|
) {
|
||||||
if (playerPlotPlayer instanceof BukkitPlayer) {
|
if (playerPlotPlayer instanceof final BukkitPlayer bukkitPlayer) {
|
||||||
final BukkitPlayer bukkitPlayer = (BukkitPlayer) playerPlotPlayer;
|
|
||||||
return Optional.of(new VaultPermissionProfile(bukkitPlayer.getPlatformPlayer()));
|
return Optional.of(new VaultPermissionProfile(bukkitPlayer.getPlatformPlayer()));
|
||||||
} else if (playerPlotPlayer instanceof ConsolePlayer) {
|
} else if (playerPlotPlayer instanceof ConsolePlayer) {
|
||||||
return Optional.of(ConsolePermissionProfile.INSTANCE);
|
return Optional.of(ConsolePermissionProfile.INSTANCE);
|
||||||
|
@ -263,32 +263,20 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
|||||||
@Override
|
@Override
|
||||||
public void setWeather(final @NonNull PlotWeather weather) {
|
public void setWeather(final @NonNull PlotWeather weather) {
|
||||||
switch (weather) {
|
switch (weather) {
|
||||||
case CLEAR:
|
case CLEAR -> this.player.setPlayerWeather(WeatherType.CLEAR);
|
||||||
this.player.setPlayerWeather(WeatherType.CLEAR);
|
case RAIN -> this.player.setPlayerWeather(WeatherType.DOWNFALL);
|
||||||
break;
|
default -> this.player.resetPlayerWeather();
|
||||||
case RAIN:
|
|
||||||
this.player.setPlayerWeather(WeatherType.DOWNFALL);
|
|
||||||
break;
|
|
||||||
case RESET:
|
|
||||||
default:
|
|
||||||
this.player.resetPlayerWeather();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public com.sk89q.worldedit.world.gamemode.GameMode getGameMode() {
|
public com.sk89q.worldedit.world.gamemode.GameMode getGameMode() {
|
||||||
switch (this.player.getGameMode()) {
|
return switch (this.player.getGameMode()) {
|
||||||
case ADVENTURE:
|
case ADVENTURE -> ADVENTURE;
|
||||||
return ADVENTURE;
|
case CREATIVE -> CREATIVE;
|
||||||
case CREATIVE:
|
case SPECTATOR -> SPECTATOR;
|
||||||
return CREATIVE;
|
default -> SURVIVAL;
|
||||||
case SPECTATOR:
|
};
|
||||||
return SPECTATOR;
|
|
||||||
case SURVIVAL:
|
|
||||||
default:
|
|
||||||
return SURVIVAL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -372,14 +360,11 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PlayerTeleportEvent.TeleportCause getTeleportCause(final @NonNull TeleportCause cause) {
|
public PlayerTeleportEvent.TeleportCause getTeleportCause(final @NonNull TeleportCause cause) {
|
||||||
switch (cause) {
|
return switch (cause) {
|
||||||
case COMMAND:
|
case COMMAND -> PlayerTeleportEvent.TeleportCause.COMMAND;
|
||||||
return PlayerTeleportEvent.TeleportCause.COMMAND;
|
case PLUGIN -> PlayerTeleportEvent.TeleportCause.PLUGIN;
|
||||||
case PLUGIN:
|
default -> PlayerTeleportEvent.TeleportCause.UNKNOWN;
|
||||||
return PlayerTeleportEvent.TeleportCause.PLUGIN;
|
};
|
||||||
default:
|
|
||||||
return PlayerTeleportEvent.TeleportCause.UNKNOWN;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -177,19 +177,11 @@ public class StateWrapper {
|
|||||||
}
|
}
|
||||||
org.bukkit.block.BlockState state = block.getState();
|
org.bukkit.block.BlockState state = block.getState();
|
||||||
switch (getId()) {
|
switch (getId()) {
|
||||||
case "chest":
|
case "chest", "beacon", "brewingstand", "dispenser", "dropper", "furnace", "hopper", "shulkerbox" -> {
|
||||||
case "beacon":
|
if (!(state instanceof Container container)) {
|
||||||
case "brewingstand":
|
|
||||||
case "dispenser":
|
|
||||||
case "dropper":
|
|
||||||
case "furnace":
|
|
||||||
case "hopper":
|
|
||||||
case "shulkerbox":
|
|
||||||
if (!(state instanceof Container)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
List<Tag> itemsTag = this.tag.getListTag("Items").getValue();
|
List<Tag> itemsTag = this.tag.getListTag("Items").getValue();
|
||||||
Container container = (Container) state;
|
|
||||||
Inventory inv = container.getSnapshotInventory();
|
Inventory inv = container.getSnapshotInventory();
|
||||||
for (Tag itemTag : itemsTag) {
|
for (Tag itemTag : itemsTag) {
|
||||||
CompoundTag itemComp = (CompoundTag) itemTag;
|
CompoundTag itemComp = (CompoundTag) itemTag;
|
||||||
@ -206,9 +198,9 @@ public class StateWrapper {
|
|||||||
}
|
}
|
||||||
container.update(true, false);
|
container.update(true, false);
|
||||||
return true;
|
return true;
|
||||||
case "sign":
|
}
|
||||||
if (state instanceof Sign) {
|
case "sign" -> {
|
||||||
Sign sign = (Sign) state;
|
if (state instanceof Sign sign) {
|
||||||
sign.setLine(0, jsonToColourCode(tag.getString("Text1")));
|
sign.setLine(0, jsonToColourCode(tag.getString("Text1")));
|
||||||
sign.setLine(1, jsonToColourCode(tag.getString("Text2")));
|
sign.setLine(1, jsonToColourCode(tag.getString("Text2")));
|
||||||
sign.setLine(2, jsonToColourCode(tag.getString("Text3")));
|
sign.setLine(2, jsonToColourCode(tag.getString("Text3")));
|
||||||
@ -217,6 +209,7 @@ public class StateWrapper {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -225,8 +218,7 @@ public class StateWrapper {
|
|||||||
if (this.tag != null) {
|
if (this.tag != null) {
|
||||||
return this.tag;
|
return this.tag;
|
||||||
}
|
}
|
||||||
if (this.state instanceof InventoryHolder) {
|
if (this.state instanceof InventoryHolder inv) {
|
||||||
InventoryHolder inv = (InventoryHolder) this.state;
|
|
||||||
ItemStack[] contents = inv.getInventory().getContents();
|
ItemStack[] contents = inv.getInventory().getContents();
|
||||||
Map<String, Tag> values = new HashMap<>();
|
Map<String, Tag> values = new HashMap<>();
|
||||||
values.put("Items", new ListTag(CompoundTag.class, serializeInventory(contents)));
|
values.put("Items", new ListTag(CompoundTag.class, serializeInventory(contents)));
|
||||||
|
@ -144,8 +144,7 @@ public class BukkitEntityUtil {
|
|||||||
Player player;
|
Player player;
|
||||||
if (damager instanceof Player) { // attacker is player
|
if (damager instanceof Player) { // attacker is player
|
||||||
player = (Player) damager;
|
player = (Player) damager;
|
||||||
} else if (damager instanceof Projectile) {
|
} else if (damager instanceof Projectile projectile) {
|
||||||
Projectile projectile = (Projectile) damager;
|
|
||||||
ProjectileSource shooter = projectile.getShooter();
|
ProjectileSource shooter = projectile.getShooter();
|
||||||
if (shooter instanceof Player) { // shooter is player
|
if (shooter instanceof Player) { // shooter is player
|
||||||
player = (Player) shooter;
|
player = (Player) shooter;
|
||||||
|
@ -135,7 +135,7 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||||||
PlotAreaType type = builder.plotAreaType();
|
PlotAreaType type = builder.plotAreaType();
|
||||||
String worldPath = "worlds." + builder.worldName();
|
String worldPath = "worlds." + builder.worldName();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case PARTIAL: {
|
case PARTIAL -> {
|
||||||
if (builder.areaName() != null) {
|
if (builder.areaName() != null) {
|
||||||
if (!this.worldConfiguration.contains(worldPath)) {
|
if (!this.worldConfiguration.contains(worldPath)) {
|
||||||
this.worldConfiguration.createSection(worldPath);
|
this.worldConfiguration.createSection(worldPath);
|
||||||
@ -177,9 +177,8 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||||||
if (gen != null && gen.isFull()) {
|
if (gen != null && gen.isFull()) {
|
||||||
builder.generatorName(null);
|
builder.generatorName(null);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case AUGMENTED: {
|
case AUGMENTED -> {
|
||||||
if (!builder.plotManager().endsWith(":single")) {
|
if (!builder.plotManager().endsWith(":single")) {
|
||||||
if (!this.worldConfiguration.contains(worldPath)) {
|
if (!this.worldConfiguration.contains(worldPath)) {
|
||||||
this.worldConfiguration.createSection(worldPath);
|
this.worldConfiguration.createSection(worldPath);
|
||||||
@ -207,9 +206,8 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||||||
if (gen != null && gen.isFull()) {
|
if (gen != null && gen.isFull()) {
|
||||||
builder.generatorName(null);
|
builder.generatorName(null);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case NORMAL: {
|
case NORMAL -> {
|
||||||
if (steps.length != 0) {
|
if (steps.length != 0) {
|
||||||
if (!this.worldConfiguration.contains(worldPath)) {
|
if (!this.worldConfiguration.contains(worldPath)) {
|
||||||
this.worldConfiguration.createSection(worldPath);
|
this.worldConfiguration.createSection(worldPath);
|
||||||
@ -220,7 +218,6 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||||||
worldSection.set(step.getConstant(), step.getValue());
|
worldSection.set(step.getConstant(), step.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,8 +297,7 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
return TaskManager.getPlatformImplementation().sync(() -> {
|
return TaskManager.getPlatformImplementation().sync(() -> {
|
||||||
if (block.getState() instanceof Sign) {
|
if (block.getState() instanceof Sign sign) {
|
||||||
Sign sign = (Sign) block.getState();
|
|
||||||
return sign.getLines();
|
return sign.getLines();
|
||||||
}
|
}
|
||||||
return new String[0];
|
return new String[0];
|
||||||
@ -364,8 +363,7 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
block.setBlockData(sign, false);
|
block.setBlockData(sign, false);
|
||||||
}
|
}
|
||||||
final org.bukkit.block.BlockState blockstate = block.getState();
|
final org.bukkit.block.BlockState blockstate = block.getState();
|
||||||
if (blockstate instanceof Sign) {
|
if (blockstate instanceof final Sign sign) {
|
||||||
final Sign sign = (Sign) blockstate;
|
|
||||||
for (int i = 0; i < lines.length; i++) {
|
for (int i = 0; i < lines.length; i++) {
|
||||||
sign.setLine(i, LEGACY_COMPONENT_SERIALIZER
|
sign.setLine(i, LEGACY_COMPONENT_SERIALIZER
|
||||||
.serialize(MINI_MESSAGE.parse(lines[i].getComponent(LocaleHolder.console()), replacements)));
|
.serialize(MINI_MESSAGE.parse(lines[i].getComponent(LocaleHolder.console()), replacements)));
|
||||||
@ -454,23 +452,20 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
public @NonNull Set<com.sk89q.worldedit.world.entity.EntityType> getTypesInCategory(final @NonNull String category) {
|
public @NonNull Set<com.sk89q.worldedit.world.entity.EntityType> getTypesInCategory(final @NonNull String category) {
|
||||||
final Collection<Class<?>> allowedInterfaces = new HashSet<>();
|
final Collection<Class<?>> allowedInterfaces = new HashSet<>();
|
||||||
switch (category) {
|
switch (category) {
|
||||||
case "animal": {
|
case "animal" -> {
|
||||||
allowedInterfaces.add(IronGolem.class);
|
allowedInterfaces.add(IronGolem.class);
|
||||||
allowedInterfaces.add(Snowman.class);
|
allowedInterfaces.add(Snowman.class);
|
||||||
allowedInterfaces.add(Animals.class);
|
allowedInterfaces.add(Animals.class);
|
||||||
allowedInterfaces.add(WaterMob.class);
|
allowedInterfaces.add(WaterMob.class);
|
||||||
allowedInterfaces.add(Ambient.class);
|
allowedInterfaces.add(Ambient.class);
|
||||||
}
|
}
|
||||||
break;
|
case "tameable" -> {
|
||||||
case "tameable": {
|
|
||||||
allowedInterfaces.add(Tameable.class);
|
allowedInterfaces.add(Tameable.class);
|
||||||
}
|
}
|
||||||
break;
|
case "vehicle" -> {
|
||||||
case "vehicle": {
|
|
||||||
allowedInterfaces.add(Vehicle.class);
|
allowedInterfaces.add(Vehicle.class);
|
||||||
}
|
}
|
||||||
break;
|
case "hostile" -> {
|
||||||
case "hostile": {
|
|
||||||
allowedInterfaces.add(Shulker.class);
|
allowedInterfaces.add(Shulker.class);
|
||||||
allowedInterfaces.add(Monster.class);
|
allowedInterfaces.add(Monster.class);
|
||||||
allowedInterfaces.add(Boss.class);
|
allowedInterfaces.add(Boss.class);
|
||||||
@ -479,20 +474,16 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
allowedInterfaces.add(Phantom.class);
|
allowedInterfaces.add(Phantom.class);
|
||||||
allowedInterfaces.add(EnderCrystal.class);
|
allowedInterfaces.add(EnderCrystal.class);
|
||||||
}
|
}
|
||||||
break;
|
case "hanging" -> {
|
||||||
case "hanging": {
|
|
||||||
allowedInterfaces.add(Hanging.class);
|
allowedInterfaces.add(Hanging.class);
|
||||||
}
|
}
|
||||||
break;
|
case "villager" -> {
|
||||||
case "villager": {
|
|
||||||
allowedInterfaces.add(NPC.class);
|
allowedInterfaces.add(NPC.class);
|
||||||
}
|
}
|
||||||
break;
|
case "projectile" -> {
|
||||||
case "projectile": {
|
|
||||||
allowedInterfaces.add(Projectile.class);
|
allowedInterfaces.add(Projectile.class);
|
||||||
}
|
}
|
||||||
break;
|
case "other" -> {
|
||||||
case "other": {
|
|
||||||
allowedInterfaces.add(ArmorStand.class);
|
allowedInterfaces.add(ArmorStand.class);
|
||||||
allowedInterfaces.add(FallingBlock.class);
|
allowedInterfaces.add(FallingBlock.class);
|
||||||
allowedInterfaces.add(Item.class);
|
allowedInterfaces.add(Item.class);
|
||||||
@ -504,15 +495,12 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
allowedInterfaces.add(EnderSignal.class);
|
allowedInterfaces.add(EnderSignal.class);
|
||||||
allowedInterfaces.add(Firework.class);
|
allowedInterfaces.add(Firework.class);
|
||||||
}
|
}
|
||||||
break;
|
case "player" -> {
|
||||||
case "player": {
|
|
||||||
allowedInterfaces.add(Player.class);
|
allowedInterfaces.add(Player.class);
|
||||||
}
|
}
|
||||||
break;
|
default -> {
|
||||||
default: {
|
|
||||||
logger.error("Unknown entity category requested: {}", category);
|
logger.error("Unknown entity category requested: {}", category);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
final Set<com.sk89q.worldedit.world.entity.EntityType> types = new HashSet<>();
|
final Set<com.sk89q.worldedit.world.entity.EntityType> types = new HashSet<>();
|
||||||
outer:
|
outer:
|
||||||
|
@ -87,10 +87,9 @@ public class BukkitWorld implements World<org.bukkit.World> {
|
|||||||
if (o == this) {
|
if (o == this) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(o instanceof BukkitWorld)) {
|
if (!(o instanceof final BukkitWorld other)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final BukkitWorld other = (BukkitWorld) o;
|
|
||||||
if (!other.canEqual(this)) {
|
if (!other.canEqual(this)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,71 +0,0 @@
|
|||||||
/*
|
|
||||||
* _____ _ _ _____ _
|
|
||||||
* | __ \| | | | / ____| | |
|
|
||||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
|
||||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
|
||||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
|
||||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
|
||||||
* | |
|
|
||||||
* |_|
|
|
||||||
* PlotSquared plot management system for Minecraft
|
|
||||||
* Copyright (C) 2021 IntellectualSites
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package com.plotsquared.bukkit.util;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public class JavaVersionCheck {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger("P2/" + JavaVersionCheck.class.getSimpleName());
|
|
||||||
|
|
||||||
private static int checkJavaVersion() {
|
|
||||||
String javaVersion = System.getProperty("java.version");
|
|
||||||
final Matcher matcher = Pattern.compile("(?:1\\.)?(\\d+)").matcher(javaVersion);
|
|
||||||
if (!matcher.find()) {
|
|
||||||
logger.error("Failed to determine Java version; Could not parse: {}", javaVersion);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String version = matcher.group(1);
|
|
||||||
try {
|
|
||||||
return Integer.parseInt(version);
|
|
||||||
} catch (final NumberFormatException e) {
|
|
||||||
logger.error("Failed to determine Java version; Could not parse {} from {}", version, javaVersion, e);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void checkJvm() {
|
|
||||||
if (checkJavaVersion() < 11) {
|
|
||||||
logger.error("************************************************************");
|
|
||||||
logger.error("* WARNING - YOU ARE RUNNING AN OUTDATED VERSION OF JAVA.");
|
|
||||||
logger.error("* PLOTSQUARED WILL STOP BEING COMPATIBLE WITH THIS VERSION OF");
|
|
||||||
logger.error("* JAVA WHEN MINECRAFT 1.17 IS RELEASED.");
|
|
||||||
logger.error("*");
|
|
||||||
logger.error("* Please update the version of Java to 11. When Minecraft 1.17");
|
|
||||||
logger.error("* is released, support for versions of Java prior to 11 will");
|
|
||||||
logger.error("* be dropped.");
|
|
||||||
logger.error("*");
|
|
||||||
logger.error("* Current Java version: {}", System.getProperty("java.version"));
|
|
||||||
logger.error("************************************************************");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -233,7 +233,7 @@ public interface PlotPlatform<P> extends LocaleHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@link SetupUtils} implementation for the platform
|
* Get the {@link SetupUtils} implementation for the platform
|
||||||
*
|
*
|
||||||
* @return Setup utils
|
* @return Setup utils
|
||||||
*/
|
*/
|
||||||
|
@ -1077,22 +1077,15 @@ public class PlotSquared {
|
|||||||
try {
|
try {
|
||||||
String base = "worlds." + world + ".";
|
String base = "worlds." + world + ".";
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "s":
|
case "s", "size" -> this.worldConfiguration.set(
|
||||||
case "size":
|
base + "plot.size",
|
||||||
this.worldConfiguration.set(
|
ConfigurationUtil.INTEGER.parseString(value).shortValue()
|
||||||
base + "plot.size",
|
);
|
||||||
ConfigurationUtil.INTEGER.parseString(value).shortValue()
|
case "g", "gap" -> this.worldConfiguration.set(
|
||||||
);
|
base + "road.width",
|
||||||
break;
|
ConfigurationUtil.INTEGER.parseString(value).shortValue()
|
||||||
case "g":
|
);
|
||||||
case "gap":
|
case "h", "height" -> {
|
||||||
this.worldConfiguration.set(
|
|
||||||
base + "road.width",
|
|
||||||
ConfigurationUtil.INTEGER.parseString(value).shortValue()
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case "h":
|
|
||||||
case "height":
|
|
||||||
this.worldConfiguration.set(
|
this.worldConfiguration.set(
|
||||||
base + "road.height",
|
base + "road.height",
|
||||||
ConfigurationUtil.INTEGER.parseString(value).shortValue()
|
ConfigurationUtil.INTEGER.parseString(value).shortValue()
|
||||||
@ -1105,38 +1098,27 @@ public class PlotSquared {
|
|||||||
base + "wall.height",
|
base + "wall.height",
|
||||||
ConfigurationUtil.INTEGER.parseString(value).shortValue()
|
ConfigurationUtil.INTEGER.parseString(value).shortValue()
|
||||||
);
|
);
|
||||||
break;
|
}
|
||||||
case "f":
|
case "f", "floor" -> this.worldConfiguration.set(
|
||||||
case "floor":
|
base + "plot.floor",
|
||||||
this.worldConfiguration.set(
|
ConfigurationUtil.BLOCK_BUCKET.parseString(value).toString()
|
||||||
base + "plot.floor",
|
);
|
||||||
ConfigurationUtil.BLOCK_BUCKET.parseString(value).toString()
|
case "m", "main" -> this.worldConfiguration.set(
|
||||||
);
|
base + "plot.filling",
|
||||||
break;
|
ConfigurationUtil.BLOCK_BUCKET.parseString(value).toString()
|
||||||
case "m":
|
);
|
||||||
case "main":
|
case "w", "wall" -> this.worldConfiguration.set(
|
||||||
this.worldConfiguration.set(
|
base + "wall.filling",
|
||||||
base + "plot.filling",
|
ConfigurationUtil.BLOCK_BUCKET.parseString(value).toString()
|
||||||
ConfigurationUtil.BLOCK_BUCKET.parseString(value).toString()
|
);
|
||||||
);
|
case "b", "border" -> this.worldConfiguration.set(
|
||||||
break;
|
base + "wall.block",
|
||||||
case "w":
|
ConfigurationUtil.BLOCK_BUCKET.parseString(value).toString()
|
||||||
case "wall":
|
);
|
||||||
this.worldConfiguration.set(
|
default -> {
|
||||||
base + "wall.filling",
|
|
||||||
ConfigurationUtil.BLOCK_BUCKET.parseString(value).toString()
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case "b":
|
|
||||||
case "border":
|
|
||||||
this.worldConfiguration.set(
|
|
||||||
base + "wall.block",
|
|
||||||
ConfigurationUtil.BLOCK_BUCKET.parseString(value).toString()
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
logger.error("Key not found: {}", element);
|
logger.error("Key not found: {}", element);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Invalid value '{}' for arg '{}'", value, element);
|
logger.error("Invalid value '{}' for arg '{}'", value, element);
|
||||||
|
@ -33,7 +33,7 @@ import java.util.Random;
|
|||||||
|
|
||||||
public class FlatRandomCollection<T> extends RandomCollection<T> {
|
public class FlatRandomCollection<T> extends RandomCollection<T> {
|
||||||
|
|
||||||
private T[] values;
|
private final T[] values;
|
||||||
|
|
||||||
public FlatRandomCollection(Map<T, Double> weights, Random random) {
|
public FlatRandomCollection(Map<T, Double> weights, Random random) {
|
||||||
super(weights, random);
|
super(weights, random);
|
||||||
|
@ -82,12 +82,11 @@ public class Alias extends SubCommand {
|
|||||||
boolean permission;
|
boolean permission;
|
||||||
boolean admin;
|
boolean admin;
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
case "set":
|
case "set" -> {
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
sendUsage(player);
|
sendUsage(player);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
permission = isPermitted(player, Permission.PERMISSION_ALIAS_SET);
|
permission = isPermitted(player, Permission.PERMISSION_ALIAS_SET);
|
||||||
admin = isPermitted(player, Permission.PERMISSION_ADMIN_ALIAS_SET);
|
admin = isPermitted(player, Permission.PERMISSION_ADMIN_ALIAS_SET);
|
||||||
if (!admin && !owner) {
|
if (!admin && !owner) {
|
||||||
@ -103,9 +102,8 @@ public class Alias extends SubCommand {
|
|||||||
Template.of("node", String.valueOf(Permission.PERMISSION_ALIAS_SET))
|
Template.of("node", String.valueOf(Permission.PERMISSION_ALIAS_SET))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
case "remove" -> {
|
||||||
case "remove":
|
|
||||||
permission = isPermitted(player, Permission.PERMISSION_ALIAS_REMOVE);
|
permission = isPermitted(player, Permission.PERMISSION_ALIAS_REMOVE);
|
||||||
admin = isPermitted(player, Permission.PERMISSION_ADMIN_ALIAS_REMOVE);
|
admin = isPermitted(player, Permission.PERMISSION_ADMIN_ALIAS_REMOVE);
|
||||||
if (!admin && !owner) {
|
if (!admin && !owner) {
|
||||||
@ -120,10 +118,11 @@ public class Alias extends SubCommand {
|
|||||||
Template.of("node", String.valueOf(Permission.PERMISSION_ALIAS_REMOVE))
|
Template.of("node", String.valueOf(Permission.PERMISSION_ALIAS_REMOVE))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
default:
|
default -> {
|
||||||
sendUsage(player);
|
sendUsage(player);
|
||||||
result = false;
|
result = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -109,7 +109,6 @@ public class Area extends SubCommand {
|
|||||||
private final HybridPlotWorldFactory hybridPlotWorldFactory;
|
private final HybridPlotWorldFactory hybridPlotWorldFactory;
|
||||||
private final SetupUtils setupUtils;
|
private final SetupUtils setupUtils;
|
||||||
private final WorldUtil worldUtil;
|
private final WorldUtil worldUtil;
|
||||||
private final RegionManager regionManager;
|
|
||||||
private final GlobalBlockQueue blockQueue;
|
private final GlobalBlockQueue blockQueue;
|
||||||
|
|
||||||
private final Map<UUID, Map<String, Object>> metaData = new HashMap<>();
|
private final Map<UUID, Map<String, Object>> metaData = new HashMap<>();
|
||||||
@ -122,7 +121,6 @@ public class Area extends SubCommand {
|
|||||||
final @NonNull HybridPlotWorldFactory hybridPlotWorldFactory,
|
final @NonNull HybridPlotWorldFactory hybridPlotWorldFactory,
|
||||||
final @NonNull SetupUtils setupUtils,
|
final @NonNull SetupUtils setupUtils,
|
||||||
final @NonNull WorldUtil worldUtil,
|
final @NonNull WorldUtil worldUtil,
|
||||||
final @NonNull RegionManager regionManager,
|
|
||||||
final @NonNull GlobalBlockQueue blockQueue
|
final @NonNull GlobalBlockQueue blockQueue
|
||||||
) {
|
) {
|
||||||
this.plotAreaManager = plotAreaManager;
|
this.plotAreaManager = plotAreaManager;
|
||||||
@ -131,7 +129,6 @@ public class Area extends SubCommand {
|
|||||||
this.hybridPlotWorldFactory = hybridPlotWorldFactory;
|
this.hybridPlotWorldFactory = hybridPlotWorldFactory;
|
||||||
this.setupUtils = setupUtils;
|
this.setupUtils = setupUtils;
|
||||||
this.worldUtil = worldUtil;
|
this.worldUtil = worldUtil;
|
||||||
this.regionManager = regionManager;
|
|
||||||
this.blockQueue = blockQueue;
|
this.blockQueue = blockQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +139,7 @@ public class Area extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
case "single":
|
case "single" -> {
|
||||||
if (player instanceof ConsolePlayer) {
|
if (player instanceof ConsolePlayer) {
|
||||||
player.sendMessage(RequiredType.CONSOLE.getErrorMessage());
|
player.sendMessage(RequiredType.CONSOLE.getErrorMessage());
|
||||||
return false;
|
return false;
|
||||||
@ -195,14 +192,16 @@ public class Area extends SubCommand {
|
|||||||
final BlockVector3 playerSelectionMax = playerSelectedRegion.getMaximumPoint();
|
final BlockVector3 playerSelectionMax = playerSelectedRegion.getMaximumPoint();
|
||||||
// Create a new selection that spans the entire vertical range of the world
|
// Create a new selection that spans the entire vertical range of the world
|
||||||
final CuboidRegion selectedRegion =
|
final CuboidRegion selectedRegion =
|
||||||
new CuboidRegion(playerSelectedRegion.getWorld(),
|
new CuboidRegion(
|
||||||
|
playerSelectedRegion.getWorld(),
|
||||||
BlockVector3.at(playerSelectionMin.getX(), 0, playerSelectionMin.getZ()),
|
BlockVector3.at(playerSelectionMin.getX(), 0, playerSelectionMin.getZ()),
|
||||||
BlockVector3.at(playerSelectionMax.getX(), 255, playerSelectionMax.getZ())
|
BlockVector3.at(playerSelectionMax.getX(), 255, playerSelectionMax.getZ())
|
||||||
);
|
);
|
||||||
// There's only one plot in the area...
|
// There's only one plot in the area...
|
||||||
final PlotId plotId = PlotId.of(1, 1);
|
final PlotId plotId = PlotId.of(1, 1);
|
||||||
final HybridPlotWorld hybridPlotWorld = this.hybridPlotWorldFactory
|
final HybridPlotWorld hybridPlotWorld = this.hybridPlotWorldFactory
|
||||||
.create(player.getLocation().getWorldName(),
|
.create(
|
||||||
|
player.getLocation().getWorldName(),
|
||||||
args[1],
|
args[1],
|
||||||
Objects.requireNonNull(PlotSquared.platform()).defaultGenerator(),
|
Objects.requireNonNull(PlotSquared.platform()).defaultGenerator(),
|
||||||
plotId,
|
plotId,
|
||||||
@ -292,9 +291,8 @@ public class Area extends SubCommand {
|
|||||||
};
|
};
|
||||||
singleRun.run();
|
singleRun.run();
|
||||||
return true;
|
return true;
|
||||||
case "c":
|
}
|
||||||
case "setup":
|
case "c", "setup", "create" -> {
|
||||||
case "create":
|
|
||||||
if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_CREATE)) {
|
if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_CREATE)) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("permission.no_permission"),
|
TranslatableCaption.of("permission.no_permission"),
|
||||||
@ -311,7 +309,7 @@ public class Area extends SubCommand {
|
|||||||
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 = (HybridPlotWorld) metaData.computeIfAbsent(
|
HybridPlotWorld area = (HybridPlotWorld) metaData.computeIfAbsent(
|
||||||
player.getUUID(),
|
player.getUUID(),
|
||||||
missingUUID -> new HashMap<>()
|
missingUUID -> new HashMap<>()
|
||||||
@ -329,7 +327,8 @@ public class Area extends SubCommand {
|
|||||||
"area_pos1",
|
"area_pos1",
|
||||||
location
|
location
|
||||||
);
|
);
|
||||||
player.sendMessage(TranslatableCaption.of("set.set_attribute"),
|
player.sendMessage(
|
||||||
|
TranslatableCaption.of("set.set_attribute"),
|
||||||
Template.of("attribute", "area_pos1"),
|
Template.of("attribute", "area_pos1"),
|
||||||
Template.of("value", location.getX() + "," + location.getZ())
|
Template.of("value", location.getX() + "," + location.getZ())
|
||||||
);
|
);
|
||||||
@ -339,7 +338,7 @@ public class Area extends SubCommand {
|
|||||||
);
|
);
|
||||||
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 =
|
final HybridPlotWorld area =
|
||||||
(HybridPlotWorld) metaData.computeIfAbsent(
|
(HybridPlotWorld) metaData.computeIfAbsent(
|
||||||
player.getUUID(),
|
player.getUUID(),
|
||||||
@ -424,6 +423,7 @@ public class Area extends SubCommand {
|
|||||||
run.run();
|
run.run();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
default: // Start creation
|
default: // Start creation
|
||||||
String[] split = args[1].split(":");
|
String[] split = args[1].split(":");
|
||||||
@ -468,56 +468,42 @@ public class Area extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (pair[0].toLowerCase()) {
|
switch (pair[0].toLowerCase()) {
|
||||||
case "s":
|
case "s", "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;
|
}
|
||||||
case "g":
|
case "g", "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;
|
}
|
||||||
case "h":
|
case "h", "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;
|
}
|
||||||
case "f":
|
case "f", "floor" -> pa.TOP_BLOCK = ConfigurationUtil.BLOCK_BUCKET.parseString(pair[1]);
|
||||||
case "floor":
|
case "m", "main" -> pa.MAIN_BLOCK = ConfigurationUtil.BLOCK_BUCKET.parseString(pair[1]);
|
||||||
pa.TOP_BLOCK = ConfigurationUtil.BLOCK_BUCKET.parseString(pair[1]);
|
case "w", "wall" -> pa.WALL_FILLING = ConfigurationUtil.BLOCK_BUCKET.parseString(pair[1]);
|
||||||
break;
|
case "b", "border" -> pa.WALL_BLOCK = ConfigurationUtil.BLOCK_BUCKET.parseString(pair[1]);
|
||||||
case "m":
|
case "terrain" -> {
|
||||||
case "main":
|
|
||||||
pa.MAIN_BLOCK = ConfigurationUtil.BLOCK_BUCKET.parseString(pair[1]);
|
|
||||||
break;
|
|
||||||
case "w":
|
|
||||||
case "wall":
|
|
||||||
pa.WALL_FILLING = ConfigurationUtil.BLOCK_BUCKET.parseString(pair[1]);
|
|
||||||
break;
|
|
||||||
case "b":
|
|
||||||
case "border":
|
|
||||||
pa.WALL_BLOCK = ConfigurationUtil.BLOCK_BUCKET.parseString(pair[1]);
|
|
||||||
break;
|
|
||||||
case "terrain":
|
|
||||||
pa.setTerrain(PlotAreaTerrainType.fromString(pair[1])
|
pa.setTerrain(PlotAreaTerrainType.fromString(pair[1])
|
||||||
.orElseThrow(() -> new IllegalArgumentException(pair[1] + " is not a valid terrain.")));
|
.orElseThrow(() -> new IllegalArgumentException(pair[1] + " is not a valid terrain.")));
|
||||||
builder.terrainType(pa.getTerrain());
|
builder.terrainType(pa.getTerrain());
|
||||||
break;
|
}
|
||||||
case "type":
|
case "type" -> {
|
||||||
pa.setType(PlotAreaType.fromString(pair[1])
|
pa.setType(PlotAreaType.fromString(pair[1])
|
||||||
.orElseThrow(() -> new IllegalArgumentException(pair[1] + " is not a valid type.")));
|
.orElseThrow(() -> new IllegalArgumentException(pair[1] + " is not a valid type.")));
|
||||||
builder.plotAreaType(pa.getType());
|
builder.plotAreaType(pa.getType());
|
||||||
break;
|
}
|
||||||
default:
|
default -> {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("commandconfig.command_syntax_extended"),
|
TranslatableCaption.of("commandconfig.command_syntax_extended"),
|
||||||
Template.of("value1", getCommandString()),
|
Template.of("value1", getCommandString()),
|
||||||
Template.of("value2", " create [world[:id]] [<modifier>=<value>]...")
|
Template.of("value2", " create [world[:id]] [<modifier>=<value>]...")
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pa.getType() != PlotAreaType.PARTIAL) {
|
if (pa.getType() != PlotAreaType.PARTIAL) {
|
||||||
@ -566,7 +552,8 @@ public class Area extends SubCommand {
|
|||||||
TranslatableCaption.of("commandconfig.command_syntax"),
|
TranslatableCaption.of("commandconfig.command_syntax"),
|
||||||
Template.of("value", getUsage())
|
Template.of("value", getUsage())
|
||||||
);
|
);
|
||||||
player.sendMessage(TranslatableCaption.of("commandconfig.command_syntax_extended"),
|
player.sendMessage(
|
||||||
|
TranslatableCaption.of("commandconfig.command_syntax_extended"),
|
||||||
Template.of("value1", getCommandString()),
|
Template.of("value1", getCommandString()),
|
||||||
Template.of("value2", " create [world[:id]] [<modifier>=<value>]...")
|
Template.of("value2", " create [world[:id]] [<modifier>=<value>]...")
|
||||||
);
|
);
|
||||||
@ -590,8 +577,8 @@ public class Area extends SubCommand {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case "i":
|
}
|
||||||
case "info": {
|
case "i", "info" -> {
|
||||||
if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_INFO)) {
|
if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_INFO)) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("permission.no_permission"),
|
TranslatableCaption.of("permission.no_permission"),
|
||||||
@ -601,18 +588,16 @@ public class Area extends SubCommand {
|
|||||||
}
|
}
|
||||||
PlotArea area;
|
PlotArea area;
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1 -> area = player.getApplicablePlotArea();
|
||||||
area = player.getApplicablePlotArea();
|
case 2 -> area = this.plotAreaManager.getPlotAreaByString(args[1]);
|
||||||
break;
|
default -> {
|
||||||
case 2:
|
player.sendMessage(
|
||||||
area = this.plotAreaManager.getPlotAreaByString(args[1]);
|
TranslatableCaption.of("commandconfig.command_syntax_extended"),
|
||||||
break;
|
|
||||||
default:
|
|
||||||
player.sendMessage(TranslatableCaption.of("commandconfig.command_syntax_extended"),
|
|
||||||
Template.of("value1", getCommandString()),
|
Template.of("value1", getCommandString()),
|
||||||
Template.of("value2", " info [area]")
|
Template.of("value2", " info [area]")
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
@ -656,7 +641,8 @@ public class Area extends SubCommand {
|
|||||||
"footer",
|
"footer",
|
||||||
TranslatableCaption.of("info.plot_info_footer").getComponent(player)
|
TranslatableCaption.of("info.plot_info_footer").getComponent(player)
|
||||||
);
|
);
|
||||||
player.sendMessage(TranslatableCaption.of("info.area_info_format"),
|
player.sendMessage(
|
||||||
|
TranslatableCaption.of("info.area_info_format"),
|
||||||
headerTemplate,
|
headerTemplate,
|
||||||
nameTemplate,
|
nameTemplate,
|
||||||
typeTemplate,
|
typeTemplate,
|
||||||
@ -670,8 +656,7 @@ public class Area extends SubCommand {
|
|||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "l":
|
case "l", "list" -> {
|
||||||
case "list":
|
|
||||||
if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_LIST)) {
|
if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_LIST)) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("permission.no_permission"),
|
TranslatableCaption.of("permission.no_permission"),
|
||||||
@ -690,7 +675,8 @@ public class Area extends SubCommand {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
player.sendMessage(TranslatableCaption.of("commandconfig.command_syntax_extended"),
|
player.sendMessage(
|
||||||
|
TranslatableCaption.of("commandconfig.command_syntax_extended"),
|
||||||
Template.of("value1", getCommandString()),
|
Template.of("value1", getCommandString()),
|
||||||
Template.of("value2", " list [#]")
|
Template.of("value2", " list [#]")
|
||||||
);
|
);
|
||||||
@ -724,7 +710,8 @@ public class Area extends SubCommand {
|
|||||||
Template regionTemplate = Template.of("region", region);
|
Template regionTemplate = Template.of("region", region);
|
||||||
Template generatorTemplate = Template.of("generator", generator);
|
Template generatorTemplate = Template.of("generator", generator);
|
||||||
String tooltip = MINI_MESSAGE.serialize(MINI_MESSAGE
|
String tooltip = MINI_MESSAGE.serialize(MINI_MESSAGE
|
||||||
.parse(TranslatableCaption.of("info.area_list_tooltip").getComponent(player),
|
.parse(
|
||||||
|
TranslatableCaption.of("info.area_list_tooltip").getComponent(player),
|
||||||
claimedTemplate,
|
claimedTemplate,
|
||||||
usageTemplate,
|
usageTemplate,
|
||||||
clustersTemplate,
|
clustersTemplate,
|
||||||
@ -739,7 +726,8 @@ public class Area extends SubCommand {
|
|||||||
Template typeTemplate = Template.of("area_type", area.getType().name());
|
Template typeTemplate = Template.of("area_type", area.getType().name());
|
||||||
Template terrainTemplate = Template.of("area_terrain", area.getTerrain().name());
|
Template terrainTemplate = Template.of("area_terrain", area.getTerrain().name());
|
||||||
caption.set(TranslatableCaption.of("info.area_list_item"));
|
caption.set(TranslatableCaption.of("info.area_list_item"));
|
||||||
caption.setTemplates(tooltipTemplate,
|
caption.setTemplates(
|
||||||
|
tooltipTemplate,
|
||||||
visitcmdTemplate,
|
visitcmdTemplate,
|
||||||
numberTemplate,
|
numberTemplate,
|
||||||
nameTemplate,
|
nameTemplate,
|
||||||
@ -750,10 +738,8 @@ public class Area extends SubCommand {
|
|||||||
}
|
}
|
||||||
}, "/plot area list", TranslatableCaption.of("list.area_list_header_paged"));
|
}, "/plot area list", TranslatableCaption.of("list.area_list_header_paged"));
|
||||||
return true;
|
return true;
|
||||||
case "regen":
|
}
|
||||||
case "clear":
|
case "regen", "clear", "reset", "regenerate" -> {
|
||||||
case "reset":
|
|
||||||
case "regenerate": {
|
|
||||||
if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_REGEN)) {
|
if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_REGEN)) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("permission.no_permission"),
|
TranslatableCaption.of("permission.no_permission"),
|
||||||
@ -786,11 +772,7 @@ public class Area extends SubCommand {
|
|||||||
queue.enqueue();
|
queue.enqueue();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "goto":
|
case "goto", "v", "teleport", "visit", "tp" -> {
|
||||||
case "v":
|
|
||||||
case "teleport":
|
|
||||||
case "visit":
|
|
||||||
case "tp":
|
|
||||||
if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_TP)) {
|
if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_TP)) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("permission.no_permission"),
|
TranslatableCaption.of("permission.no_permission"),
|
||||||
@ -833,10 +815,11 @@ public class Area extends SubCommand {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case "delete":
|
}
|
||||||
case "remove":
|
case "delete", "remove" -> {
|
||||||
player.sendMessage(TranslatableCaption.of("single.worldcreation_location"));
|
player.sendMessage(TranslatableCaption.of("single.worldcreation_location"));
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sendUsage(player);
|
sendUsage(player);
|
||||||
return false;
|
return false;
|
||||||
|
@ -29,7 +29,7 @@ import com.plotsquared.core.plot.PlotId;
|
|||||||
|
|
||||||
public abstract class Argument<T> {
|
public abstract class Argument<T> {
|
||||||
|
|
||||||
public static final Argument<Integer> Integer = new Argument<Integer>("int", 16) {
|
public static final Argument<Integer> Integer = new Argument<>("int", 16) {
|
||||||
@Override
|
@Override
|
||||||
public Integer parse(String in) {
|
public Integer parse(String in) {
|
||||||
Integer value = null;
|
Integer value = null;
|
||||||
@ -40,7 +40,7 @@ public abstract class Argument<T> {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static final Argument<Boolean> Boolean = new Argument<Boolean>("boolean", true) {
|
public static final Argument<Boolean> Boolean = new Argument<>("boolean", true) {
|
||||||
@Override
|
@Override
|
||||||
public Boolean parse(String in) {
|
public Boolean parse(String in) {
|
||||||
Boolean value = null;
|
Boolean value = null;
|
||||||
@ -54,21 +54,21 @@ public abstract class Argument<T> {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static final Argument<String> String = new Argument<String>("String", "Example") {
|
public static final Argument<String> String = new Argument<>("String", "Example") {
|
||||||
@Override
|
@Override
|
||||||
public String parse(String in) {
|
public String parse(String in) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static final Argument<String> PlayerName =
|
public static final Argument<String> PlayerName =
|
||||||
new Argument<String>("PlayerName", "<player | *>") {
|
new Argument<>("PlayerName", "<player | *>") {
|
||||||
@Override
|
@Override
|
||||||
public String parse(String in) {
|
public String parse(String in) {
|
||||||
return in.length() <= 16 ? in : null;
|
return in.length() <= 16 ? in : null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static final Argument<PlotId> PlotID =
|
public static final Argument<PlotId> PlotID =
|
||||||
new Argument<PlotId>("PlotID", PlotId.of(-6, 3)) {
|
new Argument<>("PlotID", PlotId.of(-6, 3)) {
|
||||||
@Override
|
@Override
|
||||||
public PlotId parse(String in) {
|
public PlotId parse(String in) {
|
||||||
return PlotId.fromString(in);
|
return PlotId.fromString(in);
|
||||||
|
@ -162,7 +162,7 @@ public class Auto extends SubCommand {
|
|||||||
}
|
}
|
||||||
plot.setOwnerAbs(player.getUUID());
|
plot.setOwnerAbs(player.getUUID());
|
||||||
|
|
||||||
final RunnableVal<Plot> runnableVal = new RunnableVal<Plot>() {
|
final RunnableVal<Plot> runnableVal = new RunnableVal<>() {
|
||||||
{
|
{
|
||||||
this.value = plot;
|
this.value = plot;
|
||||||
}
|
}
|
||||||
@ -217,20 +217,21 @@ public class Auto extends SubCommand {
|
|||||||
try {
|
try {
|
||||||
String[] split = args[0].split(",|;");
|
String[] split = args[0].split(",|;");
|
||||||
switch (split.length) {
|
switch (split.length) {
|
||||||
case 1:
|
case 1 -> {
|
||||||
size_x = 1;
|
size_x = 1;
|
||||||
size_z = 1;
|
size_z = 1;
|
||||||
break;
|
}
|
||||||
case 2:
|
case 2 -> {
|
||||||
size_x = Integer.parseInt(split[0]);
|
size_x = Integer.parseInt(split[0]);
|
||||||
size_z = Integer.parseInt(split[1]);
|
size_z = Integer.parseInt(split[1]);
|
||||||
break;
|
}
|
||||||
default:
|
default -> {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("commandconfig.command_syntax"),
|
TranslatableCaption.of("commandconfig.command_syntax"),
|
||||||
Template.of("value", getUsage())
|
Template.of("value", getUsage())
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (size_x < 1 || size_z < 1) {
|
if (size_x < 1 || size_z < 1) {
|
||||||
player.sendMessage(TranslatableCaption.of("error.plot_size"));
|
player.sendMessage(TranslatableCaption.of("error.plot_size"));
|
||||||
|
@ -34,6 +34,7 @@ import com.plotsquared.core.plot.PlotArea;
|
|||||||
permission = "plots.chat",
|
permission = "plots.chat",
|
||||||
category = CommandCategory.CHAT,
|
category = CommandCategory.CHAT,
|
||||||
requiredType = RequiredType.PLAYER)
|
requiredType = RequiredType.PLAYER)
|
||||||
|
@Deprecated
|
||||||
public class Chat extends SubCommand {
|
public class Chat extends SubCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -84,7 +84,7 @@ public class Condense extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (args[1].toLowerCase()) {
|
switch (args[1].toLowerCase()) {
|
||||||
case "start": {
|
case "start" -> {
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("commandconfig.command_syntax"),
|
TranslatableCaption.of("commandconfig.command_syntax"),
|
||||||
@ -216,7 +216,7 @@ public class Condense extends SubCommand {
|
|||||||
TaskManager.runTaskAsync(run);
|
TaskManager.runTaskAsync(run);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "stop":
|
case "stop" -> {
|
||||||
if (!Condense.TASK) {
|
if (!Condense.TASK) {
|
||||||
player.sendMessage(TranslatableCaption.of("condense.task_stopped"));
|
player.sendMessage(TranslatableCaption.of("condense.task_stopped"));
|
||||||
return false;
|
return false;
|
||||||
@ -224,7 +224,8 @@ public class Condense extends SubCommand {
|
|||||||
Condense.TASK = false;
|
Condense.TASK = false;
|
||||||
player.sendMessage(TranslatableCaption.of("condense.task_stopped"));
|
player.sendMessage(TranslatableCaption.of("condense.task_stopped"));
|
||||||
return true;
|
return true;
|
||||||
case "info":
|
}
|
||||||
|
case "info" -> {
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("commandconfig.command_syntax"),
|
TranslatableCaption.of("commandconfig.command_syntax"),
|
||||||
@ -267,6 +268,7 @@ public class Condense extends SubCommand {
|
|||||||
player.sendMessage(TranslatableCaption.of("condense.eta"));
|
player.sendMessage(TranslatableCaption.of("condense.eta"));
|
||||||
player.sendMessage(TranslatableCaption.of("condense.radius_measured"));
|
player.sendMessage(TranslatableCaption.of("condense.radius_measured"));
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("commandconfig.command_syntax"),
|
TranslatableCaption.of("commandconfig.command_syntax"),
|
||||||
|
@ -132,7 +132,7 @@ public class DatabaseCommand extends SubCommand {
|
|||||||
Database implementation;
|
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) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("commandconfig.command_syntax"),
|
TranslatableCaption.of("commandconfig.command_syntax"),
|
||||||
@ -210,7 +210,8 @@ public class DatabaseCommand extends SubCommand {
|
|||||||
() -> player.sendMessage(TranslatableCaption.of("database.conversion_done"))
|
() -> player.sendMessage(TranslatableCaption.of("database.conversion_done"))
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
case "mysql":
|
}
|
||||||
|
case "mysql" -> {
|
||||||
if (args.length < 6) {
|
if (args.length < 6) {
|
||||||
player.sendMessage(StaticCaption.of(
|
player.sendMessage(StaticCaption.of(
|
||||||
"/plot database mysql [host] [port] [username] [password] [database] {prefix}"));
|
"/plot database mysql [host] [port] [username] [password] [database] {prefix}"));
|
||||||
@ -224,18 +225,19 @@ public class DatabaseCommand extends SubCommand {
|
|||||||
prefix = args[6];
|
prefix = args[6];
|
||||||
}
|
}
|
||||||
implementation = new MySQL(host, port, database, username, password);
|
implementation = new MySQL(host, port, database, username, password);
|
||||||
break;
|
}
|
||||||
case "sqlite":
|
case "sqlite" -> {
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
player.sendMessage(StaticCaption.of("/plot database sqlite [file]"));
|
player.sendMessage(StaticCaption.of("/plot database sqlite [file]"));
|
||||||
}
|
}
|
||||||
File sqliteFile =
|
File sqliteFile =
|
||||||
FileUtils.getFile(PlotSquared.platform().getDirectory(), args[1] + ".db");
|
FileUtils.getFile(PlotSquared.platform().getDirectory(), args[1] + ".db");
|
||||||
implementation = new SQLite(sqliteFile);
|
implementation = new SQLite(sqliteFile);
|
||||||
break;
|
}
|
||||||
default:
|
default -> {
|
||||||
player.sendMessage(StaticCaption.of("/plot database [sqlite/mysql]"));
|
player.sendMessage(StaticCaption.of("/plot database [sqlite/mysql]"));
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
SQLManager manager = new SQLManager(
|
SQLManager manager = new SQLManager(
|
||||||
|
@ -93,7 +93,7 @@ public class DebugExec extends SubCommand {
|
|||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
String arg = args[0].toLowerCase();
|
String arg = args[0].toLowerCase();
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
case "analyze": {
|
case "analyze" -> {
|
||||||
Plot plot = player.getCurrentPlot();
|
Plot plot = player.getCurrentPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
|
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
|
||||||
@ -103,7 +103,7 @@ public class DebugExec extends SubCommand {
|
|||||||
if (analysis != null) {
|
if (analysis != null) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("debugexec.changes_column"),
|
TranslatableCaption.of("debugexec.changes_column"),
|
||||||
Template.of("value", String.valueOf(analysis.changes / 1.0))
|
Template.of("value", String.valueOf(analysis.changes))
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ public class DebugExec extends SubCommand {
|
|||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "calibrate-analysis":
|
case "calibrate-analysis" -> {
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("commandconfig.command_syntax"),
|
TranslatableCaption.of("commandconfig.command_syntax"),
|
||||||
@ -144,7 +144,8 @@ public class DebugExec extends SubCommand {
|
|||||||
threshold
|
threshold
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
case "start-expire":
|
}
|
||||||
|
case "start-expire" -> {
|
||||||
if (ExpireManager.IMP == null) {
|
if (ExpireManager.IMP == null) {
|
||||||
ExpireManager.IMP = new ExpireManager(this.eventDispatcher);
|
ExpireManager.IMP = new ExpireManager(this.eventDispatcher);
|
||||||
}
|
}
|
||||||
@ -154,14 +155,16 @@ public class DebugExec extends SubCommand {
|
|||||||
player.sendMessage(TranslatableCaption.of("debugexec.expiry_already_started"));
|
player.sendMessage(TranslatableCaption.of("debugexec.expiry_already_started"));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case "stop-expire":
|
}
|
||||||
|
case "stop-expire" -> {
|
||||||
if (ExpireManager.IMP == null || !ExpireManager.IMP.cancelTask()) {
|
if (ExpireManager.IMP == null || !ExpireManager.IMP.cancelTask()) {
|
||||||
player.sendMessage(TranslatableCaption.of("debugexec.task_halted"));
|
player.sendMessage(TranslatableCaption.of("debugexec.task_halted"));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(TranslatableCaption.of("debugexec.task_cancelled"));
|
player.sendMessage(TranslatableCaption.of("debugexec.task_cancelled"));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case "remove-flag":
|
}
|
||||||
|
case "remove-flag" -> {
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("commandconfig.command_syntax"),
|
TranslatableCaption.of("commandconfig.command_syntax"),
|
||||||
@ -186,7 +189,8 @@ public class DebugExec extends SubCommand {
|
|||||||
Template.of("value", flag)
|
Template.of("value", flag)
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
case "start-rgar": {
|
}
|
||||||
|
case "start-rgar" -> {
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("commandconfig.command_syntax"),
|
TranslatableCaption.of("commandconfig.command_syntax"),
|
||||||
@ -214,7 +218,7 @@ public class DebugExec extends SubCommand {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "stop-rgar":
|
case "stop-rgar" -> {
|
||||||
if (!HybridUtils.UPDATE) {
|
if (!HybridUtils.UPDATE) {
|
||||||
player.sendMessage(TranslatableCaption.of("debugexec.task_not_running"));
|
player.sendMessage(TranslatableCaption.of("debugexec.task_not_running"));
|
||||||
return false;
|
return false;
|
||||||
@ -222,6 +226,7 @@ public class DebugExec extends SubCommand {
|
|||||||
HybridUtils.UPDATE = false;
|
HybridUtils.UPDATE = false;
|
||||||
player.sendMessage(TranslatableCaption.of("debugexec.task_cancelled"));
|
player.sendMessage(TranslatableCaption.of("debugexec.task_cancelled"));
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.sendMessage(StaticCaption.of("<prefix><gold>Possible sub commands: </gold><gray>/plot debugexec <"
|
player.sendMessage(StaticCaption.of("<prefix><gold>Possible sub commands: </gold><gray>/plot debugexec <"
|
||||||
|
@ -105,7 +105,7 @@ public class Done extends SubCommand {
|
|||||||
finish(plot, player, true);
|
finish(plot, player, true);
|
||||||
plot.removeRunning();
|
plot.removeRunning();
|
||||||
} else {
|
} else {
|
||||||
this.hybridUtils.analyzePlot(plot, new RunnableVal<PlotAnalysis>() {
|
this.hybridUtils.analyzePlot(plot, new RunnableVal<>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(PlotAnalysis value) {
|
public void run(PlotAnalysis value) {
|
||||||
plot.removeRunning();
|
plot.removeRunning();
|
||||||
|
@ -119,8 +119,7 @@ public final class FlagCommand extends Command {
|
|||||||
}
|
}
|
||||||
} catch (NumberFormatException ignore) {
|
} catch (NumberFormatException ignore) {
|
||||||
}
|
}
|
||||||
} else if (flag instanceof ListFlag) {
|
} else if (flag instanceof final ListFlag<?, ?> listFlag) {
|
||||||
final ListFlag<?, ?> listFlag = (ListFlag<?, ?>) flag;
|
|
||||||
try {
|
try {
|
||||||
PlotFlag<? extends List<?>, ?> parsedFlag = listFlag.parse(value);
|
PlotFlag<? extends List<?>, ?> parsedFlag = listFlag.parse(value);
|
||||||
for (final Object entry : parsedFlag.getValue()) {
|
for (final Object entry : parsedFlag.getValue()) {
|
||||||
@ -295,7 +294,7 @@ public final class FlagCommand extends Command {
|
|||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tabOf(player, args, space);
|
return tabOf(player, args, space);
|
||||||
|
@ -75,8 +75,7 @@ public class Grant extends Command {
|
|||||||
);
|
);
|
||||||
final String arg0 = args[0].toLowerCase();
|
final String arg0 = args[0].toLowerCase();
|
||||||
switch (arg0) {
|
switch (arg0) {
|
||||||
case "add":
|
case "add", "check" -> {
|
||||||
case "check":
|
|
||||||
if (!Permissions.hasPermission(player, Permission.PERMISSION_GRANT.format(arg0))) {
|
if (!Permissions.hasPermission(player, Permission.PERMISSION_GRANT.format(arg0))) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("permission.no_permission"),
|
TranslatableCaption.of("permission.no_permission"),
|
||||||
@ -111,7 +110,7 @@ public class Grant extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DBFunc.getPersistentMeta(uuid.getUuid(), new RunnableVal<Map<String, byte[]>>() {
|
DBFunc.getPersistentMeta(uuid.getUuid(), new RunnableVal<>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Map<String, byte[]> value) {
|
public void run(Map<String, byte[]> value) {
|
||||||
final byte[] array = value.get("grantedPlots");
|
final byte[] array = value.get("grantedPlots");
|
||||||
@ -148,6 +147,7 @@ public class Grant extends Command {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
return CompletableFuture.completedFuture(true);
|
return CompletableFuture.completedFuture(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sendUsage(player);
|
sendUsage(player);
|
||||||
return CompletableFuture.completedFuture(true);
|
return CompletableFuture.completedFuture(true);
|
||||||
|
@ -129,7 +129,7 @@ public class HomeCommand extends Command {
|
|||||||
PlotArea plotArea;
|
PlotArea plotArea;
|
||||||
boolean basePlotOnly = true;
|
boolean basePlotOnly = true;
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1 -> {
|
||||||
identifier = args[0];
|
identifier = args[0];
|
||||||
if (MathMan.isInteger(identifier)) {
|
if (MathMan.isInteger(identifier)) {
|
||||||
try {
|
try {
|
||||||
@ -160,8 +160,8 @@ public class HomeCommand extends Command {
|
|||||||
}
|
}
|
||||||
// it wasn't a valid plot id, trying to find plot by alias
|
// it wasn't a valid plot id, trying to find plot by alias
|
||||||
query.withAlias(identifier);
|
query.withAlias(identifier);
|
||||||
break;
|
}
|
||||||
case 2:
|
case 2 -> {
|
||||||
// we assume args[0] is a plot area and args[1] an identifier
|
// we assume args[0] is a plot area and args[1] an identifier
|
||||||
plotArea = this.plotAreaManager.getPlotAreaByString(args[0]);
|
plotArea = this.plotAreaManager.getPlotAreaByString(args[0]);
|
||||||
identifier = args[1];
|
identifier = args[1];
|
||||||
@ -201,10 +201,8 @@ public class HomeCommand extends Command {
|
|||||||
// as the query already filters by owner, this is fine
|
// as the query already filters by owner, this is fine
|
||||||
basePlotOnly = false;
|
basePlotOnly = false;
|
||||||
query.withPlot(plot);
|
query.withPlot(plot);
|
||||||
break;
|
}
|
||||||
case 0:
|
case 0 -> sortBySettings(query, player);
|
||||||
sortBySettings(query, player);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (basePlotOnly) {
|
if (basePlotOnly) {
|
||||||
query.whereBasePlot();
|
query.whereBasePlot();
|
||||||
@ -226,7 +224,7 @@ public class HomeCommand extends Command {
|
|||||||
public Collection<Command> tab(PlotPlayer<?> player, String[] args, boolean space) {
|
public Collection<Command> tab(PlotPlayer<?> player, String[] args, boolean space) {
|
||||||
final List<Command> completions = new ArrayList<>();
|
final List<Command> completions = new ArrayList<>();
|
||||||
switch (args.length - 1) {
|
switch (args.length - 1) {
|
||||||
case 0:
|
case 0 -> {
|
||||||
completions.addAll(
|
completions.addAll(
|
||||||
TabCompletions.completeAreas(args[0]));
|
TabCompletions.completeAreas(args[0]));
|
||||||
if (args[0].isEmpty()) {
|
if (args[0].isEmpty()) {
|
||||||
@ -238,11 +236,9 @@ public class HomeCommand extends Command {
|
|||||||
// complete more numbers from the already given input
|
// complete more numbers from the already given input
|
||||||
completions.addAll(
|
completions.addAll(
|
||||||
TabCompletions.completeNumbers(args[0], 10, 999));
|
TabCompletions.completeNumbers(args[0], 10, 999));
|
||||||
break;
|
}
|
||||||
case 1:
|
case 1 -> completions.addAll(
|
||||||
completions.addAll(
|
TabCompletions.completeNumbers(args[1], 10, 999));
|
||||||
TabCompletions.completeNumbers(args[1], 10, 999));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return completions;
|
return completions;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.configuration.caption.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.caption.StaticCaption;
|
import com.plotsquared.core.configuration.caption.StaticCaption;
|
||||||
@ -43,9 +42,7 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
@CommandDeclaration(command = "info",
|
@CommandDeclaration(command = "info",
|
||||||
aliases = "i",
|
aliases = "i",
|
||||||
@ -60,30 +57,16 @@ public class Info extends SubCommand {
|
|||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
arg = args[0];
|
arg = args[0];
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
case "trusted":
|
case "trusted", "alias", "inv", "biome", "denied", "flags", "id", "size", "members", "creationdate", "seen", "owner", "rating", "likes" -> plot = Plot
|
||||||
case "alias":
|
.getPlotFromString(player, null, false);
|
||||||
case "inv":
|
default -> {
|
||||||
case "biome":
|
|
||||||
case "denied":
|
|
||||||
case "flags":
|
|
||||||
case "id":
|
|
||||||
case "size":
|
|
||||||
case "members":
|
|
||||||
case "creationdate":
|
|
||||||
case "seen":
|
|
||||||
case "owner":
|
|
||||||
case "rating":
|
|
||||||
case "likes":
|
|
||||||
plot = Plot.getPlotFromString(player, null, false);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
plot = Plot.getPlotFromString(player, arg, false);
|
plot = Plot.getPlotFromString(player, arg, false);
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
arg = args[1];
|
arg = args[1];
|
||||||
} else {
|
} else {
|
||||||
arg = null;
|
arg = null;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
plot = player.getCurrentPlot();
|
plot = player.getCurrentPlot();
|
||||||
@ -185,36 +168,22 @@ public class Info extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Caption getCaption(String string) {
|
private Caption getCaption(String string) {
|
||||||
switch (string) {
|
return switch (string) {
|
||||||
case "trusted":
|
case "trusted" -> TranslatableCaption.of("info.plot_info_trusted");
|
||||||
return TranslatableCaption.of("info.plot_info_trusted");
|
case "alias" -> TranslatableCaption.of("info.plot_info_alias");
|
||||||
case "alias":
|
case "biome" -> TranslatableCaption.of("info.plot_info_biome");
|
||||||
return TranslatableCaption.of("info.plot_info_alias");
|
case "denied" -> TranslatableCaption.of("info.plot_info_denied");
|
||||||
case "biome":
|
case "flags" -> TranslatableCaption.of("info.plot_info_flags");
|
||||||
return TranslatableCaption.of("info.plot_info_biome");
|
case "id" -> TranslatableCaption.of("info.plot_info_id");
|
||||||
case "denied":
|
case "size" -> TranslatableCaption.of("info.plot_info_size");
|
||||||
return TranslatableCaption.of("info.plot_info_denied");
|
case "members" -> TranslatableCaption.of("info.plot_info_members");
|
||||||
case "flags":
|
case "owner" -> TranslatableCaption.of("info.plot_info_owner");
|
||||||
return TranslatableCaption.of("info.plot_info_flags");
|
case "rating" -> TranslatableCaption.of("info.plot_info_rating");
|
||||||
case "id":
|
case "likes" -> TranslatableCaption.of("info.plot_info_likes");
|
||||||
return TranslatableCaption.of("info.plot_info_id");
|
case "seen" -> TranslatableCaption.of("info.plot_info_seen");
|
||||||
case "size":
|
case "creationdate" -> TranslatableCaption.of("info.plot_info_creationdate");
|
||||||
return TranslatableCaption.of("info.plot_info_size");
|
default -> null;
|
||||||
case "members":
|
};
|
||||||
return TranslatableCaption.of("info.plot_info_members");
|
|
||||||
case "owner":
|
|
||||||
return TranslatableCaption.of("info.plot_info_owner");
|
|
||||||
case "rating":
|
|
||||||
return TranslatableCaption.of("info.plot_info_rating");
|
|
||||||
case "likes":
|
|
||||||
return TranslatableCaption.of("info.plot_info_likes");
|
|
||||||
case "seen":
|
|
||||||
return TranslatableCaption.of("info.plot_info_seen");
|
|
||||||
case "creationdate":
|
|
||||||
return TranslatableCaption.of("info.plot_info_creationdate");
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ public class Like extends SubCommand {
|
|||||||
final UUID uuid = player.getUUID();
|
final UUID uuid = player.getUUID();
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
case "next": {
|
case "next" -> {
|
||||||
final List<Plot> plots = PlotQuery.newQuery().whereBasePlot().asList();
|
final List<Plot> plots = PlotQuery.newQuery().whereBasePlot().asList();
|
||||||
plots.sort((p1, p2) -> {
|
plots.sort((p1, p2) -> {
|
||||||
double v1 = getLikesPercentage(p1);
|
double v1 = getLikesPercentage(p1);
|
||||||
@ -122,7 +122,7 @@ public class Like extends SubCommand {
|
|||||||
player.sendMessage(TranslatableCaption.of("invalid.found_no_plots"));
|
player.sendMessage(TranslatableCaption.of("invalid.found_no_plots"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "purge": {
|
case "purge" -> {
|
||||||
final Plot plot = player.getCurrentPlot();
|
final Plot plot = player.getCurrentPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
|
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
|
||||||
|
@ -192,7 +192,7 @@ public class ListCmd extends SubCommand {
|
|||||||
};
|
};
|
||||||
|
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
case "mine":
|
case "mine" -> {
|
||||||
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_MINE)) {
|
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_MINE)) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("permission.no_permission"),
|
TranslatableCaption.of("permission.no_permission"),
|
||||||
@ -206,8 +206,8 @@ public class ListCmd extends SubCommand {
|
|||||||
.ownedBy(player)
|
.ownedBy(player)
|
||||||
.whereBasePlot()
|
.whereBasePlot()
|
||||||
.withSortingStrategy(SortingStrategy.SORT_BY_TEMP));
|
.withSortingStrategy(SortingStrategy.SORT_BY_TEMP));
|
||||||
break;
|
}
|
||||||
case "shared":
|
case "shared" -> {
|
||||||
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_SHARED)) {
|
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_SHARED)) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("permission.no_permission"),
|
TranslatableCaption.of("permission.no_permission"),
|
||||||
@ -219,8 +219,8 @@ public class ListCmd extends SubCommand {
|
|||||||
.newQuery()
|
.newQuery()
|
||||||
.withMember(player.getUUID())
|
.withMember(player.getUUID())
|
||||||
.thatPasses(plot -> !plot.isOwnerAbs(player.getUUID())));
|
.thatPasses(plot -> !plot.isOwnerAbs(player.getUUID())));
|
||||||
break;
|
}
|
||||||
case "world":
|
case "world" -> {
|
||||||
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_WORLD)) {
|
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_WORLD)) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("permission.no_permission"),
|
TranslatableCaption.of("permission.no_permission"),
|
||||||
@ -236,8 +236,8 @@ public class ListCmd extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
plotConsumer.accept(PlotQuery.newQuery().inWorld(world));
|
plotConsumer.accept(PlotQuery.newQuery().inWorld(world));
|
||||||
break;
|
}
|
||||||
case "expired":
|
case "expired" -> {
|
||||||
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_EXPIRED)) {
|
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_EXPIRED)) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("permission.no_permission"),
|
TranslatableCaption.of("permission.no_permission"),
|
||||||
@ -250,8 +250,8 @@ public class ListCmd extends SubCommand {
|
|||||||
} else {
|
} else {
|
||||||
plotConsumer.accept(PlotQuery.newQuery().expiredPlots());
|
plotConsumer.accept(PlotQuery.newQuery().expiredPlots());
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case "area":
|
case "area" -> {
|
||||||
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_AREA)) {
|
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_AREA)) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("permission.no_permission"),
|
TranslatableCaption.of("permission.no_permission"),
|
||||||
@ -271,8 +271,8 @@ public class ListCmd extends SubCommand {
|
|||||||
} else {
|
} else {
|
||||||
plotConsumer.accept(PlotQuery.newQuery().inArea(area));
|
plotConsumer.accept(PlotQuery.newQuery().inArea(area));
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case "all":
|
case "all" -> {
|
||||||
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_ALL)) {
|
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_ALL)) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("permission.no_permission"),
|
TranslatableCaption.of("permission.no_permission"),
|
||||||
@ -281,8 +281,8 @@ public class ListCmd extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
plotConsumer.accept(PlotQuery.newQuery().allPlots());
|
plotConsumer.accept(PlotQuery.newQuery().allPlots());
|
||||||
break;
|
}
|
||||||
case "done":
|
case "done" -> {
|
||||||
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_DONE)) {
|
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_DONE)) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("permission.no_permission"),
|
TranslatableCaption.of("permission.no_permission"),
|
||||||
@ -296,8 +296,8 @@ public class ListCmd extends SubCommand {
|
|||||||
.allPlots()
|
.allPlots()
|
||||||
.thatPasses(DoneFlag::isDone)
|
.thatPasses(DoneFlag::isDone)
|
||||||
.withSortingStrategy(SortingStrategy.SORT_BY_DONE));
|
.withSortingStrategy(SortingStrategy.SORT_BY_DONE));
|
||||||
break;
|
}
|
||||||
case "top":
|
case "top" -> {
|
||||||
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_TOP)) {
|
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_TOP)) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("permission.no_permission"),
|
TranslatableCaption.of("permission.no_permission"),
|
||||||
@ -307,8 +307,8 @@ public class ListCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
sort[0] = false;
|
sort[0] = false;
|
||||||
plotConsumer.accept(PlotQuery.newQuery().allPlots().withSortingStrategy(SortingStrategy.SORT_BY_RATING));
|
plotConsumer.accept(PlotQuery.newQuery().allPlots().withSortingStrategy(SortingStrategy.SORT_BY_RATING));
|
||||||
break;
|
}
|
||||||
case "forsale":
|
case "forsale" -> {
|
||||||
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_FOR_SALE)) {
|
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_FOR_SALE)) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("permission.no_permission"),
|
TranslatableCaption.of("permission.no_permission"),
|
||||||
@ -320,8 +320,8 @@ public class ListCmd extends SubCommand {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
plotConsumer.accept(PlotQuery.newQuery().allPlots().thatPasses(plot -> plot.getFlag(PriceFlag.class) > 0));
|
plotConsumer.accept(PlotQuery.newQuery().allPlots().thatPasses(plot -> plot.getFlag(PriceFlag.class) > 0));
|
||||||
break;
|
}
|
||||||
case "unowned":
|
case "unowned" -> {
|
||||||
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_UNOWNED)) {
|
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_UNOWNED)) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("permission.no_permission"),
|
TranslatableCaption.of("permission.no_permission"),
|
||||||
@ -330,8 +330,8 @@ public class ListCmd extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
plotConsumer.accept(PlotQuery.newQuery().allPlots().thatPasses(plot -> plot.getOwner() == null));
|
plotConsumer.accept(PlotQuery.newQuery().allPlots().thatPasses(plot -> plot.getOwner() == null));
|
||||||
break;
|
}
|
||||||
case "fuzzy":
|
case "fuzzy" -> {
|
||||||
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_FUZZY)) {
|
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_FUZZY)) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("permission.no_permission"),
|
TranslatableCaption.of("permission.no_permission"),
|
||||||
@ -354,8 +354,8 @@ public class ListCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
sort[0] = false;
|
sort[0] = false;
|
||||||
plotConsumer.accept(PlotQuery.newQuery().plotsBySearch(term));
|
plotConsumer.accept(PlotQuery.newQuery().plotsBySearch(term));
|
||||||
break;
|
}
|
||||||
default:
|
default -> {
|
||||||
if (this.plotAreaManager.hasPlotArea(args[0])) {
|
if (this.plotAreaManager.hasPlotArea(args[0])) {
|
||||||
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_WORLD)) {
|
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_WORLD)) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
@ -374,7 +374,6 @@ public class ListCmd extends SubCommand {
|
|||||||
plotConsumer.accept(PlotQuery.newQuery().inWorld(args[0]));
|
plotConsumer.accept(PlotQuery.newQuery().inWorld(args[0]));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlotSquared.get().getImpromptuUUIDPipeline().getSingle(args[0], (uuid, throwable) -> {
|
PlotSquared.get().getImpromptuUUIDPipeline().getSingle(args[0], (uuid, throwable) -> {
|
||||||
if (throwable instanceof TimeoutException) {
|
if (throwable instanceof TimeoutException) {
|
||||||
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
|
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
|
||||||
@ -403,6 +402,7 @@ public class ListCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -411,7 +411,7 @@ public class ListCmd extends SubCommand {
|
|||||||
public void displayPlots(final PlotPlayer<?> player, List<Plot> plots, int pageSize, int page, String[] args) {
|
public void displayPlots(final PlotPlayer<?> player, List<Plot> plots, int pageSize, int page, String[] args) {
|
||||||
// Header
|
// Header
|
||||||
plots.removeIf(plot -> !plot.isBasePlot());
|
plots.removeIf(plot -> !plot.isBasePlot());
|
||||||
this.paginate(player, plots, pageSize, page, new RunnableVal3<Integer, Plot, CaptionHolder>() {
|
this.paginate(player, plots, pageSize, page, new RunnableVal3<>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Integer i, Plot plot, CaptionHolder caption) {
|
public void run(Integer i, Plot plot, CaptionHolder caption) {
|
||||||
Caption color;
|
Caption color;
|
||||||
|
@ -184,7 +184,7 @@ public class MainCommand extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
getInstance().execute(player, args, new RunnableVal3<Command, Runnable, Runnable>() {
|
getInstance().execute(player, args, new RunnableVal3<>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(final Command cmd, final Runnable success, final Runnable failure) {
|
public void run(final Command cmd, final Runnable success, final Runnable failure) {
|
||||||
if (cmd.hasConfirmation(player)) {
|
if (cmd.hasConfirmation(player)) {
|
||||||
@ -222,7 +222,7 @@ public class MainCommand extends Command {
|
|||||||
success.run();
|
success.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new RunnableVal2<Command, CommandResult>() {
|
}, new RunnableVal2<>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Command cmd, CommandResult result) {
|
public void run(Command cmd, CommandResult result) {
|
||||||
// Post command stuff!?
|
// Post command stuff!?
|
||||||
@ -281,7 +281,7 @@ public class MainCommand extends Command {
|
|||||||
}
|
}
|
||||||
if (args.length >= 2 && !args[0].isEmpty() && args[0].charAt(0) == '-') {
|
if (args.length >= 2 && !args[0].isEmpty() && args[0].charAt(0) == '-') {
|
||||||
if ("f".equals(args[0].substring(1))) {
|
if ("f".equals(args[0].substring(1))) {
|
||||||
confirm = new RunnableVal3<Command, Runnable, Runnable>() {
|
confirm = new RunnableVal3<>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Command cmd, Runnable success, Runnable failure) {
|
public void run(Command cmd, Runnable success, Runnable failure) {
|
||||||
if (area != null && PlotSquared.platform().econHandler().isEnabled(area)) {
|
if (area != null && PlotSquared.platform().econHandler().isEnabled(area)) {
|
||||||
|
@ -74,23 +74,13 @@ public class Merge extends SubCommand {
|
|||||||
public static String direction(float yaw) {
|
public static String direction(float yaw) {
|
||||||
yaw = yaw / 90;
|
yaw = yaw / 90;
|
||||||
int i = Math.round(yaw);
|
int i = Math.round(yaw);
|
||||||
switch (i) {
|
return switch (i) {
|
||||||
case -4:
|
case -4, 0, 4 -> "SOUTH";
|
||||||
case 0:
|
case -1, 3 -> "EAST";
|
||||||
case 4:
|
case -2, 2 -> "NORTH";
|
||||||
return "SOUTH";
|
case -3, 1 -> "WEST";
|
||||||
case -1:
|
default -> "";
|
||||||
case 3:
|
};
|
||||||
return "EAST";
|
|
||||||
case -2:
|
|
||||||
case 2:
|
|
||||||
return "NORTH";
|
|
||||||
case -3:
|
|
||||||
case 1:
|
|
||||||
return "WEST";
|
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -112,18 +102,10 @@ public class Merge extends SubCommand {
|
|||||||
Direction direction = null;
|
Direction direction = null;
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
switch (direction(player.getLocationFull().getYaw())) {
|
switch (direction(player.getLocationFull().getYaw())) {
|
||||||
case "NORTH":
|
case "NORTH" -> direction = Direction.NORTH;
|
||||||
direction = Direction.NORTH;
|
case "EAST" -> direction = Direction.EAST;
|
||||||
break;
|
case "SOUTH" -> direction = Direction.SOUTH;
|
||||||
case "EAST":
|
case "WEST" -> direction = Direction.WEST;
|
||||||
direction = Direction.EAST;
|
|
||||||
break;
|
|
||||||
case "SOUTH":
|
|
||||||
direction = Direction.SOUTH;
|
|
||||||
break;
|
|
||||||
case "WEST":
|
|
||||||
direction = Direction.WEST;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < values.length; i++) {
|
for (int i = 0; i < values.length; i++) {
|
||||||
|
@ -70,7 +70,6 @@ public class Owner extends SetCommand {
|
|||||||
@Override
|
@Override
|
||||||
public boolean set(final PlotPlayer<?> player, final Plot plot, String value) {
|
public boolean set(final PlotPlayer<?> player, final Plot plot, String value) {
|
||||||
if (value == null || value.isEmpty()) {
|
if (value == null || value.isEmpty()) {
|
||||||
player.sendMessage(TranslatableCaption.of("owner.set_owner_missing_player"));
|
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("commandconfig.command_syntax"),
|
TranslatableCaption.of("commandconfig.command_syntax"),
|
||||||
Template.of("value", "/plot setowner <owner>")
|
Template.of("value", "/plot setowner <owner>")
|
||||||
@ -155,7 +154,7 @@ public class Owner extends SetCommand {
|
|||||||
other.getPlotCount() :
|
other.getPlotCount() :
|
||||||
other.getPlotCount(plot.getWorldName())) + size;
|
other.getPlotCount(plot.getWorldName())) + size;
|
||||||
try (final MetaDataAccess<Integer> metaDataAccess = player.accessPersistentMetaData(PlayerMetaDataKeys.PERSISTENT_GRANTED_PLOTS)) {
|
try (final MetaDataAccess<Integer> metaDataAccess = player.accessPersistentMetaData(PlayerMetaDataKeys.PERSISTENT_GRANTED_PLOTS)) {
|
||||||
int grants = 0;
|
int grants;
|
||||||
if (currentPlots >= other.getAllowedPlots()) {
|
if (currentPlots >= other.getAllowedPlots()) {
|
||||||
if (metaDataAccess.isPresent()) {
|
if (metaDataAccess.isPresent()) {
|
||||||
grants = metaDataAccess.get().orElse(0);
|
grants = metaDataAccess.get().orElse(0);
|
||||||
|
@ -206,9 +206,7 @@ public class Purge extends SubCommand {
|
|||||||
"/plot purge " + StringMan.join(args, " ") + " (" + toDelete.size() + " plots)";
|
"/plot purge " + StringMan.join(args, " ") + " (" + toDelete.size() + " plots)";
|
||||||
boolean finalClear = clear;
|
boolean finalClear = clear;
|
||||||
Runnable run = () -> {
|
Runnable run = () -> {
|
||||||
if (Settings.DEBUG) {
|
logger.info("Calculating plots to purge, please wait...");
|
||||||
logger.info("Calculating plots to purge, please wait...");
|
|
||||||
}
|
|
||||||
HashSet<Integer> ids = new HashSet<>();
|
HashSet<Integer> ids = new HashSet<>();
|
||||||
Iterator<Plot> iterator = toDelete.iterator();
|
Iterator<Plot> iterator = toDelete.iterator();
|
||||||
AtomicBoolean cleared = new AtomicBoolean(true);
|
AtomicBoolean cleared = new AtomicBoolean(true);
|
||||||
@ -223,9 +221,7 @@ public class Purge extends SubCommand {
|
|||||||
ids.add(plot.temp);
|
ids.add(plot.temp);
|
||||||
if (finalClear) {
|
if (finalClear) {
|
||||||
plot.getPlotModificationManager().clear(false, true, player, () -> {
|
plot.getPlotModificationManager().clear(false, true, player, () -> {
|
||||||
if (Settings.DEBUG) {
|
logger.info("Plot {} cleared by purge", plot.getId());
|
||||||
logger.info("Plot {} cleared by purge", plot.getId());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
plot.getPlotModificationManager().removeSign();
|
plot.getPlotModificationManager().removeSign();
|
||||||
|
@ -81,7 +81,7 @@ public class Rate extends SubCommand {
|
|||||||
public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
case "next": {
|
case "next" -> {
|
||||||
final List<Plot> plots = PlotQuery.newQuery().whereBasePlot().asList();
|
final List<Plot> plots = PlotQuery.newQuery().whereBasePlot().asList();
|
||||||
plots.sort((p1, p2) -> {
|
plots.sort((p1, p2) -> {
|
||||||
double v1 = 0;
|
double v1 = 0;
|
||||||
@ -115,7 +115,7 @@ public class Rate extends SubCommand {
|
|||||||
player.sendMessage(TranslatableCaption.of("invalid.found_no_plots"));
|
player.sendMessage(TranslatableCaption.of("invalid.found_no_plots"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case "purge": {
|
case "purge" -> {
|
||||||
final Plot plot = player.getCurrentPlot();
|
final Plot plot = player.getCurrentPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
|
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
|
||||||
@ -292,7 +292,7 @@ public class Rate extends SubCommand {
|
|||||||
return TabCompletions.completePlayers(String.join(",", args).trim(), Collections.emptyList());
|
return TabCompletions.completePlayers(String.join(",", args).trim(), Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MutableInt {
|
private static class MutableInt {
|
||||||
|
|
||||||
private int value;
|
private int value;
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ public class SchematicCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
String arg = args[0].toLowerCase();
|
String arg = args[0].toLowerCase();
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
case "paste": {
|
case "paste" -> {
|
||||||
if (!Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC_PASTE)) {
|
if (!Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC_PASTE)) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("permission.no_permission"),
|
TranslatableCaption.of("permission.no_permission"),
|
||||||
@ -179,10 +179,8 @@ public class SchematicCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case "saveall":
|
case "saveall", "exportall" -> {
|
||||||
case "exportall": {
|
|
||||||
Location loc = player.getLocation();
|
Location loc = player.getLocation();
|
||||||
final Plot plot = loc.getPlotAbs();
|
final Plot plot = loc.getPlotAbs();
|
||||||
if (!(player instanceof ConsolePlayer)) {
|
if (!(player instanceof ConsolePlayer)) {
|
||||||
@ -227,10 +225,8 @@ public class SchematicCmd extends SubCommand {
|
|||||||
Template.of("amount", String.valueOf(plots.size()))
|
Template.of("amount", String.valueOf(plots.size()))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case "export":
|
case "export", "save" -> {
|
||||||
case "save":
|
|
||||||
if (!Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC_SAVE)) {
|
if (!Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC_SAVE)) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("permission.no_permission"),
|
TranslatableCaption.of("permission.no_permission"),
|
||||||
@ -272,8 +268,8 @@ public class SchematicCmd extends SubCommand {
|
|||||||
} else {
|
} else {
|
||||||
player.sendMessage(TranslatableCaption.of("schematics.schematic_exportall_started"));
|
player.sendMessage(TranslatableCaption.of("schematics.schematic_exportall_started"));
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case "list": {
|
case "list" -> {
|
||||||
if (!Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC_LIST)) {
|
if (!Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC_LIST)) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("permission.no_permission"),
|
TranslatableCaption.of("permission.no_permission"),
|
||||||
@ -287,13 +283,10 @@ public class SchematicCmd extends SubCommand {
|
|||||||
Template.of("list", string)
|
Template.of("list", string)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
default -> player.sendMessage(
|
||||||
default:
|
TranslatableCaption.of("commandconfig.command_syntax"),
|
||||||
player.sendMessage(
|
Template.of("value", "Possible values: save, paste, exportall, list")
|
||||||
TranslatableCaption.of("commandconfig.command_syntax"),
|
);
|
||||||
Template.of("value", "Possible values: save, paste, exportall, list")
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -47,16 +47,13 @@ public class SetHome extends SetCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (value.toLowerCase()) {
|
switch (value.toLowerCase()) {
|
||||||
case "unset":
|
case "unset", "reset", "remove", "none" -> {
|
||||||
case "reset":
|
|
||||||
case "remove":
|
|
||||||
case "none": {
|
|
||||||
Plot base = plot.getBasePlot(false);
|
Plot base = plot.getBasePlot(false);
|
||||||
base.setHome(null);
|
base.setHome(null);
|
||||||
player.sendMessage(TranslatableCaption.of("position.position_unset"));
|
player.sendMessage(TranslatableCaption.of("position.position_unset"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "": {
|
case "" -> {
|
||||||
Plot base = plot.getBasePlot(false);
|
Plot base = plot.getBasePlot(false);
|
||||||
Location bottom = base.getBottomAbs();
|
Location bottom = base.getBottomAbs();
|
||||||
Location location = player.getLocationFull();
|
Location location = player.getLocationFull();
|
||||||
@ -67,12 +64,13 @@ public class SetHome extends SetCommand {
|
|||||||
player.sendMessage(TranslatableCaption.of("position.position_set"));
|
player.sendMessage(TranslatableCaption.of("position.position_set"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
default:
|
default -> {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("commandconfig.command_syntax"),
|
TranslatableCaption.of("commandconfig.command_syntax"),
|
||||||
Template.of("value", "Use /plot set home [none]")
|
Template.of("value", "Use /plot set home [none]")
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public abstract class SubCommand extends Command {
|
|||||||
super(MainCommand.getInstance(), true);
|
super(MainCommand.getInstance(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SubCommand(Argument... arguments) {
|
public SubCommand(Argument<?>... arguments) {
|
||||||
this();
|
this();
|
||||||
setRequiredArguments(arguments);
|
setRequiredArguments(arguments);
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ public class Template extends SubCommand {
|
|||||||
}
|
}
|
||||||
final String world = args[1];
|
final String world = args[1];
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
case "import": {
|
case "import" -> {
|
||||||
if (args.length != 3) {
|
if (args.length != 3) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("commandconfig.command_syntax"),
|
TranslatableCaption.of("commandconfig.command_syntax"),
|
||||||
@ -245,7 +245,7 @@ public class Template extends SubCommand {
|
|||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "export":
|
case "export" -> {
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("commandconfig.command_syntax"),
|
TranslatableCaption.of("commandconfig.command_syntax"),
|
||||||
@ -276,8 +276,8 @@ public class Template extends SubCommand {
|
|||||||
player.sendMessage(TranslatableCaption.of("debugimportworlds.done"));
|
player.sendMessage(TranslatableCaption.of("debugimportworlds.done"));
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
default:
|
}
|
||||||
sendUsage(player);
|
default -> sendUsage(player);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ public class Trim extends SubCommand {
|
|||||||
StaticCaption.of(" - MCA #: " + result.value1.size());
|
StaticCaption.of(" - MCA #: " + result.value1.size());
|
||||||
StaticCaption.of(" - CHUNKS: " + (result.value1.size() * 1024) + " (max)");
|
StaticCaption.of(" - CHUNKS: " + (result.value1.size() * 1024) + " (max)");
|
||||||
StaticCaption.of(" - TIME ESTIMATE: 12 Parsecs");
|
StaticCaption.of(" - TIME ESTIMATE: 12 Parsecs");
|
||||||
TaskManager.getPlatformImplementation().objectTask(plots, new RunnableVal<Plot>() {
|
TaskManager.getPlatformImplementation().objectTask(plots, new RunnableVal<>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Plot plot) {
|
public void run(Plot plot) {
|
||||||
Location pos1 = plot.getCorners()[0];
|
Location pos1 = plot.getCorners()[0];
|
||||||
@ -147,7 +147,7 @@ public class Trim extends SubCommand {
|
|||||||
}
|
}
|
||||||
Trim.TASK = true;
|
Trim.TASK = true;
|
||||||
final boolean regen = args.length == 2 && Boolean.parseBoolean(args[1]);
|
final boolean regen = args.length == 2 && Boolean.parseBoolean(args[1]);
|
||||||
getTrimRegions(world, new RunnableVal2<Set<BlockVector2>, Set<BlockVector2>>() {
|
getTrimRegions(world, new RunnableVal2<>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Set<BlockVector2> viable, final Set<BlockVector2> nonViable) {
|
public void run(Set<BlockVector2> viable, final Set<BlockVector2> nonViable) {
|
||||||
Runnable regenTask;
|
Runnable regenTask;
|
||||||
@ -199,7 +199,7 @@ public class Trim extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
final QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(world));
|
final QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(world));
|
||||||
TaskManager.getPlatformImplementation().objectTask(chunks, new RunnableVal<BlockVector2>() {
|
TaskManager.getPlatformImplementation().objectTask(chunks, new RunnableVal<>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(BlockVector2 value) {
|
public void run(BlockVector2 value) {
|
||||||
queue.regenChunk(value.getX(), value.getZ());
|
queue.regenChunk(value.getX(), value.getZ());
|
||||||
|
@ -314,10 +314,8 @@ public class Visit extends Command {
|
|||||||
public Collection<Command> tab(PlotPlayer<?> player, String[] args, boolean space) {
|
public Collection<Command> tab(PlotPlayer<?> player, String[] args, boolean space) {
|
||||||
final List<Command> completions = new ArrayList<>();
|
final List<Command> completions = new ArrayList<>();
|
||||||
switch (args.length - 1) {
|
switch (args.length - 1) {
|
||||||
case 0:
|
case 0 -> completions.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList()));
|
||||||
completions.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList()));
|
case 1 -> {
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
completions.addAll(
|
completions.addAll(
|
||||||
TabCompletions.completeAreas(args[1]));
|
TabCompletions.completeAreas(args[1]));
|
||||||
if (args[1].isEmpty()) {
|
if (args[1].isEmpty()) {
|
||||||
@ -328,8 +326,8 @@ public class Visit extends Command {
|
|||||||
}
|
}
|
||||||
completions.addAll(
|
completions.addAll(
|
||||||
TabCompletions.completeNumbers(args[1], 10, 999));
|
TabCompletions.completeNumbers(args[1], 10, 999));
|
||||||
break;
|
}
|
||||||
case 2:
|
case 2 -> {
|
||||||
if (args[2].isEmpty()) {
|
if (args[2].isEmpty()) {
|
||||||
// if no input is given, only suggest 1 - 3
|
// if no input is given, only suggest 1 - 3
|
||||||
completions.addAll(
|
completions.addAll(
|
||||||
@ -338,7 +336,7 @@ public class Visit extends Command {
|
|||||||
}
|
}
|
||||||
completions.addAll(
|
completions.addAll(
|
||||||
TabCompletions.completeNumbers(args[2], 10, 999));
|
TabCompletions.completeNumbers(args[2], 10, 999));
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return completions;
|
return completions;
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* _____ _ _ _____ _
|
|
||||||
* | __ \| | | | / ____| | |
|
|
||||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
|
||||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
|
||||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
|
||||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
|
||||||
* | |
|
|
||||||
* |_|
|
|
||||||
* PlotSquared plot management system for Minecraft
|
|
||||||
* Copyright (C) 2021 IntellectualSites
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package com.plotsquared.core.command;
|
|
||||||
|
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
|
||||||
|
|
||||||
@CommandDeclaration(command = "weanywhere",
|
|
||||||
permission = "plots.worldedit.bypass",
|
|
||||||
aliases = {"wea"},
|
|
||||||
usage = "/plot weanywhere",
|
|
||||||
requiredType = RequiredType.NONE,
|
|
||||||
category = CommandCategory.ADMINISTRATION)
|
|
||||||
@Deprecated
|
|
||||||
public class WE_Anywhere extends SubCommand {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(PlotPlayer<?> player, String[] arguments) {
|
|
||||||
MainCommand.getInstance().toggle.worldedit(this, player, new String[0], null, null);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -170,12 +170,11 @@ public class Config {
|
|||||||
}
|
}
|
||||||
StringBuilder m = new StringBuilder();
|
StringBuilder m = new StringBuilder();
|
||||||
for (Object obj : listValue) {
|
for (Object obj : listValue) {
|
||||||
m.append(System.lineSeparator() + spacing + "- " + toYamlString(obj, spacing));
|
m.append(System.lineSeparator()).append(spacing).append("- ").append(toYamlString(obj, spacing));
|
||||||
}
|
}
|
||||||
return m.toString();
|
return m.toString();
|
||||||
}
|
}
|
||||||
if (value instanceof String) {
|
if (value instanceof String stringValue) {
|
||||||
String stringValue = (String) value;
|
|
||||||
if (stringValue.isEmpty()) {
|
if (stringValue.isEmpty()) {
|
||||||
return "''";
|
return "''";
|
||||||
}
|
}
|
||||||
@ -448,7 +447,7 @@ public class Config {
|
|||||||
@Ignore // This is not part of the config
|
@Ignore // This is not part of the config
|
||||||
public static class ConfigBlock<T> {
|
public static class ConfigBlock<T> {
|
||||||
|
|
||||||
private HashMap<String, T> INSTANCES = new HashMap<>();
|
private final HashMap<String, T> INSTANCES = new HashMap<>();
|
||||||
|
|
||||||
public T get(String key) {
|
public T get(String key) {
|
||||||
return INSTANCES.get(key);
|
return INSTANCES.get(key);
|
||||||
|
@ -255,7 +255,7 @@ public interface ConfigurationSection {
|
|||||||
* <p>If the path exists but is not a String, this will return false. If
|
* <p>If the path exists but is not a String, this will return false. If
|
||||||
* the path does not exist, this will return false. If the path does not
|
* the path does not exist, this will return false. If the path does not
|
||||||
* exist but a default value has been specified, this will check if that
|
* exist but a default value has been specified, this will check if that
|
||||||
* defaultvalue is a String and return appropriately.
|
* default value is a String and return appropriately.
|
||||||
*
|
*
|
||||||
* @param path Path of the String to check.
|
* @param path Path of the String to check.
|
||||||
* @return Whether or not the specified path is a String.
|
* @return Whether or not the specified path is a String.
|
||||||
|
@ -45,7 +45,7 @@ import java.util.function.Supplier;
|
|||||||
*/
|
*/
|
||||||
public class ConfigurationUtil {
|
public class ConfigurationUtil {
|
||||||
|
|
||||||
public static final SettingValue<Integer> INTEGER = new SettingValue<Integer>("INTEGER") {
|
public static final SettingValue<Integer> INTEGER = new SettingValue<>("INTEGER") {
|
||||||
@Override
|
@Override
|
||||||
public boolean validateValue(String string) {
|
public boolean validateValue(String string) {
|
||||||
try {
|
try {
|
||||||
@ -61,7 +61,7 @@ public class ConfigurationUtil {
|
|||||||
return Integer.parseInt(string);
|
return Integer.parseInt(string);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static final SettingValue<Boolean> BOOLEAN = new SettingValue<Boolean>("BOOLEAN") {
|
public static final SettingValue<Boolean> BOOLEAN = new SettingValue<>("BOOLEAN") {
|
||||||
@Override
|
@Override
|
||||||
public boolean validateValue(String string) {
|
public boolean validateValue(String string) {
|
||||||
//noinspection ResultOfMethodCallIgnored
|
//noinspection ResultOfMethodCallIgnored
|
||||||
@ -74,7 +74,7 @@ public class ConfigurationUtil {
|
|||||||
return Boolean.parseBoolean(string);
|
return Boolean.parseBoolean(string);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static final SettingValue<BiomeType> BIOME = new SettingValue<BiomeType>("BIOME") {
|
public static final SettingValue<BiomeType> BIOME = new SettingValue<>("BIOME") {
|
||||||
@Override
|
@Override
|
||||||
public boolean validateValue(String string) {
|
public boolean validateValue(String string) {
|
||||||
try {
|
try {
|
||||||
@ -94,7 +94,7 @@ public class ConfigurationUtil {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public static final SettingValue<BlockBucket> BLOCK_BUCKET =
|
public static final SettingValue<BlockBucket> BLOCK_BUCKET =
|
||||||
new SettingValue<BlockBucket>("BLOCK_BUCKET") {
|
new SettingValue<>("BLOCK_BUCKET") {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockBucket parseString(final String string) {
|
public BlockBucket parseString(final String string) {
|
||||||
|
@ -95,8 +95,7 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
return Double.parseDouble((String) obj);
|
return Double.parseDouble((String) obj);
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
}
|
}
|
||||||
} else if (obj instanceof List) {
|
} else if (obj instanceof List<?> val) {
|
||||||
List<?> val = (List<?>) obj;
|
|
||||||
if (!val.isEmpty()) {
|
if (!val.isEmpty()) {
|
||||||
return toDouble(val.get(0), def);
|
return toDouble(val.get(0), def);
|
||||||
}
|
}
|
||||||
@ -113,8 +112,7 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
return Integer.parseInt((String) obj);
|
return Integer.parseInt((String) obj);
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
}
|
}
|
||||||
} else if (obj instanceof List) {
|
} else if (obj instanceof List<?> val) {
|
||||||
List<?> val = (List<?>) obj;
|
|
||||||
if (!val.isEmpty()) {
|
if (!val.isEmpty()) {
|
||||||
return toInt(val.get(0), def);
|
return toInt(val.get(0), def);
|
||||||
}
|
}
|
||||||
@ -131,8 +129,7 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
return Long.parseLong((String) obj);
|
return Long.parseLong((String) obj);
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
}
|
}
|
||||||
} else if (obj instanceof List) {
|
} else if (obj instanceof List<?> val) {
|
||||||
List<?> val = (List<?>) obj;
|
|
||||||
if (!val.isEmpty()) {
|
if (!val.isEmpty()) {
|
||||||
return toLong(val.get(0), def);
|
return toLong(val.get(0), def);
|
||||||
}
|
}
|
||||||
@ -716,8 +713,7 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
for (Object object : list) {
|
for (Object object : list) {
|
||||||
if (object instanceof Character) {
|
if (object instanceof Character) {
|
||||||
result.add((Character) object);
|
result.add((Character) object);
|
||||||
} else if (object instanceof String) {
|
} else if (object instanceof String str) {
|
||||||
String str = (String) object;
|
|
||||||
|
|
||||||
if (str.length() == 1) {
|
if (str.length() == 1) {
|
||||||
result.add(str.charAt(0));
|
result.add(str.charAt(0));
|
||||||
@ -798,14 +794,12 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void mapChildrenKeys(Set<String> output, ConfigurationSection section, boolean deep) {
|
protected void mapChildrenKeys(Set<String> output, ConfigurationSection section, boolean deep) {
|
||||||
if (section instanceof MemorySection) {
|
if (section instanceof MemorySection sec) {
|
||||||
MemorySection sec = (MemorySection) section;
|
|
||||||
|
|
||||||
for (Map.Entry<String, Object> entry : sec.map.entrySet()) {
|
for (Map.Entry<String, Object> entry : sec.map.entrySet()) {
|
||||||
output.add(createPath(section, entry.getKey(), this));
|
output.add(createPath(section, entry.getKey(), this));
|
||||||
|
|
||||||
if (deep && (entry.getValue() instanceof ConfigurationSection)) {
|
if (deep && (entry.getValue() instanceof ConfigurationSection subsection)) {
|
||||||
ConfigurationSection subsection = (ConfigurationSection) entry.getValue();
|
|
||||||
mapChildrenKeys(output, subsection, deep);
|
mapChildrenKeys(output, subsection, deep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -822,8 +816,7 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
Map<String, Object> output, ConfigurationSection section,
|
Map<String, Object> output, ConfigurationSection section,
|
||||||
boolean deep
|
boolean deep
|
||||||
) {
|
) {
|
||||||
if (section instanceof MemorySection) {
|
if (section instanceof MemorySection sec) {
|
||||||
MemorySection sec = (MemorySection) section;
|
|
||||||
|
|
||||||
for (Map.Entry<String, Object> entry : sec.map.entrySet()) {
|
for (Map.Entry<String, Object> entry : sec.map.entrySet()) {
|
||||||
output.put(createPath(section, entry.getKey(), this), entry.getValue());
|
output.put(createPath(section, entry.getKey(), this), entry.getValue());
|
||||||
|
@ -167,9 +167,6 @@ public class Settings extends Config {
|
|||||||
Teleport.ON_CLEAR = config.getBoolean("teleport.on_clear", Teleport.ON_CLEAR);
|
Teleport.ON_CLEAR = config.getBoolean("teleport.on_clear", Teleport.ON_CLEAR);
|
||||||
Teleport.ON_DELETE = config.getBoolean("teleport.on_delete", Teleport.ON_DELETE);
|
Teleport.ON_DELETE = config.getBoolean("teleport.on_delete", Teleport.ON_DELETE);
|
||||||
|
|
||||||
// WorldEdit
|
|
||||||
//WE_ALLOW_HELPER = config.getBoolean("worldedit.enable-for-helpers");
|
|
||||||
|
|
||||||
// Chunk processor
|
// Chunk processor
|
||||||
Enabled_Components.CHUNK_PROCESSOR =
|
Enabled_Components.CHUNK_PROCESSOR =
|
||||||
config.getBoolean("chunk-processor.enabled", Enabled_Components.CHUNK_PROCESSOR);
|
config.getBoolean("chunk-processor.enabled", Enabled_Components.CHUNK_PROCESSOR);
|
||||||
|
@ -81,13 +81,11 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
dest = new File(file.getAbsolutePath() + "_broken_" + i++);
|
dest = new File(file.getAbsolutePath() + "_broken_" + i++);
|
||||||
}
|
}
|
||||||
Files.copy(file.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(file.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
if (Settings.DEBUG) {
|
logger.error("Could not read: {}", file);
|
||||||
logger.error("Could not read: {}", file);
|
logger.error("Renamed to: {}", file);
|
||||||
logger.error("Renamed to: {}", file);
|
logger.error("============ Full stacktrace ============");
|
||||||
logger.error("============ Full stacktrace ============");
|
ex.printStackTrace();
|
||||||
ex.printStackTrace();
|
logger.error("=========================================");
|
||||||
logger.error("=========================================");
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -117,7 +115,7 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
|
|
||||||
Map<?, ?> input;
|
Map<?, ?> input;
|
||||||
try {
|
try {
|
||||||
input = (Map<?, ?>) yaml.load(contents);
|
input = yaml.load(contents);
|
||||||
} catch (YAMLException e) {
|
} catch (YAMLException e) {
|
||||||
throw new InvalidConfigurationException(e);
|
throw new InvalidConfigurationException(e);
|
||||||
} catch (ClassCastException ignored) {
|
} catch (ClassCastException ignored) {
|
||||||
@ -183,8 +181,7 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
if (options().copyHeader()) {
|
if (options().copyHeader()) {
|
||||||
Configuration def = getDefaults();
|
Configuration def = getDefaults();
|
||||||
|
|
||||||
if (def instanceof FileConfiguration) {
|
if (def instanceof FileConfiguration fileDefaults) {
|
||||||
FileConfiguration fileDefaults = (FileConfiguration) def;
|
|
||||||
String defaultsHeader = fileDefaults.buildHeader();
|
String defaultsHeader = fileDefaults.buildHeader();
|
||||||
|
|
||||||
if ((defaultsHeader != null) && !defaultsHeader.isEmpty()) {
|
if ((defaultsHeader != null) && !defaultsHeader.isEmpty()) {
|
||||||
|
@ -51,7 +51,6 @@ class YamlRepresenter extends Representer {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class RepresentConfigurationSerializable extends RepresentMap {
|
private class RepresentConfigurationSerializable extends RepresentMap {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -196,10 +196,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
TaskManager.runTaskAsync(() -> {
|
TaskManager.runTaskAsync(() -> {
|
||||||
long last = System.currentTimeMillis();
|
long last = System.currentTimeMillis();
|
||||||
while (true) {
|
while (!SQLManager.this.closed) {
|
||||||
if (SQLManager.this.closed) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
boolean hasTask =
|
boolean hasTask =
|
||||||
!globalTasks.isEmpty() || !playerTasks.isEmpty() || !plotTasks.isEmpty()
|
!globalTasks.isEmpty() || !playerTasks.isEmpty() || !plotTasks.isEmpty()
|
||||||
|| !clusterTasks.isEmpty();
|
|| !clusterTasks.isEmpty();
|
||||||
@ -685,7 +682,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
* @param myList list of plots to be created
|
* @param myList list of plots to be created
|
||||||
*/
|
*/
|
||||||
public void createTiers(ArrayList<UUIDPair> myList, final String tier, Runnable whenDone) {
|
public void createTiers(ArrayList<UUIDPair> myList, final String tier, Runnable whenDone) {
|
||||||
StmtMod<UUIDPair> mod = new StmtMod<UUIDPair>() {
|
StmtMod<UUIDPair> mod = new StmtMod<>() {
|
||||||
@Override
|
@Override
|
||||||
public String getCreateMySQL(int size) {
|
public String getCreateMySQL(int size) {
|
||||||
return getCreateMySQL(size, SQLManager.this.CREATE_TIERS.replaceAll("%tier%", tier),
|
return getCreateMySQL(size, SQLManager.this.CREATE_TIERS.replaceAll("%tier%", tier),
|
||||||
@ -750,12 +747,10 @@ public class SQLManager implements AbstractDB {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (Settings.DEBUG) {
|
logger.info(
|
||||||
logger.info(
|
"- Finished converting flag values for plot with entry ID: {}",
|
||||||
"- Finished converting flag values for plot with entry ID: {}",
|
plot.getId()
|
||||||
plot.getId()
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
logger.error("Failed to store flag values", e);
|
logger.error("Failed to store flag values", e);
|
||||||
@ -770,7 +765,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
* @param myList list of plots to be created
|
* @param myList list of plots to be created
|
||||||
*/
|
*/
|
||||||
public void createPlots(List<Plot> myList, Runnable whenDone) {
|
public void createPlots(List<Plot> myList, Runnable whenDone) {
|
||||||
StmtMod<Plot> mod = new StmtMod<Plot>() {
|
StmtMod<Plot> mod = new StmtMod<>() {
|
||||||
@Override
|
@Override
|
||||||
public String getCreateMySQL(int size) {
|
public String getCreateMySQL(int size) {
|
||||||
return getCreateMySQL(size, SQLManager.this.CREATE_PLOTS, 5);
|
return getCreateMySQL(size, SQLManager.this.CREATE_PLOTS, 5);
|
||||||
@ -1007,7 +1002,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void createEmptySettings(final ArrayList<Integer> myList, final Runnable whenDone) {
|
public void createEmptySettings(final ArrayList<Integer> myList, final Runnable whenDone) {
|
||||||
final StmtMod<Integer> mod = new StmtMod<Integer>() {
|
final StmtMod<Integer> mod = new StmtMod<>() {
|
||||||
@Override
|
@Override
|
||||||
public String getCreateMySQL(int size) {
|
public String getCreateMySQL(int size) {
|
||||||
return getCreateMySQL(size, SQLManager.this.CREATE_SETTINGS, 1);
|
return getCreateMySQL(size, SQLManager.this.CREATE_SETTINGS, 1);
|
||||||
@ -1673,7 +1668,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void deleteRows(ArrayList<Integer> rowIds, final String table, final String column) {
|
public void deleteRows(ArrayList<Integer> rowIds, final String table, final String column) {
|
||||||
setBulk(rowIds, new StmtMod<Integer>() {
|
setBulk(rowIds, new StmtMod<>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCreateMySQL(int size) {
|
public String getCreateMySQL(int size) {
|
||||||
@ -1786,13 +1781,10 @@ public class SQLManager implements AbstractDB {
|
|||||||
String.format("%.1f", ((float) flagsProcessed / totalFlags) * 100)
|
String.format("%.1f", ((float) flagsProcessed / totalFlags) * 100)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
logger.info(
|
||||||
if (Settings.DEBUG) {
|
"- Finished converting flags for plot with entry ID: {}",
|
||||||
logger.info(
|
plotFlagEntry.getKey()
|
||||||
"- Finished converting flags for plot with entry ID: {}",
|
);
|
||||||
plotFlagEntry.getKey()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
logger.error("Failed to store flag values", e);
|
logger.error("Failed to store flag values", e);
|
||||||
@ -1905,7 +1897,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
if (last != null) {
|
if (last != null) {
|
||||||
if (Settings.Enabled_Components.DATABASE_PURGER) {
|
if (Settings.Enabled_Components.DATABASE_PURGER) {
|
||||||
toDelete.add(last.temp);
|
toDelete.add(last.temp);
|
||||||
} else if (Settings.DEBUG) {
|
} else {
|
||||||
logger.info(
|
logger.info(
|
||||||
"Plot #{}({}) in `{}plot` is a duplicate."
|
"Plot #{}({}) in `{}plot` is a duplicate."
|
||||||
+ " Delete this plot or set `database-purger: true` in the settings.yml",
|
+ " Delete this plot or set `database-purger: true` in the settings.yml",
|
||||||
@ -1942,7 +1934,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
plot.getSettings().getRatings().put(user, r.getInt("rating"));
|
plot.getSettings().getRatings().put(user, r.getInt("rating"));
|
||||||
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
||||||
toDelete.add(id);
|
toDelete.add(id);
|
||||||
} else if (Settings.DEBUG) {
|
} else {
|
||||||
logger.info("Entry #{}({}) in `plot_rating` does not exist."
|
logger.info("Entry #{}({}) in `plot_rating` does not exist."
|
||||||
+ " Create this plot or set `database-purger: true` in settings.yml", id, plot);
|
+ " Create this plot or set `database-purger: true` in settings.yml", id, plot);
|
||||||
}
|
}
|
||||||
@ -1970,7 +1962,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
plot.getTrusted().add(user);
|
plot.getTrusted().add(user);
|
||||||
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
||||||
toDelete.add(id);
|
toDelete.add(id);
|
||||||
} else if (Settings.DEBUG) {
|
} else {
|
||||||
logger.info("Entry #{}({}) in `plot_helpers` does not exist."
|
logger.info("Entry #{}({}) in `plot_helpers` does not exist."
|
||||||
+ " Create this plot or set `database-purger: true` in settings.yml", id, plot);
|
+ " Create this plot or set `database-purger: true` in settings.yml", id, plot);
|
||||||
}
|
}
|
||||||
@ -1997,7 +1989,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
plot.getMembers().add(user);
|
plot.getMembers().add(user);
|
||||||
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
||||||
toDelete.add(id);
|
toDelete.add(id);
|
||||||
} else if (Settings.DEBUG) {
|
} else {
|
||||||
logger.info("Entry #{}({}) in `plot_trusted` does not exist."
|
logger.info("Entry #{}({}) in `plot_trusted` does not exist."
|
||||||
+ " Create this plot or set `database-purger: true` in settings.yml", id, plot);
|
+ " Create this plot or set `database-purger: true` in settings.yml", id, plot);
|
||||||
}
|
}
|
||||||
@ -2024,7 +2016,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
plot.getDenied().add(user);
|
plot.getDenied().add(user);
|
||||||
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
||||||
toDelete.add(id);
|
toDelete.add(id);
|
||||||
} else if (Settings.DEBUG) {
|
} else {
|
||||||
logger.info("Entry #{}({}) in `plot_denied` does not exist."
|
logger.info("Entry #{}({}) in `plot_denied` does not exist."
|
||||||
+ " Create this plot or set `database-purger: true` in settings.yml", id, plot);
|
+ " Create this plot or set `database-purger: true` in settings.yml", id, plot);
|
||||||
}
|
}
|
||||||
@ -2065,7 +2057,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
||||||
toDelete.add(id);
|
toDelete.add(id);
|
||||||
} else if (Settings.DEBUG) {
|
} else {
|
||||||
logger.info("Entry #{}({}) in `plot_flags` does not exist."
|
logger.info("Entry #{}({}) in `plot_flags` does not exist."
|
||||||
+ " Create this plot or set `database-purger: true` in settings.yml", id, plot);
|
+ " Create this plot or set `database-purger: true` in settings.yml", id, plot);
|
||||||
}
|
}
|
||||||
@ -2076,12 +2068,10 @@ public class SQLManager implements AbstractDB {
|
|||||||
for (final Map.Entry<Plot, Collection<PlotFlag<?, ?>>> plotFlagEntry : invalidFlags
|
for (final Map.Entry<Plot, Collection<PlotFlag<?, ?>>> plotFlagEntry : invalidFlags
|
||||||
.entrySet()) {
|
.entrySet()) {
|
||||||
for (final PlotFlag<?, ?> flag : plotFlagEntry.getValue()) {
|
for (final PlotFlag<?, ?> flag : plotFlagEntry.getValue()) {
|
||||||
if (Settings.DEBUG) {
|
logger.info(
|
||||||
logger.info(
|
"Plot {} has an invalid flag ({}). A fix has been attempted",
|
||||||
"Plot {} has an invalid flag ({}). A fix has been attempted",
|
plotFlagEntry.getKey(), flag.getName()
|
||||||
plotFlagEntry.getKey(), flag.getName()
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
removeFlag(plotFlagEntry.getKey(), flag);
|
removeFlag(plotFlagEntry.getKey(), flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2122,7 +2112,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
plot.getSettings().setMerged(merged);
|
plot.getSettings().setMerged(merged);
|
||||||
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
||||||
toDelete.add(id);
|
toDelete.add(id);
|
||||||
} else if (Settings.DEBUG) {
|
} else {
|
||||||
logger.info("Entry #{}({}) in `plot_settings` does not exist."
|
logger.info("Entry #{}({}) in `plot_settings` does not exist."
|
||||||
+ " Create this plot or set `database-purger: true` in settings.yml", id, plot);
|
+ " Create this plot or set `database-purger: true` in settings.yml", id, plot);
|
||||||
}
|
}
|
||||||
@ -2295,71 +2285,66 @@ public class SQLManager implements AbstractDB {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void purgeIds(final Set<Integer> uniqueIds) {
|
public void purgeIds(final Set<Integer> uniqueIds) {
|
||||||
addGlobalTask(new Runnable() {
|
addGlobalTask(() -> {
|
||||||
@Override
|
if (!uniqueIds.isEmpty()) {
|
||||||
public void run() {
|
try {
|
||||||
if (!uniqueIds.isEmpty()) {
|
ArrayList<Integer> uniqueIdsList = new ArrayList<>(uniqueIds);
|
||||||
try {
|
int size = uniqueIdsList.size();
|
||||||
ArrayList<Integer> uniqueIdsList = new ArrayList<>(uniqueIds);
|
int packet = 990;
|
||||||
int size = uniqueIdsList.size();
|
int amount = size / packet;
|
||||||
int packet = 990;
|
int count = 0;
|
||||||
int amount = size / packet;
|
int last = -1;
|
||||||
int count = 0;
|
for (int j = 0; j <= amount; j++) {
|
||||||
int last = -1;
|
List<Integer> subList =
|
||||||
for (int j = 0; j <= amount; j++) {
|
uniqueIdsList.subList(j * packet, Math.min(size, (j + 1) * packet));
|
||||||
List<Integer> subList =
|
if (subList.isEmpty()) {
|
||||||
uniqueIdsList.subList(j * packet, Math.min(size, (j + 1) * packet));
|
break;
|
||||||
if (subList.isEmpty()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
StringBuilder idstr2 = new StringBuilder();
|
|
||||||
String stmt_prefix = "";
|
|
||||||
for (Integer id : subList) {
|
|
||||||
idstr2.append(stmt_prefix).append(id);
|
|
||||||
stmt_prefix = " OR `id` = ";
|
|
||||||
}
|
|
||||||
stmt_prefix = "";
|
|
||||||
StringBuilder idstr = new StringBuilder();
|
|
||||||
for (Integer id : subList) {
|
|
||||||
idstr.append(stmt_prefix).append(id);
|
|
||||||
stmt_prefix = " OR `plot_plot_id` = ";
|
|
||||||
}
|
|
||||||
PreparedStatement stmt = SQLManager.this.connection.prepareStatement(
|
|
||||||
"DELETE FROM `" + SQLManager.this.prefix
|
|
||||||
+ "plot_helpers` WHERE `plot_plot_id` = " + idstr);
|
|
||||||
stmt.executeUpdate();
|
|
||||||
stmt.close();
|
|
||||||
stmt = SQLManager.this.connection.prepareStatement(
|
|
||||||
"DELETE FROM `" + SQLManager.this.prefix
|
|
||||||
+ "plot_denied` WHERE `plot_plot_id` = " + idstr);
|
|
||||||
stmt.executeUpdate();
|
|
||||||
stmt.close();
|
|
||||||
stmt = SQLManager.this.connection.prepareStatement(
|
|
||||||
"DELETE FROM `" + SQLManager.this.prefix
|
|
||||||
+ "plot_settings` WHERE `plot_plot_id` = " + idstr);
|
|
||||||
stmt.executeUpdate();
|
|
||||||
stmt.close();
|
|
||||||
stmt = SQLManager.this.connection.prepareStatement(
|
|
||||||
"DELETE FROM `" + SQLManager.this.prefix
|
|
||||||
+ "plot_trusted` WHERE `plot_plot_id` = " + idstr);
|
|
||||||
stmt.executeUpdate();
|
|
||||||
stmt.close();
|
|
||||||
stmt = SQLManager.this.connection.prepareStatement(
|
|
||||||
"DELETE FROM `" + SQLManager.this.prefix + "plot` WHERE `id` = "
|
|
||||||
+ idstr2);
|
|
||||||
stmt.executeUpdate();
|
|
||||||
stmt.close();
|
|
||||||
commit();
|
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
StringBuilder idstr2 = new StringBuilder();
|
||||||
logger.error("Failed to purge plots", e);
|
String stmt_prefix = "";
|
||||||
return;
|
for (Integer id : subList) {
|
||||||
|
idstr2.append(stmt_prefix).append(id);
|
||||||
|
stmt_prefix = " OR `id` = ";
|
||||||
|
}
|
||||||
|
stmt_prefix = "";
|
||||||
|
StringBuilder idstr = new StringBuilder();
|
||||||
|
for (Integer id : subList) {
|
||||||
|
idstr.append(stmt_prefix).append(id);
|
||||||
|
stmt_prefix = " OR `plot_plot_id` = ";
|
||||||
|
}
|
||||||
|
PreparedStatement stmt = SQLManager.this.connection.prepareStatement(
|
||||||
|
"DELETE FROM `" + SQLManager.this.prefix
|
||||||
|
+ "plot_helpers` WHERE `plot_plot_id` = " + idstr);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
stmt.close();
|
||||||
|
stmt = SQLManager.this.connection.prepareStatement(
|
||||||
|
"DELETE FROM `" + SQLManager.this.prefix
|
||||||
|
+ "plot_denied` WHERE `plot_plot_id` = " + idstr);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
stmt.close();
|
||||||
|
stmt = SQLManager.this.connection.prepareStatement(
|
||||||
|
"DELETE FROM `" + SQLManager.this.prefix
|
||||||
|
+ "plot_settings` WHERE `plot_plot_id` = " + idstr);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
stmt.close();
|
||||||
|
stmt = SQLManager.this.connection.prepareStatement(
|
||||||
|
"DELETE FROM `" + SQLManager.this.prefix
|
||||||
|
+ "plot_trusted` WHERE `plot_plot_id` = " + idstr);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
stmt.close();
|
||||||
|
stmt = SQLManager.this.connection.prepareStatement(
|
||||||
|
"DELETE FROM `" + SQLManager.this.prefix + "plot` WHERE `id` = "
|
||||||
|
+ idstr2);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
stmt.close();
|
||||||
|
commit();
|
||||||
}
|
}
|
||||||
}
|
} catch (SQLException e) {
|
||||||
if (Settings.DEBUG) {
|
logger.error("Failed to purge plots", e);
|
||||||
logger.info("Successfully purged {} plots", uniqueIds.size());
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logger.info("Successfully purged {} plots", uniqueIds.size());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2919,7 +2904,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
cluster = clusters.get(id);
|
cluster = clusters.get(id);
|
||||||
if (cluster != null) {
|
if (cluster != null) {
|
||||||
cluster.helpers.add(user);
|
cluster.helpers.add(user);
|
||||||
} else if (Settings.DEBUG) {
|
} else {
|
||||||
logger.warn("Cluster #{}({}) in cluster_helpers does not exist."
|
logger.warn("Cluster #{}({}) in cluster_helpers does not exist."
|
||||||
+ " Please create the cluster or remove this entry", id, cluster);
|
+ " Please create the cluster or remove this entry", id, cluster);
|
||||||
}
|
}
|
||||||
@ -2938,7 +2923,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
cluster = clusters.get(id);
|
cluster = clusters.get(id);
|
||||||
if (cluster != null) {
|
if (cluster != null) {
|
||||||
cluster.invited.add(user);
|
cluster.invited.add(user);
|
||||||
} else if (Settings.DEBUG) {
|
} else {
|
||||||
logger.warn("Cluster #{}({}) in cluster_helpers does not exist."
|
logger.warn("Cluster #{}({}) in cluster_helpers does not exist."
|
||||||
+ " Please create the cluster or remove this entry", id, cluster);
|
+ " Please create the cluster or remove this entry", id, cluster);
|
||||||
}
|
}
|
||||||
@ -2973,7 +2958,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
merged[3 - i] = (m & 1 << i) != 0;
|
merged[3 - i] = (m & 1 << i) != 0;
|
||||||
}
|
}
|
||||||
cluster.settings.setMerged(merged);
|
cluster.settings.setMerged(merged);
|
||||||
} else if (Settings.DEBUG) {
|
} else {
|
||||||
logger.warn("Cluster #{}({}) in cluster_helpers does not exist."
|
logger.warn("Cluster #{}({}) in cluster_helpers does not exist."
|
||||||
+ " Please create the cluster or remove this entry", id, cluster);
|
+ " Please create the cluster or remove this entry", id, cluster);
|
||||||
}
|
}
|
||||||
@ -3446,7 +3431,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class UniqueStatement {
|
public abstract static class UniqueStatement {
|
||||||
|
|
||||||
public final String method;
|
public final String method;
|
||||||
|
|
||||||
@ -3468,7 +3453,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class UUIDPair {
|
private static class UUIDPair {
|
||||||
|
|
||||||
public final int id;
|
public final int id;
|
||||||
public final UUID uuid;
|
public final UUID uuid;
|
||||||
|
@ -42,7 +42,7 @@ public enum Result {
|
|||||||
ACCEPT(1),
|
ACCEPT(1),
|
||||||
FORCE(2);
|
FORCE(2);
|
||||||
|
|
||||||
private static Map<Integer, Result> map = new HashMap<>();
|
private static final Map<Integer, Result> map = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
for (Result eventResult : Result.values()) {
|
for (Result eventResult : Result.values()) {
|
||||||
@ -50,7 +50,7 @@ public enum Result {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int value;
|
private final int value;
|
||||||
|
|
||||||
Result(int value) {
|
Result(int value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
@ -76,27 +76,16 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
@Nullable QueueCoordinator queue
|
@Nullable QueueCoordinator queue
|
||||||
) {
|
) {
|
||||||
final Optional<ClassicPlotManagerComponent> componentOptional = ClassicPlotManagerComponent.fromString(component);
|
final Optional<ClassicPlotManagerComponent> componentOptional = ClassicPlotManagerComponent.fromString(component);
|
||||||
if (componentOptional.isPresent()) {
|
return componentOptional.map(classicPlotManagerComponent -> switch (classicPlotManagerComponent) {
|
||||||
switch (componentOptional.get()) {
|
case FLOOR -> setFloor(plotId, blocks, actor, queue);
|
||||||
case FLOOR:
|
case WALL -> setWallFilling(plotId, blocks, actor, queue);
|
||||||
return setFloor(plotId, blocks, actor, queue);
|
case AIR -> setAir(plotId, blocks, actor, queue);
|
||||||
case WALL:
|
case MAIN -> setMain(plotId, blocks, actor, queue);
|
||||||
return setWallFilling(plotId, blocks, actor, queue);
|
case MIDDLE -> setMiddle(plotId, blocks, queue);
|
||||||
case AIR:
|
case OUTLINE -> setOutline(plotId, blocks, actor, queue);
|
||||||
return setAir(plotId, blocks, actor, queue);
|
case BORDER -> setWall(plotId, blocks, actor, queue);
|
||||||
case MAIN:
|
case ALL -> setAll(plotId, blocks, actor, queue);
|
||||||
return setMain(plotId, blocks, actor, queue);
|
}).orElse(false);
|
||||||
case MIDDLE:
|
|
||||||
return setMiddle(plotId, blocks, queue);
|
|
||||||
case OUTLINE:
|
|
||||||
return setOutline(plotId, blocks, actor, queue);
|
|
||||||
case BORDER:
|
|
||||||
return setWall(plotId, blocks, actor, queue);
|
|
||||||
case ALL:
|
|
||||||
return setAll(plotId, blocks, actor, queue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -144,11 +144,10 @@ public class HybridUtils {
|
|||||||
|
|
||||||
final PlotArea area = this.plotAreaManager.getPlotArea(world, null);
|
final PlotArea area = this.plotAreaManager.getPlotArea(world, null);
|
||||||
|
|
||||||
if (!(area instanceof HybridPlotWorld)) {
|
if (!(area instanceof HybridPlotWorld hpw)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HybridPlotWorld hpw = (HybridPlotWorld) area;
|
|
||||||
ChunkQueueCoordinator chunk = new ChunkQueueCoordinator(bot, top, false);
|
ChunkQueueCoordinator chunk = new ChunkQueueCoordinator(bot, top, false);
|
||||||
hpw.getGenerator().generateChunk(chunk, hpw);
|
hpw.getGenerator().generateChunk(chunk, hpw);
|
||||||
|
|
||||||
@ -352,7 +351,7 @@ public class HybridUtils {
|
|||||||
}
|
}
|
||||||
CuboidRegion region = zones.poll();
|
CuboidRegion region = zones.poll();
|
||||||
final Runnable task = this;
|
final Runnable task = this;
|
||||||
analyzeRegion(origin.getWorldName(), region, new RunnableVal<PlotAnalysis>() {
|
analyzeRegion(origin.getWorldName(), region, new RunnableVal<>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(PlotAnalysis value) {
|
public void run(PlotAnalysis value) {
|
||||||
analysis.add(value);
|
analysis.add(value);
|
||||||
@ -431,13 +430,11 @@ public class HybridUtils {
|
|||||||
BlockVector2 chunk = iter.next();
|
BlockVector2 chunk = iter.next();
|
||||||
iter.remove();
|
iter.remove();
|
||||||
boolean regenedRoad = regenerateRoad(area, chunk, extend);
|
boolean regenedRoad = regenerateRoad(area, chunk, extend);
|
||||||
if (!regenedRoad && Settings.DEBUG) {
|
if (!regenedRoad) {
|
||||||
logger.info("Failed to regenerate roads");
|
logger.info("Failed to regenerate roads");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Settings.DEBUG) {
|
logger.info("Cancelled road task");
|
||||||
logger.info("Cancelled road task");
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
count.incrementAndGet();
|
count.incrementAndGet();
|
||||||
@ -459,10 +456,8 @@ public class HybridUtils {
|
|||||||
Iterator<BlockVector2> iterator = HybridUtils.regions.iterator();
|
Iterator<BlockVector2> iterator = HybridUtils.regions.iterator();
|
||||||
BlockVector2 loc = iterator.next();
|
BlockVector2 loc = iterator.next();
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
if (Settings.DEBUG) {
|
logger.info("Updating .mcr: {}, {} (approx 1024 chunks)", loc.getX(), loc.getZ());
|
||||||
logger.info("Updating .mcr: {}, {} (approx 1024 chunks)", loc.getX(), loc.getZ());
|
logger.info("- Remaining: {}", HybridUtils.regions.size());
|
||||||
logger.info("- Remaining: {}", HybridUtils.regions.size());
|
|
||||||
}
|
|
||||||
chunks.addAll(getChunks(loc));
|
chunks.addAll(getChunks(loc));
|
||||||
System.gc();
|
System.gc();
|
||||||
}
|
}
|
||||||
@ -475,7 +470,7 @@ public class HybridUtils {
|
|||||||
final BlockVector2 chunk = iterator.next();
|
final BlockVector2 chunk = iterator.next();
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
boolean regenedRoads = regenerateRoad(area, chunk, extend);
|
boolean regenedRoads = regenerateRoad(area, chunk, extend);
|
||||||
if (!regenedRoads && Settings.DEBUG) {
|
if (!regenedRoads) {
|
||||||
logger.info("Failed to regenerate road");
|
logger.info("Failed to regenerate road");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
boolean Eblocked = false;
|
boolean Eblocked = false;
|
||||||
private int count;
|
private int count;
|
||||||
private Extent parent;
|
private Extent parent;
|
||||||
private Map<Long, Integer[]> tileEntityCount = new HashMap<>();
|
private final Map<Long, Integer[]> tileEntityCount = new HashMap<>();
|
||||||
|
|
||||||
public ProcessedWEExtent(
|
public ProcessedWEExtent(
|
||||||
String world,
|
String world,
|
||||||
|
@ -98,7 +98,7 @@ public class WESubscriber {
|
|||||||
if (Permissions.hasPermission(plotPlayer, "plots.worldedit.bypass")) {
|
if (Permissions.hasPermission(plotPlayer, "plots.worldedit.bypass")) {
|
||||||
plotPlayer.sendMessage(
|
plotPlayer.sendMessage(
|
||||||
TranslatableCaption.of("worldedit.worldedit_bypass"),
|
TranslatableCaption.of("worldedit.worldedit_bypass"),
|
||||||
Template.of("command", "/plot wea")
|
Template.of("command", "/plot toggle worldedit")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (this.plotAreaManager.hasPlotArea(world)) {
|
if (this.plotAreaManager.hasPlotArea(world)) {
|
||||||
|
@ -44,8 +44,8 @@ public enum Direction {
|
|||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
private int index;
|
private final int index;
|
||||||
private String name;
|
private final String name;
|
||||||
|
|
||||||
Direction(int index, String name) {
|
Direction(int index, String name) {
|
||||||
|
|
||||||
|
@ -58,7 +58,6 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class ConsolePlayer extends PlotPlayer<Actor> {
|
public class ConsolePlayer extends PlotPlayer<Actor> {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger("P2/" + ConsolePlayer.class.getSimpleName());
|
|
||||||
private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
|
private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
|
||||||
private static ConsolePlayer instance;
|
private static ConsolePlayer instance;
|
||||||
|
|
||||||
|
@ -587,9 +587,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
|
|||||||
if (Settings.Enabled_Components.BAN_DELETER && isBanned()) {
|
if (Settings.Enabled_Components.BAN_DELETER && isBanned()) {
|
||||||
for (Plot owned : getPlots()) {
|
for (Plot owned : getPlots()) {
|
||||||
owned.getPlotModificationManager().deletePlot(null, null);
|
owned.getPlotModificationManager().deletePlot(null, null);
|
||||||
if (Settings.DEBUG) {
|
logger.info("Plot {} was deleted + cleared due to {} getting banned", owned.getId(), getName());
|
||||||
logger.info("Plot {} was deleted + cleared due to {} getting banned", owned.getId(), getName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ExpireManager.IMP != null) {
|
if (ExpireManager.IMP != null) {
|
||||||
@ -636,7 +634,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
|
|||||||
|
|
||||||
public void populatePersistentMetaMap() {
|
public void populatePersistentMetaMap() {
|
||||||
if (Settings.Enabled_Components.PERSISTENT_META) {
|
if (Settings.Enabled_Components.PERSISTENT_META) {
|
||||||
DBFunc.getPersistentMeta(getUUID(), new RunnableVal<Map<String, byte[]>>() {
|
DBFunc.getPersistentMeta(getUUID(), new RunnableVal<>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Map<String, byte[]> value) {
|
public void run(Map<String, byte[]> value) {
|
||||||
try {
|
try {
|
||||||
@ -928,10 +926,9 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) {
|
public boolean equals(final Object obj) {
|
||||||
if (!(obj instanceof PlotPlayer)) {
|
if (!(obj instanceof final PlotPlayer<?> other)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final PlotPlayer<?> other = (PlotPlayer<?>) obj;
|
|
||||||
return this.getUUID().equals(other.getUUID());
|
return this.getUUID().equals(other.getUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,10 +50,10 @@ import java.util.regex.Matcher;
|
|||||||
@SuppressWarnings({"unused", "WeakerAccess"})
|
@SuppressWarnings({"unused", "WeakerAccess"})
|
||||||
public final class BlockBucket implements ConfigurationSerializable {
|
public final class BlockBucket implements ConfigurationSerializable {
|
||||||
|
|
||||||
private static java.util.regex.Pattern regex = java.util.regex.Pattern.compile(
|
private static final java.util.regex.Pattern regex = java.util.regex.Pattern.compile(
|
||||||
"((?<namespace>[A-Za-z_]+):)?(?<block>([A-Za-z_]+(\\[?[\\S\\s]+\\])?))(:(?<chance>[0-9]{1,3}))?");
|
"((?<namespace>[A-Za-z_]+):)?(?<block>([A-Za-z_]+(\\[?[\\S\\s]+\\])?))(:(?<chance>[0-9]{1,3}))?");
|
||||||
private boolean compiled;
|
private boolean compiled;
|
||||||
private StringBuilder input;
|
private final StringBuilder input;
|
||||||
private BlockState single;
|
private BlockState single;
|
||||||
private Pattern pattern;
|
private Pattern pattern;
|
||||||
|
|
||||||
@ -198,10 +198,9 @@ public final class BlockBucket implements ConfigurationSerializable {
|
|||||||
if (o == this) {
|
if (o == this) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(o instanceof BlockBucket)) {
|
if (!(o instanceof final BlockBucket other)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final BlockBucket other = (BlockBucket) o;
|
|
||||||
final Object this$input = this.input;
|
final Object this$input = this.input;
|
||||||
final Object other$input = other.input;
|
final Object other$input = other.input;
|
||||||
return Objects.equals(this$input, other$input);
|
return Objects.equals(this$input, other$input);
|
||||||
@ -247,10 +246,9 @@ public final class BlockBucket implements ConfigurationSerializable {
|
|||||||
if (o == this) {
|
if (o == this) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(o instanceof Range)) {
|
if (!(o instanceof final Range other)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final Range other = (Range) o;
|
|
||||||
if (this.getMin() != other.getMin()) {
|
if (this.getMin() != other.getMin()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1699,7 +1699,7 @@ public class Plot {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
schematicHandler.paste(sch, this, 0, 1, 0, Settings.Schematics.PASTE_ON_TOP, player, new RunnableVal<Boolean>() {
|
schematicHandler.paste(sch, this, 0, 1, 0, Settings.Schematics.PASTE_ON_TOP, player, new RunnableVal<>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Boolean value) {
|
public void run(Boolean value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
|
@ -355,26 +355,10 @@ public abstract class PlotArea {
|
|||||||
this.minBuildHeight = config.getInt("world.min_height");
|
this.minBuildHeight = config.getInt("world.min_height");
|
||||||
|
|
||||||
switch (config.getString("world.gamemode").toLowerCase()) {
|
switch (config.getString("world.gamemode").toLowerCase()) {
|
||||||
case "creative":
|
case "creative", "c", "1" -> this.gameMode = GameModes.CREATIVE;
|
||||||
case "c":
|
case "adventure", "a", "2" -> this.gameMode = GameModes.ADVENTURE;
|
||||||
case "1":
|
case "spectator", "3" -> this.gameMode = GameModes.SPECTATOR;
|
||||||
this.gameMode = GameModes.CREATIVE;
|
default -> this.gameMode = GameModes.SURVIVAL;
|
||||||
break;
|
|
||||||
case "adventure":
|
|
||||||
case "a":
|
|
||||||
case "2":
|
|
||||||
this.gameMode = GameModes.ADVENTURE;
|
|
||||||
break;
|
|
||||||
case "spectator":
|
|
||||||
case "3":
|
|
||||||
this.gameMode = GameModes.SPECTATOR;
|
|
||||||
break;
|
|
||||||
case "survival":
|
|
||||||
case "s":
|
|
||||||
case "0":
|
|
||||||
default:
|
|
||||||
this.gameMode = GameModes.SURVIVAL;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String homeNonMembers = config.getString("home.nonmembers");
|
String homeNonMembers = config.getString("home.nonmembers");
|
||||||
@ -1114,7 +1098,7 @@ public abstract class PlotArea {
|
|||||||
|
|
||||||
public void addCluster(final @Nullable PlotCluster plotCluster) {
|
public void addCluster(final @Nullable PlotCluster plotCluster) {
|
||||||
if (this.clusters == null) {
|
if (this.clusters == null) {
|
||||||
this.clusters = new QuadMap<PlotCluster>(Integer.MAX_VALUE, 0, 0, 62) {
|
this.clusters = new QuadMap<>(Integer.MAX_VALUE, 0, 0, 62) {
|
||||||
@Override
|
@Override
|
||||||
public CuboidRegion getRegion(PlotCluster value) {
|
public CuboidRegion getRegion(PlotCluster value) {
|
||||||
BlockVector2 pos1 = BlockVector2.at(value.getP1().getX(), value.getP1().getY());
|
BlockVector2 pos1 = BlockVector2.at(value.getP1().getX(), value.getP1().getY());
|
||||||
|
@ -181,17 +181,13 @@ public final class PlotId {
|
|||||||
* @return Relative plot ID
|
* @return Relative plot ID
|
||||||
*/
|
*/
|
||||||
public @NonNull PlotId getRelative(final @NonNull Direction direction) {
|
public @NonNull PlotId getRelative(final @NonNull Direction direction) {
|
||||||
switch (direction) {
|
return switch (direction) {
|
||||||
case NORTH:
|
case NORTH -> PlotId.of(this.getX(), this.getY() - 1);
|
||||||
return PlotId.of(this.getX(), this.getY() - 1);
|
case EAST -> PlotId.of(this.getX() + 1, this.getY());
|
||||||
case EAST:
|
case SOUTH -> PlotId.of(this.getX(), this.getY() + 1);
|
||||||
return PlotId.of(this.getX() + 1, this.getY());
|
case WEST -> PlotId.of(this.getX() - 1, this.getY());
|
||||||
case SOUTH:
|
default -> this;
|
||||||
return PlotId.of(this.getX(), this.getY() + 1);
|
};
|
||||||
case WEST:
|
|
||||||
return PlotId.of(this.getX() - 1, this.getY());
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,8 +35,6 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
public class PlotInventory {
|
public class PlotInventory {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger("P2/" + PlotInventory.class.getSimpleName());
|
|
||||||
|
|
||||||
private final PlotPlayer<?> player;
|
private final PlotPlayer<?> player;
|
||||||
private final int lines;
|
private final int lines;
|
||||||
private final PlotItemStack[] items;
|
private final PlotItemStack[] items;
|
||||||
|
@ -106,10 +106,9 @@ public abstract class PlotWorld {
|
|||||||
if (o == this) {
|
if (o == this) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(o instanceof PlotWorld)) {
|
if (!(o instanceof final PlotWorld other)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final PlotWorld other = (PlotWorld) o;
|
|
||||||
if (!other.canEqual(this)) {
|
if (!other.canEqual(this)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -58,11 +58,11 @@ public abstract class CommentInbox {
|
|||||||
*/
|
*/
|
||||||
public boolean canWrite(Plot plot, PlotPlayer<?> player) {
|
public boolean canWrite(Plot plot, PlotPlayer<?> player) {
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return Permissions.hasPermission(player, "plots.inbox.write." + toString(), true);
|
return Permissions.hasPermission(player, "plots.inbox.write." + this, true);
|
||||||
}
|
}
|
||||||
return Permissions.hasPermission(player, "plots.inbox.write." + toString(), true) && (
|
return Permissions.hasPermission(player, "plots.inbox.write." + this, true) && (
|
||||||
plot.isOwner(player.getUUID()) || Permissions
|
plot.isOwner(player.getUUID()) || Permissions
|
||||||
.hasPermission(player, "plots.inbox.write." + toString() + ".other", true));
|
.hasPermission(player, "plots.inbox.write." + this + ".other", true));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,9 +72,9 @@ public abstract class CommentInbox {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings({"BooleanMethodIsAlwaysInverted"})
|
@SuppressWarnings({"BooleanMethodIsAlwaysInverted"})
|
||||||
public boolean canModify(Plot plot, PlotPlayer<?> player) {
|
public boolean canModify(Plot plot, PlotPlayer<?> player) {
|
||||||
if (Permissions.hasPermission(player, "plots.inbox.modify." + toString(), true)) {
|
if (Permissions.hasPermission(player, "plots.inbox.modify." + this, true)) {
|
||||||
return plot.isOwner(player.getUUID()) || Permissions
|
return plot.isOwner(player.getUUID()) || Permissions
|
||||||
.hasPermission(player, "plots.inbox.modify." + toString() + ".other", true);
|
.hasPermission(player, "plots.inbox.modify." + this + ".other", true);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,6 @@ import java.util.concurrent.ConcurrentLinkedDeque;
|
|||||||
public class ExpireManager {
|
public class ExpireManager {
|
||||||
|
|
||||||
public static ExpireManager IMP;
|
public static ExpireManager IMP;
|
||||||
private final Logger logger = LoggerFactory.getLogger("P2/" + ExpireManager.class);
|
|
||||||
private final ConcurrentHashMap<UUID, Long> dates_cache;
|
private final ConcurrentHashMap<UUID, Long> dates_cache;
|
||||||
private final ConcurrentHashMap<UUID, Long> account_age_cache;
|
private final ConcurrentHashMap<UUID, Long> account_age_cache;
|
||||||
private final EventDispatcher eventDispatcher;
|
private final EventDispatcher eventDispatcher;
|
||||||
@ -195,7 +194,7 @@ public class ExpireManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean runAutomatedTask() {
|
public boolean runAutomatedTask() {
|
||||||
return runTask(new RunnableVal3<Plot, Runnable, Boolean>() {
|
return runTask(new RunnableVal3<>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Plot plot, Runnable runnable, Boolean confirm) {
|
public void run(Plot plot, Runnable runnable, Boolean confirm) {
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
@ -346,10 +345,10 @@ public class ExpireManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
final RunnableVal<PlotAnalysis> handleAnalysis =
|
final RunnableVal<PlotAnalysis> handleAnalysis =
|
||||||
new RunnableVal<PlotAnalysis>() {
|
new RunnableVal<>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(final PlotAnalysis changed) {
|
public void run(final PlotAnalysis changed) {
|
||||||
passesComplexity(changed, expired, new RunnableVal<Boolean>() {
|
passesComplexity(changed, expired, new RunnableVal<>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Boolean confirmation) {
|
public void run(Boolean confirmation) {
|
||||||
expiredTask.run(
|
expiredTask.run(
|
||||||
@ -379,7 +378,7 @@ public class ExpireManager {
|
|||||||
|
|
||||||
PlotAnalysis analysis = newPlot.getComplexity(null);
|
PlotAnalysis analysis = newPlot.getComplexity(null);
|
||||||
if (analysis != null) {
|
if (analysis != null) {
|
||||||
passesComplexity(analysis, expired, new RunnableVal<Boolean>() {
|
passesComplexity(analysis, expired, new RunnableVal<>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Boolean value) {
|
public void run(Boolean value) {
|
||||||
doAnalysis.run();
|
doAnalysis.run();
|
||||||
|
@ -97,16 +97,11 @@ public class PlotAnalysis {
|
|||||||
*/
|
*/
|
||||||
public static void calcOptimalModifiers(final Runnable whenDone, final double threshold) {
|
public static void calcOptimalModifiers(final Runnable whenDone, final double threshold) {
|
||||||
if (running) {
|
if (running) {
|
||||||
if (Settings.DEBUG) {
|
logger.info("Calibration task already in progress!");
|
||||||
logger.info("Calibration task already in progress!");
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (threshold <= 0 || threshold >= 1) {
|
if (threshold <= 0 || threshold >= 1) {
|
||||||
if (Settings.DEBUG) {
|
logger.info("Invalid threshold provided! (Cannot be 0 or 100 as then there's no point in calibrating)");
|
||||||
logger.info(
|
|
||||||
"Invalid threshold provided! (Cannot be 0 or 100 as then there's no point in calibrating)");
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
running = true;
|
running = true;
|
||||||
@ -115,9 +110,7 @@ public class PlotAnalysis {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Iterator<Plot> iterator = plots.iterator();
|
Iterator<Plot> iterator = plots.iterator();
|
||||||
if (Settings.DEBUG) {
|
logger.info("- Reducing {} plots to those with sufficient data", plots.size());
|
||||||
logger.info("- Reducing {} plots to those with sufficient data", plots.size());
|
|
||||||
}
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Plot plot = iterator.next();
|
Plot plot = iterator.next();
|
||||||
if (plot.getSettings().getRatings() == null || plot.getSettings().getRatings()
|
if (plot.getSettings().getRatings() == null || plot.getSettings().getRatings()
|
||||||
@ -129,20 +122,14 @@ public class PlotAnalysis {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (plots.size() < 3) {
|
if (plots.size() < 3) {
|
||||||
if (Settings.DEBUG) {
|
logger.info("Calibration cancelled due to insufficient comparison data, please try again later");
|
||||||
logger.info(
|
|
||||||
"Calibration cancelled due to insufficient comparison data, please try again later");
|
|
||||||
}
|
|
||||||
running = false;
|
running = false;
|
||||||
for (Plot plot : plots) {
|
for (Plot plot : plots) {
|
||||||
plot.removeRunning();
|
plot.removeRunning();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
logger.info("- Analyzing plot contents (this may take a while)");
|
||||||
if (Settings.DEBUG) {
|
|
||||||
logger.info("- Analyzing plot contents (this may take a while)");
|
|
||||||
}
|
|
||||||
|
|
||||||
int[] changes = new int[plots.size()];
|
int[] changes = new int[plots.size()];
|
||||||
int[] faces = new int[plots.size()];
|
int[] faces = new int[plots.size()];
|
||||||
@ -160,19 +147,15 @@ public class PlotAnalysis {
|
|||||||
|
|
||||||
final AtomicInteger mi = new AtomicInteger(0);
|
final AtomicInteger mi = new AtomicInteger(0);
|
||||||
|
|
||||||
Thread ratingAnalysis = new Thread(new Runnable() {
|
Thread ratingAnalysis = new Thread(() -> {
|
||||||
@Override
|
for (; mi.intValue() < plots.size(); mi.incrementAndGet()) {
|
||||||
public void run() {
|
int i = mi.intValue();
|
||||||
for (; mi.intValue() < plots.size(); mi.incrementAndGet()) {
|
Plot plot = plots.get(i);
|
||||||
int i = mi.intValue();
|
ratings[i] = (int) (
|
||||||
Plot plot = plots.get(i);
|
(plot.getAverageRating() + plot.getSettings().getRatings().size())
|
||||||
ratings[i] = (int) (
|
* 100);
|
||||||
(plot.getAverageRating() + plot.getSettings().getRatings().size())
|
logger.info(" | {} (rating) {}", plot, ratings[i]);
|
||||||
* 100);
|
|
||||||
if (Settings.DEBUG) {
|
|
||||||
logger.info(" | {} (rating) {}", plot, ratings[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ratingAnalysis.start();
|
ratingAnalysis.start();
|
||||||
@ -183,14 +166,13 @@ public class PlotAnalysis {
|
|||||||
if (queuePlot == null) {
|
if (queuePlot == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (Settings.DEBUG) {
|
logger.info(" | {}", queuePlot);
|
||||||
logger.info(" | {}", queuePlot);
|
|
||||||
}
|
|
||||||
final Object lock = new Object();
|
final Object lock = new Object();
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
analyzePlot(queuePlot, new RunnableVal<PlotAnalysis>() {
|
analyzePlot(queuePlot, new RunnableVal<>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(PlotAnalysis value) {
|
public void run(PlotAnalysis value) {
|
||||||
try {
|
try {
|
||||||
@ -217,9 +199,7 @@ public class PlotAnalysis {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.DEBUG) {
|
logger.info(" - Waiting on plot rating thread: {}%", mi.intValue() * 100 / plots.size());
|
||||||
logger.info(" - Waiting on plot rating thread: {}%", mi.intValue() * 100 / plots.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ratingAnalysis.join();
|
ratingAnalysis.join();
|
||||||
@ -227,15 +207,12 @@ public class PlotAnalysis {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.DEBUG) {
|
logger.info(" - Processing and grouping single plot analysis for bulk processing");
|
||||||
logger.info(
|
|
||||||
" - Processing and grouping single plot analysis for bulk processing");
|
|
||||||
}
|
|
||||||
for (int i = 0; i < plots.size(); i++) {
|
for (int i = 0; i < plots.size(); i++) {
|
||||||
Plot plot = plots.get(i);
|
Plot plot = plots.get(i);
|
||||||
if (Settings.DEBUG) {
|
logger.info(" | {}", plot);
|
||||||
logger.info(" | {}", plot);
|
|
||||||
}
|
|
||||||
PlotAnalysis analysis = plot.getComplexity(null);
|
PlotAnalysis analysis = plot.getComplexity(null);
|
||||||
|
|
||||||
changes[i] = analysis.changes;
|
changes[i] = analysis.changes;
|
||||||
@ -251,22 +228,16 @@ public class PlotAnalysis {
|
|||||||
variety_sd[i] = analysis.variety_sd;
|
variety_sd[i] = analysis.variety_sd;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.DEBUG) {
|
logger.info(" - Calculating rankings");
|
||||||
logger.info(" - Calculating rankings");
|
|
||||||
}
|
|
||||||
|
|
||||||
int[] rankRatings = rank(ratings);
|
int[] rankRatings = rank(ratings);
|
||||||
int n = rankRatings.length;
|
int n = rankRatings.length;
|
||||||
|
|
||||||
int optimalIndex = (int) Math.round((1 - threshold) * (n - 1));
|
int optimalIndex = (int) Math.round((1 - threshold) * (n - 1));
|
||||||
|
|
||||||
if (Settings.DEBUG) {
|
logger.info(" - Calculating rank correlation: ");
|
||||||
logger.info(" - Calculating rank correlation: ");
|
logger.info(" - The analyzed plots which were processed and put into bulk data will be compared and correlated to the plot ranking");
|
||||||
logger.info(
|
logger.info(" - The calculated correlation constant will then be used to calibrate the threshold for auto plot clearing");
|
||||||
" - The analyzed plots which were processed and put into bulk data will be compared and correlated to the plot ranking");
|
|
||||||
logger.info(
|
|
||||||
" - The calculated correlation constant will then be used to calibrate the threshold for auto plot clearing");
|
|
||||||
}
|
|
||||||
|
|
||||||
Settings.Auto_Clear settings = new Settings.Auto_Clear();
|
Settings.Auto_Clear settings = new Settings.Auto_Clear();
|
||||||
|
|
||||||
@ -279,9 +250,7 @@ public class PlotAnalysis {
|
|||||||
0 :
|
0 :
|
||||||
(int) (factorChanges * 1000 / MathMan.getMean(changes));
|
(int) (factorChanges * 1000 / MathMan.getMean(changes));
|
||||||
|
|
||||||
if (Settings.DEBUG) {
|
logger.info(" - | changes {}", factorChanges);
|
||||||
logger.info(" - | changes {}", factorChanges);
|
|
||||||
}
|
|
||||||
|
|
||||||
int[] rankFaces = rank(faces);
|
int[] rankFaces = rank(faces);
|
||||||
int[] sdFaces = getSD(rankFaces, rankRatings);
|
int[] sdFaces = getSD(rankFaces, rankRatings);
|
||||||
@ -291,9 +260,7 @@ public class PlotAnalysis {
|
|||||||
settings.CALIBRATION.FACES =
|
settings.CALIBRATION.FACES =
|
||||||
factorFaces == 1 ? 0 : (int) (factorFaces * 1000 / MathMan.getMean(faces));
|
factorFaces == 1 ? 0 : (int) (factorFaces * 1000 / MathMan.getMean(faces));
|
||||||
|
|
||||||
if (Settings.DEBUG) {
|
logger.info(" - | faces {}", factorFaces);
|
||||||
logger.info(" - | faces {}", factorFaces);
|
|
||||||
}
|
|
||||||
|
|
||||||
int[] rankData = rank(data);
|
int[] rankData = rank(data);
|
||||||
int[] sdData = getSD(rankData, rankRatings);
|
int[] sdData = getSD(rankData, rankRatings);
|
||||||
@ -303,9 +270,7 @@ public class PlotAnalysis {
|
|||||||
settings.CALIBRATION.DATA =
|
settings.CALIBRATION.DATA =
|
||||||
factor_data == 1 ? 0 : (int) (factor_data * 1000 / MathMan.getMean(data));
|
factor_data == 1 ? 0 : (int) (factor_data * 1000 / MathMan.getMean(data));
|
||||||
|
|
||||||
if (Settings.DEBUG) {
|
logger.info(" - | data {}", factor_data);
|
||||||
logger.info(" - | data {}", factor_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
int[] rank_air = rank(air);
|
int[] rank_air = rank(air);
|
||||||
int[] sd_air = getSD(rank_air, rankRatings);
|
int[] sd_air = getSD(rank_air, rankRatings);
|
||||||
@ -315,9 +280,8 @@ public class PlotAnalysis {
|
|||||||
settings.CALIBRATION.AIR =
|
settings.CALIBRATION.AIR =
|
||||||
factor_air == 1 ? 0 : (int) (factor_air * 1000 / MathMan.getMean(air));
|
factor_air == 1 ? 0 : (int) (factor_air * 1000 / MathMan.getMean(air));
|
||||||
|
|
||||||
if (Settings.DEBUG) {
|
logger.info("- | air {}", factor_air);
|
||||||
logger.info("- | air {}", factor_air);
|
|
||||||
}
|
|
||||||
|
|
||||||
int[] rank_variety = rank(variety);
|
int[] rank_variety = rank(variety);
|
||||||
int[] sd_variety = getSD(rank_variety, rankRatings);
|
int[] sd_variety = getSD(rank_variety, rankRatings);
|
||||||
@ -328,9 +292,7 @@ public class PlotAnalysis {
|
|||||||
0 :
|
0 :
|
||||||
(int) (factor_variety * 1000 / MathMan.getMean(variety));
|
(int) (factor_variety * 1000 / MathMan.getMean(variety));
|
||||||
|
|
||||||
if (Settings.DEBUG) {
|
logger.info("- | variety {}", factor_variety);
|
||||||
logger.info("- | variety {}", factor_variety);
|
|
||||||
}
|
|
||||||
|
|
||||||
int[] rank_changes_sd = rank(changes_sd);
|
int[] rank_changes_sd = rank(changes_sd);
|
||||||
int[] sd_changes_sd = getSD(rank_changes_sd, rankRatings);
|
int[] sd_changes_sd = getSD(rank_changes_sd, rankRatings);
|
||||||
@ -341,9 +303,7 @@ public class PlotAnalysis {
|
|||||||
0 :
|
0 :
|
||||||
(int) (factor_changes_sd * 1000 / MathMan.getMean(changes_sd));
|
(int) (factor_changes_sd * 1000 / MathMan.getMean(changes_sd));
|
||||||
|
|
||||||
if (Settings.DEBUG) {
|
logger.info(" - | changed_sd {}", factor_changes_sd);
|
||||||
logger.info(" - | changed_sd {}", factor_changes_sd);
|
|
||||||
}
|
|
||||||
|
|
||||||
int[] rank_faces_sd = rank(faces_sd);
|
int[] rank_faces_sd = rank(faces_sd);
|
||||||
int[] sd_faces_sd = getSD(rank_faces_sd, rankRatings);
|
int[] sd_faces_sd = getSD(rank_faces_sd, rankRatings);
|
||||||
@ -354,9 +314,7 @@ public class PlotAnalysis {
|
|||||||
0 :
|
0 :
|
||||||
(int) (factor_faces_sd * 1000 / MathMan.getMean(faces_sd));
|
(int) (factor_faces_sd * 1000 / MathMan.getMean(faces_sd));
|
||||||
|
|
||||||
if (Settings.DEBUG) {
|
logger.info(" - | faced_sd {}", factor_faces_sd);
|
||||||
logger.info(" - | faced_sd {}", factor_faces_sd);
|
|
||||||
}
|
|
||||||
|
|
||||||
int[] rank_data_sd = rank(data_sd);
|
int[] rank_data_sd = rank(data_sd);
|
||||||
int[] sd_data_sd = getSD(rank_data_sd, rankRatings);
|
int[] sd_data_sd = getSD(rank_data_sd, rankRatings);
|
||||||
@ -367,9 +325,7 @@ public class PlotAnalysis {
|
|||||||
0 :
|
0 :
|
||||||
(int) (factor_data_sd * 1000 / MathMan.getMean(data_sd));
|
(int) (factor_data_sd * 1000 / MathMan.getMean(data_sd));
|
||||||
|
|
||||||
if (Settings.DEBUG) {
|
logger.info(" - | data_sd {}", factor_data_sd);
|
||||||
logger.info(" - | data_sd {}", factor_data_sd);
|
|
||||||
}
|
|
||||||
|
|
||||||
int[] rank_air_sd = rank(air_sd);
|
int[] rank_air_sd = rank(air_sd);
|
||||||
int[] sd_air_sd = getSD(rank_air_sd, rankRatings);
|
int[] sd_air_sd = getSD(rank_air_sd, rankRatings);
|
||||||
@ -379,9 +335,7 @@ public class PlotAnalysis {
|
|||||||
settings.CALIBRATION.AIR_SD =
|
settings.CALIBRATION.AIR_SD =
|
||||||
factor_air_sd == 1 ? 0 : (int) (factor_air_sd * 1000 / MathMan.getMean(air_sd));
|
factor_air_sd == 1 ? 0 : (int) (factor_air_sd * 1000 / MathMan.getMean(air_sd));
|
||||||
|
|
||||||
if (Settings.DEBUG) {
|
logger.info(" - | air_sd {}", factor_air_sd);
|
||||||
logger.info(" - | air_sd {}", factor_air_sd);
|
|
||||||
}
|
|
||||||
|
|
||||||
int[] rank_variety_sd = rank(variety_sd);
|
int[] rank_variety_sd = rank(variety_sd);
|
||||||
int[] sd_variety_sd = getSD(rank_variety_sd, rankRatings);
|
int[] sd_variety_sd = getSD(rank_variety_sd, rankRatings);
|
||||||
@ -392,15 +346,11 @@ public class PlotAnalysis {
|
|||||||
0 :
|
0 :
|
||||||
(int) (factor_variety_sd * 1000 / MathMan.getMean(variety_sd));
|
(int) (factor_variety_sd * 1000 / MathMan.getMean(variety_sd));
|
||||||
|
|
||||||
if (Settings.DEBUG) {
|
logger.info(" - | variety_sd {}", factor_variety_sd);
|
||||||
logger.info(" - | variety_sd {}", factor_variety_sd);
|
|
||||||
}
|
|
||||||
|
|
||||||
int[] complexity = new int[n];
|
int[] complexity = new int[n];
|
||||||
|
|
||||||
if (Settings.DEBUG) {
|
logger.info("Calculating threshold");
|
||||||
logger.info(" Calculating threshold");
|
|
||||||
}
|
|
||||||
|
|
||||||
int max = 0;
|
int max = 0;
|
||||||
int min = 0;
|
int min = 0;
|
||||||
@ -430,11 +380,9 @@ public class PlotAnalysis {
|
|||||||
logln("Correlation: ");
|
logln("Correlation: ");
|
||||||
logln(getCC(n, sum(square(getSD(rankComplexity, rankRatings)))));
|
logln(getCC(n, sum(square(getSD(rankComplexity, rankRatings)))));
|
||||||
if (optimalComplexity == Integer.MAX_VALUE) {
|
if (optimalComplexity == Integer.MAX_VALUE) {
|
||||||
if (Settings.DEBUG) {
|
logger.info("Insufficient data to determine correlation! {} | {}",
|
||||||
logger.info("Insufficient data to determine correlation! {} | {}",
|
|
||||||
optimalIndex, n
|
optimalIndex, n
|
||||||
);
|
);
|
||||||
}
|
|
||||||
running = false;
|
running = false;
|
||||||
for (Plot plot : plots) {
|
for (Plot plot : plots) {
|
||||||
plot.removeRunning();
|
plot.removeRunning();
|
||||||
@ -444,7 +392,6 @@ public class PlotAnalysis {
|
|||||||
} else { // Use the fast radix sort algorithm
|
} else { // Use the fast radix sort algorithm
|
||||||
int[] sorted = complexity.clone();
|
int[] sorted = complexity.clone();
|
||||||
sort(sorted);
|
sort(sorted);
|
||||||
optimalComplexity = sorted[optimalIndex];
|
|
||||||
logln("Complexity: ");
|
logln("Complexity: ");
|
||||||
logln(complexity);
|
logln(complexity);
|
||||||
logln("Ratings: ");
|
logln("Ratings: ");
|
||||||
@ -452,43 +399,37 @@ public class PlotAnalysis {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save calibration
|
// Save calibration
|
||||||
if (Settings.DEBUG) {
|
logger.info(" Saving calibration");
|
||||||
logger.info(" Saving calibration");
|
|
||||||
}
|
|
||||||
Settings.AUTO_CLEAR.put("auto-calibrated", settings);
|
Settings.AUTO_CLEAR.put("auto-calibrated", settings);
|
||||||
Settings.save(PlotSquared.get().getWorldsFile());
|
Settings.save(PlotSquared.get().getWorldsFile());
|
||||||
running = false;
|
running = false;
|
||||||
for (Plot plot : plots) {
|
for (Plot plot : plots) {
|
||||||
plot.removeRunning();
|
plot.removeRunning();
|
||||||
}
|
}
|
||||||
if (Settings.DEBUG) {
|
logger.info(" Done!");
|
||||||
logger.info(" Done!");
|
|
||||||
}
|
|
||||||
whenDone.run();
|
whenDone.run();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void logln(Object obj) {
|
public static void logln(Object obj) {
|
||||||
if (Settings.DEBUG) {
|
logger.info("" + log(obj));
|
||||||
logger.info("" + log(obj));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String log(Object obj) {
|
public static String log(Object obj) {
|
||||||
String result = "";
|
StringBuilder result = new StringBuilder();
|
||||||
if (obj.getClass().isArray()) {
|
if (obj.getClass().isArray()) {
|
||||||
String prefix = "";
|
String prefix = "";
|
||||||
|
|
||||||
for (int i = 0; i < Array.getLength(obj); i++) {
|
for (int i = 0; i < Array.getLength(obj); i++) {
|
||||||
result += prefix + log(Array.get(obj, i));
|
result.append(prefix).append(log(Array.get(obj, i)));
|
||||||
prefix = ",";
|
prefix = ",";
|
||||||
}
|
}
|
||||||
return "( " + result + " )";
|
return "( " + result + " )";
|
||||||
} else if (obj instanceof List<?>) {
|
} else if (obj instanceof List<?>) {
|
||||||
String prefix = "";
|
String prefix = "";
|
||||||
for (Object element : (List<?>) obj) {
|
for (Object element : (List<?>) obj) {
|
||||||
result += prefix + log(element);
|
result.append(prefix).append(log(element));
|
||||||
prefix = ",";
|
prefix = ",";
|
||||||
}
|
}
|
||||||
return "[ " + result + " ]";
|
return "[ " + result + " ]";
|
||||||
|
@ -340,10 +340,9 @@ public class FlagContainer {
|
|||||||
if (o == this) {
|
if (o == this) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(o instanceof FlagContainer)) {
|
if (!(o instanceof final FlagContainer other)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final FlagContainer other = (FlagContainer) o;
|
|
||||||
if (!other.canEqual(this)) {
|
if (!other.canEqual(this)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -193,11 +193,10 @@ public abstract class PlotFlag<T, F extends PlotFlag<T, F>> {
|
|||||||
if (o == this) {
|
if (o == this) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(o instanceof PlotFlag)) {
|
if (!(o instanceof final PlotFlag<?, ?> other)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final PlotFlag<?, ?> other = (PlotFlag<?, ?>) o;
|
if (!other.canEqual(this)) {
|
||||||
if (!other.canEqual((Object) this)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final Object this$value = this.getValue();
|
final Object this$value = this.getValue();
|
||||||
|
@ -48,18 +48,11 @@ public class FlyFlag extends PlotFlag<FlyFlag.FlyStatus, FlyFlag> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FlyFlag parse(final @NonNull String input) {
|
public FlyFlag parse(final @NonNull String input) {
|
||||||
switch (input.toLowerCase()) {
|
return switch (input.toLowerCase()) {
|
||||||
case "true":
|
case "true", "enabled", "allow" -> FLIGHT_FLAG_ENABLED;
|
||||||
case "enabled":
|
case "false", "disabled", "disallow" -> FLIGHT_FLAG_DISABLED;
|
||||||
case "allow":
|
default -> FLIGHT_FLAG_DEFAULT;
|
||||||
return FLIGHT_FLAG_ENABLED;
|
};
|
||||||
case "false":
|
|
||||||
case "disabled":
|
|
||||||
case "disallow":
|
|
||||||
return FLIGHT_FLAG_DISABLED;
|
|
||||||
default:
|
|
||||||
return FLIGHT_FLAG_DEFAULT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -65,26 +65,13 @@ public class GamemodeFlag extends PlotFlag<GameMode, GamemodeFlag> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GamemodeFlag parse(@NonNull String input) throws FlagParseException {
|
public GamemodeFlag parse(@NonNull String input) throws FlagParseException {
|
||||||
switch (input) {
|
return switch (input) {
|
||||||
case "creative":
|
case "creative", "c", "1" -> flagOf(GameModes.CREATIVE);
|
||||||
case "c":
|
case "adventure", "a", "2" -> flagOf(GameModes.ADVENTURE);
|
||||||
case "1":
|
case "spectator", "sp", "3" -> flagOf(GameModes.SPECTATOR);
|
||||||
return flagOf(GameModes.CREATIVE);
|
case "survival", "s", "0" -> flagOf(GameModes.SURVIVAL);
|
||||||
case "adventure":
|
default -> flagOf(DEFAULT);
|
||||||
case "a":
|
};
|
||||||
case "2":
|
|
||||||
return flagOf(GameModes.ADVENTURE);
|
|
||||||
case "spectator":
|
|
||||||
case "sp":
|
|
||||||
case "3":
|
|
||||||
return flagOf(GameModes.SPECTATOR);
|
|
||||||
case "survival":
|
|
||||||
case "s":
|
|
||||||
case "0":
|
|
||||||
return flagOf(GameModes.SURVIVAL);
|
|
||||||
default:
|
|
||||||
return flagOf(DEFAULT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -104,18 +91,13 @@ public class GamemodeFlag extends PlotFlag<GameMode, GamemodeFlag> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected GamemodeFlag flagOf(@NonNull GameMode value) {
|
protected GamemodeFlag flagOf(@NonNull GameMode value) {
|
||||||
switch (value.getId()) {
|
return switch (value.getId()) {
|
||||||
case "creative":
|
case "creative" -> GAMEMODE_FLAG_CREATIVE;
|
||||||
return GAMEMODE_FLAG_CREATIVE;
|
case "adventure" -> GAMEMODE_FLAG_ADVENTURE;
|
||||||
case "adventure":
|
case "spectator" -> GAMEMODE_FLAG_SPECTATOR;
|
||||||
return GAMEMODE_FLAG_ADVENTURE;
|
case "survival" -> GAMEMODE_FLAG_SURVIVAL;
|
||||||
case "spectator":
|
default -> GAMEMODE_FLAG_DEFAULT;
|
||||||
return GAMEMODE_FLAG_SPECTATOR;
|
};
|
||||||
case "survival":
|
|
||||||
return GAMEMODE_FLAG_SURVIVAL;
|
|
||||||
default:
|
|
||||||
return GAMEMODE_FLAG_DEFAULT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -60,26 +60,13 @@ public class GuestGamemodeFlag extends PlotFlag<GameMode, GuestGamemodeFlag> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GuestGamemodeFlag parse(@NonNull String input) throws FlagParseException {
|
public GuestGamemodeFlag parse(@NonNull String input) throws FlagParseException {
|
||||||
switch (input) {
|
return switch (input) {
|
||||||
case "creative":
|
case "creative", "c", "1" -> flagOf(GameModes.CREATIVE);
|
||||||
case "c":
|
case "adventure", "a", "2" -> flagOf(GameModes.ADVENTURE);
|
||||||
case "1":
|
case "spectator", "sp", "3" -> flagOf(GameModes.SPECTATOR);
|
||||||
return flagOf(GameModes.CREATIVE);
|
case "survival", "s", "0" -> flagOf(GameModes.SURVIVAL);
|
||||||
case "adventure":
|
default -> flagOf(GamemodeFlag.DEFAULT);
|
||||||
case "a":
|
};
|
||||||
case "2":
|
|
||||||
return flagOf(GameModes.ADVENTURE);
|
|
||||||
case "spectator":
|
|
||||||
case "sp":
|
|
||||||
case "3":
|
|
||||||
return flagOf(GameModes.SPECTATOR);
|
|
||||||
case "survival":
|
|
||||||
case "s":
|
|
||||||
case "0":
|
|
||||||
return flagOf(GameModes.SURVIVAL);
|
|
||||||
default:
|
|
||||||
return flagOf(GamemodeFlag.DEFAULT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -99,18 +86,13 @@ public class GuestGamemodeFlag extends PlotFlag<GameMode, GuestGamemodeFlag> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected GuestGamemodeFlag flagOf(@NonNull GameMode value) {
|
protected GuestGamemodeFlag flagOf(@NonNull GameMode value) {
|
||||||
switch (value.getId()) {
|
return switch (value.getId()) {
|
||||||
case "creative":
|
case "creative" -> GUEST_GAMEMODE_FLAG_CREATIVE;
|
||||||
return GUEST_GAMEMODE_FLAG_CREATIVE;
|
case "adventure" -> GUEST_GAMEMODE_FLAG_ADVENTURE;
|
||||||
case "adventure":
|
case "spectator" -> GUEST_GAMEMODE_FLAG_SPECTATOR;
|
||||||
return GUEST_GAMEMODE_FLAG_ADVENTURE;
|
case "survival" -> GUEST_GAMEMODE_FLAG_SURVIVAL;
|
||||||
case "spectator":
|
default -> GUEST_GAMEMODE_FLAG_DEFAULT;
|
||||||
return GUEST_GAMEMODE_FLAG_SPECTATOR;
|
};
|
||||||
case "survival":
|
|
||||||
return GUEST_GAMEMODE_FLAG_SURVIVAL;
|
|
||||||
default:
|
|
||||||
return GUEST_GAMEMODE_FLAG_DEFAULT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -55,14 +55,11 @@ public class KeepFlag extends PlotFlag<Object, KeepFlag> {
|
|||||||
return flagOf(value);
|
return flagOf(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (input.toLowerCase()) {
|
return switch (input.toLowerCase()) {
|
||||||
case "true":
|
case "true" -> flagOf(true);
|
||||||
return flagOf(true);
|
case "false" -> flagOf(false);
|
||||||
case "false":
|
default -> flagOf(TimeUtil.timeToSec(input) * 1000 + System.currentTimeMillis());
|
||||||
return flagOf(false);
|
};
|
||||||
default:
|
|
||||||
return flagOf(TimeUtil.timeToSec(input) * 1000 + System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,18 +49,11 @@ public class LiquidFlowFlag extends PlotFlag<LiquidFlowFlag.FlowStatus, LiquidFl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LiquidFlowFlag parse(final @NonNull String input) {
|
public LiquidFlowFlag parse(final @NonNull String input) {
|
||||||
switch (input.toLowerCase()) {
|
return switch (input.toLowerCase()) {
|
||||||
case "true":
|
case "true", "enabled", "allow" -> LIQUID_FLOW_ENABLED;
|
||||||
case "enabled":
|
case "false", "disabled", "disallow" -> LIQUID_FLOW_DISABLED;
|
||||||
case "allow":
|
default -> LIQUID_FLOW_DEFAULT;
|
||||||
return LIQUID_FLOW_ENABLED;
|
};
|
||||||
case "false":
|
|
||||||
case "disabled":
|
|
||||||
case "disallow":
|
|
||||||
return LIQUID_FLOW_DISABLED;
|
|
||||||
default:
|
|
||||||
return LIQUID_FLOW_DEFAULT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -83,14 +76,11 @@ public class LiquidFlowFlag extends PlotFlag<LiquidFlowFlag.FlowStatus, LiquidFl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected LiquidFlowFlag flagOf(final @NonNull FlowStatus value) {
|
protected LiquidFlowFlag flagOf(final @NonNull FlowStatus value) {
|
||||||
switch (value) {
|
return switch (value) {
|
||||||
case ENABLED:
|
case ENABLED -> LIQUID_FLOW_ENABLED;
|
||||||
return LIQUID_FLOW_ENABLED;
|
case DISABLED -> LIQUID_FLOW_DISABLED;
|
||||||
case DISABLED:
|
default -> LIQUID_FLOW_DEFAULT;
|
||||||
return LIQUID_FLOW_DISABLED;
|
};
|
||||||
default:
|
|
||||||
return LIQUID_FLOW_DEFAULT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,20 +54,11 @@ public class WeatherFlag extends PlotFlag<PlotWeather, WeatherFlag> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WeatherFlag parse(@NonNull String input) {
|
public WeatherFlag parse(@NonNull String input) {
|
||||||
switch (input.toLowerCase()) {
|
return switch (input.toLowerCase()) {
|
||||||
case "rain":
|
case "rain" -> flagOf(PlotWeather.RAIN);
|
||||||
case "storm":
|
case "clear" -> flagOf(PlotWeather.CLEAR);
|
||||||
case "on":
|
default -> flagOf(PlotWeather.RESET);
|
||||||
case "lightning":
|
};
|
||||||
case "thunder":
|
|
||||||
return flagOf(PlotWeather.RAIN);
|
|
||||||
case "clear":
|
|
||||||
case "off":
|
|
||||||
case "sun":
|
|
||||||
return flagOf(PlotWeather.CLEAR);
|
|
||||||
default:
|
|
||||||
return flagOf(PlotWeather.RESET);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -82,25 +73,22 @@ public class WeatherFlag extends PlotFlag<PlotWeather, WeatherFlag> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getExample() {
|
public String getExample() {
|
||||||
return "storm";
|
return "rain";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected WeatherFlag flagOf(@NonNull PlotWeather value) {
|
protected WeatherFlag flagOf(@NonNull PlotWeather value) {
|
||||||
switch (value) {
|
return switch (value) {
|
||||||
case RAIN:
|
case RAIN -> PLOT_WEATHER_FLAG_RAIN;
|
||||||
return PLOT_WEATHER_FLAG_RAIN;
|
case CLEAR -> PLOT_WEATHER_FLAG_CLEAR;
|
||||||
case CLEAR:
|
default -> PLOT_WEATHER_FLAG_OFF;
|
||||||
return PLOT_WEATHER_FLAG_CLEAR;
|
};
|
||||||
default:
|
|
||||||
return PLOT_WEATHER_FLAG_OFF;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> getTabCompletions() {
|
public Collection<String> getTabCompletions() {
|
||||||
return Arrays
|
return Arrays
|
||||||
.asList("rain", "storm", "on", "lightning", "thunder", "clear", "off", "sun", "reset");
|
.asList("clear", "rain");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ import java.util.function.Consumer;
|
|||||||
|
|
||||||
public class SinglePlot extends Plot {
|
public class SinglePlot extends Plot {
|
||||||
|
|
||||||
private Set<CuboidRegion> regions = Collections.singleton(
|
private final Set<CuboidRegion> regions = Collections.singleton(
|
||||||
new CuboidRegion(
|
new CuboidRegion(
|
||||||
BlockVector3.at(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE),
|
BlockVector3.at(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE),
|
||||||
BlockVector3.at(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE)
|
BlockVector3.at(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE)
|
||||||
|
@ -278,9 +278,7 @@ public enum CommonSetupSteps implements SetupStep {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isValidWorldName(String s) {
|
private static boolean isValidWorldName(String s) {
|
||||||
return s.chars().allMatch((i) -> {
|
return s.chars().allMatch((i) -> i == 95 || i == 45 || i >= 97 && i <= 122 || i >= 65 && i <= 90 || i >= 48 && i <= 57 || i == 46);
|
||||||
return i == 95 || i == 45 || i >= 97 && i <= 122 || i >= 65 && i <= 90 || i >= 48 && i <= 57 || i == 46;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -135,7 +135,7 @@ public final class BlockUtil {
|
|||||||
* Deserialize a serialized {@link BlockState}
|
* Deserialize a serialized {@link BlockState}
|
||||||
*
|
*
|
||||||
* @param map Serialized block state
|
* @param map Serialized block state
|
||||||
* @return Deserialized block state, or {@code null} if the map is
|
* @return Deserialized block state, or {@code null} if the map is
|
||||||
* not a properly serialized block state
|
* not a properly serialized block state
|
||||||
*/
|
*/
|
||||||
public static @Nullable BlockState deserialize(final @NonNull Map<String, Object> map) {
|
public static @Nullable BlockState deserialize(final @NonNull Map<String, Object> map) {
|
||||||
|
@ -25,9 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.util;
|
package com.plotsquared.core.util;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* plot functions
|
* plot functions
|
||||||
*
|
*
|
||||||
@ -36,9 +33,6 @@ import org.slf4j.LoggerFactory;
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public class MainUtil {
|
public class MainUtil {
|
||||||
|
|
||||||
private static final Logger logger =
|
|
||||||
LoggerFactory.getLogger("P2/" + MainUtil.class.getSimpleName());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache of mapping x,y,z coordinates to the chunk array<br>
|
* Cache of mapping x,y,z coordinates to the chunk array<br>
|
||||||
* - Used for efficient world generation<br>
|
* - Used for efficient world generation<br>
|
||||||
|
@ -355,7 +355,7 @@ public abstract class WorldUtil {
|
|||||||
*
|
*
|
||||||
* @param block1 First block
|
* @param block1 First block
|
||||||
* @param block2 Second block
|
* @param block2 Second block
|
||||||
* @return {@code true} if the blocks have the same type, {@code false} if not
|
* @return {@code true} if the blocks have the same type, {@code false} if not
|
||||||
*/
|
*/
|
||||||
public abstract boolean isBlockSame(@NonNull BlockState block1, @NonNull BlockState block2);
|
public abstract boolean isBlockSame(@NonNull BlockState block1, @NonNull BlockState block2);
|
||||||
|
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* _____ _ _ _____ _
|
|
||||||
* | __ \| | | | / ____| | |
|
|
||||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
|
||||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
|
||||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
|
||||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
|
||||||
* | |
|
|
||||||
* |_|
|
|
||||||
* PlotSquared plot management system for Minecraft
|
|
||||||
* Copyright (C) 2021 IntellectualSites
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package com.plotsquared.core.util.net;
|
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.Settings;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
public class HttpUtil {
|
|
||||||
|
|
||||||
public static String readUrl(String urlString) {
|
|
||||||
try (BufferedReader reader = new BufferedReader(
|
|
||||||
new InputStreamReader(new URL(urlString).openStream()))) {
|
|
||||||
StringBuilder buffer = new StringBuilder();
|
|
||||||
int read;
|
|
||||||
char[] chars = new char[1024];
|
|
||||||
while ((read = reader.read(chars)) != -1) {
|
|
||||||
buffer.append(chars, 0, read);
|
|
||||||
}
|
|
||||||
return buffer.toString();
|
|
||||||
} catch (IOException e) {
|
|
||||||
if (Settings.DEBUG) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -55,10 +55,9 @@ public class UUIDMapping {
|
|||||||
if (o == this) {
|
if (o == this) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(o instanceof UUIDMapping)) {
|
if (!(o instanceof final UUIDMapping other)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final UUIDMapping other = (UUIDMapping) o;
|
|
||||||
if (!other.canEqual(this)) {
|
if (!other.canEqual(this)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ public class UUIDPipeline {
|
|||||||
} catch (TimeoutException ignored) {
|
} catch (TimeoutException ignored) {
|
||||||
// This is completely valid, we just don't care anymore
|
// This is completely valid, we just don't care anymore
|
||||||
if (Settings.DEBUG) {
|
if (Settings.DEBUG) {
|
||||||
logger.warn("(UUID) Request for {} timed out", username);
|
logger.warn("(UUID) Request for {} timed out. Rate limit.", username);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -201,7 +201,7 @@ public class UUIDPipeline {
|
|||||||
} catch (TimeoutException ignored) {
|
} catch (TimeoutException ignored) {
|
||||||
// This is completely valid, we just don't care anymore
|
// This is completely valid, we just don't care anymore
|
||||||
if (Settings.DEBUG) {
|
if (Settings.DEBUG) {
|
||||||
logger.warn("(UUID) Request for {} timed out", uuid);
|
logger.warn("(UUID) Request for {} timed out. Rate limit.", uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -392,7 +392,6 @@
|
|||||||
"members.not_added_trusted": "<prefix><red>You must be added or trusted to the plot to run that command.</red>",
|
"members.not_added_trusted": "<prefix><red>You must be added or trusted to the plot to run that command.</red>",
|
||||||
"owner.set_owner": "<prefix><dark_aqua>You successfully set the plot owner.</dark_aqua>",
|
"owner.set_owner": "<prefix><dark_aqua>You successfully set the plot owner.</dark_aqua>",
|
||||||
"owner.set_owner_cancelled": "<prefix><red>The set owner action was cancelled.</red>",
|
"owner.set_owner_cancelled": "<prefix><red>The set owner action was cancelled.</red>",
|
||||||
"owner.set_owner_missing_player": "<prefix><red>You need to specify a new owner.</red>",
|
|
||||||
"owner.now_owner": "<prefix><dark_aqua>You are now the plot owner of plot <plot>.</dark_aqua>",
|
"owner.now_owner": "<prefix><dark_aqua>You are now the plot owner of plot <plot>.</dark_aqua>",
|
||||||
"signs.owner_sign_line_1": "<gold>ID: </gold><gray><id></gray>",
|
"signs.owner_sign_line_1": "<gold>ID: </gold><gray><id></gray>",
|
||||||
"signs.owner_sign_line_2": "<gold>Owner:",
|
"signs.owner_sign_line_2": "<gold>Owner:",
|
||||||
|
Loading…
Reference in New Issue
Block a user