mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Merge branch 'v6' into feature/v6/platform
# Conflicts: # Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java # Core/src/main/java/com/plotsquared/core/PlotSquared.java # Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java # Core/src/main/java/com/plotsquared/core/location/Location.java
This commit is contained in:
@ -148,12 +148,10 @@ public class PlotSquared {
|
||||
public File styleFile;
|
||||
public File configFile;
|
||||
public File worldsFile;
|
||||
public File commandsFile;
|
||||
public File translationFile;
|
||||
public YamlConfiguration style;
|
||||
public YamlConfiguration worlds;
|
||||
public YamlConfiguration storage;
|
||||
public YamlConfiguration commands;
|
||||
// Temporary hold the plots/clusters before the worlds load
|
||||
public HashMap<String, Set<PlotCluster>> clusters_tmp;
|
||||
public HashMap<String, HashMap<PlotId, Plot>> plots_tmp;
|
||||
@ -261,6 +259,7 @@ public class PlotSquared {
|
||||
if (Settings.Enabled_Components.CHUNK_PROCESSOR) {
|
||||
this.platform.registerChunkProcessor();
|
||||
}
|
||||
startExpiryTasks();
|
||||
// create Hybrid utility class
|
||||
HybridUtils.manager = this.platform.initHybridUtils();
|
||||
// Inventory utility class
|
||||
@ -1578,6 +1577,7 @@ public class PlotSquared {
|
||||
}
|
||||
this.style = YamlConfiguration.loadConfiguration(this.styleFile);
|
||||
setupStyle();
|
||||
this.style.save(this.styleFile);
|
||||
} catch (IOException err) {
|
||||
err.printStackTrace();
|
||||
PlotSquared.log("Failed to save style.yml");
|
||||
@ -1593,23 +1593,6 @@ public class PlotSquared {
|
||||
} catch (IOException ignored) {
|
||||
PlotSquared.log("Failed to save storage.yml");
|
||||
}
|
||||
try {
|
||||
this.commandsFile = new File(folder, "commands.yml");
|
||||
if (!this.commandsFile.exists() && !this.commandsFile.createNewFile()) {
|
||||
PlotSquared.log(
|
||||
"Could not the storage settings file, please create \"commands.yml\" manually.");
|
||||
}
|
||||
this.commands = YamlConfiguration.loadConfiguration(this.commandsFile);
|
||||
} catch (IOException ignored) {
|
||||
PlotSquared.log("Failed to save commands.yml");
|
||||
}
|
||||
try {
|
||||
this.style.save(this.styleFile);
|
||||
this.commands.save(this.commandsFile);
|
||||
} catch (IOException e) {
|
||||
PlotSquared.log("Configuration file saving failed");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -25,9 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.message.PlotMessage;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
@ -40,7 +38,6 @@ import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import lombok.SneakyThrows;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
@ -190,36 +187,16 @@ public abstract class Command {
|
||||
this.permission = declaration.permission();
|
||||
this.required = declaration.requiredType();
|
||||
this.category = declaration.category();
|
||||
|
||||
List<String> aliasOptions = new ArrayList<>();
|
||||
aliasOptions.add(this.id);
|
||||
aliasOptions.addAll(Arrays.asList(declaration.aliases()));
|
||||
HashMap<String, Object> options = new HashMap<>();
|
||||
options.put("aliases", aliasOptions);
|
||||
options.put("description", declaration.description());
|
||||
options.put("usage", declaration.usage());
|
||||
options.put("confirmation", declaration.confirmation());
|
||||
boolean set = false;
|
||||
YamlConfiguration commands =
|
||||
PlotSquared.get() == null ? new YamlConfiguration() : PlotSquared.get().commands;
|
||||
for (Map.Entry<String, Object> entry : options.entrySet()) {
|
||||
String key = this.getFullId() + "." + entry.getKey();
|
||||
if (!commands.contains(key)) {
|
||||
commands.set(key, entry.getValue());
|
||||
set = true;
|
||||
}
|
||||
}
|
||||
if (set && PlotSquared.get() != null) {
|
||||
try {
|
||||
commands.save(PlotSquared.get().commandsFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
this.aliases = commands.getStringList(this.getFullId() + ".aliases");
|
||||
this.description = commands.getString(this.getFullId() + ".description");
|
||||
this.usage = commands.getString(this.getFullId() + ".usage");
|
||||
this.confirmation = commands.getBoolean(this.getFullId() + ".confirmation");
|
||||
this.aliases = aliasOptions;
|
||||
this.description = declaration.description();
|
||||
this.usage = declaration.usage();
|
||||
this.confirmation = declaration.confirmation();
|
||||
|
||||
if (this.parent != null) {
|
||||
this.parent.register(this);
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class HomeCommand extends Command {
|
||||
|
||||
@NotNull private PlotQuery query(@NotNull final PlotPlayer<?> player) {
|
||||
// everything plots need to have in common here
|
||||
return PlotQuery.newQuery().ownedBy(player).whereBasePlot();
|
||||
return PlotQuery.newQuery().ownedBy(player);
|
||||
}
|
||||
|
||||
@Override public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
|
||||
@ -111,6 +111,7 @@ public class HomeCommand extends Command {
|
||||
PlotQuery query = query(player);
|
||||
int page = 1; // page = index + 1
|
||||
String identifier;
|
||||
boolean basePlotOnly = true;
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
identifier = args[0];
|
||||
@ -128,6 +129,7 @@ public class HomeCommand extends Command {
|
||||
Plot fromId = MainUtil.getPlotFromString(player, identifier, false);
|
||||
if (fromId != null && fromId.isOwner(player.getUUID())) {
|
||||
// it was a valid plot id
|
||||
basePlotOnly = false;
|
||||
query.withPlot(fromId);
|
||||
break;
|
||||
}
|
||||
@ -169,12 +171,16 @@ public class HomeCommand extends Command {
|
||||
break;
|
||||
}
|
||||
// as the query already filters by owner, this is fine
|
||||
basePlotOnly = false;
|
||||
query.withPlot(plot);
|
||||
break;
|
||||
case 0:
|
||||
query.withSortingStrategy(SortingStrategy.SORT_BY_CREATION);
|
||||
break;
|
||||
}
|
||||
if (basePlotOnly) {
|
||||
query.whereBasePlot();
|
||||
}
|
||||
home(player, query, page, confirm, whenDone);
|
||||
return CompletableFuture.completedFuture(true);
|
||||
}
|
||||
|
@ -388,6 +388,9 @@ public class Settings extends Config {
|
||||
@Comment(
|
||||
"Whether schematic based generation should paste schematic on top of plots, or from Y=1")
|
||||
public static boolean PASTE_ON_TOP = true;
|
||||
@Comment(
|
||||
"Whether schematic based road generation should paste schematic on top of roads, or from Y=1")
|
||||
public static boolean PASTE_ROAD_ON_TOP = true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -53,7 +53,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
private void placeSchem(HybridPlotWorld world, ScopedLocalBlockQueue result, short relativeX,
|
||||
short relativeZ, int x, int z, boolean isRoad) {
|
||||
int minY; // Math.min(world.PLOT_HEIGHT, world.ROAD_HEIGHT);
|
||||
if (isRoad || Settings.Schematics.PASTE_ON_TOP) {
|
||||
if ((isRoad && Settings.Schematics.PASTE_ROAD_ON_TOP) || (!isRoad
|
||||
&& Settings.Schematics.PASTE_ON_TOP)) {
|
||||
minY = world.SCHEM_Y;
|
||||
} else {
|
||||
minY = 1;
|
||||
|
@ -111,15 +111,17 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
return true;
|
||||
}
|
||||
LocalBlockQueue queue = hybridPlotWorld.getQueue(false);
|
||||
createSchemAbs(queue, pos1, pos2);
|
||||
createSchemAbs(queue, pos1, pos2, true);
|
||||
queue.enqueue();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void createSchemAbs(LocalBlockQueue queue, Location pos1, Location pos2) {
|
||||
private void createSchemAbs(LocalBlockQueue queue, Location pos1, Location pos2,
|
||||
boolean isRoad) {
|
||||
int size = hybridPlotWorld.SIZE;
|
||||
int minY;
|
||||
if (Settings.Schematics.PASTE_ON_TOP) {
|
||||
if ((isRoad && Settings.Schematics.PASTE_ROAD_ON_TOP) || (!isRoad
|
||||
&& Settings.Schematics.PASTE_ON_TOP)) {
|
||||
minY = hybridPlotWorld.SCHEM_Y;
|
||||
} else {
|
||||
minY = 1;
|
||||
@ -170,7 +172,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
return true;
|
||||
}
|
||||
LocalBlockQueue queue = hybridPlotWorld.getQueue(false);
|
||||
createSchemAbs(queue, pos1, pos2);
|
||||
createSchemAbs(queue, pos1, pos2, true);
|
||||
queue.enqueue();
|
||||
return true;
|
||||
}
|
||||
@ -182,9 +184,9 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
Location pos1 = getPlotTopLocAbs(id).add(1, 0, 1).withY(0);
|
||||
Location pos2 = getPlotBottomLocAbs(id2).withY(Math.min(getWorldHeight(), 255));
|
||||
LocalBlockQueue queue = hybridPlotWorld.getQueue(false);
|
||||
createSchemAbs(queue, pos1, pos2);
|
||||
createSchemAbs(queue, pos1, pos2, true);
|
||||
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||
createSchemAbs(queue, pos1, pos2);
|
||||
createSchemAbs(queue, pos1, pos2, true);
|
||||
}
|
||||
return queue.enqueue();
|
||||
}
|
||||
@ -263,7 +265,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
if (!hybridPlotWorld.PLOT_SCHEMATIC) {
|
||||
return;
|
||||
}
|
||||
createSchemAbs(queue, bottom, top);
|
||||
createSchemAbs(queue, bottom, top, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -91,6 +91,11 @@ public abstract class HybridUtils {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
public static boolean regeneratePlotWalls(final PlotArea area) {
|
||||
PlotManager plotManager = area.getPlotManager();
|
||||
return plotManager.regenerateAllPlotWalls();
|
||||
}
|
||||
|
||||
public void analyzeRegion(final String world, final CuboidRegion region,
|
||||
final RunnableVal<PlotAnalysis> whenDone) {
|
||||
// int diff, int variety, int vertices, int rotation, int height_sd
|
||||
@ -509,7 +514,7 @@ public abstract class HybridUtils {
|
||||
PlotManager plotManager = plotworld.getPlotManager();
|
||||
int sx = bot.getX() - plotworld.ROAD_WIDTH + 1;
|
||||
int sz = bot.getZ() + 1;
|
||||
int sy = plotworld.ROAD_HEIGHT;
|
||||
int sy = Settings.Schematics.PASTE_ROAD_ON_TOP ? plotworld.ROAD_HEIGHT : 1;
|
||||
int ex = bot.getX();
|
||||
int ez = top.getZ();
|
||||
int ey = get_ey(plotManager, queue, sx, ex, sz, ez, sy);
|
||||
@ -629,10 +634,7 @@ public abstract class HybridUtils {
|
||||
}
|
||||
if (condition) {
|
||||
BaseBlock[] blocks = plotWorld.G_SCH.get(MathMan.pair(absX, absZ));
|
||||
int minY = plotWorld.SCHEM_Y;
|
||||
if (!Settings.Schematics.PASTE_ON_TOP) {
|
||||
minY = 1;
|
||||
}
|
||||
int minY = Settings.Schematics.PASTE_ROAD_ON_TOP ? plotWorld.SCHEM_Y : 1;
|
||||
int maxY = Math.max(extend, blocks.length);
|
||||
for (int y = 0; y < maxY; y++) {
|
||||
if (y > blocks.length - 1) {
|
||||
@ -667,9 +669,4 @@ public abstract class HybridUtils {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean regeneratePlotWalls(final PlotArea area) {
|
||||
PlotManager plotManager = area.getPlotManager();
|
||||
return plotManager.regenerateAllPlotWalls();
|
||||
}
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
||||
@NotNull public Location getLocation() {
|
||||
Location location = getMeta("location");
|
||||
if (location != null) {
|
||||
return location;
|
||||
return location.copy(); // Always return a copy of the location
|
||||
}
|
||||
return getLocationFull();
|
||||
}
|
||||
|
@ -3009,11 +3009,9 @@ public class Plot {
|
||||
final String name = player.getName();
|
||||
TaskManager.TELEPORT_QUEUE.add(name);
|
||||
TaskManager.runTaskLater(() -> {
|
||||
if (!TaskManager.TELEPORT_QUEUE.contains(name)) {
|
||||
MainUtil.sendMessage(player, Captions.TELEPORT_FAILED);
|
||||
if (!TaskManager.TELEPORT_QUEUE.remove(name)) {
|
||||
return;
|
||||
}
|
||||
TaskManager.TELEPORT_QUEUE.remove(name);
|
||||
if (player.isOnline()) {
|
||||
MainUtil.sendMessage(player, Captions.TELEPORTED_TO_PLOT);
|
||||
player.teleport(location, cause);
|
||||
|
@ -373,10 +373,21 @@ public class MainUtil {
|
||||
/**
|
||||
* Get the name from a UUID.
|
||||
*
|
||||
* @param owner
|
||||
* @param owner Owner UUID
|
||||
* @return The player's name, None, Everyone or Unknown
|
||||
*/
|
||||
@NotNull public static String getName(UUID owner) {
|
||||
@NotNull public static String getName(@Nullable UUID owner) {
|
||||
return getName(owner, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name from a UUID.
|
||||
*
|
||||
* @param owner Owner UUID
|
||||
* @param blocking Whether or not the operation can be blocking
|
||||
* @return The player's name, None, Everyone or Unknown
|
||||
*/
|
||||
@NotNull public static String getName(@Nullable final UUID owner, final boolean blocking) {
|
||||
if (owner == null) {
|
||||
return Captions.NONE.getTranslated();
|
||||
}
|
||||
@ -386,7 +397,17 @@ public class MainUtil {
|
||||
if (owner.equals(DBFunc.SERVER)) {
|
||||
return Captions.SERVER.getTranslated();
|
||||
}
|
||||
String name = PlotSquared.get().getImpromptuUUIDPipeline().getSingle(owner, Settings.UUID.BLOCKING_TIMEOUT);
|
||||
final String name;
|
||||
if (blocking) {
|
||||
name = PlotSquared.get().getImpromptuUUIDPipeline().getSingle(owner, Settings.UUID.BLOCKING_TIMEOUT);
|
||||
} else {
|
||||
final UUIDMapping uuidMapping = PlotSquared.get().getImpromptuUUIDPipeline().getImmediately(owner);
|
||||
if (uuidMapping != null) {
|
||||
name = uuidMapping.getUsername();
|
||||
} else {
|
||||
name = null;
|
||||
}
|
||||
}
|
||||
if (name == null) {
|
||||
return Captions.UNKNOWN.getTranslated();
|
||||
}
|
||||
|
Reference in New Issue
Block a user