mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-08 08:34:43 +02:00
Compare commits
104 Commits
Author | SHA1 | Date | |
---|---|---|---|
ac9042bbe4 | |||
b280644661 | |||
b924809c91 | |||
a913983d99 | |||
3633576e03 | |||
73318f23a1 | |||
248751378b | |||
1918000668 | |||
9037b74720 | |||
f6540bbfcb | |||
507d0f19e4 | |||
355e16fe92 | |||
2b1905889c | |||
7ee67c8b41 | |||
f8ab36b67c | |||
b5ef5df20d | |||
509b1f1c3d | |||
bfe98f3285 | |||
47915b8b86 | |||
3c110bb125 | |||
a87fee1224 | |||
757b9c695f | |||
193948d4fd | |||
b616951e23 | |||
37977f1da4 | |||
7eb7cd9b53 | |||
ddfcc5b077 | |||
9f6bf14649 | |||
f99994737c | |||
6e0ade4f63 | |||
c1a6c75ebe | |||
022372e9b7 | |||
3f54ba23c2 | |||
e8672df760 | |||
5d6f4c6668 | |||
a07ed4eafd | |||
5262ff665a | |||
1129a80329 | |||
a628c5927f | |||
478ad9670b | |||
8e3407505a | |||
e208d7f72a | |||
b0df79bb80 | |||
411c75b219 | |||
491cc50440 | |||
e9723f5be1 | |||
a015039dad | |||
a0640a1e66 | |||
0b6d2d3dd6 | |||
ad11ad3472 | |||
93717e670c | |||
38a33248e7 | |||
52496af9a1 | |||
4d4950090d | |||
c8c144b6da | |||
e94adb04ea | |||
395c1c743f | |||
b1fb01303d | |||
aa7b770c03 | |||
e7990a06e2 | |||
88f5e5b0bc | |||
47db330764 | |||
35ebc8c830 | |||
686a6c499f | |||
cb6d839214 | |||
6af96f43d4 | |||
e3eccfd476 | |||
15d4b6d34b | |||
c3e2421d51 | |||
f7793f027c | |||
6ec96870c0 | |||
a843203ca3 | |||
3240fc9559 | |||
5fd1486cec | |||
d648148f51 | |||
d554dab8c8 | |||
9ad45750ee | |||
a554ae5633 | |||
7b1c4a5042 | |||
9fc464e896 | |||
bec11b244e | |||
dc94418b51 | |||
72ab10c079 | |||
f50d32f06b | |||
6cc744a2e6 | |||
e40dc37f89 | |||
7e34d9e20a | |||
c891abce09 | |||
2b561f2efa | |||
dea0a452df | |||
81418b07a8 | |||
a3c1ad3ec8 | |||
7c6c19ba63 | |||
2e23ae0811 | |||
28e7f5bc08 | |||
7a1417dc56 | |||
e7fa9e01be | |||
93414d54c1 | |||
5642fd3899 | |||
f3d950f6e1 | |||
95f8aaa2fe | |||
878010255c | |||
8edc357d01 | |||
588639d9c2 |
28
.github/ISSUE_TEMPLATE.md
vendored
28
.github/ISSUE_TEMPLATE.md
vendored
@ -1,12 +1,22 @@
|
||||
# Bug report template (Follow this template unless you are making a feature request.)
|
||||
**Debug paste link**:
|
||||
# Bug report template
|
||||
<!--- In order to create a valid issue report you have to follow this template. -->
|
||||
<!--- Incomplete reports might be marked as invalid. -->
|
||||
<!--- You may remove it if you are posting a feature request. -->
|
||||
**Debug paste link:**
|
||||
<!--- Enter /plot debugpaste in game or in your console and copy the output here -->
|
||||
|
||||
**Description of the problem:**
|
||||
|
||||
|
||||
**How to replicate:**
|
||||
<!--- If you can reproduce the issue please tell us as detailed as possible step by step how to do that -->
|
||||
|
||||
**Checklist**:
|
||||
<!-- Make sure you have completed the following steps (put an "X" between of brackets): -->
|
||||
- [] I included a `/plot debugpaste` link
|
||||
- [] I made sure there are no duplicates of this report [(Use Search)](https://github.com/IntellectualSites/PlotSquared/issues?utf8=%E2%9C%93&q=is%3Aissue)
|
||||
- [] I made sure I am using an up-to-date version of PlotSquared
|
||||
- [] I Made sure the bug/error is not caused by any other plugin
|
||||
|
||||
**Description of the problem:**
|
||||
|
||||
**How to replicate**:
|
||||
|
||||
Make sure you've completed the following steps (put an X between of brackets):
|
||||
- [] Include `/plot debugpaste`
|
||||
- [] Made sure there aren't duplicates of this report [(Use Search)](https://github.com/IntellectualSites/PlotSquared/issues?utf8=%E2%9C%93&q=is%3Aissue)
|
||||
- [] Made sure you're using an up-to-date version of PlotSquared
|
||||
- [] Made sure the bug/error isn't caused by any other plugin
|
||||
|
6
.gitignore
vendored
6
.gitignore
vendored
@ -5,8 +5,10 @@
|
||||
Sponge/build
|
||||
Core/build
|
||||
Bukkit/build
|
||||
Nukkit/build
|
||||
|
||||
### Maven ###
|
||||
/mvn
|
||||
/target/lib
|
||||
/target/maven-archiver
|
||||
/target/classes
|
||||
@ -135,4 +137,6 @@ Nukkit/build/classes/
|
||||
Nukkit/build/dependency-cache/
|
||||
checkstyle.xml
|
||||
classes/
|
||||
p2error.txt
|
||||
p2error.txt
|
||||
*.bat
|
||||
Nukkit/build/resources/main/plugin.yml
|
@ -7,7 +7,7 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
compile project(':Core')
|
||||
compile 'org.spigotmc:spigot-api:1.11-R0.1-SNAPSHOT'
|
||||
compile 'org.spigotmc:spigot-api:1.11.2-R0.1-SNAPSHOT'
|
||||
compile("net.milkbowl.vault:VaultAPI:1.6") {
|
||||
exclude module: 'bukkit'
|
||||
}
|
||||
|
@ -12,10 +12,15 @@ import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
import com.intellectualcrafters.plot.object.chat.PlainChatManager;
|
||||
import com.intellectualcrafters.plot.object.worlds.PlotAreaManager;
|
||||
import com.intellectualcrafters.plot.object.worlds.SinglePlotArea;
|
||||
import com.intellectualcrafters.plot.object.worlds.SinglePlotAreaManager;
|
||||
import com.intellectualcrafters.plot.object.worlds.SingleWorldGenerator;
|
||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||
import com.intellectualcrafters.plot.util.ChatManager;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
@ -45,7 +50,7 @@ import com.plotsquared.bukkit.listeners.PlayerEvents_1_8;
|
||||
import com.plotsquared.bukkit.listeners.PlayerEvents_1_9;
|
||||
import com.plotsquared.bukkit.listeners.PlotPlusListener;
|
||||
import com.plotsquared.bukkit.listeners.WorldEvents;
|
||||
import com.plotsquared.bukkit.titles.DefaultTitle_19;
|
||||
import com.plotsquared.bukkit.titles.DefaultTitle_111;
|
||||
import com.plotsquared.bukkit.util.BukkitChatManager;
|
||||
import com.plotsquared.bukkit.util.BukkitChunkManager;
|
||||
import com.plotsquared.bukkit.util.BukkitCommand;
|
||||
@ -72,8 +77,18 @@ import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
|
||||
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
|
||||
import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
@ -88,16 +103,6 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
private static ConcurrentHashMap<String, Plugin> pluginMap;
|
||||
@ -187,6 +192,41 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
} else {
|
||||
PS.log(C.CONSOLE_PLEASE_ENABLE_METRICS.f(getPluginName()));
|
||||
}
|
||||
if (Settings.Enabled_Components.WORLDS) {
|
||||
TaskManager.IMP.taskRepeat(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
unload();
|
||||
}
|
||||
}, 20);
|
||||
}
|
||||
}
|
||||
|
||||
public void unload() {
|
||||
PlotAreaManager manager = PS.get().getPlotAreaManager();
|
||||
if (manager instanceof SinglePlotAreaManager) {
|
||||
long start = System.currentTimeMillis();
|
||||
SinglePlotArea area = ((SinglePlotAreaManager) manager).getArea();
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
String name = world.getName();
|
||||
PlotId id = PlotId.fromString(name);
|
||||
if (id != null) {
|
||||
Plot plot = area.getOwnedPlot(id);
|
||||
if (plot != null) {
|
||||
List<PlotPlayer> players = plot.getPlayersInPlot();
|
||||
if (players.isEmpty() && PlotPlayer.wrap(plot.owner) == null) {
|
||||
for (Chunk chunk : world.getLoadedChunks()) {
|
||||
chunk.unload(true, false);
|
||||
if (System.currentTimeMillis() - start > 20) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Bukkit.unloadWorld(world, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -437,9 +477,14 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
initPlotMeConverter();
|
||||
Settings.Enabled_Components.PLOTME_CONVERTER = false;
|
||||
}
|
||||
IndependentPlotGenerator result = PS.get().IMP.getDefaultGenerator();
|
||||
if (!PS.get().setupPlotWorld(world, id, result)) {
|
||||
return null;
|
||||
IndependentPlotGenerator result;
|
||||
if (id != null && id.equalsIgnoreCase("single")) {
|
||||
result = new SingleWorldGenerator();
|
||||
} else {
|
||||
result = PS.get().IMP.getDefaultGenerator();
|
||||
if (!PS.get().setupPlotWorld(world, id, result)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return (ChunkGenerator) result.specify(world);
|
||||
}
|
||||
@ -450,8 +495,9 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
getServer().getPluginManager().registerEvents(main, this);
|
||||
try {
|
||||
getServer().getClass().getMethod("spigot");
|
||||
Class.forName("org.bukkit.event.entity.EntitySpawnEvent");
|
||||
getServer().getPluginManager().registerEvents(new EntitySpawnListener(), this);
|
||||
} catch (NoSuchMethodException ignored) {
|
||||
} catch (NoSuchMethodException | ClassNotFoundException ignored) {
|
||||
PS.debug("Not running Spigot. Skipping EntitySpawnListener event.");
|
||||
}
|
||||
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_8_0)) {
|
||||
@ -603,7 +649,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
PS.log(C.PREFIX + " &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature.");
|
||||
Settings.TITLES = false;
|
||||
} else {
|
||||
AbstractTitle.TITLE_CLASS = new DefaultTitle_19();
|
||||
AbstractTitle.TITLE_CLASS = new DefaultTitle_111();
|
||||
if (wrapper instanceof DefaultUUIDWrapper || wrapper.getClass() == OfflineUUIDWrapper.class && !Bukkit.getOnlineMode()) {
|
||||
Settings.UUID.NATIVE_UUID_PROVIDER = true;
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
||||
plots.put(key, plot);
|
||||
}
|
||||
for (Plot plot : plots.values()) {
|
||||
HashMap<PlotId, boolean[]> mergeMap = merges.get(plot.getArea().worldname);
|
||||
HashMap<PlotId, boolean[]> mergeMap = merges.get(plot.getWorldName());
|
||||
if (mergeMap != null) {
|
||||
if (mergeMap.containsKey(plot.getId())) {
|
||||
plot.setMerged(mergeMap.get(plot.getId()));
|
||||
@ -174,10 +174,10 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
||||
HashMap<String, HashMap<PlotId, Plot>> processed = new HashMap<>();
|
||||
|
||||
for (Plot plot : plots.values()) {
|
||||
HashMap<PlotId, Plot> map = processed.get(plot.getArea().worldname);
|
||||
HashMap<PlotId, Plot> map = processed.get(plot.getWorldName());
|
||||
if (map == null) {
|
||||
map = new HashMap<>();
|
||||
processed.put(plot.getArea().worldname, map);
|
||||
processed.put(plot.getWorldName(), map);
|
||||
}
|
||||
map.put(plot.getId(), plot);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class PlotClearEvent extends PlotEvent implements Cancellable {
|
||||
* @return String
|
||||
*/
|
||||
public String getWorld() {
|
||||
return getPlot().getArea().worldname;
|
||||
return getPlot().getWorldName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,7 +37,7 @@ public class PlotComponentSetEvent extends PlotEvent {
|
||||
* @return String
|
||||
*/
|
||||
public String getWorld() {
|
||||
return getPlot().getArea().worldname;
|
||||
return getPlot().getWorldName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,7 +35,7 @@ public class PlotDeleteEvent extends PlotEvent {
|
||||
* @return String
|
||||
*/
|
||||
public String getWorld() {
|
||||
return getPlot().getArea().worldname;
|
||||
return getPlot().getWorldName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,17 +19,16 @@ import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.block.ScopedLocalBlockQueue;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.bukkit.util.block.GenChunk;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrapper<ChunkGenerator> {
|
||||
|
||||
|
@ -23,6 +23,11 @@ public class EntitySpawnListener implements Listener {
|
||||
}
|
||||
Plot plot = area.getOwnedPlotAbs(location);
|
||||
if (plot == null) {
|
||||
if (!area.MOB_SPAWNING) {
|
||||
if (event.getEntityType().isAlive() || !area.MISC_SPAWN_UNOWNED) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
|
||||
@ -30,12 +35,6 @@ public class EntitySpawnListener implements Listener {
|
||||
}
|
||||
switch (entity.getType()) {
|
||||
case ENDER_CRYSTAL:
|
||||
if (plot == null) {
|
||||
if (!area.MOB_SPAWNING) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (PlayerEvents.checkEntity(entity, plot)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -1,18 +1,19 @@
|
||||
package com.plotsquared.bukkit.listeners;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.flag.Flags;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class ForceFieldListener {
|
||||
|
||||
@ -79,14 +80,18 @@ public class ForceFieldListener {
|
||||
if (plot.isAdded(uuid)) {
|
||||
Set<PlotPlayer> players = getNearbyPlayers(player, plot);
|
||||
for (PlotPlayer oPlayer : players) {
|
||||
((BukkitPlayer) oPlayer).player.setVelocity(calculateVelocity(plotPlayer, oPlayer));
|
||||
if (!Permissions.hasPermission(oPlayer, C.PERMISSION_ADMIN_ENTRY_FORCEFIELD)) {
|
||||
((BukkitPlayer) oPlayer).player.setVelocity(calculateVelocity(plotPlayer, oPlayer));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
PlotPlayer oPlayer = hasNearbyPermitted(player, plot);
|
||||
if (oPlayer == null) {
|
||||
return;
|
||||
}
|
||||
player.setVelocity(calculateVelocity(oPlayer, plotPlayer));
|
||||
if (!Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_ENTRY_FORCEFIELD)) {
|
||||
player.setVelocity(calculateVelocity(oPlayer, plotPlayer));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,12 +22,24 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.RegExUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.bukkit.BukkitMain;
|
||||
import com.plotsquared.bukkit.object.BukkitLazyBlock;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.bukkit.util.BukkitVersion;
|
||||
import com.plotsquared.listener.PlayerBlockEventType;
|
||||
import com.plotsquared.listener.PlotListener;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -115,18 +127,6 @@ import org.bukkit.projectiles.BlockProjectileSource;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Player Events involving plots.
|
||||
*
|
||||
@ -364,14 +364,31 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
Location loc = pp.getLocation();
|
||||
PlotArea area = loc.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
String[] parts = msg.split(" ");
|
||||
Plot plot = pp.getCurrentPlot();
|
||||
if (BukkitMain.worldEdit != null) { // Check WorldEdit
|
||||
switch (parts[0].toLowerCase()) {
|
||||
case "up":
|
||||
case "/up":
|
||||
case "worldedit:up":
|
||||
case "worldedit:/up":
|
||||
if (plot == null || (!plot.isAdded(pp.getUUID()) && !Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER, true))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
Optional<List<String>> flag = plot.getFlag(Flags.BLOCKED_CMDS);
|
||||
if (flag.isPresent() && !Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
|
||||
List<String> blocked_cmds = flag.get();
|
||||
String[] parts = msg.split(" ");
|
||||
String c = parts[0];
|
||||
if (parts[0].contains(":")) {
|
||||
c = parts[0].split(":")[1];
|
||||
@ -429,10 +446,11 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onConnect(PlayerJoinEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
BukkitUtil.getPlayer(event.getPlayer()).unregister();
|
||||
UUIDHandler.getPlayers().remove(player.getName());
|
||||
BukkitUtil.removePlayer(player.getName());
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
// Now
|
||||
String name = pp.getName();
|
||||
@ -471,9 +489,23 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onTeleport(PlayerTeleportEvent event) {
|
||||
if (event.getTo() == null || event.getFrom() == null) {
|
||||
if (event.getTo() == null || event.getFrom() == null || !event.getFrom().getWorld().equals(event.getTo().getWorld())) {
|
||||
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("location");
|
||||
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("lastplot");
|
||||
org.bukkit.Location to = event.getTo();
|
||||
if (to != null) {
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = PlotPlayer.wrap(player);
|
||||
Location loc = BukkitUtil.getLocation(to);
|
||||
PlotArea area = PS.get().getPlotAreaAbs(loc);
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getPlot(loc);
|
||||
if (plot != null) {
|
||||
plotEntry(pp, plot);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
playerMove(event);
|
||||
@ -526,16 +558,16 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
Integer border = area.getBorder();
|
||||
if (x2 > border) {
|
||||
to.setX(border - 4);
|
||||
if (x2 > border && this.tmpTeleport) {
|
||||
to.setX(x2 - 1);
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(event.getTo());
|
||||
this.tmpTeleport = true;
|
||||
MainUtil.sendMessage(pp, C.BORDER);
|
||||
return;
|
||||
}
|
||||
if (x2 < -border) {
|
||||
to.setX(-border + 4);
|
||||
if (x2 < -border && this.tmpTeleport) {
|
||||
to.setX(x2 + 1);
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(event.getTo());
|
||||
this.tmpTeleport = true;
|
||||
@ -588,14 +620,14 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
Integer border = area.getBorder();
|
||||
if (z2 > border) {
|
||||
to.setZ(border - 4);
|
||||
if (z2 > border && this.tmpTeleport) {
|
||||
to.setZ(z2 - 1);
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(event.getTo());
|
||||
this.tmpTeleport = true;
|
||||
MainUtil.sendMessage(pp, C.BORDER);
|
||||
} else if (z2 < -border) {
|
||||
to.setZ(-border + 4);
|
||||
} else if (z2 < -border && this.tmpTeleport) {
|
||||
to.setZ(z2 + 1);
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(event.getTo());
|
||||
this.tmpTeleport = true;
|
||||
@ -622,13 +654,12 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
String sender = event.getPlayer().getDisplayName();
|
||||
PlotId id = plot.getId();
|
||||
Set<Player> recipients = event.getRecipients();
|
||||
Set<Player> spies = new HashSet<>();
|
||||
recipients.clear();
|
||||
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
|
||||
PlotPlayer pp = entry.getValue();
|
||||
if (pp.getAttribute("chatspy")) {
|
||||
String spy = event.getFormat();
|
||||
spy = String.format(spy, sender, message);
|
||||
pp.sendMessage(spy);
|
||||
spies.add(((BukkitPlayer) pp).player);
|
||||
} else {
|
||||
Plot current = pp.getCurrentPlot();
|
||||
if (current != null && current.getBasePlot(false).equals(plot)) {
|
||||
@ -637,10 +668,19 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
}
|
||||
String partial = ChatColor.translateAlternateColorCodes('&',format.replace("%plot_id%", id.x + ";" + id.y).replace("%sender%", sender));
|
||||
if (plotPlayer.hasPermission("plots.chat.color")) {
|
||||
message = C.color(message);
|
||||
}
|
||||
String full = partial.replace("%msg%", message);
|
||||
for (Player receiver : recipients) {
|
||||
receiver.sendMessage(full);
|
||||
}
|
||||
if (!spies.isEmpty()) {
|
||||
String spyMessage = C.PLOT_CHAT_SPY_FORMAT.s().replace("%plot_id%", id.x + ";" + id.y).replace("%sender%", sender).replace("%msg%", message);
|
||||
for (Player player : spies) {
|
||||
player.sendMessage(spyMessage);
|
||||
}
|
||||
}
|
||||
PS.debug(full);
|
||||
}
|
||||
|
||||
@ -760,15 +800,12 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
public void onWorldChanged(PlayerChangedWorldEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
|
||||
|
||||
// Delete last location
|
||||
pp.deleteMeta("location");
|
||||
Plot plot = (Plot) pp.deleteMeta("lastplot");
|
||||
if (plot != null) {
|
||||
plotExit(pp, plot);
|
||||
}
|
||||
|
||||
if (PS.get().worldedit != null) {
|
||||
if (!Permissions.hasPermission(pp, C.PERMISSION_WORLDEDIT_BYPASS)) {
|
||||
if (pp.getAttribute("worldedit")) {
|
||||
@ -779,6 +816,15 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (Settings.Enabled_Components.PERMISSION_CACHE) {
|
||||
pp.deleteMeta("perm");
|
||||
}
|
||||
Location loc = pp.getLocation();
|
||||
PlotArea area = PS.get().getPlotAreaAbs(loc);
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
plot = area.getPlot(loc);
|
||||
if (plot != null) {
|
||||
plotEntry(pp, plot);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@ -799,7 +845,38 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (!PS.get().hasPlotArea(world)) {
|
||||
return;
|
||||
}
|
||||
if (BukkitUtil.getLocation(event.getBlock().getLocation()).getPlotArea() != null) {
|
||||
Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlot(location);
|
||||
if (plot == null) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
Entity entity = event.getEntity();
|
||||
if (entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
if (!plot.hasOwner()) {
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
if (Flags.ICE_FORM.isTrue(plot)) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||
if (Flags.ICE_FORM.isTrue(plot)) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!Flags.ICE_FORM.isTrue(plot)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -2109,6 +2186,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
onEntityDamageByEntityEvent(eventChange);
|
||||
if (eventChange.isCancelled()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
|
@ -2,6 +2,8 @@ package com.plotsquared.bukkit.listeners;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
||||
import com.intellectualcrafters.plot.object.worlds.PlotAreaManager;
|
||||
import com.intellectualcrafters.plot.object.worlds.SinglePlotAreaManager;
|
||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -16,6 +18,14 @@ public class WorldEvents implements Listener {
|
||||
public void onWorldInit(WorldInitEvent event) {
|
||||
World world = event.getWorld();
|
||||
String name = world.getName();
|
||||
PlotAreaManager manager = PS.get().getPlotAreaManager();
|
||||
if (manager instanceof SinglePlotAreaManager) {
|
||||
SinglePlotAreaManager single = (SinglePlotAreaManager) manager;
|
||||
if (single.isWorld(name)) {
|
||||
world.setKeepSpawnInMemory(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ChunkGenerator gen = world.getGenerator();
|
||||
if (gen instanceof GeneratorWrapper) {
|
||||
PS.get().loadWorld(name, (GeneratorWrapper<?>) gen);
|
||||
|
@ -102,6 +102,11 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
return this.player.hasPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(String permission) {
|
||||
return this.player.isPermissionSet(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
if (!StringMan.isEqual(this.<String>getMeta("lastMessage"), message) || (System.currentTimeMillis() - this.<Long>getMeta("lastMessageTime") > 5000)) {
|
||||
|
@ -0,0 +1,32 @@
|
||||
package com.plotsquared.bukkit.titles;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import com.plotsquared.bukkit.util.BukkitVersion;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DefaultTitle_111 extends AbstractTitle {
|
||||
|
||||
private final boolean valid;
|
||||
|
||||
public DefaultTitle_111() {
|
||||
this.valid = PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_11_0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(PlotPlayer player, String head, String sub, int in, int delay, int out) {
|
||||
if (valid) {
|
||||
try {
|
||||
final Player playerObj = ((BukkitPlayer) player).player;
|
||||
TitleManager_1_11 title = new TitleManager_1_11(head, sub, in, delay, out);
|
||||
title.send(playerObj);
|
||||
return;
|
||||
} catch (Throwable ignored) {}
|
||||
}
|
||||
AbstractTitle.TITLE_CLASS = new DefaultTitle_180();
|
||||
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out);
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
|
||||
public class DefaultTitle extends AbstractTitle {
|
||||
public class DefaultTitle_180 extends AbstractTitle {
|
||||
|
||||
@Override
|
||||
public void sendTitle(PlotPlayer player, String head, String sub, int in, int delay, int out) {
|
||||
@ -12,7 +12,7 @@ public class DefaultTitle extends AbstractTitle {
|
||||
DefaultTitleManager title = new DefaultTitleManager(head, sub, in, delay, out);
|
||||
title.send(((BukkitPlayer) player).player);
|
||||
} catch (Exception ignored) {
|
||||
AbstractTitle.TITLE_CLASS = new DefaultTitle_183();
|
||||
AbstractTitle.TITLE_CLASS = new DefaultTitle_19();
|
||||
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out);
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ public class DefaultTitle_19 extends AbstractTitle {
|
||||
}
|
||||
}, delay * 20);
|
||||
} catch (Throwable ignored) {
|
||||
AbstractTitle.TITLE_CLASS = new DefaultTitle();
|
||||
AbstractTitle.TITLE_CLASS = new DefaultTitle_183();
|
||||
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,526 @@
|
||||
package com.plotsquared.bukkit.titles;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Minecraft 1.8 Title
|
||||
* For 1.11
|
||||
*
|
||||
* @author Maxim Van de Wynckel
|
||||
* @version 1.1.0
|
||||
*/
|
||||
public class TitleManager_1_11 {
|
||||
/* Title packet */
|
||||
private static Class<?> packetTitle;
|
||||
/* Title packet actions ENUM */
|
||||
private static Class<?> packetActions;
|
||||
/* Chat serializer */
|
||||
private static Class<?> nmsChatSerializer;
|
||||
private static Class<?> chatBaseComponent;
|
||||
/* NMS player and connection */
|
||||
private static Class<?> nmsPlayer;
|
||||
private static Class<?> nmsPlayerConnection;
|
||||
private static Field playerConnection;
|
||||
private static Method sendPacket;
|
||||
private static Class<?> obcPlayer;
|
||||
private static Method methodPlayerGetHandle;
|
||||
/* Title text and color */
|
||||
private String title = "";
|
||||
private ChatColor titleColor = ChatColor.WHITE;
|
||||
/* Subtitle text and color */
|
||||
private String subtitle = "";
|
||||
private ChatColor subtitleColor = ChatColor.WHITE;
|
||||
/* Title timings */
|
||||
private int fadeInTime = -1;
|
||||
private int stayTime = -1;
|
||||
private int fadeOutTime = -1;
|
||||
private boolean ticks = false;
|
||||
|
||||
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<Class<?>, Class<?>>();
|
||||
|
||||
public TitleManager_1_11() {
|
||||
loadClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new 1.8 title
|
||||
*
|
||||
* @param title Title
|
||||
*/
|
||||
public TitleManager_1_11(String title) {
|
||||
this.title = title;
|
||||
loadClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new 1.8 title
|
||||
*
|
||||
* @param title Title text
|
||||
* @param subtitle Subtitle text
|
||||
*/
|
||||
public TitleManager_1_11(String title, String subtitle) {
|
||||
this.title = title;
|
||||
this.subtitle = subtitle;
|
||||
loadClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy 1.8 title
|
||||
*
|
||||
* @param title Title
|
||||
*/
|
||||
public TitleManager_1_11(TitleManager_1_11 title) {
|
||||
// Copy title
|
||||
this.title = title.getTitle();
|
||||
this.subtitle = title.getSubtitle();
|
||||
this.titleColor = title.getTitleColor();
|
||||
this.subtitleColor = title.getSubtitleColor();
|
||||
this.fadeInTime = title.getFadeInTime();
|
||||
this.fadeOutTime = title.getFadeOutTime();
|
||||
this.stayTime = title.getStayTime();
|
||||
this.ticks = title.isTicks();
|
||||
loadClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new 1.8 title
|
||||
*
|
||||
* @param title Title text
|
||||
* @param subtitle Subtitle text
|
||||
* @param fadeInTime Fade in time
|
||||
* @param stayTime Stay on screen time
|
||||
* @param fadeOutTime Fade out time
|
||||
*/
|
||||
public TitleManager_1_11(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
|
||||
this.title = title;
|
||||
this.subtitle = subtitle;
|
||||
this.fadeInTime = fadeInTime;
|
||||
this.stayTime = stayTime;
|
||||
this.fadeOutTime = fadeOutTime;
|
||||
loadClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load spigot and NMS classes
|
||||
*/
|
||||
private void loadClasses() {
|
||||
if (packetTitle == null) {
|
||||
packetTitle = getNMSClass("PacketPlayOutTitle");
|
||||
packetActions = getNMSClass("PacketPlayOutTitle$EnumTitleAction");
|
||||
chatBaseComponent = getNMSClass("IChatBaseComponent");
|
||||
nmsChatSerializer = getNMSClass("ChatComponentText");
|
||||
nmsPlayer = getNMSClass("EntityPlayer");
|
||||
nmsPlayerConnection = getNMSClass("PlayerConnection");
|
||||
playerConnection = getField(nmsPlayer,
|
||||
"playerConnection");
|
||||
sendPacket = getMethod(nmsPlayerConnection, "sendPacket");
|
||||
obcPlayer = getOBCClass("entity.CraftPlayer");
|
||||
methodPlayerGetHandle = getMethod("getHandle", obcPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title text
|
||||
*
|
||||
* @param title Title
|
||||
*/
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title text
|
||||
*
|
||||
* @return Title text
|
||||
*/
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set subtitle text
|
||||
*
|
||||
* @param subtitle Subtitle text
|
||||
*/
|
||||
public void setSubtitle(String subtitle) {
|
||||
this.subtitle = subtitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get subtitle text
|
||||
*
|
||||
* @return Subtitle text
|
||||
*/
|
||||
public String getSubtitle() {
|
||||
return this.subtitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the title color
|
||||
*
|
||||
* @param color Chat color
|
||||
*/
|
||||
public void setTitleColor(ChatColor color) {
|
||||
this.titleColor = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the subtitle color
|
||||
*
|
||||
* @param color Chat color
|
||||
*/
|
||||
public void setSubtitleColor(ChatColor color) {
|
||||
this.subtitleColor = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title fade in time
|
||||
*
|
||||
* @param time Time
|
||||
*/
|
||||
public void setFadeInTime(int time) {
|
||||
this.fadeInTime = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title fade out time
|
||||
*
|
||||
* @param time Time
|
||||
*/
|
||||
public void setFadeOutTime(int time) {
|
||||
this.fadeOutTime = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title stay time
|
||||
*
|
||||
* @param time Time
|
||||
*/
|
||||
public void setStayTime(int time) {
|
||||
this.stayTime = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set timings to ticks
|
||||
*/
|
||||
public void setTimingsToTicks() {
|
||||
ticks = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set timings to seconds
|
||||
*/
|
||||
public void setTimingsToSeconds() {
|
||||
ticks = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the title to a player
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
public void send(Player player) {
|
||||
if (packetTitle != null) {
|
||||
// First reset previous settings
|
||||
resetTitle(player);
|
||||
try {
|
||||
// Send timings first
|
||||
Object handle = getHandle(player);
|
||||
Object connection = playerConnection.get(handle);
|
||||
Object[] actions = packetActions.getEnumConstants();
|
||||
Object packet = packetTitle.getConstructor(packetActions,
|
||||
chatBaseComponent, Integer.TYPE, Integer.TYPE,
|
||||
Integer.TYPE).newInstance(actions[3], null,
|
||||
fadeInTime * (ticks ? 1 : 20),
|
||||
stayTime * (ticks ? 1 : 20),
|
||||
fadeOutTime * (ticks ? 1 : 20));
|
||||
// Send if set
|
||||
if (fadeInTime != -1 && fadeOutTime != -1 && stayTime != -1)
|
||||
sendPacket.invoke(connection, packet);
|
||||
|
||||
Object serialized;
|
||||
if (!subtitle.equals("")) {
|
||||
// Send subtitle if present
|
||||
serialized = nmsChatSerializer.getConstructor(String.class)
|
||||
.newInstance(subtitleColor +
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
subtitle));
|
||||
packet = packetTitle.getConstructor(packetActions,
|
||||
chatBaseComponent).newInstance(actions[1],
|
||||
serialized);
|
||||
sendPacket.invoke(connection, packet);
|
||||
}
|
||||
|
||||
// Send title
|
||||
serialized = nmsChatSerializer.getConstructor(
|
||||
String.class).newInstance(titleColor +
|
||||
ChatColor.translateAlternateColorCodes('&', title));
|
||||
packet = packetTitle.getConstructor(packetActions,
|
||||
chatBaseComponent).newInstance(actions[0], serialized);
|
||||
sendPacket.invoke(connection, packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTimes(Player player) {
|
||||
if (TitleManager_1_11.packetTitle != null) {
|
||||
try {
|
||||
Object handle = getHandle(player);
|
||||
Object connection = playerConnection.get(handle);
|
||||
Object[] actions = TitleManager_1_11.packetActions.getEnumConstants();
|
||||
Object packet = TitleManager_1_11.packetTitle.getConstructor(
|
||||
new Class[]{TitleManager_1_11.packetActions, chatBaseComponent,
|
||||
Integer.TYPE, Integer.TYPE, Integer.TYPE})
|
||||
.newInstance(
|
||||
actions[3],
|
||||
null,
|
||||
this.fadeInTime
|
||||
* (this.ticks ? 1 : 20),
|
||||
this.stayTime
|
||||
* (this.ticks ? 1 : 20),
|
||||
this.fadeOutTime
|
||||
* (this.ticks ? 1 : 20));
|
||||
if ((this.fadeInTime != -1) && (this.fadeOutTime != -1)
|
||||
&& (this.stayTime != -1)) {
|
||||
sendPacket.invoke(connection, packet);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTitle(Player player) {
|
||||
if (TitleManager_1_11.packetTitle != null) {
|
||||
try {
|
||||
Object handle = getHandle(player);
|
||||
Object connection = getField(handle.getClass(),
|
||||
"playerConnection").get(handle);
|
||||
Object[] actions = TitleManager_1_11.packetActions.getEnumConstants();
|
||||
Method sendPacket = getMethod(connection.getClass(),
|
||||
"sendPacket");
|
||||
Object serialized = nmsChatSerializer.getConstructor(
|
||||
String.class)
|
||||
.newInstance(titleColor +
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
this.title));
|
||||
Object packet = TitleManager_1_11.packetTitle
|
||||
.getConstructor(
|
||||
new Class[]{TitleManager_1_11.packetActions,
|
||||
chatBaseComponent}).newInstance(
|
||||
actions[0], serialized);
|
||||
sendPacket.invoke(connection, packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateSubtitle(Player player) {
|
||||
if (TitleManager_1_11.packetTitle != null) {
|
||||
try {
|
||||
Object handle = getHandle(player);
|
||||
Object connection = playerConnection.get(handle);
|
||||
Object[] actions = TitleManager_1_11.packetActions.getEnumConstants();
|
||||
Object serialized = nmsChatSerializer.getConstructor(
|
||||
String.class)
|
||||
.newInstance(subtitleColor +
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
this.subtitle));
|
||||
Object packet = TitleManager_1_11.packetTitle
|
||||
.getConstructor(
|
||||
new Class[]{TitleManager_1_11.packetActions,
|
||||
chatBaseComponent}).newInstance(
|
||||
actions[1], serialized);
|
||||
sendPacket.invoke(connection, packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast the title to all players
|
||||
*/
|
||||
public void broadcast() {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
send(p);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the title
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
public void clearTitle(Player player) {
|
||||
try {
|
||||
// Send timings first
|
||||
Object handle = getHandle(player);
|
||||
Object connection = playerConnection.get(handle);
|
||||
Object[] actions = packetActions.getEnumConstants();
|
||||
Object packet = packetTitle.getConstructor(packetActions,
|
||||
chatBaseComponent).newInstance(actions[4], null);
|
||||
sendPacket.invoke(connection, packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the title settings
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
public void resetTitle(Player player) {
|
||||
try {
|
||||
// Send timings first
|
||||
Object handle = getHandle(player);
|
||||
Object connection = playerConnection.get(handle);
|
||||
Object[] actions = packetActions.getEnumConstants();
|
||||
Object packet = packetTitle.getConstructor(packetActions,
|
||||
chatBaseComponent).newInstance(actions[5], null);
|
||||
sendPacket.invoke(connection, packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private Class<?> getPrimitiveType(Class<?> clazz) {
|
||||
return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES
|
||||
.get(clazz) : clazz;
|
||||
}
|
||||
|
||||
private Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
|
||||
int a = classes != null ? classes.length : 0;
|
||||
Class<?>[] types = new Class<?>[a];
|
||||
for (int i = 0; i < a; i++)
|
||||
types[i] = getPrimitiveType(classes[i]);
|
||||
return types;
|
||||
}
|
||||
|
||||
private static boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
|
||||
if (a.length != o.length)
|
||||
return false;
|
||||
for (int i = 0; i < a.length; i++)
|
||||
if (!a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i]))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private Object getHandle(Player player) {
|
||||
try {
|
||||
return methodPlayerGetHandle.invoke(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Method getMethod(String name, Class<?> clazz,
|
||||
Class<?>... paramTypes) {
|
||||
Class<?>[] t = toPrimitiveTypeArray(paramTypes);
|
||||
for (Method m : clazz.getMethods()) {
|
||||
Class<?>[] types = toPrimitiveTypeArray(m.getParameterTypes());
|
||||
if (m.getName().equals(name) && equalsTypeArray(types, t))
|
||||
return m;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getVersion() {
|
||||
String name = Bukkit.getServer().getClass().getPackage().getName();
|
||||
String version = name.substring(name.lastIndexOf('.') + 1) + ".";
|
||||
return version;
|
||||
}
|
||||
|
||||
private Class<?> getNMSClass(String className) {
|
||||
String fullName = "net.minecraft.server." + getVersion() + className;
|
||||
Class<?> clazz = null;
|
||||
try {
|
||||
clazz = Class.forName(fullName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
|
||||
private Class<?> getOBCClass(String className) {
|
||||
String fullName = "org.bukkit.craftbukkit." + getVersion() + className;
|
||||
Class<?> clazz = null;
|
||||
try {
|
||||
clazz = Class.forName(fullName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
|
||||
|
||||
private Field getField(Class<?> clazz, String name) {
|
||||
try {
|
||||
Field field = clazz.getDeclaredField(name);
|
||||
field.setAccessible(true);
|
||||
return field;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Method getMethod(Class<?> clazz, String name, Class<?>... args) {
|
||||
for (Method m : clazz.getMethods())
|
||||
if (m.getName().equals(name)
|
||||
&& (args.length == 0 || ClassListEqual(args,
|
||||
m.getParameterTypes()))) {
|
||||
m.setAccessible(true);
|
||||
return m;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean ClassListEqual(Class<?>[] l1, Class<?>[] l2) {
|
||||
boolean equal = true;
|
||||
if (l1.length != l2.length)
|
||||
return false;
|
||||
for (int i = 0; i < l1.length; i++)
|
||||
if (l1[i] != l2[i]) {
|
||||
equal = false;
|
||||
break;
|
||||
}
|
||||
return equal;
|
||||
}
|
||||
|
||||
public ChatColor getTitleColor() {
|
||||
return titleColor;
|
||||
}
|
||||
|
||||
public ChatColor getSubtitleColor() {
|
||||
return subtitleColor;
|
||||
}
|
||||
|
||||
public int getFadeInTime() {
|
||||
return fadeInTime;
|
||||
}
|
||||
|
||||
public int getFadeOutTime() {
|
||||
return fadeOutTime;
|
||||
}
|
||||
|
||||
public int getStayTime() {
|
||||
return stayTime;
|
||||
}
|
||||
|
||||
public boolean isTicks() {
|
||||
return ticks;
|
||||
}
|
||||
}
|
@ -85,7 +85,7 @@ public class BukkitEventUtil extends EventUtil {
|
||||
|
||||
@Override
|
||||
public boolean callMerge(Plot plot, ArrayList<PlotId> plots) {
|
||||
return callEvent(new PlotMergeEvent(BukkitUtil.getWorld(plot.getArea().worldname), plot, plots));
|
||||
return callEvent(new PlotMergeEvent(BukkitUtil.getWorld(plot.getWorldName()), plot, plots));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -173,11 +173,13 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
}
|
||||
|
||||
Material material = Material.getMaterial(now);
|
||||
Class<? extends MaterialData> md = material.getData();
|
||||
if (md.equals(Directional.class)) {
|
||||
data[i] += 8;
|
||||
} else if (!md.equals(MaterialData.class)) {
|
||||
data[i]++;
|
||||
if (material != null) {
|
||||
Class<? extends MaterialData> md = material.getData();
|
||||
if (md.equals(Directional.class)) {
|
||||
data[i] += 8;
|
||||
} else if (!md.equals(MaterialData.class)) {
|
||||
data[i]++;
|
||||
}
|
||||
}
|
||||
types.add(now);
|
||||
}
|
||||
|
@ -9,18 +9,20 @@ import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class BukkitSetupUtils extends SetupUtils {
|
||||
|
||||
@ -52,6 +54,28 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload(String worldName, boolean save) {
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
if (world == null) {
|
||||
return;
|
||||
}
|
||||
World dw = Bukkit.getWorlds().get(0);
|
||||
for (Player player : world.getPlayers()) {
|
||||
player.teleport(dw.getSpawnLocation());
|
||||
}
|
||||
if (save) {
|
||||
for (Chunk chunk : world.getLoadedChunks()) {
|
||||
chunk.unload(true, false);
|
||||
}
|
||||
} else {
|
||||
for (Chunk chunk : world.getLoadedChunks()) {
|
||||
chunk.unload(false, false);
|
||||
}
|
||||
}
|
||||
Bukkit.unloadWorld(world, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String setupWorld(SetupObject object) {
|
||||
SetupUtils.manager.updateGenerators();
|
||||
@ -59,13 +83,13 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
String world = object.world;
|
||||
int type = object.type;
|
||||
String worldPath = "worlds." + object.world;
|
||||
if (!PS.get().worlds.contains(worldPath)) {
|
||||
PS.get().worlds.createSection(worldPath);
|
||||
}
|
||||
ConfigurationSection worldSection = PS.get().worlds.getConfigurationSection(worldPath);
|
||||
switch (type) {
|
||||
case 2: {
|
||||
if (object.id != null) {
|
||||
if (!PS.get().worlds.contains(worldPath)) {
|
||||
PS.get().worlds.createSection(worldPath);
|
||||
}
|
||||
ConfigurationSection worldSection = PS.get().worlds.getConfigurationSection(worldPath);
|
||||
String areaName = object.id + "-" + object.min + "-" + object.max;
|
||||
String areaPath = "areas." + areaName;
|
||||
if (!worldSection.contains(areaPath)) {
|
||||
@ -101,7 +125,11 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
case 1: {
|
||||
if (!PS.get().worlds.contains(worldPath)) {
|
||||
PS.get().worlds.createSection(worldPath);
|
||||
}
|
||||
ConfigurationSection worldSection = PS.get().worlds.getConfigurationSection(worldPath);
|
||||
for (ConfigurationNode step : steps) {
|
||||
worldSection.set(step.getConstant(), step.getValue());
|
||||
}
|
||||
@ -116,11 +144,19 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
object.setupGenerator = null;
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
for (ConfigurationNode step : steps) {
|
||||
worldSection.set(step.getConstant(), step.getValue());
|
||||
}
|
||||
case 0: {
|
||||
if (steps.length != 0) {
|
||||
if (!PS.get().worlds.contains(worldPath)) {
|
||||
PS.get().worlds.createSection(worldPath);
|
||||
}
|
||||
ConfigurationSection worldSection = PS.get().worlds.getConfigurationSection(worldPath);
|
||||
for (ConfigurationNode step : steps) {
|
||||
worldSection.set(step.getConstant(), step.getValue());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
PS.get().worlds.save(PS.get().worldsFile);
|
||||
@ -147,6 +183,7 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
WorldCreator wc = new WorldCreator(object.world);
|
||||
wc.generator(object.setupGenerator);
|
||||
wc.environment(Environment.NORMAL);
|
||||
wc.type(WorldType.FLAT);
|
||||
Bukkit.createWorld(wc);
|
||||
setGenerator(world, object.setupGenerator);
|
||||
} else {
|
||||
@ -163,7 +200,7 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
return world;
|
||||
}
|
||||
}
|
||||
Bukkit.createWorld(new WorldCreator(object.world).environment(World.Environment.NORMAL));
|
||||
World bw = Bukkit.createWorld(new WorldCreator(object.world).environment(Environment.NORMAL));
|
||||
}
|
||||
return object.world;
|
||||
}
|
||||
|
@ -7,10 +7,10 @@ import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.StringComparison;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -80,15 +80,7 @@ public class BukkitUtil extends WorldUtil {
|
||||
}
|
||||
|
||||
public static World getWorld(String string) {
|
||||
if (StringMan.isEqual(string, lastString)) {
|
||||
if (lastWorld != null) {
|
||||
return lastWorld;
|
||||
}
|
||||
}
|
||||
World world = Bukkit.getWorld(string);
|
||||
lastString = string;
|
||||
lastWorld = world;
|
||||
return world;
|
||||
return Bukkit.getWorld(string);
|
||||
}
|
||||
|
||||
public static String getWorld(Entity entity) {
|
||||
@ -96,7 +88,8 @@ public class BukkitUtil extends WorldUtil {
|
||||
}
|
||||
|
||||
public static List<Entity> getEntities(String worldName) {
|
||||
return getWorld(worldName).getEntities();
|
||||
World world = getWorld(worldName);
|
||||
return world != null ? world.getEntities() : new ArrayList<Entity>();
|
||||
}
|
||||
|
||||
public static Location getLocation(Entity entity) {
|
||||
@ -179,13 +172,25 @@ public class BukkitUtil extends WorldUtil {
|
||||
@Override
|
||||
public int getHighestBlock(String world, int x, int z) {
|
||||
World bukkitWorld = getWorld(world);
|
||||
for (int y = bukkitWorld.getMaxHeight() - 1; y > 0; y--) {
|
||||
// Skip top and bottom block
|
||||
for (int y = bukkitWorld.getMaxHeight() - 2; y > 0; y--) {
|
||||
Block block = bukkitWorld.getBlockAt(x, y, z);
|
||||
if (block != null && block.getType().isSolid()) {
|
||||
return y+1;
|
||||
if (block != null) {
|
||||
Material type = block.getType();
|
||||
if (type.isSolid()) {
|
||||
return y + 1;
|
||||
} else {
|
||||
switch (type) {
|
||||
case WATER:
|
||||
case LAVA:
|
||||
case STATIONARY_LAVA:
|
||||
case STATIONARY_WATER:
|
||||
return y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return bukkitWorld.getMaxHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,14 +6,9 @@ import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.google.common.io.ByteSink;
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.common.io.Closeables;
|
||||
import com.google.common.io.InputSupplier;
|
||||
import com.google.common.primitives.Primitives;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataInputStream;
|
||||
@ -39,6 +34,10 @@ import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class NbtFactory {
|
||||
|
||||
@ -164,13 +163,11 @@ public class NbtFactory {
|
||||
* @return The decoded NBT compound.
|
||||
* @throws IOException If anything went wrong.
|
||||
*/
|
||||
public static NbtCompound fromStream(ByteSource stream, StreamOptions option) throws IOException {
|
||||
InputStream input = null;
|
||||
public static NbtCompound fromStream(InputStream input, StreamOptions option) throws IOException {
|
||||
DataInputStream data = null;
|
||||
boolean suppress = true;
|
||||
|
||||
try {
|
||||
input = stream.openStream();
|
||||
if (option == StreamOptions.GZIP_COMPRESSION) {
|
||||
data = new DataInputStream(new BufferedInputStream(new GZIPInputStream(input)));
|
||||
} else {
|
||||
|
@ -89,7 +89,7 @@ public class SendChunk {
|
||||
Location location = null;
|
||||
String world;
|
||||
if (plot != null) {
|
||||
world = plot.getArea().worldname;
|
||||
world = plot.getWorldName();
|
||||
} else {
|
||||
location = pp.getLocation();
|
||||
world = location.getWorld();
|
||||
|
@ -25,7 +25,9 @@ public class BukkitLocalQueue_1_7 extends BukkitLocalQueue<PlotBlock[]> {
|
||||
private final ReflectionUtils.RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||
private final ReflectionUtils.RefClass classWorld = getRefClass("{nms}.World");
|
||||
private final ReflectionUtils.RefClass classCraftWorld = getRefClass("{cb}.CraftWorld");
|
||||
private final ReflectionUtils.RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
||||
private final ReflectionUtils.RefMethod methodGetHandle;
|
||||
private final ReflectionUtils.RefMethod methodGetHandleChunk;
|
||||
private final ReflectionUtils.RefMethod methodGetChunkAt;
|
||||
private final ReflectionUtils.RefMethod methodA;
|
||||
private final ReflectionUtils.RefMethod methodGetById;
|
||||
@ -40,6 +42,7 @@ public class BukkitLocalQueue_1_7 extends BukkitLocalQueue<PlotBlock[]> {
|
||||
this.methodGetChunkAt = this.classWorld.getMethod("getChunkAt", int.class, int.class);
|
||||
this.methodA = this.classChunk.getMethod("a", int.class, int.class, int.class, this.classBlock, int.class);
|
||||
this.methodGetById = this.classBlock.getMethod("getById", int.class);
|
||||
this.methodGetHandleChunk = this.classCraftChunk.getMethod("getHandle");
|
||||
this.methodInitLighting = this.classChunk.getMethod("initLighting");
|
||||
this.sendChunk = new SendChunk();
|
||||
TaskManager.runTaskRepeat(new Runnable() {
|
||||
@ -87,7 +90,7 @@ public class BukkitLocalQueue_1_7 extends BukkitLocalQueue<PlotBlock[]> {
|
||||
|
||||
@Override
|
||||
public void fixChunkLighting(int x, int z) {
|
||||
Object c = this.methodGetHandle.of(getChunk(x, z)).call();
|
||||
Object c = this.methodGetHandleChunk.of(getChunk(x, z)).call();
|
||||
this.methodInitLighting.of(c).call();
|
||||
}
|
||||
|
||||
@ -112,12 +115,14 @@ public class BukkitLocalQueue_1_7 extends BukkitLocalQueue<PlotBlock[]> {
|
||||
int y = MainUtil.y_loc[i][j];
|
||||
int z = MainUtil.z_loc[i][j];
|
||||
PlotBlock newBlock = result2[j];
|
||||
if (newBlock.id == -1) {
|
||||
chunk.getBlock(x, y, z).setData(newBlock.data, false);
|
||||
continue;
|
||||
if (newBlock != null) {
|
||||
if (newBlock.id == -1) {
|
||||
chunk.getBlock(x, y, z).setData(newBlock.data, false);
|
||||
continue;
|
||||
}
|
||||
Object block = this.methodGetById.call(newBlock.id);
|
||||
this.methodA.of(c).call(x, y, z, block, newBlock.data);
|
||||
}
|
||||
Object block = this.methodGetById.call(newBlock.id);
|
||||
this.methodA.of(c).call(x, y, z, block, newBlock.data);
|
||||
}
|
||||
}
|
||||
fixChunkLighting(lc.getX(), lc.getZ());
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.plotsquared.bukkit.util.block;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.ChunkWrapper;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
@ -11,11 +9,6 @@ import com.intellectualcrafters.plot.util.ReflectionUtils;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.block.BasicLocalBlockQueue;
|
||||
import com.plotsquared.bukkit.util.SendChunk;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
@ -25,6 +18,13 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
public class BukkitLocalQueue_1_8_3 extends BukkitLocalQueue<char[]> {
|
||||
|
||||
@ -276,7 +276,7 @@ public class BukkitLocalQueue_1_8_3 extends BukkitLocalQueue<char[]> {
|
||||
Field tileEntities = clazz.getDeclaredField("tileEntities");
|
||||
Field entitySlices = clazz.getDeclaredField("entitySlices");
|
||||
Object[] sections = (Object[]) sections1.get(c);
|
||||
HashMap<?, ?> tiles = (HashMap<?, ?>) tileEntities.get(c);
|
||||
Map<?, ?> tiles = (Map<?, ?>) tileEntities.get(c);
|
||||
Collection<?>[] entities = (Collection<?>[]) entitySlices.get(c);
|
||||
|
||||
Method getX = null;
|
||||
|
@ -9,7 +9,6 @@ import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -254,14 +253,14 @@ public class BukkitLocalQueue_1_9 extends BukkitLocalQueue<char[]> {
|
||||
Field tf = clazz.getDeclaredField("tileEntities");
|
||||
Field entitySlices = clazz.getDeclaredField("entitySlices");
|
||||
Object[] sections = (Object[]) sf.get(c);
|
||||
HashMap<?, ?> tiles = (HashMap<?, ?>) tf.get(c);
|
||||
Map<?, ?> tiles = (Map<?, ?>) tf.get(c);
|
||||
Collection<?>[] entities = (Collection<?>[]) entitySlices.get(c);
|
||||
|
||||
Method xm = null;
|
||||
Method ym = null;
|
||||
Method zm = null;
|
||||
// Trim tiles
|
||||
boolean removed = false;
|
||||
Collection tickList = ((Collection) this.tileEntityListTick.of(w).get());
|
||||
Set<Map.Entry<?, ?>> entrySet = (Set<Map.Entry<?, ?>>) (Set<?>) tiles.entrySet();
|
||||
Iterator<Map.Entry<?, ?>> iterator = entrySet.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
@ -283,13 +282,10 @@ public class BukkitLocalQueue_1_9 extends BukkitLocalQueue<char[]> {
|
||||
continue;
|
||||
}
|
||||
if (array[k] != 0) {
|
||||
removed = true;
|
||||
tickList.remove(tile.getValue());
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
if (removed) {
|
||||
((Collection) this.tileEntityListTick.of(w).get()).clear();
|
||||
}
|
||||
|
||||
// Trim entities
|
||||
for (int i = 0; i < 16; i++) {
|
||||
|
@ -2,7 +2,6 @@ package com.plotsquared.bukkit.uuid;
|
||||
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -17,6 +16,7 @@ import com.intellectualcrafters.plot.util.expiry.ExpireManager;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import com.plotsquared.bukkit.util.NbtFactory;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
@ -94,8 +94,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
UUID uuid = UUID.fromString(s);
|
||||
if (check || all.remove(uuid)) {
|
||||
File file = new File(playerDataFolder, current);
|
||||
ByteSource is = com.google.common.io.Files.asByteSource(file);
|
||||
NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION);
|
||||
NbtFactory.NbtCompound compound = NbtFactory.fromStream(new FileInputStream(file), NbtFactory.StreamOptions.GZIP_COMPRESSION);
|
||||
if (!compound.containsKey("bukkit")) {
|
||||
PS.debug("ERROR: Player data (" + uuid.toString() + ".dat) does not contain the the key \"bukkit\"");
|
||||
} else {
|
||||
@ -160,8 +159,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
if (!file.exists()) {
|
||||
continue;
|
||||
}
|
||||
ByteSource is = com.google.common.io.Files.asByteSource(file);
|
||||
NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION);
|
||||
NbtFactory.NbtCompound compound = NbtFactory.fromStream(new FileInputStream(file), NbtFactory.StreamOptions.GZIP_COMPRESSION);
|
||||
if (!compound.containsKey("bukkit")) {
|
||||
PS.debug("ERROR: Player data (" + uuid.toString() + ".dat) does not contain the the key \"bukkit\"");
|
||||
} else {
|
||||
|
@ -13,6 +13,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
@ -123,15 +124,17 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
HttpURLConnection connection =
|
||||
(HttpURLConnection) new URL(SQLUUIDHandler.this.PROFILE_URL + uuid.toString().replace("-", ""))
|
||||
.openConnection();
|
||||
InputStreamReader reader = new InputStreamReader(connection.getInputStream());
|
||||
JSONObject response = (JSONObject) SQLUUIDHandler.this.jsonParser.parse(reader);
|
||||
String name = (String) response.get("name");
|
||||
if (name != null) {
|
||||
add(new StringWrapper(name), uuid);
|
||||
try (InputStream con = connection.getInputStream()) {
|
||||
InputStreamReader reader = new InputStreamReader(con);
|
||||
JSONObject response = (JSONObject) SQLUUIDHandler.this.jsonParser.parse(reader);
|
||||
String name = (String) response.get("name");
|
||||
if (name != null) {
|
||||
add(new StringWrapper(name), uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException | ParseException e) {
|
||||
e.printStackTrace();
|
||||
PS.debug("Invalid response from Mojang: Some UUIDs will be cached later. (`unknown` until then or player joins)");
|
||||
}
|
||||
TaskManager.runTaskLaterAsync(this, SQLUUIDHandler.this.INTERVAL);
|
||||
}
|
||||
|
@ -104,6 +104,7 @@ permissions:
|
||||
plots.home: true
|
||||
plots.clear: true
|
||||
plots.delete: true
|
||||
plots.music: true
|
||||
plots.list: true
|
||||
plots.list.mine: true
|
||||
plots.list.shared: true
|
||||
@ -130,6 +131,10 @@ permissions:
|
||||
plots.toggle.chat: true
|
||||
plots.set.biome: true
|
||||
plots.set.home: true
|
||||
plots.set.alias: true
|
||||
plots.set.description: true
|
||||
plots.description: true
|
||||
plots.alias: true
|
||||
plots.merge: true
|
||||
plots.merge.other: true
|
||||
plots.merge.4: true
|
||||
|
@ -7,5 +7,46 @@ dependencies {
|
||||
sourceCompatibility = 1.7
|
||||
targetCompatibility = 1.7
|
||||
|
||||
jar.archiveName = rootProject.name + "-Core-${parent.version}.jar"
|
||||
jar.destinationDir = file '../target'
|
||||
|
||||
processResources {
|
||||
from('src/main/resources') {
|
||||
include 'plugin.properties'
|
||||
expand(
|
||||
version: "${project.parent.version}",
|
||||
name: project.parent.name,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
jar.archiveName="plotsquared-api-${project.parent.version}.jar"
|
||||
jar.destinationDir = file '../mvn/com/plotsquared/plotsquared-api/' + project.parent.version
|
||||
task createPom << {
|
||||
pom {
|
||||
project {
|
||||
groupId 'com.plotsquared'
|
||||
artifactId 'plotsquared-api'
|
||||
version project.parent.version
|
||||
}
|
||||
}.writeTo("../mvn/com/plotsquared/plotsquared-api/${project.parent.version}/plotsquared-api-${project.parent.version}.pom")
|
||||
pom {
|
||||
project {
|
||||
groupId 'com.plotsquared'
|
||||
artifactId 'plotsquared-api'
|
||||
version 'latest'
|
||||
}
|
||||
}.writeTo("../mvn/com/plotsquared/plotsquared-api/latest/plotsquared-api-latest.pom")
|
||||
}
|
||||
|
||||
task copyFiles {
|
||||
doLast {
|
||||
copy {
|
||||
from "../mvn/com/plotsquared/plotsquared-api/${project.parent.version}/"
|
||||
into '../mvn/com/plotsquared/plotsquared-api/latest/'
|
||||
include('*.jar')
|
||||
rename ("plotsquared-api-${project.parent.version}.jar", 'plotsquared-api-latest.jar')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
build.finalizedBy(copyFiles)
|
||||
copyFiles.dependsOn(createPom)
|
@ -28,6 +28,10 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.object.worlds.DefaultPlotAreaManager;
|
||||
import com.intellectualcrafters.plot.object.worlds.PlotAreaManager;
|
||||
import com.intellectualcrafters.plot.object.worlds.SinglePlotArea;
|
||||
import com.intellectualcrafters.plot.object.worlds.SinglePlotAreaManager;
|
||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||
import com.intellectualcrafters.plot.util.ChatManager;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
@ -44,7 +48,6 @@ import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.intellectualcrafters.plot.util.area.QuadMap;
|
||||
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.expiry.ExpireManager;
|
||||
import com.intellectualcrafters.plot.util.expiry.ExpiryTask;
|
||||
@ -67,6 +70,7 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@ -83,7 +87,7 @@ import java.util.zip.ZipInputStream;
|
||||
/**
|
||||
* An implementation of the core, with a static getter for easy access.
|
||||
*/
|
||||
public class PS {
|
||||
public class PS{
|
||||
private static PS instance;
|
||||
// Implementation
|
||||
public final IPlotMain IMP;
|
||||
@ -92,10 +96,8 @@ public class PS {
|
||||
// Current thread
|
||||
private final Thread thread;
|
||||
// Platform / Version / Update URL
|
||||
private final String platform;
|
||||
private final int[] version;
|
||||
private int[] lastVersion;
|
||||
public URL update;
|
||||
private Updater updater;
|
||||
private PlotVersion version;
|
||||
// WorldEdit instance
|
||||
public WorldEdit worldedit;
|
||||
// Files and configuration
|
||||
@ -114,15 +116,8 @@ public class PS {
|
||||
// Temporary hold the plots/clusters before the worlds load
|
||||
public HashMap<String, Set<PlotCluster>> clusters_tmp;
|
||||
public HashMap<String, HashMap<PlotId, Plot>> plots_tmp;
|
||||
// All plot areas
|
||||
private PlotArea[] plotAreas = new PlotArea[0];
|
||||
// All plot areas mapped by world
|
||||
private final HashMap<String, PlotArea[]> plotAreaMap = new HashMap<>();
|
||||
// All plot areas mapped by position
|
||||
private final HashMap<String, QuadMap<PlotArea>> plotAreaGrid = new HashMap<>();
|
||||
// Optimization if there are no hash collisions
|
||||
private boolean plotAreaHasCollision = false;
|
||||
private final HashSet<Integer> plotAreaHashCheck = new HashSet<>();
|
||||
|
||||
private PlotAreaManager manager;
|
||||
|
||||
/**
|
||||
* Initialize PlotSquared with the desired Implementation class.
|
||||
@ -134,8 +129,7 @@ public class PS {
|
||||
this.thread = Thread.currentThread();
|
||||
this.IMP = iPlotMain;
|
||||
this.logger = iPlotMain;
|
||||
this.platform = platform;
|
||||
this.version = this.IMP.getPluginVersion();
|
||||
Settings.PLATFORM = platform;
|
||||
try {
|
||||
new ReflectionUtils(this.IMP.getNMSPackage());
|
||||
try {
|
||||
@ -149,7 +143,7 @@ public class PS {
|
||||
}
|
||||
}
|
||||
if (getJavaVersion() < 1.8) {
|
||||
PS.log(C.CONSOLE_JAVA_OUTDATED_1_8.f(IMP.getPluginName()));
|
||||
PS.log(C.CONSOLE_JAVA_OUTDATED.f(IMP.getPluginName()));
|
||||
}
|
||||
TaskManager.IMP = this.IMP.getTaskManager();
|
||||
setupConfigs();
|
||||
@ -157,6 +151,13 @@ public class PS {
|
||||
MainUtil.getFile(this.IMP.getDirectory(), Settings.Paths.TRANSLATIONS + File.separator + IMP.getPluginName() + ".use_THIS.yml");
|
||||
C.load(this.translationFile);
|
||||
|
||||
// Setup manager
|
||||
if (Settings.Enabled_Components.WORLDS) {
|
||||
this.manager = new SinglePlotAreaManager();
|
||||
} else {
|
||||
this.manager = new DefaultPlotAreaManager();
|
||||
}
|
||||
|
||||
// Database
|
||||
if (Settings.Enabled_Components.DATABASE) {
|
||||
setupDatabase();
|
||||
@ -245,21 +246,19 @@ public class PS {
|
||||
|
||||
// Check for updates
|
||||
if (Settings.Enabled_Components.UPDATER) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
updater = new Updater();
|
||||
TaskManager.IMP.taskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
URL url = Updater.getUpdate();
|
||||
if (url != null) {
|
||||
PS.this.update = url;
|
||||
} else if (PS.this.lastVersion == null) {
|
||||
PS.log("&aThanks for installing " + IMP.getPluginName() + "!");
|
||||
} else if (!get().checkVersion(PS.this.lastVersion, PS.this.version)) {
|
||||
PS.log("&aThanks for updating from " + StringMan.join(PS.this.lastVersion, ".") + " to " + StringMan
|
||||
.join(PS.this.version, ".") + "!");
|
||||
DBFunc.updateTables(PS.this.lastVersion);
|
||||
}
|
||||
updater.update(getPlatform(), getVersion());
|
||||
}
|
||||
});
|
||||
TaskManager.IMP.taskRepeatAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updater.update(getPlatform(), getVersion());
|
||||
}
|
||||
}, 36000);
|
||||
}
|
||||
|
||||
// World generators:
|
||||
@ -280,11 +279,9 @@ public class PS {
|
||||
if (world.equals("CheckingPlotSquaredGenerator")) {
|
||||
continue;
|
||||
}
|
||||
if (!WorldUtil.IMP.isWorld(world)) {
|
||||
if (!WorldUtil.IMP.isWorld(world) && !world.equals("*")) {
|
||||
debug("&c`" + world + "` was not properly loaded - " + IMP.getPluginName() + " will now try to load it properly: ");
|
||||
debug(
|
||||
"&8 - &7Are you trying to delete this world? Remember to remove it from the settings.yml, bukkit.yml and "
|
||||
+ "multiverse worlds.yml");
|
||||
debug("&8 - &7Are you trying to delete this world? Remember to remove it from the settings.yml, bukkit.yml and multiverse worlds.yml");
|
||||
debug("&8 - &7Your world management plugin may be faulty (or non existent)");
|
||||
PS.this.IMP.setGenerator(world);
|
||||
}
|
||||
@ -358,6 +355,18 @@ public class PS {
|
||||
return logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* The plugin updater
|
||||
* @return
|
||||
*/
|
||||
public Updater getUpdater() {
|
||||
return updater;
|
||||
}
|
||||
|
||||
public PlotAreaManager getPlotAreaManager() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Logger.
|
||||
* @see DelegateLogger
|
||||
@ -440,19 +449,11 @@ public class PS {
|
||||
&& version[1] == version2[1] && version[2] >= version2[2];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last PlotSquared version.
|
||||
* @return last version in config or null
|
||||
*/
|
||||
public int[] getLastVersion() {
|
||||
return this.lastVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current PlotSquared version.
|
||||
* @return current version in config or null
|
||||
*/
|
||||
public int[] getVersion() {
|
||||
public PlotVersion getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
@ -463,204 +464,7 @@ public class PS {
|
||||
* @return the server implementation
|
||||
*/
|
||||
public String getPlatform() {
|
||||
return this.platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the relevant plot area for a specified location.
|
||||
* <ul>
|
||||
* <li>If there is only one plot area globally that will be returned.
|
||||
* <li>If there is only one plot area in the world, it will return that.
|
||||
* <li>If the plot area for a location cannot be unambiguously
|
||||
* resolved, null will be returned.
|
||||
* </ul>
|
||||
* Note: An applicable plot area may not include the location i.e. clusters
|
||||
* @param location the location
|
||||
* @return
|
||||
*/
|
||||
public PlotArea getApplicablePlotArea(Location location) {
|
||||
switch (this.plotAreas.length) {
|
||||
case 0:
|
||||
return null;
|
||||
case 1:
|
||||
return this.plotAreas[0];
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
String world = location.getWorld();
|
||||
int hash = world.hashCode();
|
||||
for (PlotArea area : this.plotAreas) {
|
||||
if (hash == area.worldhash) {
|
||||
if (area.contains(location.getX(), location.getZ()) && (!this.plotAreaHasCollision || world.equals(area.worldname))) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
default:
|
||||
PlotArea[] areas = this.plotAreaMap.get(location.getWorld());
|
||||
if (areas == null) {
|
||||
return null;
|
||||
}
|
||||
int y;
|
||||
int x;
|
||||
switch (areas.length) {
|
||||
case 1:
|
||||
return areas[0];
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
x = location.getX();
|
||||
y = location.getY();
|
||||
for (PlotArea area : areas) {
|
||||
if (area.contains(x, y)) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
default:
|
||||
QuadMap<PlotArea> search = this.plotAreaGrid.get(location.getWorld());
|
||||
return search.get(location.getX(), location.getZ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PlotArea getPlotArea(String world, String id) {
|
||||
PlotArea[] areas = this.plotAreaMap.get(world);
|
||||
if (areas == null) {
|
||||
return null;
|
||||
}
|
||||
if (areas.length == 1) {
|
||||
return areas[0];
|
||||
} else if (id == null) {
|
||||
return null;
|
||||
}
|
||||
for (PlotArea area : areas) {
|
||||
if (StringMan.isEqual(id, area.id)) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public PlotArea getPlotAreaAbs(String world, String id) {
|
||||
PlotArea[] areas = this.plotAreaMap.get(world);
|
||||
if (areas == null) {
|
||||
return null;
|
||||
}
|
||||
for (PlotArea area : areas) {
|
||||
if (StringMan.isEqual(id, area.id)) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@code PlotArea} which contains a location.
|
||||
* <ul>
|
||||
* <li>If the plot area does not contain a location, null
|
||||
* will be returned.
|
||||
* </ul>
|
||||
*
|
||||
* @param location the location
|
||||
* @return the {@link PlotArea} in the location, null if non existent
|
||||
*/
|
||||
public PlotArea getPlotAreaAbs(Location location) {
|
||||
switch (this.plotAreas.length) {
|
||||
case 0:
|
||||
return null;
|
||||
case 1:
|
||||
PlotArea pa = this.plotAreas[0];
|
||||
return pa.contains(location) ? pa : null;
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
String world = location.getWorld();
|
||||
int hash = world.hashCode();
|
||||
for (PlotArea area : this.plotAreas) {
|
||||
if (hash == area.worldhash) {
|
||||
if (area.contains(location.getX(), location.getZ()) && (!this.plotAreaHasCollision || world.equals(area.worldname))) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
default:
|
||||
PlotArea[] areas = this.plotAreaMap.get(location.getWorld());
|
||||
if (areas == null) {
|
||||
return null;
|
||||
}
|
||||
int x;
|
||||
int y;
|
||||
switch (areas.length) {
|
||||
case 0:
|
||||
PlotArea a = areas[0];
|
||||
return a.contains(location.getX(), location.getZ()) ? a : null;
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
x = location.getX();
|
||||
y = location.getY();
|
||||
for (PlotArea area : areas) {
|
||||
if (area.contains(x, y)) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
default:
|
||||
QuadMap<PlotArea> search = this.plotAreaGrid.get(location.getWorld());
|
||||
return search.get(location.getX(), location.getZ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PlotArea getPlotAreaByString(String search) {
|
||||
String[] split = search.split(";|,");
|
||||
PlotArea[] areas = this.plotAreaMap.get(split[0]);
|
||||
if (areas == null) {
|
||||
for (PlotArea area : this.plotAreas) {
|
||||
if (area.worldname.equalsIgnoreCase(split[0])) {
|
||||
if (area.id == null || split.length == 2 && area.id.equalsIgnoreCase(split[1])) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (areas.length == 1) {
|
||||
return areas[0];
|
||||
} else if (split.length == 1) {
|
||||
return null;
|
||||
} else {
|
||||
for (PlotArea area : areas) {
|
||||
if (StringMan.isEqual(split[1], area.id)) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Set<PlotArea> getPlotAreas(String world, RegionWrapper region) {
|
||||
QuadMap<PlotArea> areas = this.plotAreaGrid.get(world);
|
||||
return areas != null ? areas.get(region) : new HashSet<PlotArea>();
|
||||
return Settings.PLATFORM;
|
||||
}
|
||||
|
||||
public PlotManager getPlotManager(Plot plot) {
|
||||
@ -720,23 +524,7 @@ public class PS {
|
||||
cluster.setArea(plotArea);
|
||||
}
|
||||
}
|
||||
Set<PlotArea> localAreas = getPlotAreas(plotArea.worldname);
|
||||
Set<PlotArea> globalAreas = getPlotAreas();
|
||||
localAreas.add(plotArea);
|
||||
globalAreas.add(plotArea);
|
||||
this.plotAreas = globalAreas.toArray(new PlotArea[globalAreas.size()]);
|
||||
this.plotAreaMap.put(plotArea.worldname, localAreas.toArray(new PlotArea[localAreas.size()]));
|
||||
QuadMap<PlotArea> map = this.plotAreaGrid.get(plotArea.worldname);
|
||||
if (map == null) {
|
||||
map = new QuadMap<PlotArea>(Integer.MAX_VALUE, 0, 0) {
|
||||
@Override
|
||||
public RegionWrapper getRegion(PlotArea value) {
|
||||
return value.getRegion();
|
||||
}
|
||||
};
|
||||
this.plotAreaGrid.put(plotArea.worldname, map);
|
||||
}
|
||||
map.add(plotArea);
|
||||
manager.addPlotArea(plotArea);
|
||||
plotArea.setupBorder();
|
||||
}
|
||||
|
||||
@ -746,16 +534,7 @@ public class PS {
|
||||
* @param area the {@code PlotArea} to remove
|
||||
*/
|
||||
public void removePlotArea(PlotArea area) {
|
||||
Set<PlotArea> areas = getPlotAreas();
|
||||
areas.remove(area);
|
||||
this.plotAreas = areas.toArray(new PlotArea[areas.size()]);
|
||||
if (areas.isEmpty()) {
|
||||
this.plotAreaMap.remove(area.worldname);
|
||||
this.plotAreaGrid.remove(area.worldname);
|
||||
} else {
|
||||
this.plotAreaMap.put(area.worldname, areas.toArray(new PlotArea[areas.size()]));
|
||||
this.plotAreaGrid.get(area.worldname).remove(area);
|
||||
}
|
||||
manager.removePlotArea(area);
|
||||
setPlotsTmp(area);
|
||||
}
|
||||
|
||||
@ -1027,11 +806,11 @@ public class PS {
|
||||
HashMap<PlotArea, Collection<Plot>> map = new HashMap<>();
|
||||
int totalSize = getPlotCount();
|
||||
if (plots.size() == totalSize) {
|
||||
for (PlotArea area : this.plotAreas) {
|
||||
for (PlotArea area : manager.getAllPlotAreas()) {
|
||||
map.put(area, area.getPlots());
|
||||
}
|
||||
} else {
|
||||
for (PlotArea area : this.plotAreas) {
|
||||
for (PlotArea area : manager.getAllPlotAreas()) {
|
||||
map.put(area, new ArrayList<Plot>(0));
|
||||
}
|
||||
Collection<Plot> lastList = null;
|
||||
@ -1046,7 +825,7 @@ public class PS {
|
||||
}
|
||||
}
|
||||
}
|
||||
List<PlotArea> areas = Arrays.asList(this.plotAreas);
|
||||
List<PlotArea> areas = Arrays.asList(manager.getAllPlotAreas());
|
||||
Collections.sort(areas, new Comparator<PlotArea>() {
|
||||
@Override
|
||||
public int compare(PlotArea a, PlotArea b) {
|
||||
@ -1235,7 +1014,7 @@ public class PS {
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isPlotWorld(String world) {
|
||||
return this.plotAreaMap.containsKey(world);
|
||||
return hasPlotArea(world);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1245,29 +1024,7 @@ public class PS {
|
||||
* @return if a plot world is registered
|
||||
*/
|
||||
public boolean hasPlotArea(String world) {
|
||||
switch (this.plotAreas.length) {
|
||||
case 0:
|
||||
return false;
|
||||
case 1:
|
||||
PlotArea a = this.plotAreas[0];
|
||||
return world.hashCode() == a.worldhash && (!this.plotAreaHasCollision || a.worldname.equals(world));
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
int hash = world.hashCode();
|
||||
for (PlotArea area : this.plotAreas) {
|
||||
if (area.worldhash == hash && (!this.plotAreaHasCollision || area.worldname.equals(world))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
default:
|
||||
return this.plotAreaMap.containsKey(world);
|
||||
}
|
||||
return manager.getPlotAreas(world, null).length != 0;
|
||||
}
|
||||
|
||||
public Collection<Plot> getPlots(String world) {
|
||||
@ -1397,9 +1154,7 @@ public class PS {
|
||||
if (world.equals("CheckingPlotSquaredGenerator")) {
|
||||
return;
|
||||
}
|
||||
if (!this.plotAreaHasCollision && !this.plotAreaHashCheck.add(world.hashCode())) {
|
||||
this.plotAreaHasCollision = true;
|
||||
}
|
||||
this.manager.addWorld(world);
|
||||
Set<String> worlds;
|
||||
if (this.worlds.contains("worlds")) {
|
||||
worlds = this.worlds.getConfigurationSection("worlds").getKeys(false);
|
||||
@ -1415,7 +1170,7 @@ public class PS {
|
||||
type = 0;
|
||||
}
|
||||
if (type == 0) {
|
||||
if (this.plotAreaMap.containsKey(world)) {
|
||||
if (manager.getPlotAreas(world, null).length != 0) {
|
||||
debug("World possibly already loaded: " + world);
|
||||
return;
|
||||
}
|
||||
@ -1466,7 +1221,7 @@ public class PS {
|
||||
}
|
||||
ConfigurationSection areasSection = worldSection.getConfigurationSection("areas");
|
||||
if (areasSection == null) {
|
||||
if (this.plotAreaMap.containsKey(world)) {
|
||||
if (manager.getPlotAreas(world, null).length != 0) {
|
||||
debug("World possibly already loaded: " + world);
|
||||
return;
|
||||
}
|
||||
@ -1547,7 +1302,8 @@ public class PS {
|
||||
if (pos1 == null || pos2 == null || name.isEmpty()) {
|
||||
throw new IllegalArgumentException("Invalid Area identifier: " + areaId + ". Expected form `<name>-<x1;z1>-<x2;z2>`");
|
||||
}
|
||||
if (getPlotAreaAbs(world, name) != null) {
|
||||
PlotArea existing = getPlotArea(world, name);
|
||||
if (existing != null && name.equals(existing.id)) {
|
||||
continue;
|
||||
}
|
||||
ConfigurationSection section = areasSection.getConfigurationSection(areaId);
|
||||
@ -1703,6 +1459,10 @@ public class PS {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public File getJarFile() {
|
||||
return jarFile;
|
||||
}
|
||||
|
||||
public boolean update(PlotPlayer sender, URL url) {
|
||||
try {
|
||||
String name = this.jarFile.getName();
|
||||
@ -1789,7 +1549,7 @@ public class PS {
|
||||
|
||||
private Map<String, Map<PlotId, Plot>> getPlotsRaw() {
|
||||
HashMap<String, Map<PlotId, Plot>> map = new HashMap<>();
|
||||
for (PlotArea area : this.plotAreas) {
|
||||
for (PlotArea area : this.manager.getAllPlotAreas()) {
|
||||
Map<PlotId, Plot> map2 = map.get(area.toString());
|
||||
if (map2 == null) {
|
||||
map.put(area.toString(), area.getPlotsRaw());
|
||||
@ -1819,6 +1579,7 @@ public class PS {
|
||||
DBFunc.close();
|
||||
UUIDHandler.handleShutdown();
|
||||
} catch (NullPointerException ignored) {
|
||||
ignored.printStackTrace();
|
||||
PS.log("&cCould not close database connection!");
|
||||
}
|
||||
}
|
||||
@ -1845,6 +1606,16 @@ public class PS {
|
||||
}
|
||||
DBFunc.dbManager = new SQLManager(database, Storage.PREFIX, false);
|
||||
this.plots_tmp = DBFunc.getPlots();
|
||||
if (manager instanceof SinglePlotAreaManager) {
|
||||
SinglePlotArea area = ((SinglePlotAreaManager) manager).getArea();
|
||||
addPlotArea(area);
|
||||
ConfigurationSection section = worlds.getConfigurationSection("worlds.*");
|
||||
if (section == null) {
|
||||
section = worlds.createSection("worlds.*");
|
||||
}
|
||||
area.saveConfiguration(section);
|
||||
area.loadDefaultConfiguration(section);
|
||||
}
|
||||
this.clusters_tmp = DBFunc.getClusters();
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
PS.log(C.PREFIX + "&cFailed to open DATABASE connection. The plugin will disable itself.");
|
||||
@ -1869,25 +1640,36 @@ public class PS {
|
||||
String lastVersionString = this.config.getString("version");
|
||||
if (lastVersionString != null) {
|
||||
String[] split = lastVersionString.split("\\.");
|
||||
this.lastVersion = new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])};
|
||||
}
|
||||
if (lastVersion != null && checkVersion(new int[]{3, 4, 0}, lastVersion)) {
|
||||
Settings.convertLegacy(configFile);
|
||||
if (config.contains("worlds")) {
|
||||
ConfigurationSection worldSection = config.getConfigurationSection("worlds");
|
||||
worlds.set("worlds", worldSection);
|
||||
try {
|
||||
worlds.save(worldsFile);
|
||||
} catch (IOException e) {
|
||||
PS.debug("Failed to save " + IMP.getPluginName() + " worlds.yml");
|
||||
e.printStackTrace();
|
||||
int[] lastVersion = new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])};
|
||||
if (checkVersion(new int[]{3, 4, 0}, lastVersion)) {
|
||||
Settings.convertLegacy(configFile);
|
||||
if (config.contains("worlds")) {
|
||||
ConfigurationSection worldSection = config.getConfigurationSection("worlds");
|
||||
worlds.set("worlds", worldSection);
|
||||
try {
|
||||
worlds.save(worldsFile);
|
||||
} catch (IOException e) {
|
||||
PS.debug("Failed to save " + IMP.getPluginName() + " worlds.yml");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Settings.save(configFile);
|
||||
}
|
||||
} else {
|
||||
Settings.load(configFile);
|
||||
}
|
||||
Settings.VERSION = StringMan.join(this.version, ".");
|
||||
Settings.PLATFORM = platform;
|
||||
Settings.load(configFile);
|
||||
try {
|
||||
InputStream stream = getClass().getResourceAsStream("/plugin.properties");
|
||||
java.util.Scanner scanner = new java.util.Scanner(stream).useDelimiter("\\A");
|
||||
String versionString = scanner.next().trim();
|
||||
scanner.close();
|
||||
this.version = new PlotVersion(versionString);
|
||||
Settings.DATE = new Date(100 + version.year, version.month, version.day).toGMTString();
|
||||
Settings.BUILD = "https://ci.athion.net/job/PlotSquared/" + version.build;
|
||||
Settings.COMMIT = "https://github.com/IntellectualSites/PlotSquared/commit/" + Integer.toHexString(version.hash);
|
||||
System.out.println("Version is " + this.version);
|
||||
} catch (Throwable ignore) {
|
||||
ignore.printStackTrace();
|
||||
}
|
||||
Settings.save(configFile);
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
}
|
||||
@ -1991,7 +1773,9 @@ public class PS {
|
||||
* Setup the style.yml file
|
||||
*/
|
||||
private void setupStyle() {
|
||||
this.style.set("version", StringMan.join(this.version, "."));
|
||||
if (this.version != null) {
|
||||
this.style.set("version", this.version.toString());
|
||||
}
|
||||
Map<String, Object> o = new HashMap<>(4);
|
||||
o.put("color.1", "6");
|
||||
o.put("color.2", "7");
|
||||
@ -2008,18 +1792,18 @@ public class PS {
|
||||
* Get the Java version.
|
||||
* @return the java version
|
||||
*/
|
||||
private double getJavaVersion() {
|
||||
public double getJavaVersion() {
|
||||
return Double.parseDouble(System.getProperty("java.specification.version"));
|
||||
}
|
||||
|
||||
public void foreachPlotArea(RunnableVal<PlotArea> runnable) {
|
||||
for (PlotArea area : this.plotAreas) {
|
||||
for (PlotArea area : this.manager.getAllPlotAreas()) {
|
||||
runnable.run(area);
|
||||
}
|
||||
}
|
||||
|
||||
public void foreachPlotArea(String world, RunnableVal<PlotArea> runnable) {
|
||||
PlotArea[] array = this.plotAreaMap.get(world);
|
||||
PlotArea[] array = this.manager.getPlotAreas(world, null);
|
||||
if (array == null) {
|
||||
return;
|
||||
}
|
||||
@ -2029,7 +1813,7 @@ public class PS {
|
||||
}
|
||||
|
||||
public void foreachPlot(RunnableVal<Plot> runnable) {
|
||||
for (PlotArea area : this.plotAreas) {
|
||||
for (PlotArea area : this.manager.getAllPlotAreas()) {
|
||||
for (Plot plot : area.getPlots()) {
|
||||
runnable.run(plot);
|
||||
}
|
||||
@ -2037,7 +1821,7 @@ public class PS {
|
||||
}
|
||||
|
||||
public void foreachPlotRaw(RunnableVal<Plot> runnable) {
|
||||
for (PlotArea area : this.plotAreas) {
|
||||
for (PlotArea area : this.manager.getAllPlotAreas()) {
|
||||
for (Plot plot : area.getPlots()) {
|
||||
runnable.run(plot);
|
||||
}
|
||||
@ -2052,30 +1836,31 @@ public class PS {
|
||||
}
|
||||
|
||||
public void foreachBasePlot(RunnableVal<Plot> run) {
|
||||
for (PlotArea area : this.plotAreas) {
|
||||
for (PlotArea area : this.manager.getAllPlotAreas()) {
|
||||
area.foreachBasePlot(run);
|
||||
}
|
||||
}
|
||||
|
||||
public PlotArea getFirstPlotArea() {
|
||||
return this.plotAreas.length > 0 ? this.plotAreas[0] : null;
|
||||
PlotArea[] areas = manager.getAllPlotAreas();
|
||||
return areas.length > 0 ? areas[0] : null;
|
||||
}
|
||||
|
||||
public int getPlotAreaCount() {
|
||||
return this.plotAreas.length;
|
||||
return this.manager.getAllPlotAreas().length;
|
||||
}
|
||||
|
||||
public int getPlotCount() {
|
||||
int count = 0;
|
||||
for (PlotArea area : this.plotAreas) {
|
||||
for (PlotArea area : this.manager.getAllPlotAreas()) {
|
||||
count += area.getPlotCount();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public Set<PlotArea> getPlotAreas() {
|
||||
HashSet<PlotArea> set = new HashSet<>(this.plotAreas.length);
|
||||
Collections.addAll(set, this.plotAreas);
|
||||
HashSet<PlotArea> set = new HashSet<>();
|
||||
Collections.addAll(set, manager.getAllPlotAreas());
|
||||
return set;
|
||||
}
|
||||
|
||||
@ -2085,15 +1870,17 @@ public class PS {
|
||||
*/
|
||||
@Deprecated
|
||||
public Set<String> getPlotWorldStrings() {
|
||||
HashSet<String> set = new HashSet<>(this.plotAreaMap.size());
|
||||
for (String entry : this.plotAreaMap.keySet()) {
|
||||
set.add(entry);
|
||||
HashSet<String> set = new HashSet<>(manager.getAllPlotAreas().length);
|
||||
for (String world : manager.getAllWorlds()) {
|
||||
if (manager.getPlotAreas(world, null).length != 0) {
|
||||
set.add(world);
|
||||
}
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
public boolean isAugmented(String world) {
|
||||
PlotArea[] areas = this.plotAreaMap.get(world);
|
||||
PlotArea[] areas = manager.getPlotAreas(world, null);
|
||||
if (areas == null) {
|
||||
return false;
|
||||
}
|
||||
@ -2109,11 +1896,75 @@ public class PS {
|
||||
* @return Collection of PlotArea objects
|
||||
*/
|
||||
public Set<PlotArea> getPlotAreas(String world) {
|
||||
PlotArea[] areas = this.plotAreaMap.get(world);
|
||||
Set<PlotArea> set = new HashSet<>();
|
||||
Collections.addAll(set, manager.getPlotAreas(world, null));
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the relevant plot area for a specified location.
|
||||
* <ul>
|
||||
* <li>If there is only one plot area globally that will be returned.
|
||||
* <li>If there is only one plot area in the world, it will return that.
|
||||
* <li>If the plot area for a location cannot be unambiguously
|
||||
* resolved, null will be returned.
|
||||
* </ul>
|
||||
* Note: An applicable plot area may not include the location i.e. clusters
|
||||
* @param location the location
|
||||
* @return
|
||||
*/
|
||||
public PlotArea getApplicablePlotArea(Location location) {
|
||||
return manager.getApplicablePlotArea(location);
|
||||
}
|
||||
|
||||
public PlotArea getPlotArea(String world, String id) {
|
||||
return manager.getPlotArea(world, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@code PlotArea} which contains a location.
|
||||
* <ul>
|
||||
* <li>If the plot area does not contain a location, null
|
||||
* will be returned.
|
||||
* </ul>
|
||||
*
|
||||
* @param location the location
|
||||
* @return the {@link PlotArea} in the location, null if non existent
|
||||
*/
|
||||
public PlotArea getPlotAreaAbs(Location location) {
|
||||
return manager.getPlotArea(location);
|
||||
}
|
||||
|
||||
public PlotArea getPlotAreaByString(String search) {
|
||||
String[] split = search.split(";|,");
|
||||
PlotArea[] areas = manager.getPlotAreas(split[0], null);
|
||||
if (areas == null) {
|
||||
return new HashSet<>(0);
|
||||
for (PlotArea area : manager.getAllPlotAreas()) {
|
||||
if (area.worldname.equalsIgnoreCase(split[0])) {
|
||||
if (area.id == null || split.length == 2 && area.id.equalsIgnoreCase(split[1])) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
HashSet<PlotArea> set = new HashSet<>(areas.length);
|
||||
if (areas.length == 1) {
|
||||
return areas[0];
|
||||
} else if (split.length == 1) {
|
||||
return null;
|
||||
} else {
|
||||
for (PlotArea area : areas) {
|
||||
if (StringMan.isEqual(split[1], area.id)) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Set<PlotArea> getPlotAreas(String world, RegionWrapper region) {
|
||||
PlotArea[] areas = manager.getPlotAreas(world, region);
|
||||
Set<PlotArea> set = new HashSet<>();
|
||||
Collections.addAll(set, areas);
|
||||
return set;
|
||||
}
|
||||
|
@ -0,0 +1,28 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
public class PlotVersion {
|
||||
public final int year, month, day, hash, build;
|
||||
|
||||
public PlotVersion(String version) {
|
||||
String[] split = version.substring(version.indexOf('=') + 1).split("-");
|
||||
if (split[0].equals("unknown")) {
|
||||
this.year = month = day = hash = build = 0;
|
||||
return;
|
||||
}
|
||||
String[] date = split[0].split("\\.");
|
||||
this.year = Integer.parseInt(date[0]);
|
||||
this.month = Integer.parseInt(date[1]);
|
||||
this.day = Integer.parseInt(date[2]);
|
||||
this.hash = Integer.parseInt(split[1], 16);
|
||||
this.build = Integer.parseInt(split[2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PlotSquared-" + year + "." + month + "." + day + "-" + Integer.toHexString(hash) + "-" + build;
|
||||
}
|
||||
|
||||
public boolean isNewer(PlotVersion other) {
|
||||
return other.build < this.build;
|
||||
}
|
||||
}
|
@ -1,54 +1,73 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import com.intellectualcrafters.json.JSONArray;
|
||||
import com.intellectualcrafters.json.JSONObject;
|
||||
import com.intellectualcrafters.plot.util.HttpUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import java.net.MalformedURLException;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
import static com.intellectualcrafters.plot.PS.log;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Updater {
|
||||
|
||||
public static URL getUpdate() {
|
||||
String str = HttpUtil.readUrl("https://api.github.com/repos/IntellectualSites/PlotSquared/releases/latest");
|
||||
JSONObject release = new JSONObject(str);
|
||||
JSONArray assets = (JSONArray) release.get("assets");
|
||||
String downloadURL = String.format(PS.imp().getPluginName() + "-%s.jar", PS.get().getPlatform());
|
||||
for (int i = 0; i < assets.length(); i++) {
|
||||
JSONObject asset = assets.getJSONObject(i);
|
||||
String name = asset.getString("name");
|
||||
if (downloadURL.equals(name)) {
|
||||
try {
|
||||
String[] split = release.getString("name").split("\\.");
|
||||
int[] version;
|
||||
if (split.length == 3) {
|
||||
version = new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])};
|
||||
} else {
|
||||
version = new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), 0};
|
||||
}
|
||||
// If current version >= update
|
||||
if (PS.get().checkVersion(PS.get().getVersion(), version)) {
|
||||
if (!PS.get().IMP.getPluginVersionString().contains("-SNAPSHOT") || !Arrays.equals(PS.get().getVersion(), version)) {
|
||||
PS.debug("&7" + PS.imp().getPluginName() + " is already up to date!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
log("&6" + PS.imp().getPluginName() + " " + StringMan.join(split, ".") + " is available:");
|
||||
log("&8 - &3Use: &7/plot update");
|
||||
log("&8 - &3Or: &7" + downloadURL);
|
||||
return new URL(asset.getString("browser_download_url"));
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
log("&dCould not check for updates (1)");
|
||||
log("&7 - Manually check for updates: https://github.com/IntellectualSites/PlotSquared/releases");
|
||||
}
|
||||
PlotVersion newVersion;
|
||||
private String changes;
|
||||
|
||||
public String getChanges() {
|
||||
if (changes == null) {
|
||||
try (Scanner scanner = new Scanner(new URL("http://empcraft.com/plots/cl?" + Integer.toHexString(PS.get().getVersion().hash)).openStream(), "UTF-8")) {
|
||||
changes = scanner.useDelimiter("\\A").next();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
log("You are running the latest version of " + PS.imp().getPluginName() + "!");
|
||||
return null;
|
||||
return changes;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOutdated() {
|
||||
return newVersion != null;
|
||||
}
|
||||
|
||||
public void update(String platform, PlotVersion currentVersion) {
|
||||
if (currentVersion == null || platform == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
String downloadUrl = "https://ci.athion.net/job/PlotSquared/lastSuccessfulBuild/artifact/target/PlotSquared-%platform%-%version%.jar";
|
||||
String versionUrl = "http://empcraft.com/plots/version.php?%platform%";
|
||||
URL url = new URL(versionUrl.replace("%platform%", platform));
|
||||
try (Scanner reader = new Scanner(url.openStream())) {
|
||||
String versionString = reader.next();
|
||||
PlotVersion version = new PlotVersion(versionString);
|
||||
if (version.isNewer(newVersion != null ? newVersion : currentVersion)) {
|
||||
newVersion = version;
|
||||
URL download = new URL(downloadUrl.replaceAll("%platform%", platform).replaceAll("%version%", versionString));
|
||||
try (ReadableByteChannel rbc = Channels.newChannel(download.openStream())) {
|
||||
File jarFile = PS.get().getJarFile();
|
||||
|
||||
File finalFile = new File(jarFile.getParent(), "update" + File.separator + jarFile.getName());
|
||||
File outFile = new File(jarFile.getParent(), "update" + File.separator + jarFile.getName().replace(".jar", ".part"));
|
||||
boolean exists = outFile.exists();
|
||||
if (exists) {
|
||||
outFile.delete();
|
||||
} else {
|
||||
File outFileParent = outFile.getParentFile();
|
||||
if (!outFileParent.exists()) {
|
||||
outFileParent.mkdirs();
|
||||
}
|
||||
}
|
||||
try (FileOutputStream fos = new FileOutputStream(outFile)) {
|
||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||
}
|
||||
outFile.renameTo(finalFile);
|
||||
PS.debug("Updated PlotSquared to " + versionString);
|
||||
MainUtil.sendAdmin("&7Restart to update PlotSquared with these changes: &c/plot changelog &7or&c " + "http://empcraft.com/plot/cl?" + Integer.toHexString(currentVersion.hash));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable ignore) {
|
||||
}
|
||||
}
|
||||
}
|
@ -64,9 +64,11 @@ public class Add extends Command {
|
||||
@Override // Success
|
||||
public void run() {
|
||||
for (UUID uuid : uuids) {
|
||||
if (!plot.removeTrusted(uuid)) {
|
||||
if (plot.getDenied().contains(uuid)) {
|
||||
plot.removeDenied(uuid);
|
||||
if (uuid != DBFunc.everyone) {
|
||||
if (!plot.removeTrusted(uuid)) {
|
||||
if (plot.getDenied().contains(uuid)) {
|
||||
plot.removeDenied(uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
plot.addMember(uuid);
|
||||
|
@ -1,18 +1,22 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Expression;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.ByteArrayUtilities;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
import java.util.Set;
|
||||
|
||||
@CommandDeclaration(command = "auto",
|
||||
permission = "plots.auto",
|
||||
@ -23,41 +27,30 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
usage = "/plot auto [length,width]")
|
||||
public class Auto extends SubCommand {
|
||||
|
||||
@Deprecated
|
||||
public static PlotId getNextPlotId(PlotId id, int step) {
|
||||
int absX = Math.abs(id.x);
|
||||
int absY = Math.abs(id.y);
|
||||
if (absX > absY) {
|
||||
if (id.x > 0) {
|
||||
return new PlotId(id.x, id.y + 1);
|
||||
} else {
|
||||
return new PlotId(id.x, id.y - 1);
|
||||
}
|
||||
} else if (absY > absX) {
|
||||
if (id.y > 0) {
|
||||
return new PlotId(id.x - 1, id.y);
|
||||
} else {
|
||||
return new PlotId(id.x + 1, id.y);
|
||||
}
|
||||
} else {
|
||||
if (id.x == id.y && id.x > 0) {
|
||||
return new PlotId(id.x, id.y + step);
|
||||
}
|
||||
if (id.x == absX) {
|
||||
return new PlotId(id.x, id.y + 1);
|
||||
}
|
||||
if (id.y == absY) {
|
||||
return new PlotId(id.x, id.y - 1);
|
||||
}
|
||||
return new PlotId(id.x + 1, id.y);
|
||||
}
|
||||
return id.getNextId(step);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
PlotArea plotarea = player.getApplicablePlotArea();
|
||||
if (plotarea == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
||||
return false;
|
||||
if (EconHandler.manager != null) {
|
||||
for (PlotArea area : PS.get().getPlotAreaManager().getAllPlotAreas()) {
|
||||
if (EconHandler.manager.hasPermission(area.worldname, player.getName(), "plots.auto")) {
|
||||
if (plotarea != null) {
|
||||
plotarea = null;
|
||||
break;
|
||||
}
|
||||
plotarea = area;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plotarea == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int size_x = 1;
|
||||
int size_z = 1;
|
||||
@ -96,7 +89,7 @@ public class Auto extends SubCommand {
|
||||
int diff = currentPlots - player.getAllowedPlots();
|
||||
if (diff + size_x * size_z > 0) {
|
||||
if (diff < 0) {
|
||||
MainUtil.sendMessage(player, C.CANT_CLAIM_MORE_PLOTS_NUM, -diff + "");
|
||||
MainUtil.sendMessage(player, C.CANT_CLAIM_MORE_PLOTS_NUM, -diff + "");
|
||||
return false;
|
||||
} else if (player.hasPersistentMeta("grantedPlots")) {
|
||||
int grantedPlots = ByteArrayUtilities.bytesToInteger(player.getPersistentMeta("grantedPlots"));
|
||||
@ -117,6 +110,16 @@ public class Auto extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (schematic != null && !schematic.isEmpty()) {
|
||||
if (!plotarea.SCHEMATICS.contains(schematic.toLowerCase())) {
|
||||
sendMessage(player, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLAIM_SCHEMATIC.f(schematic)) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLAIM_SCHEMATIC.f(schematic));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (EconHandler.manager != null && plotarea.USE_ECONOMY) {
|
||||
Expression<Double> costExp = plotarea.PRICES.get("claim");
|
||||
double cost = costExp.evaluate((double) currentPlots);
|
||||
@ -130,70 +133,116 @@ public class Auto extends SubCommand {
|
||||
sendMessage(player, C.REMOVED_BALANCE, cost + "");
|
||||
}
|
||||
}
|
||||
if (schematic != null && !schematic.isEmpty()) {
|
||||
if (!plotarea.SCHEMATICS.contains(schematic.toLowerCase())) {
|
||||
sendMessage(player, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLAIM_SCHEMATIC.f(schematic)) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLAIM_SCHEMATIC.f(schematic));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// TODO handle type 2 the same as normal worlds!
|
||||
if (plotarea.TYPE == 2) {
|
||||
PlotId bot = plotarea.getMin();
|
||||
PlotId top = plotarea.getMax();
|
||||
PlotId origin = new PlotId(MathMan.average(bot.x, top.x), MathMan.average(bot.y, top.y));
|
||||
PlotId id = new PlotId(0, 0);
|
||||
int width = Math.max(top.x - bot.x + 1, top.y - bot.y + 1);
|
||||
int max = width * width;
|
||||
//
|
||||
for (int i = 0; i <= max; i++) {
|
||||
PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y);
|
||||
Plot current = plotarea.getPlotAbs(currentId);
|
||||
if (current.canClaim(player)) {
|
||||
current.claim(player, true, null);
|
||||
return true;
|
||||
}
|
||||
id = getNextPlotId(id, 1);
|
||||
if (size_x == 1 && size_z == 1) {
|
||||
autoClaimSafe(player, plotarea, null, schematic);
|
||||
return true;
|
||||
} else {
|
||||
if (plotarea.TYPE == 2) {
|
||||
// TODO
|
||||
MainUtil.sendMessage(player, C.NO_FREE_PLOTS);
|
||||
return false;
|
||||
}
|
||||
// no free plots
|
||||
MainUtil.sendMessage(player, C.NO_FREE_PLOTS);
|
||||
return false;
|
||||
}
|
||||
plotarea.setMeta("lastPlot", new PlotId(0, 0));
|
||||
while (true) {
|
||||
PlotId start = getNextPlotId(getLastPlotId(plotarea), 1);
|
||||
PlotId end = new PlotId(start.x + size_x - 1, start.y + size_z - 1);
|
||||
plotarea.setMeta("lastPlot", start);
|
||||
if (plotarea.canClaim(player, start, end)) {
|
||||
for (int i = start.x; i <= end.x; i++) {
|
||||
for (int j = start.y; j <= end.y; j++) {
|
||||
Plot plot = plotarea.getPlotAbs(new PlotId(i, j));
|
||||
boolean teleport = i == end.x && j == end.y;
|
||||
plot.claim(player, teleport, null);
|
||||
while (true) {
|
||||
PlotId start = plotarea.getMeta("lastPlot", new PlotId(0, 0)).getNextId(1);
|
||||
PlotId end = new PlotId(start.x + size_x - 1, start.y + size_z - 1);
|
||||
if (plotarea.canClaim(player, start, end)) {
|
||||
plotarea.setMeta("lastPlot", start);
|
||||
for (int i = start.x; i <= end.x; i++) {
|
||||
for (int j = start.y; j <= end.y; j++) {
|
||||
Plot plot = plotarea.getPlotAbs(new PlotId(i, j));
|
||||
boolean teleport = i == end.x && j == end.y;
|
||||
plot.claim(player, teleport, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (size_x != 1 || size_z != 1) {
|
||||
if (!plotarea.mergePlots(MainUtil.getPlotSelectionIds(start, end), true, true)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
plotarea.setMeta("lastPlot", new PlotId(0, 0));
|
||||
return true;
|
||||
}
|
||||
|
||||
public PlotId getLastPlotId(PlotArea area) {
|
||||
PlotId value = (PlotId) area.getMeta("lastPlot");
|
||||
if (value == null) {
|
||||
value = new PlotId(0, 0);
|
||||
area.setMeta("lastPlot", value);
|
||||
return value;
|
||||
/**
|
||||
* Get the next plot id (spiral out from 0,0)
|
||||
* @param start
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public static PlotId getNextPlot(PlotId start) {
|
||||
int plots;
|
||||
PlotId center;
|
||||
center = new PlotId(0, 0);
|
||||
plots = Integer.MAX_VALUE;
|
||||
PlotId currentId;
|
||||
for (int i = 0; i < plots; i++) {
|
||||
if (start == null) {
|
||||
start = new PlotId(0, 0);
|
||||
} else {
|
||||
start = start.getNextId(1);
|
||||
}
|
||||
currentId = new PlotId(center.x + start.x, center.y + start.y);
|
||||
return currentId;
|
||||
}
|
||||
return value;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Teleport the player home, or claim a new plot
|
||||
* @param player
|
||||
* @param area
|
||||
* @param start
|
||||
* @param schem
|
||||
*/
|
||||
public static void homeOrAuto(final PlotPlayer player, final PlotArea area, PlotId start, final String schem) {
|
||||
Set<Plot> plots = player.getPlots();
|
||||
if (!plots.isEmpty()) {
|
||||
plots.iterator().next().teleportPlayer(player);
|
||||
} else {
|
||||
autoClaimSafe(player, area, start, schem);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Claim a new plot for a player
|
||||
* @param player
|
||||
* @param area
|
||||
* @param start
|
||||
* @param schem
|
||||
*/
|
||||
public static void autoClaimSafe(final PlotPlayer player, final PlotArea area, PlotId start, final String schem) {
|
||||
autoClaimFromDatabase(player, area, start, new RunnableVal<Plot>() {
|
||||
@Override
|
||||
public void run(final Plot plot) {
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object ignore) {
|
||||
if (plot == null) {
|
||||
MainUtil.sendMessage(player, C.NO_FREE_PLOTS);
|
||||
} else {
|
||||
plot.claim(player, true, schem, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void autoClaimFromDatabase(final PlotPlayer player, final PlotArea area, PlotId start, final RunnableVal<Plot> whenDone) {
|
||||
final Plot plot = area.getNextFreePlot(player, start);
|
||||
if (plot == null) {
|
||||
whenDone.run(null);
|
||||
return;
|
||||
}
|
||||
whenDone.value = plot;
|
||||
plot.owner = player.getUUID();
|
||||
DBFunc.createPlotSafe(plot, whenDone, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
autoClaimFromDatabase(player, area, plot.getId(), whenDone);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.Updater;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Scanner;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "changelog",
|
||||
permission = "plots.admin.command.changelog",
|
||||
description = "View the changelog",
|
||||
usage = "/plot changelog",
|
||||
requiredType = RequiredType.NONE,
|
||||
aliases = {"cl"},
|
||||
category = CommandCategory.ADMINISTRATION)
|
||||
public class Changelog extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
try {
|
||||
Updater updater = PS.get().getUpdater();
|
||||
String changes = updater != null ? updater.getChanges() : null;
|
||||
if (changes == null) {
|
||||
try (Scanner scanner = new Scanner(new URL("http://empcraft.com/plots/cl?" + Integer.toHexString(PS.get().getVersion().hash)).openStream(), "UTF-8")) {
|
||||
changes = scanner.useDelimiter("\\A").next();
|
||||
}
|
||||
}
|
||||
changes = changes.replaceAll("#([0-9]+)", "github.com/IntellectualSites/PlotSquared/pulls/$1");
|
||||
MainUtil.sendMessage(player, changes);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -2,14 +2,17 @@ package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Expression;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.ByteArrayUtilities;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(command = "claim",
|
||||
@ -21,13 +24,13 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
public class Claim extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
String schematic = "";
|
||||
if (args.length >= 1) {
|
||||
schematic = args[0];
|
||||
}
|
||||
Location loc = player.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -47,9 +50,23 @@ public class Claim extends SubCommand {
|
||||
if (!plot.canClaim(player)) {
|
||||
return sendMessage(player, C.PLOT_IS_CLAIMED);
|
||||
}
|
||||
PlotArea world = plot.getArea();
|
||||
if ((EconHandler.manager != null) && world.USE_ECONOMY) {
|
||||
Expression<Double> costExr = world.PRICES.get("claim");
|
||||
final PlotArea area = plot.getArea();
|
||||
if (!schematic.isEmpty()) {
|
||||
if (area.SCHEMATIC_CLAIM_SPECIFY) {
|
||||
if (!area.SCHEMATICS.contains(schematic.toLowerCase())) {
|
||||
return sendMessage(player, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
|
||||
}
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLAIM_SCHEMATIC.f(schematic)) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) {
|
||||
return sendMessage(player, C.NO_SCHEMATIC_PERMISSION, schematic);
|
||||
}
|
||||
}
|
||||
}
|
||||
int border = area.getBorder();
|
||||
if (border != Integer.MAX_VALUE && plot.getDistanceFromOrigin() > border) {
|
||||
return !sendMessage(player, C.BORDER);
|
||||
}
|
||||
if ((EconHandler.manager != null) && area.USE_ECONOMY) {
|
||||
Expression<Double> costExr = area.PRICES.get("claim");
|
||||
double cost = costExr.evaluate((double) currentPlots);
|
||||
if (cost > 0d) {
|
||||
if (EconHandler.manager.getMoney(player) < cost) {
|
||||
@ -67,16 +84,29 @@ public class Claim extends SubCommand {
|
||||
}
|
||||
sendMessage(player, C.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1));
|
||||
}
|
||||
if (!schematic.isEmpty()) {
|
||||
if (world.SCHEMATIC_CLAIM_SPECIFY) {
|
||||
if (!world.SCHEMATICS.contains(schematic.toLowerCase())) {
|
||||
return sendMessage(player, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
|
||||
if (plot.canClaim(player)) {
|
||||
plot.owner = player.getUUID();
|
||||
final String finalSchematic = schematic;
|
||||
DBFunc.createPlotSafe(plot, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
plot.claim(player, true, finalSchematic, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLAIM_SCHEMATIC.f(schematic)) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) {
|
||||
return sendMessage(player, C.NO_SCHEMATIC_PERMISSION, schematic);
|
||||
}, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sendMessage(player, C.PLOT_NOT_CLAIMED);
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
} else {
|
||||
sendMessage(player, C.PLOT_NOT_CLAIMED);
|
||||
}
|
||||
return plot.claim(player, false, schematic) || sendMessage(player, C.PLOT_NOT_CLAIMED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.CmdInstance;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.CmdConfirm;
|
||||
@ -22,8 +23,8 @@ public class Confirm extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
CmdConfirm.removePending(player);
|
||||
if ((System.currentTimeMillis() - command.timestamp) > 20000) {
|
||||
MainUtil.sendMessage(player, C.FAILED_CONFIRM);
|
||||
if ((System.currentTimeMillis() - command.timestamp) > Settings.Confirmation.CONFIRMATION_TIMEOUT_SECONDS * 1000) {
|
||||
MainUtil.sendMessage(player, C.EXPIRED_CONFIRM);
|
||||
return false;
|
||||
}
|
||||
TaskManager.runTask(command.command);
|
||||
|
@ -9,10 +9,10 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.worlds.SinglePlotArea;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
@ -81,7 +81,7 @@ public class Database extends SubCommand {
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "import":
|
||||
if (args.length < 2) {
|
||||
MainUtil.sendMessage(player, "/plot database import [sqlite file] [prefix]");
|
||||
MainUtil.sendMessage(player, "/plot database import <sqlite file> [prefix]");
|
||||
return false;
|
||||
}
|
||||
File file = MainUtil.getFile(PS.get().IMP.getDirectory(), args[1].endsWith(".db") ? args[1] : args[1] + ".db");
|
||||
@ -101,11 +101,29 @@ public class Database extends SubCommand {
|
||||
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
||||
Plot plot = entry2.getValue();
|
||||
if (pa.getOwnedPlotAbs(plot.getId()) != null) {
|
||||
if (pa instanceof SinglePlotArea) {
|
||||
Plot newPlot = pa.getNextFreePlot(null, plot.getId());
|
||||
if (newPlot != null) {
|
||||
PlotId newId = newPlot.getId();
|
||||
PlotId id = plot.getId();
|
||||
File worldFile = new File(PS.imp().getWorldContainer(), id.toCommaSeparatedString());
|
||||
if (worldFile.exists()) {
|
||||
File newFile = new File(PS.imp().getWorldContainer(), newId.toCommaSeparatedString());
|
||||
worldFile.renameTo(newFile);
|
||||
}
|
||||
id.x = newId.x;
|
||||
id.y = newId.y;
|
||||
id.recalculateHash();
|
||||
plot.setArea(pa);
|
||||
plots.add(plot);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
MainUtil.sendMessage(player, "Skipping duplicate plot: " + plot + " | id=" + plot.temp);
|
||||
continue;
|
||||
}
|
||||
plot.create();
|
||||
plots.add(entry2.getValue());
|
||||
plot.setArea(pa);
|
||||
plots.add(plot);
|
||||
}
|
||||
} else {
|
||||
HashMap<PlotId, Plot> plotmap = PS.get().plots_tmp.get(areaname);
|
||||
|
@ -0,0 +1,59 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal2;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal3;
|
||||
import com.intellectualcrafters.plot.object.worlds.PlotAreaManager;
|
||||
import com.intellectualcrafters.plot.object.worlds.SinglePlotArea;
|
||||
import com.intellectualcrafters.plot.object.worlds.SinglePlotAreaManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "debugimportworlds",
|
||||
permission = "plots.admin",
|
||||
description = "Import worlds by player name",
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
category = CommandCategory.TELEPORT)
|
||||
public class DebugImportWorlds extends Command {
|
||||
public DebugImportWorlds() {
|
||||
super(MainCommand.getInstance(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
// UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8))
|
||||
PlotAreaManager pam = PS.get().getPlotAreaManager();
|
||||
if (!(pam instanceof SinglePlotAreaManager)) {
|
||||
player.sendMessage("Must be a single plot area!");
|
||||
return;
|
||||
}
|
||||
SinglePlotArea area = ((SinglePlotAreaManager) pam).getArea();
|
||||
PlotId id = new PlotId(0, 0);
|
||||
File container = PS.imp().getWorldContainer();
|
||||
for (File folder : container.listFiles()) {
|
||||
String name = folder.getName();
|
||||
if (!WorldUtil.IMP.isWorld(name) && PlotId.fromString(name) == null) {
|
||||
UUID uuid = UUIDHandler.getUUID(name, null);
|
||||
if (uuid == null) {
|
||||
uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
while (new File(container, id.toCommaSeparatedString()).exists()) {
|
||||
id = Auto.getNextPlotId(id, 1);
|
||||
}
|
||||
File newDir = new File(container, id.toCommaSeparatedString());
|
||||
if (folder.renameTo(newDir)) {
|
||||
area.getPlot(id).setOwner(uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
player.sendMessage("Done!");
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
@ -67,8 +68,10 @@ public class Deny extends SubCommand {
|
||||
MainUtil.sendMessage(player, C.ALREADY_ADDED, MainUtil.getName(uuid));
|
||||
return false;
|
||||
}
|
||||
plot.removeMember(uuid);
|
||||
plot.removeTrusted(uuid);
|
||||
if (uuid != DBFunc.everyone) {
|
||||
plot.removeMember(uuid);
|
||||
plot.removeTrusted(uuid);
|
||||
}
|
||||
plot.addDenied(uuid);
|
||||
EventUtil.manager.callDenied(player, plot, uuid, true);
|
||||
if (!uuid.equals(DBFunc.everyone)) {
|
||||
@ -98,7 +101,19 @@ public class Deny extends SubCommand {
|
||||
if (player.getGameMode() == PlotGameMode.SPECTATOR) {
|
||||
player.stopSpectating();
|
||||
}
|
||||
player.teleport(WorldUtil.IMP.getSpawn(player.getLocation().getWorld()));
|
||||
Location loc = player.getLocation();
|
||||
Location spawn = WorldUtil.IMP.getSpawn(loc.getWorld());
|
||||
MainUtil.sendMessage(player, C.YOU_GOT_DENIED);
|
||||
if (plot.equals(spawn.getPlot())) {
|
||||
Location newSpawn = WorldUtil.IMP.getSpawn(PS.get().getPlotAreaManager().getAllWorlds()[0]);
|
||||
if (plot.equals(newSpawn.getPlot())) {
|
||||
// Kick from server if you can't be teleported to spawn
|
||||
player.kick(C.YOU_GOT_DENIED.s());
|
||||
} else {
|
||||
player.teleport(newSpawn);
|
||||
}
|
||||
} else {
|
||||
player.teleport(spawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class Download extends SubCommand {
|
||||
MainUtil.sendMessage(player, C.DONE_NOT_DONE);
|
||||
return false;
|
||||
}
|
||||
if ((!plot.isOwner(player.getUUID()))) {
|
||||
if ((!plot.isOwner(player.getUUID())) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN.s())) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
@ -55,6 +55,10 @@ public class Download extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
if (args.length == 0 || (args.length == 1 && StringMan.isEqualIgnoreCaseToAny(args[0], "sch", "schem", "schematic"))) {
|
||||
if (plot.getVolume() > Integer.MAX_VALUE) {
|
||||
C.SCHEMATIC_TOO_LARGE.send(player);
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
SchematicHandler.manager.getCompoundTag(plot, new RunnableVal<CompoundTag>() {
|
||||
@Override
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
@ -78,7 +79,7 @@ public class Kick extends SubCommand {
|
||||
Location spawn = WorldUtil.IMP.getSpawn(location.getWorld());
|
||||
C.YOU_GOT_KICKED.send(player2);
|
||||
if (plot.equals(spawn.getPlot())) {
|
||||
Location newSpawn = WorldUtil.IMP.getSpawn(player2);
|
||||
Location newSpawn = WorldUtil.IMP.getSpawn(PS.get().getPlotAreaManager().getAllWorlds()[0]);
|
||||
if (plot.equals(newSpawn.getPlot())) {
|
||||
// Kick from server if you can't be teleported to spawn
|
||||
player2.kick(C.YOU_GOT_KICKED.s());
|
||||
|
@ -5,10 +5,11 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal2;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal3;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
import java.util.*;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(command = "leave",
|
||||
description = "Leave a plot",
|
||||
@ -16,7 +17,7 @@ import java.util.Set;
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Leave extends Command {
|
||||
public Leave(Command parent, boolean isStatic) {
|
||||
public Leave() {
|
||||
super(MainCommand.getInstance(), true);
|
||||
}
|
||||
|
||||
@ -27,9 +28,21 @@ public class Leave extends Command {
|
||||
checkTrue(plot.isAdded(player.getUUID()), C.NO_PLOT_PERMS);
|
||||
checkTrue(args.length == 0, C.COMMAND_SYNTAX, getUsage());
|
||||
if (plot.isOwner(player.getUUID())) {
|
||||
Set<UUID> owners = plot.getOwners();
|
||||
checkTrue(plot.hasOwner(), C.ALREADY_OWNER);
|
||||
// TODO setowner, other
|
||||
} else {
|
||||
|
||||
UUID uuid = player.getUUID();
|
||||
if (plot.isAdded(uuid)) {
|
||||
if (plot.removeTrusted(uuid)) {
|
||||
EventUtil.manager.callTrusted(player, plot, uuid, false);
|
||||
}
|
||||
if (plot.removeMember(uuid)) {
|
||||
EventUtil.manager.callMember(player, plot, uuid, false);
|
||||
}
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, args[0]);
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.REMOVED_PLAYERS, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -185,8 +185,8 @@ public class ListCmd extends SubCommand {
|
||||
Collections.sort(plots, new Comparator<Plot>() {
|
||||
@Override
|
||||
public int compare(Plot a, Plot b) {
|
||||
String va = (String) a.getFlags().get(Flags.DONE);
|
||||
String vb = (String) b.getFlags().get(Flags.DONE);
|
||||
String va = "" + a.getFlags().get(Flags.DONE);
|
||||
String vb = "" + b.getFlags().get(Flags.DONE);
|
||||
if (MathMan.isInteger(va)) {
|
||||
if (MathMan.isInteger(vb)) {
|
||||
return Integer.parseInt(vb) - Integer.parseInt(va);
|
||||
|
@ -141,7 +141,7 @@ public class Load extends SubCommand {
|
||||
try {
|
||||
String schematic = schematics.get(i);
|
||||
String[] split = schematic.split("_");
|
||||
if (split.length != 6) {
|
||||
if (split.length < 5) {
|
||||
continue;
|
||||
}
|
||||
String time = secToTime((System.currentTimeMillis() / 1000) - Long.parseLong(split[0]));
|
||||
|
@ -44,7 +44,7 @@ public class MainCommand extends Command {
|
||||
new Confirm();
|
||||
new Template();
|
||||
new Download();
|
||||
new Update();
|
||||
new Changelog();
|
||||
new Template();
|
||||
new Setup();
|
||||
new Area();
|
||||
@ -61,6 +61,7 @@ public class MainCommand extends Command {
|
||||
new Delete();
|
||||
new Trust();
|
||||
new Add();
|
||||
new Leave();
|
||||
new Deny();
|
||||
new Remove();
|
||||
new Info();
|
||||
@ -91,7 +92,6 @@ public class MainCommand extends Command {
|
||||
new DebugFixFlags();
|
||||
new Move();
|
||||
new Condense();
|
||||
new Condense();
|
||||
new Copy();
|
||||
new Chat();
|
||||
new Trim();
|
||||
@ -107,6 +107,7 @@ public class MainCommand extends Command {
|
||||
new Alias();
|
||||
new SetHome();
|
||||
new Cluster();
|
||||
new DebugImportWorlds();
|
||||
// Referenced commands
|
||||
instance.toggle = new Toggle();
|
||||
instance.help = new Help(instance);
|
||||
@ -223,12 +224,12 @@ public class MainCommand extends Command {
|
||||
// Trim command
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
}
|
||||
if (args.length >= 2 && args[0].charAt(0) == '-') {
|
||||
if (args.length >= 2 && !args[0].isEmpty() && args[0].charAt(0) == '-') {
|
||||
switch (args[0].substring(1)) {
|
||||
case "f":
|
||||
confirm = new RunnableVal3<Command, Runnable, Runnable>() {
|
||||
@Override
|
||||
public void run(final Command cmd, final Runnable success, final Runnable failure) {
|
||||
public void run(Command cmd, Runnable success, Runnable failure) {
|
||||
if (EconHandler.manager != null) {
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area != null) {
|
||||
|
@ -65,7 +65,7 @@ public class Owner extends SetCommand {
|
||||
return false;
|
||||
}
|
||||
int size = plots.size();
|
||||
int currentPlots = (Settings.Limit.GLOBAL ? other.getPlotCount() : other.getPlotCount(plot.getArea().worldname)) + size;
|
||||
int currentPlots = (Settings.Limit.GLOBAL ? other.getPlotCount() : other.getPlotCount(plot.getWorldName())) + size;
|
||||
if (currentPlots > other.getAllowedPlots()) {
|
||||
sendMessage(player, C.CANT_TRANSFER_MORE_PLOTS);
|
||||
return false;
|
||||
|
@ -5,7 +5,7 @@ import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.HttpUtil;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(command = "plugin",
|
||||
@ -16,11 +16,16 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
public class PluginCmd extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
MainUtil.sendMessage(player, String.format("$2>> $1&l" + PS.imp().getPluginName() + " $2($1Version$2: $1%s$2)", StringMan.join(PS.get().getVersion(), ".")));
|
||||
MainUtil.sendMessage(player, "$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92 $2& $1MattBDev");
|
||||
MainUtil.sendMessage(player, "$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki");
|
||||
MainUtil.sendMessage(player, "$2>> $1&lNewest Version$2: $1" + getNewestVersionString());
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
TaskManager.IMP.taskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(player, String.format("$2>> $1&l" + PS.imp().getPluginName() + " $2($1Version$2: $1%s$2)", PS.get().getVersion()));
|
||||
MainUtil.sendMessage(player, "$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92 $2& $1MattBDev");
|
||||
MainUtil.sendMessage(player, "$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki");
|
||||
MainUtil.sendMessage(player, "$2>> $1&lNewest Version$2: $1" + getNewestVersionString());
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ public class Purge extends SubCommand {
|
||||
}
|
||||
final HashSet<Plot> toDelete = new HashSet<>();
|
||||
for (Plot plot : PS.get().getBasePlots()) {
|
||||
if (world != null && !plot.getArea().worldname.equalsIgnoreCase(world)) {
|
||||
if (world != null && !plot.getWorldName().equalsIgnoreCase(world)) {
|
||||
continue;
|
||||
}
|
||||
if (area != null && !plot.getArea().equals(area)) {
|
||||
@ -146,6 +146,7 @@ public class Purge extends SubCommand {
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PS.debug("Calculating plots to purge, please wait...");
|
||||
HashSet<Integer> ids = new HashSet<>();
|
||||
for (Plot plot : toDelete) {
|
||||
if (plot.temp != Integer.MAX_VALUE) {
|
||||
|
@ -28,7 +28,7 @@ import java.util.UUID;
|
||||
@CommandDeclaration(command = "rate",
|
||||
permission = "plots.rate",
|
||||
description = "Rate the plot",
|
||||
usage = "/plot rate [#|next]",
|
||||
usage = "/plot rate [#|next|purge]",
|
||||
aliases = "rt",
|
||||
category = CommandCategory.INFO,
|
||||
requiredType = RequiredType.NONE)
|
||||
@ -37,40 +37,54 @@ public class Rate extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("next")) {
|
||||
ArrayList<Plot> plots = new ArrayList<>(PS.get().getBasePlots());
|
||||
Collections.sort(plots, new Comparator<Plot>() {
|
||||
@Override
|
||||
public int compare(Plot p1, Plot p2) {
|
||||
double v1 = 0;
|
||||
if (!p1.getRatings().isEmpty()) {
|
||||
for (Entry<UUID, Rating> entry : p1.getRatings().entrySet()) {
|
||||
v1 -= 11 - entry.getValue().getAverageRating();
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "next": {
|
||||
ArrayList<Plot> plots = new ArrayList<>(PS.get().getBasePlots());
|
||||
Collections.sort(plots, new Comparator<Plot>() {
|
||||
@Override
|
||||
public int compare(Plot p1, Plot p2) {
|
||||
double v1 = 0;
|
||||
if (!p1.getRatings().isEmpty()) {
|
||||
for (Entry<UUID, Rating> entry : p1.getRatings().entrySet()) {
|
||||
v1 -= 11 - entry.getValue().getAverageRating();
|
||||
}
|
||||
}
|
||||
}
|
||||
double v2 = 0;
|
||||
if (!p2.getRatings().isEmpty()) {
|
||||
for (Entry<UUID, Rating> entry : p2.getRatings().entrySet()) {
|
||||
v2 -= 11 - entry.getValue().getAverageRating();
|
||||
double v2 = 0;
|
||||
if (!p2.getRatings().isEmpty()) {
|
||||
for (Entry<UUID, Rating> entry : p2.getRatings().entrySet()) {
|
||||
v2 -= 11 - entry.getValue().getAverageRating();
|
||||
}
|
||||
}
|
||||
if (v1 == v2) {
|
||||
return -0;
|
||||
}
|
||||
return v2 > v1 ? 1 : -1;
|
||||
}
|
||||
if (v1 == v2) {
|
||||
return -0;
|
||||
});
|
||||
UUID uuid = player.getUUID();
|
||||
for (Plot p : plots) {
|
||||
if ((!Settings.Done.REQUIRED_FOR_RATINGS || p.hasFlag(Flags.DONE)) && p.isBasePlot() && (!p.getRatings()
|
||||
.containsKey(uuid)) && !p.isAdded(uuid)) {
|
||||
p.teleportPlayer(player);
|
||||
MainUtil.sendMessage(player, C.RATE_THIS);
|
||||
return true;
|
||||
}
|
||||
return v2 > v1 ? 1 : -1;
|
||||
}
|
||||
});
|
||||
UUID uuid = player.getUUID();
|
||||
for (Plot p : plots) {
|
||||
if ((!Settings.Done.REQUIRED_FOR_RATINGS || p.hasFlag(Flags.DONE)) && p.isBasePlot() && (p.hasRatings() || !p.getRatings()
|
||||
.containsKey(uuid)) && !p.isAdded(uuid)) {
|
||||
p.teleportPlayer(player);
|
||||
MainUtil.sendMessage(player, C.RATE_THIS);
|
||||
return true;
|
||||
}
|
||||
MainUtil.sendMessage(player, C.FOUND_NO_PLOTS);
|
||||
return false;
|
||||
}
|
||||
case "purge": {
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_RATE, true)) {
|
||||
return false;
|
||||
}
|
||||
plot.clearRatings();
|
||||
C.RATINGS_PURGED.send(player);
|
||||
return true;
|
||||
}
|
||||
MainUtil.sendMessage(player, C.FOUND_NO_PLOTS);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
|
@ -19,7 +19,7 @@ import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "remove",
|
||||
aliases = {"r","untrust", "ut", "undeny", "ud"},
|
||||
aliases = {"r","untrust", "ut", "undeny", "unban", "ud"},
|
||||
description = "Remove a player from a plot",
|
||||
usage = "/plot remove <player>",
|
||||
category = CommandCategory.SETTINGS,
|
||||
|
@ -146,6 +146,9 @@ public class Set extends SubCommand {
|
||||
}
|
||||
Command cmd = MainCommand.getInstance().getCommand("set" + args[0]);
|
||||
if (cmd != null) {
|
||||
if (!Permissions.hasPermission(player, cmd.getPermission(), true)) {
|
||||
return false;
|
||||
}
|
||||
cmd.execute(player, Arrays.copyOfRange(args, 1, args.length), null, null);
|
||||
return true;
|
||||
}
|
||||
|
@ -209,6 +209,7 @@ public class Trim extends SubCommand {
|
||||
@Override
|
||||
public void run() {
|
||||
Trim.TASK = false;
|
||||
player.sendMessage("Trim done!");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -64,9 +64,11 @@ public class Trust extends Command {
|
||||
@Override // Success
|
||||
public void run() {
|
||||
for (UUID uuid : uuids) {
|
||||
if (!plot.removeMember(uuid)) {
|
||||
if (plot.getDenied().contains(uuid)) {
|
||||
plot.removeDenied(uuid);
|
||||
if (uuid != DBFunc.everyone) {
|
||||
if (!plot.removeMember(uuid)) {
|
||||
if (plot.getDenied().contains(uuid)) {
|
||||
plot.removeDenied(uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
plot.addTrusted(uuid);
|
||||
|
@ -1,51 +0,0 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.Updater;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "update",
|
||||
permission = "plots.admin.command.update",
|
||||
description = "Update the plugin",
|
||||
usage = "/plot update",
|
||||
requiredType = RequiredType.NONE,
|
||||
aliases = {"updateplugin"},
|
||||
category = CommandCategory.ADMINISTRATION)
|
||||
public class Update extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
URL url;
|
||||
if (args.length == 0) {
|
||||
url = Updater.getUpdate();
|
||||
} else if (args.length == 1) {
|
||||
try {
|
||||
url = new URL(args[0]);
|
||||
} catch (MalformedURLException ignored) {
|
||||
MainUtil.sendMessage(player, "&cInvalid URL: " + args[0]);
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot update [url]");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, getUsage().replaceAll("\\{label\\}", "plot"));
|
||||
return false;
|
||||
}
|
||||
if (url == null) {
|
||||
MainUtil.sendMessage(player, "&cNo update found!");
|
||||
MainUtil.sendMessage(player, "&cTo manually specify an update URL: /plot update <url>");
|
||||
return false;
|
||||
}
|
||||
if (PS.get().update(player, url) && (url == PS.get().update)) {
|
||||
PS.get().update = null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -56,6 +56,7 @@ public enum C {
|
||||
PERMISSION_PLOT_TOGGLE_CHAT("plots.toggle.chat", "static.permissions"),
|
||||
PERMISSION_ADMIN_EXIT_DENIED("plots.admin.exit.denied", "static.permissions"),
|
||||
PERMISSION_ADMIN_ENTRY_DENIED("plots.admin.entry.denied", "static.permissions"),
|
||||
PERMISSION_ADMIN_ENTRY_FORCEFIELD("plots.admin.entry.forcefield", "static.permissions"),
|
||||
PERMISSION_COMMANDS_CHAT("plots.admin.command.chat", "static.permissions"),
|
||||
PERMISSION_MERGE_OTHER("plots.merge.other", "static.permissions"),
|
||||
PERMISSION_ADMIN_DESTROY_UNOWNED("plots.admin.destroy.unowned", "static.permissions"),
|
||||
@ -70,6 +71,7 @@ public enum C {
|
||||
PERMISSION_ADMIN_INTERACT_OTHER("plots.admin.interact.other", "static.permissions"),
|
||||
PERMISSION_ADMIN_BUILD_HEIGHTLIMIT("plots.admin.build.heightlimit", "static.permissions"),
|
||||
PERMISSION_ADMIN_UPDATE("plots.admin.command.update", "static.permissions"),
|
||||
PERMISSION_ADMIN_COMMAND_RATE("plots.admin.command.rate", "static.permissions"),
|
||||
PERMISSION_ADMIN_COMMAND_TRUST("plots.admin.command.trust", "static.permissions"),
|
||||
PERMISSION_TRUST_EVERYONE("plots.trust.everyone", "static.permissions"),
|
||||
PERMISSION_AREA_CREATE("plots.area.create", "static.permissions"),
|
||||
@ -158,13 +160,14 @@ public enum C {
|
||||
/*
|
||||
* Static console
|
||||
*/
|
||||
CONSOLE_JAVA_OUTDATED_1_8("&cYour version of java is outdated. It is highly recommended that you update to Java 8 as it increases performance "
|
||||
+ "and security. %s0 will require Java 9 in a future update.", "static.console"),
|
||||
CONSOLE_JAVA_OUTDATED("&cYour version of java is outdated. It is highly recommended that you update to Java 8 as it increases performance "
|
||||
+ "and security. %s0 will require Java 8 in a future update.", "static.console"),
|
||||
CONSOLE_PLEASE_ENABLE_METRICS("&dPlease enable metrics for %s0. Using metrics improves plugin stability, performance, and features. "
|
||||
+ "Bug fixes and new features are influenced on metrics.", "static.console"),
|
||||
/*
|
||||
* Confirm
|
||||
*/
|
||||
EXPIRED_CONFIRM("$2Confirmation has expired, please run the command again!", "Confirm"),
|
||||
FAILED_CONFIRM("$2You have no pending actions to confirm!", "Confirm"),
|
||||
REQUIRES_CONFIRM("$2Are you sure you wish to execute: $1%s$2?&-$2This cannot be undone! If you are sure: $1/plot confirm", "Confirm"),
|
||||
/*
|
||||
@ -310,6 +313,7 @@ public enum C {
|
||||
/*
|
||||
* Ratings
|
||||
*/
|
||||
RATINGS_PURGED("$2Purged ratings for this plot", "Ratings"),
|
||||
RATING_NOT_VALID("$2You need to specify a number between 1 and 10", "Ratings"),
|
||||
RATING_ALREADY_EXISTS("$2You have already rated plot $2%s", "Ratings"),
|
||||
RATING_APPLIED("$4You successfully rated plot $2%s", "Ratings"),
|
||||
@ -481,6 +485,7 @@ public enum C {
|
||||
*/
|
||||
NO_FREE_PLOTS("$2There are no free plots available", "Errors"),
|
||||
NOT_IN_PLOT("$2You're not in a plot", "Errors"),
|
||||
NOT_LOADED("$2The plot could not be loaded", "Errors"),
|
||||
NOT_IN_CLUSTER("$2You must be within a plot cluster to perform that action", "Errors"),
|
||||
NOT_IN_PLOT_WORLD("$2You're not in a plot area", "Errors"),
|
||||
PLOTWORLD_INCOMPATIBLE("$2The two worlds must be compatible", "Errors"),
|
||||
@ -624,6 +629,7 @@ public enum C {
|
||||
/*
|
||||
* Chat
|
||||
*/
|
||||
PLOT_CHAT_SPY_FORMAT("$2[$1Plot Spy$2][$1%plot_id%$2] $1%sender%$2: $1%msg%", "Chat"),
|
||||
PLOT_CHAT_FORMAT("$2[$1Plot Chat$2][$1%plot_id%$2] $1%sender%$2: $1%msg%", "Chat"),
|
||||
PLOT_CHAT_FORCED("$2This world forces everyone to use plot chat.", "Chat"),
|
||||
PLOT_CHAT_ON("$4Plot chat enabled.", "Chat"),
|
||||
|
@ -20,9 +20,13 @@ public class Settings extends Config {
|
||||
@Final
|
||||
public static final String WIKI = "https://github.com/IntellectualSites/PlotSquared/wiki";
|
||||
@Final
|
||||
public static String VERSION = null; // These values are set from PS before loading
|
||||
public static String DATE; // These values are set from P2 before loading
|
||||
@Final
|
||||
public static String PLATFORM = null; // These values are set from PS before loading
|
||||
public static String BUILD; // These values are set from P2 before loading
|
||||
@Final
|
||||
public static String COMMIT; // These values are set from P2 before loading
|
||||
@Final
|
||||
public static String PLATFORM; // These values are set from P2 before loading
|
||||
|
||||
@Comment("Show additional information in console")
|
||||
public static boolean DEBUG = true;
|
||||
@ -100,7 +104,6 @@ public class Settings extends Config {
|
||||
|
||||
// Web
|
||||
Web.URL = config.getString("web.url", Web.URL);
|
||||
Web.SERVER_IP = config.getString("web.server-ip", Web.SERVER_IP);
|
||||
|
||||
// Caching
|
||||
Enabled_Components.PERMISSION_CACHE = config.getBoolean("cache.permissions", Enabled_Components.PERMISSION_CACHE);
|
||||
@ -204,10 +207,20 @@ public class Settings extends Config {
|
||||
}
|
||||
|
||||
public static class Web {
|
||||
@Comment("We are already hosting a web interface for you:")
|
||||
@Comment({
|
||||
"The web interface for schematics",
|
||||
" - All schematics are anonymous and private",
|
||||
" - Downloads can be deleted by the user",
|
||||
" - Supports plot uploads, downloads and saves",
|
||||
})
|
||||
public static String URL = "http://empcraft.com/plots/";
|
||||
@Comment("The ip that will show up in the interface")
|
||||
public static String SERVER_IP = "your.ip.here";
|
||||
@Comment({
|
||||
"The web interface for assets",
|
||||
" - All schematics are organized and public",
|
||||
" - Assets can be searched, selected and downloaded",
|
||||
})
|
||||
public static String ASSETS = "http://empcraft.com/assetpack/";
|
||||
|
||||
}
|
||||
|
||||
public static final class Done {
|
||||
@ -242,6 +255,11 @@ public class Settings extends Config {
|
||||
public static boolean CACHE_UUDS = false;
|
||||
}
|
||||
|
||||
public static final class Confirmation {
|
||||
@Comment("Teleport to your plot on death")
|
||||
public static int CONFIRMATION_TIMEOUT_SECONDS = 20;
|
||||
}
|
||||
|
||||
public static final class Teleport {
|
||||
@Comment("Teleport to your plot on death")
|
||||
public static boolean ON_DEATH = false;
|
||||
@ -279,7 +297,7 @@ public class Settings extends Config {
|
||||
public static boolean COMMANDS = true;
|
||||
@Comment("The UUID cacher is used to resolve player names")
|
||||
public static boolean UUID_CACHE = true;
|
||||
@Comment("Notify players of updates")
|
||||
@Comment("The plugin auto updater")
|
||||
public static boolean UPDATER = true;
|
||||
@Comment("Stores user metadata in a database")
|
||||
public static boolean PERSISTENT_META = true;
|
||||
@ -306,6 +324,8 @@ public class Settings extends Config {
|
||||
public static boolean KILL_ROAD_VEHICLES = false;
|
||||
@Comment("Notify a player of any missed comments upon plot entry")
|
||||
public static boolean COMMENT_NOTIFIER = false;
|
||||
@Comment("Let player's claim entire worlds with PlotSquared")
|
||||
public static boolean WORLDS = false;
|
||||
@Comment("Actively purge invalid database entries")
|
||||
public static boolean DATABASE_PURGER = false;
|
||||
@Comment("Delete plots when a player is banned")
|
||||
|
@ -42,7 +42,7 @@ public interface AbstractDB {
|
||||
*
|
||||
* @param plot the plot to create
|
||||
*/
|
||||
void createPlot(Plot plot);
|
||||
void createPlotSafe(final Plot plot, final Runnable success, final Runnable failure);
|
||||
|
||||
/**
|
||||
* Create tables.
|
||||
|
@ -125,16 +125,11 @@ public class DBFunc {
|
||||
DBFunc.dbManager.createPlotsAndData(plots, whenDone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a plot
|
||||
*
|
||||
* @param plot Plot to create
|
||||
*/
|
||||
public static void createPlot(Plot plot) {
|
||||
if (plot.temp == -1 || dbManager == null) {
|
||||
public static void createPlotSafe(final Plot plot, final Runnable success, final Runnable failure) {
|
||||
if (dbManager == null) {
|
||||
return;
|
||||
}
|
||||
DBFunc.dbManager.createPlot(plot);
|
||||
DBFunc.dbManager.createPlotSafe(plot, success, failure);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ public class MySQL extends Database {
|
||||
public Connection forceConnection() throws SQLException, ClassNotFoundException {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
this.connection =
|
||||
DriverManager.getConnection("jdbc:mysql://" + this.hostname + ':' + this.port + '/' + this.database, this.user, this.password);
|
||||
DriverManager.getConnection("jdbc:mysql://" + this.hostname + ':' + this.port + '/' + this.database + "?useSSL=false", this.user, this.password);
|
||||
return this.connection;
|
||||
}
|
||||
|
||||
@ -55,9 +55,9 @@ public class MySQL extends Database {
|
||||
return this.connection;
|
||||
}
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
PS.debug("jdbc:mysql://" + this.hostname + ':' + this.port + '/' + this.database);
|
||||
PS.debug("jdbc:mysql://" + this.hostname + ':' + this.port + '/' + this.database + "?useSSL=false");
|
||||
this.connection =
|
||||
DriverManager.getConnection("jdbc:mysql://" + this.hostname + ':' + this.port + '/' + this.database, this.user, this.password);
|
||||
DriverManager.getConnection("jdbc:mysql://" + this.hostname + ':' + this.port + '/' + this.database + "?useSSL=false", this.user, this.password);
|
||||
return this.connection;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.intellectualcrafters.plot.database;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -28,7 +29,6 @@ import java.sql.Timestamp;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@ -54,6 +54,7 @@ public class SQLManager implements AbstractDB {
|
||||
public final String CREATE_SETTINGS;
|
||||
public final String CREATE_TIERS;
|
||||
public final String CREATE_PLOT;
|
||||
public final String CREATE_PLOT_SAFE;
|
||||
public final String CREATE_CLUSTER;
|
||||
private final String prefix;
|
||||
// Private Final
|
||||
@ -117,16 +118,22 @@ public class SQLManager implements AbstractDB {
|
||||
this.CREATE_SETTINGS = "INSERT INTO `" + this.prefix + "plot_settings` (`plot_plot_id`) values ";
|
||||
this.CREATE_TIERS = "INSERT INTO `" + this.prefix + "plot_%tier%` (`plot_plot_id`, `user_uuid`) values ";
|
||||
this.CREATE_PLOT = "INSERT INTO `" + this.prefix + "plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`, `timestamp`) VALUES(?, ?, ?, ?, ?)";
|
||||
|
||||
if (mySQL) {
|
||||
this.CREATE_PLOT_SAFE = "INSERT IGNORE INTO `" + this.prefix + "plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`, `timestamp`) SELECT ?, ?, ?, ?, ? FROM DUAL WHERE NOT EXISTS (SELECT null FROM `" + this.prefix + "plot` WHERE `world` = ? AND `plot_id_x` = ? AND `plot_id_z` = ?)";
|
||||
} else {
|
||||
this.CREATE_PLOT_SAFE = "INSERT INTO `" + this.prefix + "plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`, `timestamp`) SELECT ?, ?, ?, ?, ? WHERE NOT EXISTS (SELECT null FROM `" + this.prefix + "plot` WHERE `world` = ? AND `plot_id_x` = ? AND `plot_id_z` = ?)";
|
||||
}
|
||||
this.CREATE_CLUSTER =
|
||||
"INSERT INTO `" + this.prefix + "cluster`(`pos1_x`, `pos1_z`, `pos2_x`, `pos2_z`, `owner`, `world`) VALUES(?, ?, ?, ?, ?, ?)";
|
||||
try {
|
||||
createTables();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
createTables();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
long last = System.currentTimeMillis();
|
||||
while (true) {
|
||||
if (SQLManager.this.closed) {
|
||||
@ -153,7 +160,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -164,6 +171,13 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
try {
|
||||
if (connection.isClosed()) {
|
||||
return false;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
return false;
|
||||
}
|
||||
try (PreparedStatement stmt = this.connection.prepareStatement("SELECT 1")) {
|
||||
stmt.executeQuery();
|
||||
return true;
|
||||
@ -298,7 +312,16 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
Runnable task = getGlobalTasks().remove();
|
||||
if (task != null) {
|
||||
task.run();
|
||||
try {
|
||||
task.run();
|
||||
} catch (Throwable e) {
|
||||
PS.debug("============ DATABASE ERROR ============");
|
||||
PS.debug("There was an error updating the database.");
|
||||
PS.debug(" - It will be correct on shutdown");
|
||||
PS.debug("========================================");
|
||||
e.printStackTrace();
|
||||
PS.debug("========================================");
|
||||
}
|
||||
}
|
||||
commit();
|
||||
return true;
|
||||
@ -313,27 +336,39 @@ public class SQLManager implements AbstractDB {
|
||||
PreparedStatement statement = null;
|
||||
UniqueStatement task = null;
|
||||
UniqueStatement lastTask = null;
|
||||
for (Entry<Plot, Queue<UniqueStatement>> entry : this.plotTasks.entrySet()) {
|
||||
Plot plot = entry.getKey();
|
||||
if (this.plotTasks.get(plot).isEmpty()) {
|
||||
this.plotTasks.remove(plot);
|
||||
continue;
|
||||
}
|
||||
task = this.plotTasks.get(plot).remove();
|
||||
count++;
|
||||
if (task != null) {
|
||||
if (task.method == null || !task.method.equals(method)) {
|
||||
if (statement != null) {
|
||||
lastTask.execute(statement);
|
||||
statement.close();
|
||||
}
|
||||
method = task.method;
|
||||
statement = task.get();
|
||||
Iterator<Entry<Plot, Queue<UniqueStatement>>> iter = this.plotTasks.entrySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
try {
|
||||
Entry<Plot, Queue<UniqueStatement>> entry = iter.next();
|
||||
Plot plot = entry.getKey();
|
||||
Queue<UniqueStatement> tasks = entry.getValue();
|
||||
if (tasks.isEmpty()) {
|
||||
iter.remove();
|
||||
continue;
|
||||
}
|
||||
task.set(statement);
|
||||
task.addBatch(statement);
|
||||
task = tasks.remove();
|
||||
count++;
|
||||
if (task != null) {
|
||||
if (task.method == null || !task.method.equals(method)) {
|
||||
if (statement != null) {
|
||||
lastTask.execute(statement);
|
||||
statement.close();
|
||||
}
|
||||
method = task.method;
|
||||
statement = task.get();
|
||||
}
|
||||
task.set(statement);
|
||||
task.addBatch(statement);
|
||||
}
|
||||
lastTask = task;
|
||||
} catch (Throwable e) {
|
||||
PS.debug("============ DATABASE ERROR ============");
|
||||
PS.debug("There was an error updating the database.");
|
||||
PS.debug(" - It will be correct on shutdown");
|
||||
PS.debug("========================================");
|
||||
e.printStackTrace();
|
||||
PS.debug("========================================");
|
||||
}
|
||||
lastTask = task;
|
||||
}
|
||||
if (statement != null && task != null) {
|
||||
task.execute(statement);
|
||||
@ -350,26 +385,35 @@ public class SQLManager implements AbstractDB {
|
||||
UniqueStatement task = null;
|
||||
UniqueStatement lastTask = null;
|
||||
for (Entry<UUID, Queue<UniqueStatement>> entry : this.playerTasks.entrySet()) {
|
||||
UUID uuid = entry.getKey();
|
||||
if (this.playerTasks.get(uuid).isEmpty()) {
|
||||
this.playerTasks.remove(uuid);
|
||||
continue;
|
||||
}
|
||||
task = this.playerTasks.get(uuid).remove();
|
||||
count++;
|
||||
if (task != null) {
|
||||
if (task.method == null || !task.method.equals(method)) {
|
||||
if (statement != null) {
|
||||
lastTask.execute(statement);
|
||||
statement.close();
|
||||
}
|
||||
method = task.method;
|
||||
statement = task.get();
|
||||
try {
|
||||
UUID uuid = entry.getKey();
|
||||
if (this.playerTasks.get(uuid).isEmpty()) {
|
||||
this.playerTasks.remove(uuid);
|
||||
continue;
|
||||
}
|
||||
task.set(statement);
|
||||
task.addBatch(statement);
|
||||
task = this.playerTasks.get(uuid).remove();
|
||||
count++;
|
||||
if (task != null) {
|
||||
if (task.method == null || !task.method.equals(method)) {
|
||||
if (statement != null) {
|
||||
lastTask.execute(statement);
|
||||
statement.close();
|
||||
}
|
||||
method = task.method;
|
||||
statement = task.get();
|
||||
}
|
||||
task.set(statement);
|
||||
task.addBatch(statement);
|
||||
}
|
||||
lastTask = task;
|
||||
} catch (Throwable e) {
|
||||
PS.debug("============ DATABASE ERROR ============");
|
||||
PS.debug("There was an error updating the database.");
|
||||
PS.debug(" - It will be correct on shutdown");
|
||||
PS.debug("========================================");
|
||||
e.printStackTrace();
|
||||
PS.debug("========================================");
|
||||
}
|
||||
lastTask = task;
|
||||
}
|
||||
if (statement != null && task != null) {
|
||||
task.execute(statement);
|
||||
@ -386,26 +430,35 @@ public class SQLManager implements AbstractDB {
|
||||
UniqueStatement task = null;
|
||||
UniqueStatement lastTask = null;
|
||||
for (Entry<PlotCluster, Queue<UniqueStatement>> entry : this.clusterTasks.entrySet()) {
|
||||
PlotCluster cluster = entry.getKey();
|
||||
if (this.clusterTasks.get(cluster).isEmpty()) {
|
||||
this.clusterTasks.remove(cluster);
|
||||
continue;
|
||||
}
|
||||
task = this.clusterTasks.get(cluster).remove();
|
||||
count++;
|
||||
if (task != null) {
|
||||
if (task.method == null || !task.method.equals(method)) {
|
||||
if (statement != null) {
|
||||
lastTask.execute(statement);
|
||||
statement.close();
|
||||
}
|
||||
method = task.method;
|
||||
statement = task.get();
|
||||
try {
|
||||
PlotCluster cluster = entry.getKey();
|
||||
if (this.clusterTasks.get(cluster).isEmpty()) {
|
||||
this.clusterTasks.remove(cluster);
|
||||
continue;
|
||||
}
|
||||
task.set(statement);
|
||||
task.addBatch(statement);
|
||||
task = this.clusterTasks.get(cluster).remove();
|
||||
count++;
|
||||
if (task != null) {
|
||||
if (task.method == null || !task.method.equals(method)) {
|
||||
if (statement != null) {
|
||||
lastTask.execute(statement);
|
||||
statement.close();
|
||||
}
|
||||
method = task.method;
|
||||
statement = task.get();
|
||||
}
|
||||
task.set(statement);
|
||||
task.addBatch(statement);
|
||||
}
|
||||
lastTask = task;
|
||||
} catch (Throwable e) {
|
||||
PS.debug("============ DATABASE ERROR ============");
|
||||
PS.debug("There was an error updating the database.");
|
||||
PS.debug(" - It will be correct on shutdown");
|
||||
PS.debug("========================================");
|
||||
e.printStackTrace();
|
||||
PS.debug("========================================");
|
||||
}
|
||||
lastTask = task;
|
||||
}
|
||||
if (statement != null && task != null) {
|
||||
task.execute(statement);
|
||||
@ -427,8 +480,13 @@ public class SQLManager implements AbstractDB {
|
||||
if (!this.plotTasks.isEmpty()) {
|
||||
this.plotTasks.clear();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} catch (Throwable e) {
|
||||
PS.debug("============ DATABASE ERROR ============");
|
||||
PS.debug("There was an error updating the database.");
|
||||
PS.debug(" - It will be correct on shutdown");
|
||||
PS.debug("========================================");
|
||||
e.printStackTrace();
|
||||
PS.debug("========================================");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -947,14 +1005,9 @@ public class SQLManager implements AbstractDB {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a plot.
|
||||
*
|
||||
* @param plot
|
||||
*/
|
||||
@Override
|
||||
public void createPlot(final Plot plot) {
|
||||
addPlotTask(plot, new UniqueStatement("createPlot") {
|
||||
public void createPlotSafe(final Plot plot, final Runnable success, final Runnable failure) {
|
||||
final long timestamp = plot.getTimestamp();
|
||||
addPlotTask(plot, new UniqueStatement("createPlotSafe_" + plot.hashCode()) {
|
||||
@Override
|
||||
public void set(PreparedStatement stmt) throws SQLException {
|
||||
stmt.setInt(1, plot.getId().x);
|
||||
@ -962,11 +1015,45 @@ public class SQLManager implements AbstractDB {
|
||||
stmt.setString(3, plot.owner.toString());
|
||||
stmt.setString(4, plot.getArea().toString());
|
||||
stmt.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
||||
stmt.setString(6, plot.getArea().toString());
|
||||
stmt.setInt(7, plot.getId().x);
|
||||
stmt.setInt(8, plot.getId().y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreparedStatement get() throws SQLException {
|
||||
return SQLManager.this.connection.prepareStatement(SQLManager.this.CREATE_PLOT);
|
||||
return SQLManager.this.connection.prepareStatement(SQLManager.this.CREATE_PLOT_SAFE, Statement.RETURN_GENERATED_KEYS );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(PreparedStatement statement) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBatch(PreparedStatement statement) throws SQLException {
|
||||
int inserted = statement.executeUpdate();
|
||||
if (inserted > 0) {
|
||||
try (ResultSet keys = statement.getGeneratedKeys()) {
|
||||
if (keys.next()) {
|
||||
plot.temp = keys.getInt(1);
|
||||
addPlotTask(plot, new UniqueStatement("createPlotAndSettings_settings_" + plot.hashCode()) {
|
||||
@Override
|
||||
public void set(PreparedStatement stmt) throws SQLException {
|
||||
stmt.setInt(1, getId(plot));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreparedStatement get() throws SQLException {
|
||||
return SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(?)");
|
||||
}
|
||||
});
|
||||
if (success != null) addNotifyTask(success);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (failure != null) failure.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1008,9 +1095,10 @@ public class SQLManager implements AbstractDB {
|
||||
@Override
|
||||
public void addBatch(PreparedStatement statement) throws SQLException {
|
||||
statement.executeUpdate();
|
||||
ResultSet keys = statement.getGeneratedKeys();
|
||||
if (keys.next()) {
|
||||
plot.temp = keys.getInt(1);
|
||||
try (ResultSet keys = statement.getGeneratedKeys()) {
|
||||
if (keys.next()) {
|
||||
plot.temp = keys.getInt(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -1022,8 +1110,7 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
@Override
|
||||
public PreparedStatement get() throws SQLException {
|
||||
return SQLManager.this.connection
|
||||
.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(?)");
|
||||
return SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(?)");
|
||||
}
|
||||
});
|
||||
addNotifyTask(whenDone);
|
||||
@ -1370,6 +1457,7 @@ public class SQLManager implements AbstractDB {
|
||||
*/
|
||||
@Override
|
||||
public void delete(final Plot plot) {
|
||||
PS.debug("Deleting plot... Id: " + plot.getId() + " World: " + plot.getWorldName() + " Owner: " + plot.owner + " Index: " + plot.temp);
|
||||
deleteSettings(plot);
|
||||
deleteDenied(plot);
|
||||
deleteHelpers(plot);
|
||||
@ -1397,6 +1485,7 @@ public class SQLManager implements AbstractDB {
|
||||
*/
|
||||
@Override
|
||||
public void createPlotSettings(final int id, Plot plot) {
|
||||
PS.debug("Creating plot... Id: " + plot.getId() + " World: " + plot.getWorldName() + " Owner: " + plot.owner + " Index: " + id);
|
||||
addPlotTask(plot, new UniqueStatement("createPlotSettings") {
|
||||
@Override
|
||||
public void set(PreparedStatement stmt) throws SQLException {
|
||||
@ -1665,7 +1754,15 @@ public class SQLManager implements AbstractDB {
|
||||
o = resultSet.getString("owner");
|
||||
user = uuids.get(o);
|
||||
if (user == null) {
|
||||
user = UUID.fromString(o);
|
||||
try {
|
||||
user = UUID.fromString(o);
|
||||
} catch (IllegalArgumentException e) {
|
||||
if (Settings.UUID.FORCE_LOWERCASE) {
|
||||
user = UUID.nameUUIDFromBytes(("OfflinePlayer:" + o.toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
} else {
|
||||
user = UUID.nameUUIDFromBytes(("OfflinePlayer:" + o).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
}
|
||||
uuids.put(o, user);
|
||||
}
|
||||
long time;
|
||||
@ -1677,24 +1774,21 @@ public class SQLManager implements AbstractDB {
|
||||
try {
|
||||
time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(parsable).getTime();
|
||||
} catch (ParseException e) {
|
||||
PS.debug("Could not parse date for plot: " + id + " (" + parsable + ")");
|
||||
PS.debug("Could not parse date for plot: #" + id + "(" + areaid + ";" + plot_id + ") (" + parsable + ")");
|
||||
time = System.currentTimeMillis() + id;
|
||||
}
|
||||
}
|
||||
Plot p = new Plot(plot_id, user, new HashSet<UUID>(), new HashSet<UUID>(), new HashSet<UUID>(), "", null, null, null,
|
||||
new boolean[]{false, false, false, false}, time, id);
|
||||
Plot p = new Plot(plot_id, user, new HashSet<UUID>(), new HashSet<UUID>(), new HashSet<UUID>(), "", null, null, null, new boolean[]{false, false, false, false}, time, id);
|
||||
HashMap<PlotId, Plot> map = newPlots.get(areaid);
|
||||
if (map != null) {
|
||||
Plot last = map.put(p.getId(), p);
|
||||
if (last != null) {
|
||||
map.put(last.getId(), last);
|
||||
if (Settings.Enabled_Components.DATABASE_PURGER) {
|
||||
toDelete.add(id);
|
||||
toDelete.add(last.temp);
|
||||
} else {
|
||||
PS.debug("&cPLOT " + id + " in `" + this.prefix
|
||||
+ "plot` is a duplicate. Delete this plot or set `auto-purge: true` in the settings.yml.");
|
||||
PS.debug("&cPLOT #" + id + "(" + last + ") in `" + this.prefix
|
||||
+ "plot` is a duplicate. Delete this plot or set `database-purger: true` in the settings.yml.");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
map = new HashMap<>();
|
||||
@ -1722,7 +1816,7 @@ public class SQLManager implements AbstractDB {
|
||||
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
||||
toDelete.add(id);
|
||||
} else {
|
||||
PS.debug("&cENTRY " + id + " in `plot_rating` does not exist. Create this plot or set `auto-purge: true` in the "
|
||||
PS.debug("&cENTRY #" + id + "(" + plot + ") in `plot_rating` does not exist. Create this plot or set `database-purger: true` in the "
|
||||
+ "settings.yml.");
|
||||
}
|
||||
}
|
||||
@ -1749,7 +1843,7 @@ public class SQLManager implements AbstractDB {
|
||||
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
||||
toDelete.add(id);
|
||||
} else {
|
||||
PS.debug("&cENTRY " + id + " in `plot_helpers` does not exist. Create this plot or set `auto-purge: true` in the settings"
|
||||
PS.debug("&cENTRY #" + id + "(" + plot + ") in `plot_helpers` does not exist. Create this plot or set `database-purger: true` in the settings"
|
||||
+ ".yml.");
|
||||
}
|
||||
}
|
||||
@ -1775,7 +1869,7 @@ public class SQLManager implements AbstractDB {
|
||||
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
||||
toDelete.add(id);
|
||||
} else {
|
||||
PS.debug("&cENTRY " + id + " in `plot_trusted` does not exist. Create this plot or set `auto-purge: true` in the settings"
|
||||
PS.debug("&cENTRY #" + id + "(" + plot + ") in `plot_trusted` does not exist. Create this plot or set `database-purger: true` in the settings"
|
||||
+ ".yml.");
|
||||
}
|
||||
}
|
||||
@ -1802,7 +1896,7 @@ public class SQLManager implements AbstractDB {
|
||||
toDelete.add(id);
|
||||
} else {
|
||||
PS.debug("&cENTRY " + id
|
||||
+ " in `plot_denied` does not exist. Create this plot or set `auto-purge: true` in the settings.yml.");
|
||||
+ " in `plot_denied` does not exist. Create this plot or set `database-purger: true` in the settings.yml.");
|
||||
}
|
||||
}
|
||||
deleteRows(toDelete, this.prefix + "plot_denied", "plot_plot_id");
|
||||
@ -1875,7 +1969,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
}
|
||||
if (exception) {
|
||||
PS.debug("&cPlot " + id + " | " + plot + " had an invalid flag. A fix has been attempted.");
|
||||
PS.debug("&cPlot #" + id + "(" + plot + ") | " + plot + " had an invalid flag. A fix has been attempted.");
|
||||
PS.debug("&c" + myflags);
|
||||
this.setFlags(plot, flags);
|
||||
}
|
||||
@ -1884,7 +1978,7 @@ public class SQLManager implements AbstractDB {
|
||||
toDelete.add(id);
|
||||
} else {
|
||||
PS.debug(
|
||||
"&cENTRY " + id + " in `plot_settings` does not exist. Create this plot or set `auto-purge: true` in the settings"
|
||||
"&cENTRY #" + id + "(" + plot + ") in `plot_settings` does not exist. Create this plot or set `database-purger: true` in the settings"
|
||||
+ ".yml.");
|
||||
}
|
||||
}
|
||||
@ -2033,38 +2127,53 @@ public class SQLManager implements AbstractDB {
|
||||
public void run() {
|
||||
if (!uniqueIds.isEmpty()) {
|
||||
try {
|
||||
ArrayList<Integer> uniqueIdsList = new ArrayList<Integer>(uniqueIds);
|
||||
String stmt_prefix = "";
|
||||
StringBuilder idstr2 = new StringBuilder("");
|
||||
for (Integer id : uniqueIds) {
|
||||
idstr2.append(stmt_prefix).append(id);
|
||||
stmt_prefix = " OR `id` = ";
|
||||
int size = uniqueIdsList.size();
|
||||
int packet = 990;
|
||||
int amount = size / packet;
|
||||
int count = 0;
|
||||
int last = -1;
|
||||
for (int j = 0; j <= amount; j++) {
|
||||
PS.debug("Purging " + (j * packet) + " / " + size);
|
||||
List<Integer> subList = uniqueIdsList.subList(j * packet, Math.min(size, (j + 1) * packet));
|
||||
if (subList.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
StringBuilder idstr2 = new StringBuilder("");
|
||||
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();
|
||||
}
|
||||
stmt_prefix = "";
|
||||
StringBuilder idstr = new StringBuilder();
|
||||
for (Integer id : uniqueIds) {
|
||||
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();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
PS.debug("&c[ERROR] FAILED TO PURGE PLOTS!");
|
||||
@ -2602,7 +2711,7 @@ public class SQLManager implements AbstractDB {
|
||||
if (cluster != null) {
|
||||
cluster.helpers.add(user);
|
||||
} else {
|
||||
PS.debug("&cCluster " + id + " in cluster_helpers does not exist. Please create the cluster or remove this entry.");
|
||||
PS.debug("&cCluster #" + id + "(" + cluster + ") in cluster_helpers does not exist. Please create the cluster or remove this entry.");
|
||||
}
|
||||
}
|
||||
// Getting invited
|
||||
@ -2619,7 +2728,7 @@ public class SQLManager implements AbstractDB {
|
||||
if (cluster != null) {
|
||||
cluster.invited.add(user);
|
||||
} else {
|
||||
PS.debug("&cCluster " + id + " in cluster_invited does not exist. Please create the cluster or remove this entry.");
|
||||
PS.debug("&cCluster #" + id + "(" + cluster + ") in cluster_invited does not exist. Please create the cluster or remove this entry.");
|
||||
}
|
||||
}
|
||||
resultSet = stmt.executeQuery("SELECT * FROM `" + this.prefix + "cluster_settings`");
|
||||
@ -2661,7 +2770,7 @@ public class SQLManager implements AbstractDB {
|
||||
for (String element : flags_string) {
|
||||
if (element.contains(":")) {
|
||||
String[] split = element.split(":");
|
||||
String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("<EFBFBD>", ",");
|
||||
String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("´", ",");
|
||||
Flag flag = FlagManager.getOrCreateFlag(split[0]);
|
||||
if (flag == null) {
|
||||
flag = new StringFlag(split[0]) {
|
||||
@ -2685,7 +2794,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
cluster.settings.flags = flags;
|
||||
} else {
|
||||
PS.debug("&cCluster " + id + " in cluster_settings does not exist. Please create the cluster or remove this entry.");
|
||||
PS.debug("&cCluster #" + id + "(" + cluster + ") in cluster_settings does not exist. Please create the cluster or remove this entry.");
|
||||
}
|
||||
}
|
||||
resultSet.close();
|
||||
@ -2715,7 +2824,7 @@ public class SQLManager implements AbstractDB {
|
||||
flag_string.append(',');
|
||||
}
|
||||
flag_string.append(flag.getKey().getName()).append(':')
|
||||
.append(flag.getKey().valueToString(flag.getValue()).replaceAll(":", "¯").replaceAll(",", "´"));
|
||||
.append(flag.getKey().valueToString(flag.getValue()).replaceAll(":", "\u00AF").replaceAll(",", "´"));
|
||||
i++;
|
||||
}
|
||||
addClusterTask(cluster, new UniqueStatement("setFlags") {
|
||||
@ -2935,13 +3044,8 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
@Override
|
||||
public void validateAllPlots(Set<Plot> toValidate) {
|
||||
try {
|
||||
if (this.connection.isClosed() || this.closed) {
|
||||
this.closed = false;
|
||||
this.connection = this.database.forceConnection();
|
||||
}
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
if (!isValid()) {
|
||||
reconnect();
|
||||
}
|
||||
PS.debug("$1All DB transactions during this session are being validated (This may take a while if corrections need to be made)");
|
||||
commit();
|
||||
|
@ -208,8 +208,12 @@ public class FlagManager {
|
||||
flags.put(flag.getKey(), flag.getValue());
|
||||
}
|
||||
return flags;
|
||||
} else if (flags == null) {
|
||||
return settings.flags;
|
||||
} else {
|
||||
flags.putAll(settings.flags);
|
||||
}
|
||||
return settings.flags;
|
||||
return flags;
|
||||
}
|
||||
|
||||
public static Map<Flag<?>, Object> getSettingFlags(PlotArea area, PlotSettings settings) {
|
||||
|
@ -54,6 +54,7 @@ public final class Flags {
|
||||
public static final BooleanFlag ICE_MELT = new BooleanFlag("ice-melt");
|
||||
public static final BooleanFlag FIRE_SPREAD = new BooleanFlag("fire-spread");
|
||||
public static final BooleanFlag BLOCK_BURN = new BooleanFlag("block-burn");
|
||||
public static final BooleanFlag ICE_FORM = new BooleanFlag("ice-form");
|
||||
public static final BooleanFlag BLOCK_IGNITION = new BooleanFlag("block-ignition");
|
||||
public static final BooleanFlag SOIL_DRY = new BooleanFlag("soil-dry");
|
||||
public static final StringListFlag BLOCKED_CMDS = new StringListFlag("blocked-cmds");
|
||||
|
@ -23,6 +23,19 @@ public class HybridGen extends IndependentPlotGenerator {
|
||||
return PS.imp().getPluginName();
|
||||
}
|
||||
|
||||
private void placeSchem(HybridPlotWorld world, ScopedLocalBlockQueue result, short relativeX, short relativeZ, int x, int z) {
|
||||
int minY = Math.min(world.PLOT_HEIGHT, world.ROAD_HEIGHT);
|
||||
char[] blocks = world.G_SCH.get(MathMan.pair(relativeX, relativeZ));
|
||||
if (blocks != null) {
|
||||
for (int y = 0; y < blocks.length; y++) {
|
||||
PlotBlock block = PlotBlock.get(blocks[y]);
|
||||
if (block != null) {
|
||||
result.setBlock(x, minY + y, z, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateChunk(ScopedLocalBlockQueue result, PlotArea settings, PseudoRandom random) {
|
||||
HybridPlotWorld hpw = (HybridPlotWorld) settings;
|
||||
@ -83,7 +96,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
||||
}
|
||||
}
|
||||
// generation
|
||||
HashMap<Integer, HashMap<Integer, PlotBlock>> sch = hpw.G_SCH;
|
||||
HashMap<Integer, char[]> sch = hpw.G_SCH;
|
||||
for (short x = 0; x < 16; x++) {
|
||||
if (gx[x]) {
|
||||
for (short z = 0; z < 16; z++) {
|
||||
@ -92,12 +105,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
||||
result.setBlock(x, y, z, hpw.ROAD_BLOCK);
|
||||
}
|
||||
if (hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||
HashMap<Integer, PlotBlock> map = sch.get(MathMan.pair(rx[x], rz[z]));
|
||||
if (map != null) {
|
||||
for (Entry<Integer, PlotBlock> entry : map.entrySet()) {
|
||||
result.setBlock(x, entry.getKey(), z, entry.getValue());
|
||||
}
|
||||
}
|
||||
placeSchem(hpw, result, rx[x], rz[z], x, z);
|
||||
}
|
||||
}
|
||||
} else if (wx[x]) {
|
||||
@ -108,12 +116,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
||||
result.setBlock(x, y, z, hpw.ROAD_BLOCK);
|
||||
}
|
||||
if (hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||
HashMap<Integer, PlotBlock> map = sch.get(MathMan.pair(rx[x], rz[z]));
|
||||
if (map != null) {
|
||||
for (Entry<Integer, PlotBlock> entry : map.entrySet()) {
|
||||
result.setBlock(x, entry.getKey(), z, entry.getValue());
|
||||
}
|
||||
}
|
||||
placeSchem(hpw, result, rx[x], rz[z], x, z);
|
||||
}
|
||||
} else {
|
||||
// wall
|
||||
@ -123,12 +126,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
||||
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||
result.setBlock(x, hpw.WALL_HEIGHT + 1, z, hpw.WALL_BLOCK);
|
||||
} else {
|
||||
HashMap<Integer, PlotBlock> map = sch.get(MathMan.pair(rx[x], rz[z]));
|
||||
if (map != null) {
|
||||
for (Entry<Integer, PlotBlock> entry : map.entrySet()) {
|
||||
result.setBlock(x, entry.getKey(), z, entry.getValue());
|
||||
}
|
||||
}
|
||||
placeSchem(hpw, result, rx[x], rz[z], x, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -140,12 +138,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
||||
result.setBlock(x, y, z, hpw.ROAD_BLOCK);
|
||||
}
|
||||
if (hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||
HashMap<Integer, PlotBlock> map = sch.get(MathMan.pair(rx[x], rz[z]));
|
||||
if (map != null) {
|
||||
for (Entry<Integer, PlotBlock> entry : map.entrySet()) {
|
||||
result.setBlock(x, entry.getKey(), z, entry.getValue());
|
||||
}
|
||||
}
|
||||
placeSchem(hpw, result, rx[x], rz[z], x, z);
|
||||
}
|
||||
} else if (wz[z]) {
|
||||
// wall
|
||||
@ -155,12 +148,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
||||
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||
result.setBlock(x, hpw.WALL_HEIGHT + 1, z, hpw.WALL_BLOCK);
|
||||
} else {
|
||||
HashMap<Integer, PlotBlock> map = sch.get(MathMan.pair(rx[x], rz[z]));
|
||||
if (map != null) {
|
||||
for (Entry<Integer, PlotBlock> entry : map.entrySet()) {
|
||||
result.setBlock(x, entry.getKey(), z, entry.getValue());
|
||||
}
|
||||
}
|
||||
placeSchem(hpw, result, rx[x], rz[z], x, z);
|
||||
}
|
||||
} else {
|
||||
// plot
|
||||
@ -169,13 +157,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
||||
}
|
||||
result.setBlock(x, hpw.PLOT_HEIGHT, z, hpw.TOP_BLOCK[random.random(hpw.TOP_BLOCK.length)]);
|
||||
if (hpw.PLOT_SCHEMATIC) {
|
||||
int pair = MathMan.pair(rx[x], rz[z]);
|
||||
HashMap<Integer, PlotBlock> map = sch.get(pair);
|
||||
if (map != null) {
|
||||
for (Entry<Integer, PlotBlock> entry : map.entrySet()) {
|
||||
result.setBlock(x, entry.getKey(), z, entry.getValue());
|
||||
}
|
||||
}
|
||||
placeSchem(hpw, result, rx[x], rz[z], x, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class HybridPlotManager extends ClassicPlotManager {
|
||||
|
||||
@ -74,6 +72,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
|
||||
private void createSchemAbs(HybridPlotWorld hpw, LocalBlockQueue queue, Location pos1, Location pos2, boolean clear) {
|
||||
int size = hpw.SIZE;
|
||||
int minY = Math.min(hpw.PLOT_HEIGHT, hpw.ROAD_HEIGHT);
|
||||
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
|
||||
short absX = (short) ((x - hpw.ROAD_OFFSET_X) % size);
|
||||
if (absX < 0) {
|
||||
@ -84,15 +83,13 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
if (absZ < 0) {
|
||||
absZ += size;
|
||||
}
|
||||
HashMap<Integer, PlotBlock> blocks = hpw.G_SCH.get(MathMan.pair(absX, absZ));
|
||||
if (clear) {
|
||||
for (short y = (short) 0; y <= hpw.SCHEMATIC_HEIGHT; y++) {
|
||||
queue.setBlock(x, y, z, 0);
|
||||
}
|
||||
}
|
||||
char[] blocks = hpw.G_SCH.get(MathMan.pair(absX, absZ));
|
||||
if (blocks != null) {
|
||||
for (Entry<Integer, PlotBlock> entry : blocks.entrySet()) {
|
||||
queue.setBlock(x, entry.getKey(), z, entry.getValue());
|
||||
for (int y = 0; y < blocks.length; y++) {
|
||||
PlotBlock block = PlotBlock.get(blocks[y]);
|
||||
if (block != null) {
|
||||
queue.setBlock(x, minY + y, z, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,11 +21,10 @@ import java.util.Map;
|
||||
public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
|
||||
public boolean ROAD_SCHEMATIC_ENABLED;
|
||||
public short SCHEMATIC_HEIGHT;
|
||||
public boolean PLOT_SCHEMATIC = false;
|
||||
public short PATH_WIDTH_LOWER;
|
||||
public short PATH_WIDTH_UPPER;
|
||||
public HashMap<Integer, HashMap<Integer, PlotBlock>> G_SCH;
|
||||
public HashMap<Integer, char[]> G_SCH;
|
||||
public HashMap<Integer, HashMap<Integer, CompoundTag>> G_SCH_STATE;
|
||||
|
||||
public HybridPlotWorld(String worldName, String id, IndependentPlotGenerator generator, PlotId min, PlotId max) {
|
||||
@ -186,6 +185,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
Schematic schematic3 = SchematicHandler.manager.getSchematic(schem3File);
|
||||
int shift = this.ROAD_WIDTH / 2;
|
||||
int oddshift = (this.ROAD_WIDTH & 1) == 0 ? 0 : 1;
|
||||
int minY = Math.min(PLOT_HEIGHT, ROAD_HEIGHT);
|
||||
if (schematic3 != null) {
|
||||
this.PLOT_SCHEMATIC = true;
|
||||
short[] ids = schematic3.getIds();
|
||||
@ -202,6 +202,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
if (w3 < this.PLOT_WIDTH) {
|
||||
centerShiftX = (this.PLOT_WIDTH - w3) / 2;
|
||||
}
|
||||
int startY = minY - PLOT_HEIGHT;
|
||||
for (short x = 0; x < w3; x++) {
|
||||
for (short z = 0; z < l3; z++) {
|
||||
for (short y = 0; y < h3; y++) {
|
||||
@ -209,9 +210,9 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
short id = ids[index];
|
||||
byte data = datas[index];
|
||||
if (id != 0) {
|
||||
addOverlayBlock((short) (x + shift + oddshift + centerShiftX), (short) (y + this.PLOT_HEIGHT),
|
||||
addOverlayBlock((short) (x + shift + oddshift + centerShiftX), (short) (y + startY),
|
||||
(short) (z + shift + oddshift + centerShiftZ), id,
|
||||
data, false);
|
||||
data, false, h3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -256,7 +257,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
short w2 = (short) d2.getX();
|
||||
short l2 = (short) d2.getZ();
|
||||
short h2 = (short) d2.getY();
|
||||
this.SCHEMATIC_HEIGHT = (short) Math.max(h2, h1);
|
||||
int startY = minY - ROAD_HEIGHT;
|
||||
for (short x = 0; x < w1; x++) {
|
||||
for (short z = 0; z < l1; z++) {
|
||||
for (short y = 0; y < h1; y++) {
|
||||
@ -264,8 +265,8 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
short id = ids1[index];
|
||||
byte data = datas1[index];
|
||||
if (id != 0) {
|
||||
addOverlayBlock((short) (x - shift), (short) (y + this.ROAD_HEIGHT), (short) (z + shift + oddshift), id, data, false);
|
||||
addOverlayBlock((short) (z + shift + oddshift), (short) (y + this.ROAD_HEIGHT), (short) (x - shift), id, data, true);
|
||||
addOverlayBlock((short) (x - shift), (short) (y + startY), (short) (z + shift + oddshift), id, data, false, h1);
|
||||
addOverlayBlock((short) (z + shift + oddshift), (short) (y + startY), (short) (x - shift), id, data, true, h1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -277,14 +278,14 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
short id = ids2[index];
|
||||
byte data = datas2[index];
|
||||
if (id != 0) {
|
||||
addOverlayBlock((short) (x - shift), (short) (y + this.ROAD_HEIGHT), (short) (z - shift), id, data, false);
|
||||
addOverlayBlock((short) (x - shift), (short) (y + startY), (short) (z - shift), id, data, false, h2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addOverlayBlock(short x, short y, short z, short id, byte data, boolean rotate) {
|
||||
public void addOverlayBlock(short x, short y, short z, short id, byte data, boolean rotate, int height) {
|
||||
if (z < 0) {
|
||||
z += this.SIZE;
|
||||
}
|
||||
@ -298,11 +299,14 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
}
|
||||
}
|
||||
int pair = MathMan.pair(x, z);
|
||||
HashMap<Integer, PlotBlock> existing = this.G_SCH.get(pair);
|
||||
char[] existing = this.G_SCH.get(pair);
|
||||
if (existing == null) {
|
||||
existing = new HashMap<>();
|
||||
existing = new char[height];
|
||||
this.G_SCH.put(pair, existing);
|
||||
}
|
||||
existing.put((int) y, PlotBlock.get(id, data));
|
||||
if (id == 0) {
|
||||
data = 1;
|
||||
}
|
||||
existing[y] = (char) ((id << 4) + data);
|
||||
}
|
||||
}
|
||||
|
@ -21,16 +21,13 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.expiry.PlotAnalysis;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@ -96,7 +93,7 @@ public abstract class HybridUtils {
|
||||
}
|
||||
RegionWrapper region = zones.poll();
|
||||
final Runnable task = this;
|
||||
analyzeRegion(origin.getArea().worldname, region, new RunnableVal<PlotAnalysis>() {
|
||||
analyzeRegion(origin.getWorldName(), region, new RunnableVal<PlotAnalysis>() {
|
||||
@Override
|
||||
public void run(PlotAnalysis value) {
|
||||
analysis.add(value);
|
||||
@ -170,13 +167,13 @@ public abstract class HybridUtils {
|
||||
return;
|
||||
}
|
||||
RegionWrapper region = zones.poll();
|
||||
Location pos1 = new Location(plot.getArea().worldname, region.minX, region.minY, region.minZ);
|
||||
Location pos2 = new Location(plot.getArea().worldname, region.maxX, region.maxY, region.maxZ);
|
||||
Location pos1 = new Location(plot.getWorldName(), region.minX, region.minY, region.minZ);
|
||||
Location pos2 = new Location(plot.getWorldName(), region.maxX, region.maxY, region.maxZ);
|
||||
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
||||
@Override
|
||||
public void run(int[] value) {
|
||||
ChunkLoc loc = new ChunkLoc(value[0], value[1]);
|
||||
ChunkManager.manager.loadChunk(plot.getArea().worldname, loc, false);
|
||||
ChunkManager.manager.loadChunk(plot.getWorldName(), loc, false);
|
||||
int bx = value[2];
|
||||
int bz = value[3];
|
||||
int ex = value[4];
|
||||
@ -254,7 +251,7 @@ public abstract class HybridUtils {
|
||||
}
|
||||
if (!chunks.isEmpty()) {
|
||||
long diff = System.currentTimeMillis() + 1;
|
||||
if (System.currentTimeMillis() - baseTime - last.get() > 2000 && last.get() != 0) {
|
||||
if (System.currentTimeMillis() - baseTime - last.get() > 2200 && last.get() != 0) {
|
||||
last.set(0);
|
||||
PS.debug(C.PREFIX.s() + "Detected low TPS. Rescheduling in 30s");
|
||||
Iterator<ChunkLoc> iterator = chunks.iterator();
|
||||
@ -317,7 +314,7 @@ public abstract class HybridUtils {
|
||||
}
|
||||
|
||||
public boolean setupRoadSchematic(Plot plot) {
|
||||
final String world = plot.getArea().worldname;
|
||||
final String world = plot.getWorldName();
|
||||
final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
|
||||
Location bot = plot.getBottomAbs().subtract(1, 0, 1);
|
||||
Location top = plot.getTopAbs();
|
||||
@ -378,7 +375,6 @@ public abstract class HybridUtils {
|
||||
int ex = x + 15;
|
||||
int ez = z + 15;
|
||||
HybridPlotWorld plotWorld = (HybridPlotWorld) area;
|
||||
extend = Math.min(extend, 255 - plotWorld.ROAD_HEIGHT - plotWorld.SCHEMATIC_HEIGHT);
|
||||
if (!plotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||
return false;
|
||||
}
|
||||
@ -436,13 +432,14 @@ public abstract class HybridUtils {
|
||||
condition = !gx || !gz || !lx || !lz;
|
||||
}
|
||||
if (condition) {
|
||||
HashMap<Integer, PlotBlock> blocks = plotWorld.G_SCH.get(MathMan.pair(absX, absZ));
|
||||
for (short y = (short) plotWorld.ROAD_HEIGHT; y <= plotWorld.ROAD_HEIGHT + plotWorld.SCHEMATIC_HEIGHT + extend; y++) {
|
||||
queue.setBlock(x + X + plotWorld.ROAD_OFFSET_X, y, z + Z + plotWorld.ROAD_OFFSET_Z, 0);
|
||||
}
|
||||
char[] blocks = plotWorld.G_SCH.get(MathMan.pair(absX, absZ));
|
||||
int minY = Math.min(plotWorld.PLOT_HEIGHT, plotWorld.ROAD_HEIGHT);
|
||||
if (blocks != null) {
|
||||
for (Entry<Integer, PlotBlock> entry : blocks.entrySet()) {
|
||||
queue.setBlock(x + X + plotWorld.ROAD_OFFSET_X, entry.getKey(), z + Z + plotWorld.ROAD_OFFSET_Z, entry.getValue());
|
||||
for (int y = 0; y < blocks.length; y++) {
|
||||
PlotBlock block = PlotBlock.get(blocks[y]);
|
||||
if (block != null) {
|
||||
queue.setBlock(x + X + plotWorld.ROAD_OFFSET_X, minY + y, z + Z + plotWorld.ROAD_OFFSET_Z, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
Iterator<RegionWrapper> iterator = regions.iterator();
|
||||
RegionWrapper region = iterator.next();
|
||||
iterator.remove();
|
||||
Location pos1 = new Location(plot.getArea().worldname, region.minX, region.minY, region.minZ);
|
||||
Location pos2 = new Location(plot.getArea().worldname, region.maxX, region.maxY, region.maxZ);
|
||||
Location pos1 = new Location(plot.getWorldName(), region.minX, region.minY, region.minZ);
|
||||
Location pos2 = new Location(plot.getWorldName(), region.maxX, region.maxY, region.maxZ);
|
||||
ChunkManager.manager.regenerateRegion(pos1, pos2, false, this);
|
||||
}
|
||||
};
|
||||
|
@ -60,7 +60,12 @@ public class ConsolePlayer extends PlotPlayer {
|
||||
public boolean hasPermission(String permission) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(String permission) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
PS.log(message);
|
||||
|
@ -12,6 +12,7 @@ import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.flag.Flags;
|
||||
import com.intellectualcrafters.plot.generator.SquarePlotWorld;
|
||||
import com.intellectualcrafters.plot.util.BO3Handler;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
@ -28,6 +29,7 @@ import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.expiry.ExpireManager;
|
||||
import com.intellectualcrafters.plot.util.expiry.PlotAnalysis;
|
||||
import com.plotsquared.listener.PlotListener;
|
||||
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.PathIterator;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
@ -45,7 +47,6 @@ import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* The plot class<br>
|
||||
@ -208,6 +209,10 @@ public class Plot {
|
||||
this.temp = temp;
|
||||
}
|
||||
|
||||
public String getWorldName() {
|
||||
return area.worldname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a plot from a string e.g. [area];[id]
|
||||
* @param defaultArea If no area is specified
|
||||
@ -389,16 +394,17 @@ public class Plot {
|
||||
if (this.owner == null || getDenied().contains(uuid)) {
|
||||
return false;
|
||||
}
|
||||
if (getTrusted().contains(uuid) || getTrusted().contains(DBFunc.everyone)) {
|
||||
return true;
|
||||
}
|
||||
if (isOwner(uuid)) {
|
||||
return true;
|
||||
}
|
||||
if (getMembers().contains(uuid) || getMembers().contains(DBFunc.everyone)) {
|
||||
if (isOnline()) {
|
||||
return true;
|
||||
}
|
||||
if (getMembers().contains(uuid)) {
|
||||
return isOnline();
|
||||
}
|
||||
if (getTrusted().contains(uuid) || getTrusted().contains(DBFunc.everyone)) {
|
||||
return true;
|
||||
}
|
||||
if (getMembers().contains(DBFunc.everyone)) {
|
||||
return isOnline();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -766,12 +772,11 @@ public class Plot {
|
||||
@Override
|
||||
public void run() {
|
||||
if (queue.isEmpty()) {
|
||||
AtomicInteger finished = new AtomicInteger(0);
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (RegionWrapper region : regions) {
|
||||
Location[] corners = region.getCorners(Plot.this.area.worldname);
|
||||
Location[] corners = region.getCorners(getWorldName());
|
||||
ChunkManager.manager.clearAllEntities(corners[0], corners[1]);
|
||||
}
|
||||
TaskManager.runTask(whenDone);
|
||||
@ -795,17 +800,7 @@ public class Plot {
|
||||
manager.clearPlot(Plot.this.area, current, this);
|
||||
}
|
||||
};
|
||||
if (!isMerged() && this.area.getRegion().equals(getLargestRegion())) {
|
||||
final LocalBlockQueue blockQueue = area.getQueue(false);
|
||||
ChunkManager.largeRegionTask(this.area.worldname, this.area.getRegion(), new RunnableVal<ChunkLoc>() {
|
||||
@Override
|
||||
public void run(ChunkLoc value) {
|
||||
blockQueue.regenChunk(value.x, value.z);
|
||||
}
|
||||
}, whenDone);
|
||||
} else {
|
||||
run.run();
|
||||
}
|
||||
run.run();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -816,6 +811,12 @@ public class Plot {
|
||||
*/
|
||||
public void setBiome(final String biome, final Runnable whenDone) {
|
||||
final ArrayDeque<RegionWrapper> regions = new ArrayDeque<>(this.getRegions());
|
||||
final int extendBiome;
|
||||
if (area instanceof SquarePlotWorld) {
|
||||
extendBiome = (((SquarePlotWorld) area).ROAD_WIDTH > 0) ? 1 : 0;
|
||||
} else {
|
||||
extendBiome = 0;
|
||||
}
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -825,15 +826,15 @@ public class Plot {
|
||||
return;
|
||||
}
|
||||
RegionWrapper region = regions.poll();
|
||||
Location pos1 = new Location(Plot.this.area.worldname, region.minX, region.minY, region.minZ);
|
||||
Location pos2 = new Location(Plot.this.area.worldname, region.maxX, region.maxY, region.maxZ);
|
||||
Location pos1 = new Location(getWorldName(), region.minX - extendBiome, region.minY, region.minZ - extendBiome);
|
||||
Location pos2 = new Location(getWorldName(), region.maxX + extendBiome, region.maxY, region.maxZ + extendBiome);
|
||||
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
||||
@Override
|
||||
public void run(int[] value) {
|
||||
ChunkLoc loc = new ChunkLoc(value[0], value[1]);
|
||||
ChunkManager.manager.loadChunk(Plot.this.area.worldname, loc, false);
|
||||
MainUtil.setBiome(Plot.this.area.worldname, value[2], value[3], value[4], value[5], biome);
|
||||
ChunkManager.manager.unloadChunk(Plot.this.area.worldname, loc, true, true);
|
||||
ChunkManager.manager.loadChunk(getWorldName(), loc, false);
|
||||
MainUtil.setBiome(getWorldName(), value[2], value[3], value[4], value[5], biome);
|
||||
ChunkManager.manager.unloadChunk(getWorldName(), loc, true, true);
|
||||
}
|
||||
}, this, 5);
|
||||
|
||||
@ -910,6 +911,7 @@ public class Plot {
|
||||
* @param name
|
||||
*/
|
||||
public void setSign(final String name) {
|
||||
if (!isLoaded()) return;
|
||||
if (!PS.get().isMainThread(Thread.currentThread())) {
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
@ -928,10 +930,14 @@ public class Plot {
|
||||
C.OWNER_SIGN_LINE_2.formatted().replaceAll("%id%", id).replaceAll("%plr%", name),
|
||||
C.OWNER_SIGN_LINE_3.formatted().replaceAll("%id%", id).replaceAll("%plr%", name),
|
||||
C.OWNER_SIGN_LINE_4.formatted().replaceAll("%id%", id).replaceAll("%plr%", name)};
|
||||
WorldUtil.IMP.setSign(this.area.worldname, loc.getX(), loc.getY(), loc.getZ(), lines);
|
||||
WorldUtil.IMP.setSign(this.getWorldName(), loc.getX(), loc.getY(), loc.getZ(), lines);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isLoaded() {
|
||||
return WorldUtil.IMP.isWorld(getWorldName());
|
||||
}
|
||||
|
||||
/**
|
||||
* This will return null if the plot hasn't been analyzed
|
||||
* @return analysis of plot
|
||||
@ -1084,11 +1090,15 @@ public class Plot {
|
||||
return false;
|
||||
}
|
||||
for (Plot current : getConnectedPlots()) {
|
||||
List<PlotPlayer> players = current.getPlayersInPlot();
|
||||
for (PlotPlayer pp : players) {
|
||||
PlotListener.plotExit(pp, current);
|
||||
}
|
||||
getArea().removePlot(getId());
|
||||
DBFunc.delete(current);
|
||||
current.owner = null;
|
||||
current.settings = null;
|
||||
for (PlotPlayer pp : current.getPlayersInPlot()) {
|
||||
for (PlotPlayer pp : players) {
|
||||
PlotListener.plotEntry(pp, current);
|
||||
}
|
||||
}
|
||||
@ -1108,9 +1118,13 @@ public class Plot {
|
||||
Location[] corners = getCorners();
|
||||
Location top = corners[0];
|
||||
Location bot = corners[1];
|
||||
Location loc = new Location(this.area.worldname, MathMan.average(bot.getX(), top.getX()), MathMan.average(bot.getY(), top.getY()), MathMan.average(bot.getZ(), top.getZ()));
|
||||
loc.setY(1 + Math.max(WorldUtil.IMP.getHighestBlock(this.area.worldname, loc.getX(), loc.getZ()),
|
||||
getManager().getSignLoc(this.area, this).getY()));
|
||||
Location loc = new Location(this.getWorldName(), MathMan.average(bot.getX(), top.getX()), MathMan.average(bot.getY(), top.getY()), MathMan.average(bot.getZ(), top.getZ()));
|
||||
if (!isLoaded()) return loc;
|
||||
int y = isLoaded() ? WorldUtil.IMP.getHighestBlock(getWorldName(), loc.getX(), loc.getZ()) : 64;
|
||||
if (area.ALLOW_SIGNS) {
|
||||
y = Math.max(y, getManager().getSignLoc(area, this).getY());
|
||||
}
|
||||
loc.setY(1 + y);
|
||||
return loc;
|
||||
}
|
||||
|
||||
@ -1119,8 +1133,11 @@ public class Plot {
|
||||
int x = (largest.maxX >> 1) - (largest.minX >> 1) + largest.minX;
|
||||
int z = largest.minZ - 1;
|
||||
PlotManager manager = getManager();
|
||||
int y = Math.max(WorldUtil.IMP.getHighestBlock(area.worldname, x, z), manager.getSignLoc(area, this).getY());
|
||||
return new Location(area.worldname, x, y + 1, z);
|
||||
int y = isLoaded() ? WorldUtil.IMP.getHighestBlock(getWorldName(), x, z) : 64;
|
||||
if (area.ALLOW_SIGNS) {
|
||||
y = Math.max(y, manager.getSignLoc(area, this).getY());
|
||||
}
|
||||
return new Location(getWorldName(), x, y + 1, z);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1134,8 +1151,9 @@ public class Plot {
|
||||
} else {
|
||||
Location bot = this.getBottomAbs();
|
||||
Location loc = new Location(bot.getWorld(), bot.getX() + home.x, bot.getY() + home.y, bot.getZ() + home.z, home.yaw, home.pitch);
|
||||
if (!isLoaded()) return loc;
|
||||
if (WorldUtil.IMP.getBlock(loc).id != 0) {
|
||||
loc.setY(Math.max(WorldUtil.IMP.getHighestBlock(this.area.worldname, loc.getX(), loc.getZ()), bot.getY()));
|
||||
loc.setY(Math.max(WorldUtil.IMP.getHighestBlock(this.getWorldName(), loc.getX(), loc.getZ()), bot.getY()));
|
||||
}
|
||||
return loc;
|
||||
}
|
||||
@ -1179,8 +1197,8 @@ public class Plot {
|
||||
x = bot.getX() + this.area.DEFAULT_HOME.x;
|
||||
z = bot.getZ() + this.area.DEFAULT_HOME.z;
|
||||
}
|
||||
int y = WorldUtil.IMP.getHighestBlock(plot.area.worldname, x, z);
|
||||
return new Location(plot.area.worldname, x, y + 1, z);
|
||||
int y = isLoaded() ? WorldUtil.IMP.getHighestBlock(plot.getWorldName(), x, z) : 64;
|
||||
return new Location(plot.getWorldName(), x, y + 1, z);
|
||||
}
|
||||
// Side
|
||||
return plot.getSide();
|
||||
@ -1263,7 +1281,7 @@ public class Plot {
|
||||
* This should not need to be called
|
||||
*/
|
||||
public void refreshChunks() {
|
||||
LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(area.worldname, false);
|
||||
LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(getWorldName(), false);
|
||||
HashSet<ChunkLoc> chunks = new HashSet<>();
|
||||
for (RegionWrapper region : Plot.this.getRegions()) {
|
||||
for (int x = region.minX >> 4; x <= region.maxX >> 4; x++) {
|
||||
@ -1283,7 +1301,7 @@ public class Plot {
|
||||
return;
|
||||
}
|
||||
Location loc = manager.getSignLoc(this.area, this);
|
||||
LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(area.worldname, false);
|
||||
LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(getWorldName(), false);
|
||||
queue.setBlock(loc.getX(), loc.getY(), loc.getZ(), 0);
|
||||
queue.flush();
|
||||
}
|
||||
@ -1312,9 +1330,17 @@ public class Plot {
|
||||
if (!canClaim(player)) {
|
||||
return false;
|
||||
}
|
||||
return claim(player, teleport, schematic, true);
|
||||
}
|
||||
|
||||
public boolean claim(final PlotPlayer player, boolean teleport, String schematic, boolean updateDB) {
|
||||
boolean result = EventUtil.manager.callClaim(player, this, false);
|
||||
if (!result || !create(player.getUUID(), true)) {
|
||||
return false;
|
||||
if (updateDB) {
|
||||
if (!result || (!create(player.getUUID(), true))) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
area.addPlot(this);
|
||||
}
|
||||
setSign(player.getName());
|
||||
MainUtil.sendMessage(player, C.CLAIMED);
|
||||
@ -1415,7 +1441,9 @@ public class Plot {
|
||||
* @return
|
||||
*/
|
||||
public Location getTopAbs() {
|
||||
return this.area.getPlotManager().getPlotTopLocAbs(this.area, this.id);
|
||||
Location top = this.area.getPlotManager().getPlotTopLocAbs(this.area, this.id);
|
||||
top.setWorld(getWorldName());
|
||||
return top;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1423,7 +1451,9 @@ public class Plot {
|
||||
* @return
|
||||
*/
|
||||
public Location getBottomAbs() {
|
||||
return this.area.getPlotManager().getPlotBottomLocAbs(this.area, this.id);
|
||||
Location loc = this.area.getPlotManager().getPlotBottomLocAbs(this.area, this.id);
|
||||
loc.setWorld(getWorldName());
|
||||
return loc;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1542,7 +1572,7 @@ public class Plot {
|
||||
if (!this.isMerged()) {
|
||||
return new Location[]{this.getBottomAbs(), this.getTopAbs()};
|
||||
}
|
||||
return MainUtil.getCorners(this.area.worldname, this.getRegions());
|
||||
return MainUtil.getCorners(this.getWorldName(), this.getRegions());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1557,8 +1587,8 @@ public class Plot {
|
||||
Plot other = this.getRelative(1);
|
||||
Location bot = other.getBottomAbs();
|
||||
Location top = this.getTopAbs();
|
||||
Location pos1 = new Location(this.area.worldname, top.getX(), 0, bot.getZ());
|
||||
Location pos2 = new Location(this.area.worldname, bot.getX(), 256, top.getZ());
|
||||
Location pos1 = new Location(this.getWorldName(), top.getX(), 0, bot.getZ());
|
||||
Location pos2 = new Location(this.getWorldName(), bot.getX(), 256, top.getZ());
|
||||
ChunkManager.manager.regenerateRegion(pos1, pos2, true, null);
|
||||
} else {
|
||||
this.area.getPlotManager().removeRoadEast(this.area, this);
|
||||
@ -1650,13 +1680,14 @@ public class Plot {
|
||||
return this.area + ";" + this.id.x + ";" + this.id.y;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove a denied player (use DBFunc as well)<br>
|
||||
* Using the * uuid will remove all users
|
||||
* @param uuid
|
||||
*/
|
||||
public boolean removeDenied(UUID uuid) {
|
||||
if (uuid == DBFunc.everyone) {
|
||||
if (uuid == DBFunc.everyone && !denied.contains(uuid)) {
|
||||
boolean result = false;
|
||||
for (UUID other : new HashSet<>(getDenied())) {
|
||||
result = rmvDenied(other) || result;
|
||||
@ -1683,7 +1714,7 @@ public class Plot {
|
||||
* @param uuid
|
||||
*/
|
||||
public boolean removeTrusted(UUID uuid) {
|
||||
if (uuid == DBFunc.everyone) {
|
||||
if (uuid == DBFunc.everyone && !trusted.contains(uuid)) {
|
||||
boolean result = false;
|
||||
for (UUID other : new HashSet<>(getTrusted())) {
|
||||
result = rmvTrusted(other) || result;
|
||||
@ -1713,7 +1744,7 @@ public class Plot {
|
||||
if (this.members == null) {
|
||||
return false;
|
||||
}
|
||||
if (uuid == DBFunc.everyone) {
|
||||
if (uuid == DBFunc.everyone && !members.contains(uuid)) {
|
||||
boolean result = false;
|
||||
for (UUID other : new HashSet<>(this.members)) {
|
||||
result = rmvMember(other) || result;
|
||||
@ -1979,7 +2010,7 @@ public class Plot {
|
||||
*/
|
||||
public boolean canClaim(PlotPlayer player) {
|
||||
PlotCluster cluster = this.getCluster();
|
||||
if (cluster != null) {
|
||||
if (cluster != null && player != null) {
|
||||
if (!cluster.isAdded(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.claim")) {
|
||||
return false;
|
||||
}
|
||||
@ -2000,9 +2031,14 @@ public class Plot {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Location loc = this.getManager().getSignLoc(this.area, this);
|
||||
ChunkManager.manager.loadChunk(loc.getWorld(), loc.getChunkLoc(), false);
|
||||
String[] lines = WorldUtil.IMP.getSign(loc);
|
||||
final Location loc = this.getManager().getSignLoc(this.area, this);
|
||||
String[] lines = TaskManager.IMP.sync(new RunnableVal<String[]>() {
|
||||
@Override
|
||||
public void run(String[] value) {
|
||||
ChunkManager.manager.loadChunk(loc.getWorld(), loc.getChunkLoc(), false);
|
||||
this.value = WorldUtil.IMP.getSign(loc);
|
||||
}
|
||||
});
|
||||
if (lines == null) {
|
||||
return null;
|
||||
}
|
||||
@ -2010,7 +2046,7 @@ public class Plot {
|
||||
for (int i = 4; i > 0; i--) {
|
||||
String caption = C.valueOf("OWNER_SIGN_LINE_" + i).s();
|
||||
int index = caption.indexOf("%plr%");
|
||||
if (index == -1) {
|
||||
if (index < 0) {
|
||||
continue;
|
||||
}
|
||||
String line = lines[i - 1];
|
||||
@ -2060,8 +2096,8 @@ public class Plot {
|
||||
Plot other = this.getRelative(2);
|
||||
Location bot = other.getBottomAbs();
|
||||
Location top = this.getTopAbs();
|
||||
Location pos1 = new Location(this.area.worldname, bot.getX(), 0, top.getZ());
|
||||
Location pos2 = new Location(this.area.worldname, top.getX(), 256, bot.getZ());
|
||||
Location pos1 = new Location(this.getWorldName(), bot.getX(), 0, top.getZ());
|
||||
Location pos2 = new Location(this.getWorldName(), top.getX(), 256, bot.getZ());
|
||||
ChunkManager.manager.regenerateRegion(pos1, pos2, true, null);
|
||||
} else {
|
||||
this.getManager().removeRoadSouth(this.area, this);
|
||||
@ -2545,7 +2581,7 @@ public class Plot {
|
||||
int x = (int) MathMan.inverseRound(coords[0]);
|
||||
int z = (int) MathMan.inverseRound(coords[1]);
|
||||
if (type != 4) {
|
||||
locs.add(new Location(this.area.worldname, x, 0, z));
|
||||
locs.add(new Location(this.getWorldName(), x, 0, z));
|
||||
}
|
||||
}
|
||||
return locs;
|
||||
@ -2623,6 +2659,12 @@ public class Plot {
|
||||
return this.getManager().setComponent(this.area, this.getId(), component, blocks);
|
||||
}
|
||||
|
||||
public int getDistanceFromOrigin() {
|
||||
Location bot = getManager().getPlotBottomLocAbs(this.area, id);
|
||||
Location top = getManager().getPlotTopLocAbs(this.area, id);
|
||||
return Math.max(Math.max(Math.abs(bot.getX()), Math.abs(bot.getZ())), Math.max(Math.abs(top.getX()), Math.abs(top.getZ())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand the world border to include the provided plot (if applicable).
|
||||
*/
|
||||
@ -2634,13 +2676,7 @@ public class Plot {
|
||||
if (border == Integer.MAX_VALUE) {
|
||||
return;
|
||||
}
|
||||
PlotId id = new PlotId(Math.abs(this.getId().x) + 1, Math.abs(this.getId().x) + 1);
|
||||
PlotManager manager = this.getManager();
|
||||
Location bot = manager.getPlotBottomLocAbs(this.area, id);
|
||||
Location top = manager.getPlotTopLocAbs(this.area, id);
|
||||
int botmax = Math.max(Math.abs(bot.getX()), Math.abs(bot.getZ()));
|
||||
int topmax = Math.max(Math.abs(top.getX()), Math.abs(top.getZ()));
|
||||
int max = Math.max(botmax, topmax);
|
||||
int max = getDistanceFromOrigin();
|
||||
if (max > border) {
|
||||
this.area.setMeta("worldBorder", max);
|
||||
}
|
||||
@ -2762,11 +2798,11 @@ public class Plot {
|
||||
}
|
||||
final Runnable task = this;
|
||||
RegionWrapper region = regions.poll();
|
||||
Location[] corners = region.getCorners(Plot.this.area.worldname);
|
||||
Location[] corners = region.getCorners(getWorldName());
|
||||
final Location pos1 = corners[0];
|
||||
final Location pos2 = corners[1];
|
||||
Location newPos = pos1.clone().add(offsetX, 0, offsetZ);
|
||||
newPos.setWorld(destination.area.worldname);
|
||||
newPos.setWorld(destination.getWorldName());
|
||||
ChunkManager.manager.copyRegion(pos1, pos2, newPos, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -2783,13 +2819,13 @@ public class Plot {
|
||||
return;
|
||||
}
|
||||
RegionWrapper region = regions.poll();
|
||||
Location[] corners = region.getCorners(Plot.this.area.worldname);
|
||||
Location[] corners = region.getCorners(getWorldName());
|
||||
Location pos1 = corners[0];
|
||||
Location pos2 = corners[1];
|
||||
Location pos3 = pos1.clone().add(offsetX, 0, offsetZ);
|
||||
Location pos4 = pos2.clone().add(offsetX, 0, offsetZ);
|
||||
pos3.setWorld(destination.area.worldname);
|
||||
pos4.setWorld(destination.area.worldname);
|
||||
pos3.setWorld(destination.getWorldName());
|
||||
pos4.setWorld(destination.getWorldName());
|
||||
ChunkManager.manager.swap(pos1, pos2, pos3, pos4, this);
|
||||
}
|
||||
};
|
||||
@ -2871,11 +2907,11 @@ public class Plot {
|
||||
return;
|
||||
}
|
||||
RegionWrapper region = regions.poll();
|
||||
Location[] corners = region.getCorners(Plot.this.area.worldname);
|
||||
Location[] corners = region.getCorners(getWorldName());
|
||||
Location pos1 = corners[0];
|
||||
Location pos2 = corners[1];
|
||||
Location newPos = pos1.clone().add(offsetX, 0, offsetZ);
|
||||
newPos.setWorld(destination.area.worldname);
|
||||
newPos.setWorld(destination.getWorldName());
|
||||
ChunkManager.manager.copyRegion(pos1, pos2, newPos, this);
|
||||
}
|
||||
};
|
||||
|
@ -13,14 +13,15 @@ import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.PlotGameMode;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.area.QuadMap;
|
||||
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@ -30,6 +31,7 @@ import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* @author Jesse Boyd
|
||||
@ -42,11 +44,12 @@ public abstract class PlotArea {
|
||||
public final int worldhash;
|
||||
private final PlotId min;
|
||||
private final PlotId max;
|
||||
private final ConcurrentHashMap<PlotId, Plot> plots = new ConcurrentHashMap<>();
|
||||
protected final ConcurrentHashMap<PlotId, Plot> plots = new ConcurrentHashMap<>();
|
||||
private final IndependentPlotGenerator generator;
|
||||
public int MAX_PLOT_MEMBERS = 128;
|
||||
public boolean AUTO_MERGE = false;
|
||||
public boolean ALLOW_SIGNS = true;
|
||||
public boolean MISC_SPAWN_UNOWNED = false;
|
||||
public boolean MOB_SPAWNING = false;
|
||||
public boolean MOB_SPAWNER_SPAWNING = false;
|
||||
public String PLOT_BIOME = "FOREST";
|
||||
@ -214,6 +217,7 @@ public abstract class PlotArea {
|
||||
this.TYPE = config.getInt("generator.type");
|
||||
}
|
||||
this.MOB_SPAWNING = config.getBoolean("natural_mob_spawning");
|
||||
this.MISC_SPAWN_UNOWNED = config.getBoolean("misc_spawn_unowned");
|
||||
this.MOB_SPAWNER_SPAWNING = config.getBoolean("mob_spawner_spawning");
|
||||
this.AUTO_MERGE = config.getBoolean("plot.auto_merge");
|
||||
this.MAX_PLOT_MEMBERS = config.getInt("limits.max-members");
|
||||
@ -234,7 +238,7 @@ public abstract class PlotArea {
|
||||
this.PLOT_CHAT = config.getBoolean("chat.enabled");
|
||||
this.WORLD_BORDER = config.getBoolean("world.border");
|
||||
this.MAX_BUILD_HEIGHT = config.getInt("world.max_height");
|
||||
this.MIN_BUILD_HEIGHT = config.getInt("min.max_height");
|
||||
this.MIN_BUILD_HEIGHT = config.getInt("world.min_height");
|
||||
|
||||
switch (config.getString("world.gamemode").toLowerCase()) {
|
||||
case "survival":
|
||||
@ -313,6 +317,7 @@ public abstract class PlotArea {
|
||||
public void saveConfiguration(ConfigurationSection config) {
|
||||
HashMap<String, Object> options = new HashMap<>();
|
||||
options.put("natural_mob_spawning", this.MOB_SPAWNING);
|
||||
options.put("misc_spawn_unowned", this.MISC_SPAWN_UNOWNED);
|
||||
options.put("mob_spawner_spawning", this.MOB_SPAWNER_SPAWNING);
|
||||
options.put("plot.auto_merge", this.AUTO_MERGE);
|
||||
options.put("plot.create_signs", this.ALLOW_SIGNS);
|
||||
@ -464,11 +469,14 @@ public abstract class PlotArea {
|
||||
}
|
||||
|
||||
public Set<Plot> getPlotsAbs(final UUID uuid) {
|
||||
if (uuid == null) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
final HashSet<Plot> myPlots = new HashSet<>();
|
||||
foreachPlotAbs(new RunnableVal<Plot>() {
|
||||
@Override
|
||||
public void run(Plot value) {
|
||||
if (value.owner.equals(uuid)) {
|
||||
if (uuid.equals(value.owner)) {
|
||||
myPlots.add(value);
|
||||
}
|
||||
}
|
||||
@ -595,6 +603,11 @@ public abstract class PlotArea {
|
||||
this.meta.put(key, value);
|
||||
}
|
||||
|
||||
public <T> T getMeta(String key, T def) {
|
||||
Object v = getMeta(key);
|
||||
return v == null ? def : (T) v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the metadata for a key<br>
|
||||
* <br>
|
||||
@ -649,6 +662,36 @@ public abstract class PlotArea {
|
||||
}
|
||||
return this.plots.put(plot.getId(), plot) == null;
|
||||
}
|
||||
|
||||
public Plot getNextFreePlot(PlotPlayer player, @Nullable PlotId start) {
|
||||
int plots;
|
||||
PlotId center;
|
||||
PlotId min = getMin();
|
||||
PlotId max = getMax();
|
||||
if (TYPE == 2) {
|
||||
center = new PlotId(MathMan.average(min.x, max.x), MathMan.average(min.y, max.y));
|
||||
plots = Math.max(max.x - min.x, max.y - min.y) + 1;
|
||||
if (start != null) start = new PlotId(start.x - center.x, start.y - center.y);
|
||||
} else {
|
||||
center = new PlotId(0, 0);
|
||||
plots = Integer.MAX_VALUE;
|
||||
}
|
||||
PlotId currentId = new PlotId(0, 0);
|
||||
for (int i = 0; i < plots; i++) {
|
||||
if (start == null) {
|
||||
start = getMeta("lastPlot", new PlotId(0, 0));
|
||||
} else {
|
||||
start = start.getNextId(1);
|
||||
}
|
||||
currentId = new PlotId(center.x + start.x, center.y + start.y);
|
||||
Plot plot = getPlotAbs(currentId);
|
||||
if (plot != null && plot.canClaim(player)) {
|
||||
setMeta("lastPlot", currentId);
|
||||
return plot;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean addPlotIfAbsent(Plot plot) {
|
||||
if (this.plots.putIfAbsent(plot.getId(), plot) == null) {
|
||||
@ -698,7 +741,7 @@ public abstract class PlotArea {
|
||||
public int getBorder() {
|
||||
Integer meta = (Integer) getMeta("worldBorder");
|
||||
if (meta != null) {
|
||||
int border = meta + 16;
|
||||
int border = meta + 1;
|
||||
if (border == 0) {
|
||||
return Integer.MAX_VALUE;
|
||||
} else {
|
||||
@ -737,10 +780,19 @@ public abstract class PlotArea {
|
||||
}
|
||||
|
||||
public boolean canClaim(PlotPlayer player, PlotId pos1, PlotId pos2) {
|
||||
if (pos1.x == pos2.x && pos1.y == pos2.y) {
|
||||
if (getOwnedPlot(pos1) != null) {
|
||||
return false;
|
||||
}
|
||||
Plot plot = getPlotAbs(pos1);
|
||||
if (plot == null) return false;
|
||||
return plot.canClaim(player);
|
||||
}
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
PlotId id = new PlotId(x, y);
|
||||
Plot plot = getPlotAbs(id);
|
||||
if (plot == null) return false;
|
||||
if (!plot.canClaim(player)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -21,6 +21,17 @@ public class PlotBlock {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public static PlotBlock get(char combinedId) {
|
||||
switch (combinedId) {
|
||||
case 0:
|
||||
return null;
|
||||
case 1:
|
||||
return get(0, 0);
|
||||
default:
|
||||
return get(combinedId >> 4, combinedId & 15);
|
||||
}
|
||||
}
|
||||
|
||||
public static PlotBlock get(int id, int data) {
|
||||
return Settings.Enabled_Components.BLOCK_CACHE && data > 0 ? CACHE[(id << 4) + data] : new PlotBlock((short) id, (byte) data);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class PlotId {
|
||||
if (string == null) {
|
||||
return null;
|
||||
}
|
||||
String[] parts = string.split(";");
|
||||
String[] parts = string.split("[;|,]");
|
||||
if (parts.length < 2) {
|
||||
return null;
|
||||
}
|
||||
@ -48,6 +48,35 @@ public class PlotId {
|
||||
return new PlotId(x, y);
|
||||
}
|
||||
|
||||
public PlotId getNextId(int step) {
|
||||
int absX = Math.abs(x);
|
||||
int absY = Math.abs(y);
|
||||
if (absX > absY) {
|
||||
if (x > 0) {
|
||||
return new PlotId(x, y + 1);
|
||||
} else {
|
||||
return new PlotId(x, y - 1);
|
||||
}
|
||||
} else if (absY > absX) {
|
||||
if (y > 0) {
|
||||
return new PlotId(x - 1, y);
|
||||
} else {
|
||||
return new PlotId(x + 1, y);
|
||||
}
|
||||
} else {
|
||||
if (x == y && x > 0) {
|
||||
return new PlotId(x, y + step);
|
||||
}
|
||||
if (x == absX) {
|
||||
return new PlotId(x, y + 1);
|
||||
}
|
||||
if (y == absY) {
|
||||
return new PlotId(x, y - 1);
|
||||
}
|
||||
return new PlotId(x + 1, y);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PlotId from the HashCode<br>
|
||||
* Note: Only accurate for small x,z values (short)
|
||||
@ -119,6 +148,12 @@ public class PlotId {
|
||||
return this.x + ";" + this.y;
|
||||
}
|
||||
|
||||
public String toCommaSeparatedString() {
|
||||
return this.x + "," + this.y;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The PlotId object caches the hashcode for faster mapping/fetching/sorting<br>
|
||||
* - Recalculation is required if the x/y values change
|
||||
|
@ -5,15 +5,19 @@ import com.intellectualcrafters.plot.commands.RequiredType;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.flag.Flags;
|
||||
import com.intellectualcrafters.plot.object.worlds.PlotAreaManager;
|
||||
import com.intellectualcrafters.plot.object.worlds.SinglePlotArea;
|
||||
import com.intellectualcrafters.plot.object.worlds.SinglePlotAreaManager;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.PlotGameMode;
|
||||
import com.intellectualcrafters.plot.util.PlotWeather;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.expiry.ExpireManager;
|
||||
import com.plotsquared.general.commands.CommandCaller;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@ -401,6 +405,21 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
||||
*/
|
||||
public void unregister() {
|
||||
Plot plot = getCurrentPlot();
|
||||
if (plot != null && Settings.Enabled_Components.PERSISTENT_META && plot.getArea() instanceof SinglePlotArea) {
|
||||
PlotId id = plot.getId();
|
||||
int x = id.x;
|
||||
int z = id.y;
|
||||
ByteBuffer buffer = ByteBuffer.allocate(13);
|
||||
buffer.putShort((short) x);
|
||||
buffer.putShort((short) z);
|
||||
Location loc = getLocation();
|
||||
buffer.putInt(loc.getX());
|
||||
buffer.put((byte) loc.getY());
|
||||
buffer.putInt(loc.getZ());
|
||||
setPersistentMeta("quitLoc", buffer.array());
|
||||
} else if (hasPersistentMeta("quitLoc")) {
|
||||
removePersistentMeta("quitLoc");
|
||||
}
|
||||
if (plot != null) {
|
||||
EventUtil.manager.callLeave(this, plot);
|
||||
}
|
||||
@ -471,6 +490,34 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
||||
@Override
|
||||
public void run(Map<String, byte[]> value) {
|
||||
PlotPlayer.this.metaMap = value;
|
||||
if (!value.isEmpty()) {
|
||||
if (Settings.Enabled_Components.PERSISTENT_META) {
|
||||
PlotAreaManager manager = PS.get().getPlotAreaManager();
|
||||
if (manager instanceof SinglePlotAreaManager) {
|
||||
PlotArea area = ((SinglePlotAreaManager) manager).getArea();
|
||||
byte[] arr = PlotPlayer.this.getPersistentMeta("quitLoc");
|
||||
if (arr != null && getMeta("teleportOnLogin", true)) {
|
||||
ByteBuffer quitWorld = ByteBuffer.wrap(arr);
|
||||
PlotId id = new PlotId(quitWorld.getShort(), quitWorld.getShort());
|
||||
int x = quitWorld.getInt();
|
||||
int y = quitWorld.get() & 0xFF;
|
||||
int z = quitWorld.getInt();
|
||||
Plot plot = area.getOwnedPlot(id);
|
||||
if (plot != null && plot.isLoaded()) {
|
||||
final Location loc = new Location(plot.getWorldName(), x, y, z);
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object o) {
|
||||
if (getMeta("teleportOnLogin", true)) {
|
||||
teleport(loc);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -0,0 +1,244 @@
|
||||
package com.intellectualcrafters.plot.object.worlds;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.area.QuadMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class DefaultPlotAreaManager implements PlotAreaManager {
|
||||
|
||||
// All plot areas
|
||||
private PlotArea[] plotAreas = new PlotArea[0];
|
||||
// All plot areas mapped by world
|
||||
private final HashMap<String, PlotArea[]> plotAreaMap = new HashMap<>();
|
||||
// All plot areas mapped by position
|
||||
private final HashMap<String, QuadMap<PlotArea>> plotAreaGrid = new HashMap<>();
|
||||
// Optimization if there are no hash collisions
|
||||
private boolean plotAreaHasCollision = false;
|
||||
private final HashSet<Integer> plotAreaHashCheck = new HashSet<>();
|
||||
protected final PlotArea[] noPlotAreas = new PlotArea[0];
|
||||
private String[] worlds = new String[0];
|
||||
|
||||
@Override
|
||||
public PlotArea[] getAllPlotAreas() {
|
||||
return plotAreas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotArea getApplicablePlotArea(Location location) {
|
||||
switch (this.plotAreas.length) {
|
||||
case 0:
|
||||
return null;
|
||||
case 1:
|
||||
return this.plotAreas[0];
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
String world = location.getWorld();
|
||||
int hash = world.hashCode();
|
||||
for (PlotArea area : this.plotAreas) {
|
||||
if (hash == area.worldhash) {
|
||||
if (area.contains(location.getX(), location.getZ()) && (!this.plotAreaHasCollision || world.equals(area.worldname))) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
default:
|
||||
PlotArea[] areas = this.plotAreaMap.get(location.getWorld());
|
||||
if (areas == null) {
|
||||
return null;
|
||||
}
|
||||
int y;
|
||||
int x;
|
||||
switch (areas.length) {
|
||||
case 1:
|
||||
return areas[0];
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
x = location.getX();
|
||||
y = location.getY();
|
||||
for (PlotArea area : areas) {
|
||||
if (area.contains(x, y)) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
default:
|
||||
QuadMap<PlotArea> search = this.plotAreaGrid.get(location.getWorld());
|
||||
return search.get(location.getX(), location.getZ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlotArea(PlotArea plotArea) {
|
||||
HashSet<PlotArea> localAreas = new HashSet<>(Arrays.asList(getPlotAreas(plotArea.worldname, null)));
|
||||
HashSet<PlotArea> globalAreas = new HashSet<>(Arrays.asList(plotAreas));
|
||||
localAreas.add(plotArea);
|
||||
globalAreas.add(plotArea);
|
||||
this.plotAreas = globalAreas.toArray(new PlotArea[globalAreas.size()]);
|
||||
this.plotAreaMap.put(plotArea.worldname, localAreas.toArray(new PlotArea[localAreas.size()]));
|
||||
QuadMap<PlotArea> map = this.plotAreaGrid.get(plotArea.worldname);
|
||||
if (map == null) {
|
||||
map = new QuadMap<PlotArea>(Integer.MAX_VALUE, 0, 0) {
|
||||
@Override
|
||||
public RegionWrapper getRegion(PlotArea value) {
|
||||
return value.getRegion();
|
||||
}
|
||||
};
|
||||
this.plotAreaGrid.put(plotArea.worldname, map);
|
||||
}
|
||||
map.add(plotArea);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlotArea(PlotArea area) {
|
||||
ArrayList<PlotArea> globalAreas = new ArrayList<PlotArea>(Arrays.asList(plotAreas));
|
||||
globalAreas.remove(area);
|
||||
this.plotAreas = globalAreas.toArray(new PlotArea[globalAreas.size()]);
|
||||
if (globalAreas.isEmpty()) {
|
||||
this.plotAreaMap.remove(area.worldname);
|
||||
this.plotAreaGrid.remove(area.worldname);
|
||||
} else {
|
||||
this.plotAreaMap.put(area.worldname, globalAreas.toArray(new PlotArea[globalAreas.size()]));
|
||||
this.plotAreaGrid.get(area.worldname).remove(area);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotArea getPlotArea(String world, String id) {
|
||||
PlotArea[] areas = this.plotAreaMap.get(world);
|
||||
if (areas == null) {
|
||||
return null;
|
||||
}
|
||||
if (areas.length == 1) {
|
||||
return areas[0];
|
||||
} else if (id == null) {
|
||||
return null;
|
||||
}
|
||||
for (PlotArea area : areas) {
|
||||
if (StringMan.isEqual(id, area.id)) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotArea getPlotArea(Location location) {
|
||||
switch (this.plotAreas.length) {
|
||||
case 0:
|
||||
return null;
|
||||
case 1:
|
||||
PlotArea pa = this.plotAreas[0];
|
||||
return pa.contains(location) ? pa : null;
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
String world = location.getWorld();
|
||||
int hash = world.hashCode();
|
||||
for (PlotArea area : this.plotAreas) {
|
||||
if (hash == area.worldhash) {
|
||||
if (area.contains(location.getX(), location.getZ()) && (!this.plotAreaHasCollision || world.equals(area.worldname))) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
default:
|
||||
PlotArea[] areas = this.plotAreaMap.get(location.getWorld());
|
||||
if (areas == null) {
|
||||
return null;
|
||||
}
|
||||
int x;
|
||||
int y;
|
||||
switch (areas.length) {
|
||||
case 0:
|
||||
PlotArea a = areas[0];
|
||||
return a.contains(location.getX(), location.getZ()) ? a : null;
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
x = location.getX();
|
||||
y = location.getY();
|
||||
for (PlotArea area : areas) {
|
||||
if (area.contains(x, y)) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
default:
|
||||
QuadMap<PlotArea> search = this.plotAreaGrid.get(location.getWorld());
|
||||
return search.get(location.getX(), location.getZ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotArea[] getPlotAreas(String world, RegionWrapper region) {
|
||||
if (region == null) {
|
||||
PlotArea[] areas = this.plotAreaMap.get(world);
|
||||
if (areas == null) {
|
||||
return noPlotAreas;
|
||||
}
|
||||
return areas;
|
||||
}
|
||||
QuadMap<PlotArea> areas = this.plotAreaGrid.get(world);
|
||||
if (areas == null) {
|
||||
return noPlotAreas;
|
||||
} else {
|
||||
Set<PlotArea> found = areas.get(region);
|
||||
return found.toArray(new PlotArea[found.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWorld(String worldName) {
|
||||
if (!this.plotAreaHasCollision && !this.plotAreaHashCheck.add(worldName.hashCode())) {
|
||||
this.plotAreaHasCollision = true;
|
||||
}
|
||||
Set<String> tmp = new LinkedHashSet<>();
|
||||
Collections.addAll(tmp, worlds);
|
||||
tmp.add(worldName);
|
||||
worlds = tmp.toArray(new String[tmp.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeWorld(String worldName) {
|
||||
Set<String> tmp = new LinkedHashSet<>();
|
||||
Collections.addAll(tmp, worlds);
|
||||
tmp.remove(worldName);
|
||||
worlds = tmp.toArray(new String[tmp.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAllWorlds() {
|
||||
return worlds;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.intellectualcrafters.plot.object.worlds;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
|
||||
public interface PlotAreaManager {
|
||||
public PlotArea getApplicablePlotArea(Location location);
|
||||
public PlotArea getPlotArea(Location location);
|
||||
public PlotArea getPlotArea(String world, String id);
|
||||
public PlotArea[] getPlotAreas(String world, RegionWrapper region);
|
||||
public PlotArea[] getAllPlotAreas();
|
||||
public String[] getAllWorlds();
|
||||
public void addPlotArea(PlotArea area);
|
||||
public void removePlotArea(PlotArea area);
|
||||
public void addWorld(String worldName);
|
||||
public void removeWorld(String worldName);
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package com.intellectualcrafters.plot.object.worlds;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SinglePlot extends Plot {
|
||||
public SinglePlot(PlotArea area, PlotId id, UUID owner) {
|
||||
super(area, id, owner);
|
||||
}
|
||||
|
||||
public SinglePlot(PlotArea area, PlotId id) {
|
||||
super(area, id);
|
||||
}
|
||||
|
||||
public SinglePlot(PlotArea area, PlotId id, UUID owner, int temp) {
|
||||
super(area, id, owner, temp);
|
||||
}
|
||||
|
||||
public SinglePlot(PlotId id, UUID owner, HashSet<UUID> trusted, HashSet<UUID> members, HashSet<UUID> denied, String alias, BlockLoc position, Collection<Flag> flags, PlotArea area, boolean[] merged, long timestamp, int temp) {
|
||||
super(id, owner, trusted, members, denied, alias, position, flags, area, merged, timestamp, temp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWorldName() {
|
||||
return getId().toCommaSeparatedString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SinglePlotArea getArea() {
|
||||
return (SinglePlotArea) super.getArea();
|
||||
}
|
||||
|
||||
public boolean teleportPlayer(final PlotPlayer player) {
|
||||
if (isLoaded()) {
|
||||
return super.teleportPlayer(player);
|
||||
} else {
|
||||
C.NOT_LOADED.send(player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getSide() {
|
||||
return getCenter();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isLoaded() {
|
||||
getArea().loadWorld(getId());
|
||||
return super.isLoaded();
|
||||
}
|
||||
private HashSet<RegionWrapper> regions;
|
||||
{
|
||||
regions = new HashSet<>();
|
||||
regions.add(new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashSet<RegionWrapper> getRegions() {
|
||||
return regions;
|
||||
}
|
||||
|
||||
// getCenter getSide getHome getDefaultHome getBiome
|
||||
}
|
@ -0,0 +1,151 @@
|
||||
package com.intellectualcrafters.plot.object.worlds;
|
||||
|
||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.plot.config.Configuration;
|
||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||
import com.intellectualcrafters.plot.generator.GridPlotWorld;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotSettings;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
|
||||
public class SinglePlotArea extends GridPlotWorld {
|
||||
|
||||
private final SinglePlotArea instance;
|
||||
public boolean VOID = false;
|
||||
|
||||
public SinglePlotArea() {
|
||||
super("*", null, new SingleWorldGenerator(), null, null);
|
||||
instance = this;
|
||||
this.ALLOW_SIGNS = false;
|
||||
this.DEFAULT_HOME = new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadConfiguration(ConfigurationSection config) {
|
||||
VOID = config.getBoolean("void", false);
|
||||
}
|
||||
|
||||
public void loadWorld(final PlotId id) {
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
String worldName = id.toCommaSeparatedString();
|
||||
if (WorldUtil.IMP.isWorld(worldName)) return;
|
||||
SetupObject setup = new SetupObject();
|
||||
setup.plotManager = "PlotSquared:single";
|
||||
setup.setupGenerator = "PlotSquared:single";
|
||||
setup.type = 0;
|
||||
setup.terrain = 0;
|
||||
setup.step = new ConfigurationNode[0];
|
||||
setup.world = worldName;
|
||||
SetupUtils.manager.setupWorld(setup);
|
||||
}
|
||||
});
|
||||
// String worldName = plot.getWorldName();
|
||||
// World world = Bukkit.getWorld(worldName);
|
||||
// if (world != null) {
|
||||
// return world;
|
||||
// }
|
||||
// WorldCreator wc = new WorldCreator(worldName);
|
||||
// wc.generator("PlotSquared:single");
|
||||
// wc.environment(World.Environment.NORMAL);
|
||||
// wc.type(WorldType.FLAT);
|
||||
// return AsyncWorld.create(wc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ConfigurationNode[] getSettingNodes() {
|
||||
return new ConfigurationNode[] {
|
||||
new ConfigurationNode("void", this.VOID, "Void world", Configuration.BOOLEAN) };
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plot getOwnedPlot(Location location) {
|
||||
PlotId pid = PlotId.fromString(location.getWorld());
|
||||
if (pid == null) {
|
||||
return null;
|
||||
}
|
||||
Plot plot = this.plots.get(pid);
|
||||
return plot == null ? null : plot.getBasePlot(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plot getOwnedPlotAbs(Location location) {
|
||||
PlotId pid = PlotId.fromString(location.getWorld());
|
||||
if (pid == null) {
|
||||
return null;
|
||||
}
|
||||
return plots.get(pid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plot getPlot(Location location) {
|
||||
PlotId pid = PlotId.fromString(location.getWorld());
|
||||
if (pid == null) {
|
||||
return null;
|
||||
}
|
||||
return getPlot(pid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plot getPlotAbs(Location location) {
|
||||
PlotId pid = PlotId.fromString(location.getWorld());
|
||||
if (pid == null) {
|
||||
return null;
|
||||
}
|
||||
return getPlotAbs(pid);
|
||||
}
|
||||
|
||||
public boolean addPlot(Plot plot) {
|
||||
plot = adapt(plot);
|
||||
return super.addPlot(plot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPlotAbs(Plot plot) {
|
||||
plot = adapt(plot);
|
||||
return super.addPlotAbs(plot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPlotIfAbsent(Plot plot) {
|
||||
plot = adapt(plot);
|
||||
return super.addPlotIfAbsent(plot);
|
||||
}
|
||||
|
||||
protected Plot adapt(Plot p) {
|
||||
if (p instanceof SinglePlot) {
|
||||
return p;
|
||||
}
|
||||
PlotSettings s = p.getSettings();
|
||||
p = new SinglePlot(p.getId(), p.owner, p.getTrusted(), p.getMembers(), p.getDenied(), s.alias, s.getPosition(), null, this, s.merged, p.getTimestamp(), p.temp);
|
||||
p.getSettings().flags = s.flags;
|
||||
return p;
|
||||
}
|
||||
|
||||
public Plot getPlotAbs(PlotId id) {
|
||||
Plot plot = getOwnedPlotAbs(id);
|
||||
if (plot == null) {
|
||||
return new SinglePlot(this, id);
|
||||
}
|
||||
return plot;
|
||||
}
|
||||
|
||||
public Plot getPlot(PlotId id) {
|
||||
// TODO
|
||||
Plot plot = getOwnedPlotAbs(id);
|
||||
if (plot == null) {
|
||||
return new SinglePlot(this, id);
|
||||
}
|
||||
return plot.getBasePlot(false);
|
||||
}
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
package com.intellectualcrafters.plot.object.worlds;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.util.ArrayUtil;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
|
||||
public class SinglePlotAreaManager extends DefaultPlotAreaManager {
|
||||
private SinglePlotArea area;
|
||||
private final SinglePlotArea[] array;
|
||||
private PlotArea[] all;
|
||||
|
||||
public SinglePlotAreaManager() {
|
||||
this.area = new SinglePlotArea();
|
||||
this.array = new SinglePlotArea[] { area };
|
||||
this.all = new PlotArea[] { area };
|
||||
SetupUtils.generators.put("PlotSquared:single", new SingleWorldGenerator().specify("CheckingPlotSquaredGenerator"));
|
||||
}
|
||||
|
||||
public SinglePlotArea getArea() {
|
||||
return area;
|
||||
}
|
||||
|
||||
public boolean isWorld(String id) {
|
||||
int mode = 0;
|
||||
char[] chars = id.toCharArray();
|
||||
if (chars.length == 1 && chars[0] == '*') {
|
||||
return true;
|
||||
}
|
||||
for (int i = 0; i < chars.length; i++) {
|
||||
char c = chars[i];
|
||||
switch (mode) {
|
||||
case 0:
|
||||
mode = 1;
|
||||
if (c == '-') {
|
||||
continue;
|
||||
}
|
||||
case 1:
|
||||
if ((c <= '/') || (c >= ':')) {
|
||||
if (c == ';' || c == ',') {
|
||||
mode = 2;
|
||||
continue;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
case 2:
|
||||
mode = 3;
|
||||
if (c == '-') {
|
||||
continue;
|
||||
}
|
||||
case 3:
|
||||
if ((c <= '/') || (c >= ':')) {
|
||||
return false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setArea(SinglePlotArea area) {
|
||||
this.area = area;
|
||||
array[0] = area;
|
||||
all = ArrayUtil.concatAll(super.getAllPlotAreas(), array);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotArea getApplicablePlotArea(Location location) {
|
||||
PlotArea found = super.getApplicablePlotArea(location);
|
||||
if (found != null) return found;
|
||||
String world = location.getWorld();
|
||||
return isWorld(world) || world.equals("*") || super.getAllPlotAreas().length == 0 ? area : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotArea getPlotArea(Location location) {
|
||||
PlotArea found = super.getPlotArea(location);
|
||||
if (found != null) return found;
|
||||
return isWorld(location.getWorld()) || location.getWorld().equals("*") ? area : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotArea getPlotArea(String world, String id) {
|
||||
PlotArea found = super.getPlotArea(world, id);
|
||||
if (found != null) return found;
|
||||
return isWorld(world) || world.equals("*") ? area : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotArea[] getPlotAreas(String world, RegionWrapper region) {
|
||||
PlotArea[] found = super.getPlotAreas(world, region);
|
||||
if (found != null && found.length != 0) return found;
|
||||
return isWorld(world) || world.equals("*") ? array : noPlotAreas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotArea[] getAllPlotAreas() {
|
||||
return all;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAllWorlds() {
|
||||
return super.getAllWorlds();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlotArea(PlotArea area) {
|
||||
if(area == this.area) {
|
||||
return;
|
||||
}
|
||||
super.addPlotArea(area);
|
||||
all = ArrayUtil.concatAll(super.getAllPlotAreas(), array);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlotArea(PlotArea area) {
|
||||
if (area == this.area) {
|
||||
throw new UnsupportedOperationException("Cannot remove base area!");
|
||||
}
|
||||
super.removePlotArea(area);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWorld(String worldName) {
|
||||
super.addWorld(worldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeWorld(String worldName) {
|
||||
super.removeWorld(worldName);
|
||||
}
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
package com.intellectualcrafters.plot.object.worlds;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SinglePlotManager extends PlotManager {
|
||||
@Override
|
||||
public PlotId getPlotIdAbs(PlotArea plotArea, int x, int y, int z) {
|
||||
return new PlotId(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotId getPlotId(PlotArea plotArea, int x, int y, int z) {
|
||||
return new PlotId(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getPlotBottomLocAbs(PlotArea plotArea, PlotId plotId) {
|
||||
return new Location(plotId.toCommaSeparatedString(), -30000000, 0, -30000000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getPlotTopLocAbs(PlotArea plotArea, PlotId plotId) {
|
||||
return new Location(plotId.toCommaSeparatedString(), 30000000, 0, 30000000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean clearPlot(PlotArea plotArea, Plot plot, Runnable whenDone) {
|
||||
SetupUtils.manager.unload(plot.getWorldName(), false);
|
||||
File worldFolder = new File(PS.get().IMP.getWorldContainer(), plot.getWorldName());
|
||||
MainUtil.deleteDirectory(worldFolder);
|
||||
if (whenDone != null) whenDone.run();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean claimPlot(PlotArea plotArea, Plot plot) {
|
||||
// TODO
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unclaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone) {
|
||||
if (whenDone != null) whenDone.run();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getSignLoc(PlotArea plotArea, Plot plot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlotComponents(PlotArea plotArea, PlotId plotId) {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setComponent(PlotArea plotArea, PlotId plotId, String component, PlotBlock[] blocks) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createRoadEast(PlotArea plotArea, Plot plot) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createRoadSouth(PlotArea plotArea, Plot plot) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createRoadSouthEast(PlotArea plotArea, Plot plot) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeRoadEast(PlotArea plotArea, Plot plot) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeRoadSouth(PlotArea plotArea, Plot plot) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeRoadSouthEast(PlotArea plotArea, Plot plot) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startPlotMerge(PlotArea plotArea, ArrayList<PlotId> plotIds) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startPlotUnlink(PlotArea plotArea, ArrayList<PlotId> plotIds) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean finishPlotMerge(PlotArea plotArea, ArrayList<PlotId> plotIds) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean finishPlotUnlink(PlotArea plotArea, ArrayList<PlotId> plotIds) {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.intellectualcrafters.plot.object.worlds;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.util.block.ScopedLocalBlockQueue;
|
||||
|
||||
public class SingleWorldGenerator extends IndependentPlotGenerator {
|
||||
private Location bedrock1 = new Location(null, 0, 0, 0);
|
||||
private Location bedrock2 = new Location(null, 15, 0, 15);
|
||||
private Location dirt1 = new Location(null, 0, 1, 0);
|
||||
private Location dirt2 = new Location(null, 15, 2, 15);
|
||||
private Location grass1 = new Location(null, 0, 3, 0);
|
||||
private Location grass2 = new Location(null, 15, 3, 15);
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "PlotSquared:single";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateChunk(ScopedLocalBlockQueue result, PlotArea settings, PseudoRandom random) {
|
||||
SinglePlotArea area = (SinglePlotArea) settings;
|
||||
if (area.VOID) {
|
||||
Location min = result.getMin();
|
||||
if (min.getX() == 0 && min.getZ() == 0) {
|
||||
result.setBlock(0, 0, 0, 7, 0);
|
||||
}
|
||||
} else {
|
||||
result.setCuboid(bedrock1, bedrock2, PlotBlock.get(7, 0));
|
||||
result.setCuboid(dirt1, dirt2, PlotBlock.get(3, 0));
|
||||
result.setCuboid(grass1, grass2, PlotBlock.get(2, 0));
|
||||
}
|
||||
result.fillBiome("PLAINS");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
|
||||
return ((SinglePlotAreaManager) PS.get().getPlotAreaManager()).getArea();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotManager getNewPlotManager() {
|
||||
return new SinglePlotManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(PlotArea area) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ArrayUtil {
|
||||
public static final <T> T[] concatAll(T[] first, T[]... rest) {
|
||||
int totalLength = first.length;
|
||||
for (T[] array : rest) {
|
||||
totalLength += array.length;
|
||||
}
|
||||
T[] result = Arrays.copyOf(first, totalLength);
|
||||
int offset = first.length;
|
||||
for (T[] array : rest) {
|
||||
System.arraycopy(array, 0, result, offset, array.length);
|
||||
offset += array.length;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@ -99,7 +99,7 @@ public class BO3Handler {
|
||||
}
|
||||
}
|
||||
for (ChunkLoc loc : chunks) {
|
||||
ChunkManager.manager.loadChunk(plot.getArea().worldname, loc, false);
|
||||
ChunkManager.manager.loadChunk(plot.getWorldName(), loc, false);
|
||||
}
|
||||
|
||||
boolean content = false;
|
||||
@ -115,7 +115,7 @@ public class BO3Handler {
|
||||
ChunkLoc loc = new ChunkLoc(X, Z);
|
||||
BO3 bo3 = map.get(loc);
|
||||
for (int y = 1; y < height; y++) {
|
||||
PlotBlock block = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, y, z));
|
||||
PlotBlock block = WorldUtil.IMP.getBlock(new Location(plot.getWorldName(), x, y, z));
|
||||
if (!contains(cpw.MAIN_BLOCK, block)) {
|
||||
if (bo3 == null) {
|
||||
bo3 = new BO3(alias, plotworld.worldname, loc);
|
||||
@ -125,7 +125,7 @@ public class BO3Handler {
|
||||
bo3.addBlock(xx, y - height - 1, zz, block);
|
||||
}
|
||||
}
|
||||
PlotBlock floor = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, height, z));
|
||||
PlotBlock floor = WorldUtil.IMP.getBlock(new Location(plot.getWorldName(), x, height, z));
|
||||
if (!contains(cpw.TOP_BLOCK, floor)) {
|
||||
if (bo3 == null) {
|
||||
bo3 = new BO3(alias, plotworld.worldname, loc);
|
||||
@ -135,7 +135,7 @@ public class BO3Handler {
|
||||
bo3.addBlock(xx, -1, zz, floor);
|
||||
}
|
||||
for (int y = height + 1; y < 256; y++) {
|
||||
PlotBlock block = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, y, z));
|
||||
PlotBlock block = WorldUtil.IMP.getBlock(new Location(plot.getWorldName(), x, y, z));
|
||||
if (block.id != 0) {
|
||||
if (bo3 == null) {
|
||||
bo3 = new BO3(alias, plotworld.worldname, loc);
|
||||
@ -265,7 +265,7 @@ public class BO3Handler {
|
||||
return false;
|
||||
}
|
||||
|
||||
File base = getBaseFile(plot.getArea().worldname);
|
||||
File base = getBaseFile(plot.getWorldName());
|
||||
try {
|
||||
List<String> lines = Files.readAllLines(base.toPath(), StandardCharsets.UTF_8);
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
|
@ -119,8 +119,8 @@ public abstract class ChunkManager {
|
||||
return;
|
||||
}
|
||||
RegionWrapper value = regions.remove(0);
|
||||
Location pos1 = new Location(plot.getArea().worldname, value.minX, 0, value.minZ);
|
||||
Location pos2 = new Location(plot.getArea().worldname, value.maxX, 0, value.maxZ);
|
||||
Location pos1 = new Location(plot.getWorldName(), value.minX, 0, value.minZ);
|
||||
Location pos2 = new Location(plot.getWorldName(), value.maxX, 0, value.maxZ);
|
||||
chunkTask(pos1, pos2, task, this, allocate);
|
||||
}
|
||||
};
|
||||
|
@ -16,7 +16,7 @@ public class CmdConfirm {
|
||||
|
||||
public static void addPending(final PlotPlayer player, String commandStr, final Runnable runnable) {
|
||||
removePending(player);
|
||||
MainUtil.sendMessage(player, C.REQUIRES_CONFIRM, commandStr);
|
||||
if (commandStr != null) MainUtil.sendMessage(player, C.REQUIRES_CONFIRM, commandStr);
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -70,10 +70,6 @@ public abstract class EventUtil {
|
||||
MainUtil.sendMessage(player, C.WORLDEDIT_BYPASSED);
|
||||
}
|
||||
}
|
||||
if (PS.get().update != null && Permissions.hasPermission(player, C.PERMISSION_ADMIN_UPDATE) && Settings.Enabled_Components.UPDATER) {
|
||||
MainUtil.sendMessage(player,C.CONSOLE_JAVA_OUTDATED_1_8.f(PS.get().IMP.getPluginName()));
|
||||
MainUtil.sendMessage(player, "&6An update for " + PS.imp().getPluginName() + " is available: &7/plot update");
|
||||
}
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
if (Settings.Teleport.ON_LOGIN && plot != null) {
|
||||
TaskManager.runTask(new Runnable() {
|
||||
|
@ -10,7 +10,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class HastebinUtility {
|
||||
|
||||
public static final String BIN_URL = "http://hastebin.com/documents", USER_AGENT = "Mozilla/5.0";
|
||||
public static final String BIN_URL = "https://hastebin.com/documents", USER_AGENT = "Mozilla/5.0";
|
||||
public static final Pattern PATTERN = Pattern.compile("\\{\"key\":\"([\\S\\s]*)\"\\}");
|
||||
|
||||
public static String upload(final String string) throws IOException {
|
||||
@ -38,12 +38,12 @@ public class HastebinUtility {
|
||||
|
||||
Matcher matcher = PATTERN.matcher(response.toString());
|
||||
if (matcher.matches()) {
|
||||
return "http://hastebin.com/" + matcher.group(1);
|
||||
return "https://hastebin.com/" + matcher.group(1);
|
||||
} else {
|
||||
throw new RuntimeException("Couldn't read response!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String upload(final File file) throws IOException {
|
||||
final StringBuilder content = new StringBuilder();
|
||||
List<String> lines = new ArrayList<>();
|
||||
|
@ -112,6 +112,15 @@ public class MainUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendAdmin(final String s) {
|
||||
for (final PlotPlayer player : UUIDHandler.getPlayers().values()) {
|
||||
if (player.hasPermission(C.PERMISSION_ADMIN.s())) {
|
||||
player.sendMessage(s);
|
||||
}
|
||||
}
|
||||
PS.debug(s);
|
||||
}
|
||||
|
||||
public static void upload(UUID uuid, String file, String extension, final RunnableVal<OutputStream> writeTask, final RunnableVal<URL> whenDone) {
|
||||
if (writeTask == null) {
|
||||
PS.debug("&cWrite task cannot be null");
|
||||
@ -130,7 +139,7 @@ public class MainUtil {
|
||||
}
|
||||
final URL url;
|
||||
try {
|
||||
url = new URL(Settings.Web.URL + "?key=" + uuid + "&ip=" + Settings.Web.SERVER_IP + "&type=" + extension);
|
||||
url = new URL(Settings.Web.URL + "?key=" + uuid + "&type=" + extension);
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
whenDone.run();
|
||||
@ -720,7 +729,7 @@ public class MainUtil {
|
||||
int num = plot.getConnectedPlots().size();
|
||||
String alias = !plot.getAlias().isEmpty() ? plot.getAlias() : C.NONE.s();
|
||||
Location bot = plot.getCorners()[0];
|
||||
String biome = WorldUtil.IMP.getBiome(plot.getArea().worldname, bot.getX(), bot.getZ());
|
||||
String biome = WorldUtil.IMP.getBiome(plot.getWorldName(), bot.getX(), bot.getZ());
|
||||
String trusted = getPlayerList(plot.getTrusted());
|
||||
String members = getPlayerList(plot.getMembers());
|
||||
String denied = getPlayerList(plot.getDenied());
|
||||
@ -800,6 +809,23 @@ public class MainUtil {
|
||||
whenDone.run(info);
|
||||
}
|
||||
|
||||
public static boolean deleteDirectory(File directory) {
|
||||
if (directory.exists()) {
|
||||
File[] files = directory.listFiles();
|
||||
if (null != files) {
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
File file = files[i];
|
||||
if (file.isDirectory()) {
|
||||
deleteDirectory(files[i]);
|
||||
} else {
|
||||
PS.debug("Deleting file: " + file + " | " + file.delete());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (directory.delete());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of names given a list of uuids.<br>
|
||||
* - Uses the format {@link C#PLOT_USER_LIST} for the returned string
|
||||
@ -811,13 +837,18 @@ public class MainUtil {
|
||||
if (l.size() < 1) {
|
||||
return C.NONE.s();
|
||||
}
|
||||
List<String> users = new ArrayList<>();
|
||||
for (UUID u : l) {
|
||||
users.add(getName(u));
|
||||
}
|
||||
Collections.sort(users);
|
||||
String c = C.PLOT_USER_LIST.s();
|
||||
StringBuilder list = new StringBuilder();
|
||||
for (int x = 0; x < l.size(); x++) {
|
||||
for (int x = 0; x < users.size(); x++) {
|
||||
if (x + 1 == l.size()) {
|
||||
list.append(c.replace("%user%", getName(l.get(x))).replace(",", ""));
|
||||
list.append(c.replace("%user%",users.get(x)).replace(",", ""));
|
||||
} else {
|
||||
list.append(c.replace("%user%", getName(l.get(x))));
|
||||
list.append(c.replace("%user%", users.get(x)));
|
||||
}
|
||||
}
|
||||
return list.toString();
|
||||
|
@ -13,7 +13,11 @@ import java.util.HashMap;
|
||||
* - Checking the PlotPlayer class directly will not take the above into account<br>
|
||||
*/
|
||||
public class Permissions {
|
||||
|
||||
|
||||
public static boolean hasPermission(PlotPlayer player, C caption, boolean notify) {
|
||||
return hasPermission(player, caption.s(), notify);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player has a permission (C class helps keep track of permissions).
|
||||
* @param player
|
||||
@ -56,7 +60,12 @@ public class Permissions {
|
||||
* @return
|
||||
*/
|
||||
public static boolean hasPermission(CommandCaller caller, String permission) {
|
||||
if (caller.hasPermission(permission) || caller.hasPermission(C.PERMISSION_ADMIN.s())) {
|
||||
if (caller.hasPermission(permission)) {
|
||||
return true;
|
||||
} else if (caller.isPermissionSet(permission)) {
|
||||
return false;
|
||||
}
|
||||
if (caller.hasPermission(C.PERMISSION_ADMIN.s())) {
|
||||
return true;
|
||||
}
|
||||
permission = permission.toLowerCase().replaceAll("^[^a-z|0-9|\\.|_|-]", "");
|
||||
@ -64,9 +73,12 @@ public class Permissions {
|
||||
StringBuilder n = new StringBuilder();
|
||||
for (int i = 0; i <= (nodes.length - 1); i++) {
|
||||
n.append(nodes[i] + ".");
|
||||
if (!permission.equals(n + C.PERMISSION_STAR.s())) {
|
||||
if (caller.hasPermission(n + C.PERMISSION_STAR.s())) {
|
||||
String combined = n + C.PERMISSION_STAR.s();
|
||||
if (!permission.equals(combined)) {
|
||||
if (caller.hasPermission(combined)) {
|
||||
return true;
|
||||
} else if (caller.isPermissionSet(combined)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -123,8 +123,6 @@ public abstract class SchematicHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Paste a schematic.
|
||||
*
|
||||
@ -185,14 +183,14 @@ public abstract class SchematicHandler {
|
||||
if (pw instanceof ClassicPlotWorld) {
|
||||
y_offset_actual = yOffset + ((ClassicPlotWorld) pw).PLOT_HEIGHT;
|
||||
} else {
|
||||
y_offset_actual = yOffset + MainUtil.getHeighestBlock(plot.getArea().worldname, region.minX + 1, region.minZ + 1);
|
||||
y_offset_actual = yOffset + MainUtil.getHeighestBlock(plot.getWorldName(), region.minX + 1, region.minZ + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
y_offset_actual = yOffset;
|
||||
}
|
||||
Location pos1 = new Location(plot.getArea().worldname, region.minX + xOffset, y_offset_actual, region.minZ + zOffset);
|
||||
Location pos1 = new Location(plot.getWorldName(), region.minX + xOffset, y_offset_actual, region.minZ + zOffset);
|
||||
Location pos2 = pos1.clone().add(WIDTH - 1, HEIGHT - 1, LENGTH - 1);
|
||||
// TODO switch to ChunkManager.chunkTask(pos1, pos2, task, whenDone, allocate);
|
||||
final int p1x = pos1.getX();
|
||||
@ -352,12 +350,10 @@ public abstract class SchematicHandler {
|
||||
|
||||
public Schematic getSchematic(CompoundTag tag) {
|
||||
Map<String, Tag> tagMap = tag.getValue();
|
||||
// Slow
|
||||
// byte[] addId = new byte[0];
|
||||
// if (tagMap.containsKey("AddBlocks")) {
|
||||
// addId = ByteArrayTag.class.cast(tagMap.get("AddBlocks")).getValue();
|
||||
// }
|
||||
// end slow
|
||||
byte[] addBlocks = null;
|
||||
if (tagMap.containsKey("AddBlocks")) {
|
||||
addBlocks = ByteArrayTag.class.cast(tagMap.get("AddBlocks")).getValue();
|
||||
}
|
||||
|
||||
short width = ShortTag.class.cast(tagMap.get("Width")).getValue();
|
||||
short length = ShortTag.class.cast(tagMap.get("Length")).getValue();
|
||||
@ -379,19 +375,26 @@ public abstract class SchematicHandler {
|
||||
}
|
||||
block[i] = id;
|
||||
}
|
||||
|
||||
// Slow + has code for exceptions (addId) inside the loop rather than outside
|
||||
// for (int index = 0; index < b.length; index++) {
|
||||
// if ((index >> 1) >= addId.length) {
|
||||
// blocks[index] = (short) (b[index] & 0xFF);
|
||||
// } else {
|
||||
// if ((index & 1) == 0) {
|
||||
// blocks[index] = (short) (((addId[index >> 1] & 0x0F) << 8) + (b[index] & 0xFF));
|
||||
// } else {
|
||||
// blocks[index] = (short) (((addId[index >> 1] & 0xF0) << 4) + (b[index] & 0xFF));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if (addBlocks != null) {
|
||||
if (addBlocks.length == block.length) {
|
||||
for (int i = 0; i < addBlocks.length; i++) {
|
||||
byte val = addBlocks[i];
|
||||
if (val != 0) {
|
||||
block[i] |= (val << 8);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int index = 0; index < block.length; index++) {
|
||||
if ((index & 1) == 0) {
|
||||
block[index] = (short) (((addBlocks[index >> 1] & 0x0F) << 8) + (block[index]));
|
||||
} else {
|
||||
block[index] = (short) (((addBlocks[index >> 1] & 0xF0) << 4) + (block[index]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Slow as wrapper for each block
|
||||
// final DataCollection[] collection = new DataCollection[b.length];
|
||||
// for (int x = 0; x < b.length; x++) {
|
||||
@ -597,7 +600,7 @@ public abstract class SchematicHandler {
|
||||
public abstract void getCompoundTag(String world, Set<RegionWrapper> regions, RunnableVal<CompoundTag> whenDone);
|
||||
|
||||
public void getCompoundTag(final Plot plot, final RunnableVal<CompoundTag> whenDone) {
|
||||
getCompoundTag(plot.getArea().worldname, plot.getRegions(), new RunnableVal<CompoundTag>() {
|
||||
getCompoundTag(plot.getWorldName(), plot.getRegions(), new RunnableVal<CompoundTag>() {
|
||||
@Override
|
||||
public void run(CompoundTag value) {
|
||||
if (!plot.getFlags().isEmpty()) {
|
||||
|
@ -3,7 +3,6 @@ package com.intellectualcrafters.plot.util;
|
||||
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public abstract class SetupUtils {
|
||||
@ -17,4 +16,6 @@ public abstract class SetupUtils {
|
||||
public abstract String getGenerator(final PlotArea plotArea);
|
||||
|
||||
public abstract String setupWorld(final SetupObject object);
|
||||
|
||||
public abstract void unload(String world, boolean save);
|
||||
}
|
||||
|
@ -279,4 +279,13 @@ public class StringMan {
|
||||
}
|
||||
return col;
|
||||
}
|
||||
|
||||
public static boolean contains(String name, char c) {
|
||||
for (char current : name.toCharArray()) {
|
||||
if (c == current) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@ -91,45 +91,79 @@ public class UUIDHandler {
|
||||
}
|
||||
|
||||
public static UUID getUUID(PlotPlayer player) {
|
||||
if (implementation == null) {
|
||||
return null;
|
||||
}
|
||||
return implementation.getUUID(player);
|
||||
}
|
||||
|
||||
public static UUID getUUID(OfflinePlotPlayer player) {
|
||||
if (implementation == null) {
|
||||
return null;
|
||||
}
|
||||
return implementation.getUUID(player);
|
||||
}
|
||||
|
||||
public static String getName(UUID uuid) {
|
||||
if (implementation == null) {
|
||||
return null;
|
||||
}
|
||||
return implementation.getName(uuid);
|
||||
}
|
||||
|
||||
public static PlotPlayer getPlayer(UUID uuid) {
|
||||
if (implementation == null) {
|
||||
return null;
|
||||
}
|
||||
return implementation.getPlayer(uuid);
|
||||
}
|
||||
|
||||
public static PlotPlayer getPlayer(String name) {
|
||||
if (implementation == null) {
|
||||
return null;
|
||||
}
|
||||
return implementation.getPlayer(name);
|
||||
}
|
||||
|
||||
public static UUID getUUIDFromString(String nameOrUUIDString) {
|
||||
if (implementation == null) {
|
||||
return null;
|
||||
}
|
||||
if (nameOrUUIDString.length() > 16) {
|
||||
return UUID.fromString(nameOrUUIDString);
|
||||
try {
|
||||
return UUID.fromString(nameOrUUIDString);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return UUIDHandler.getUUID(nameOrUUIDString, null);
|
||||
}
|
||||
|
||||
public static UUID getUUID(String name, RunnableVal<UUID> ifFetch) {
|
||||
if (implementation == null) {
|
||||
return null;
|
||||
}
|
||||
return implementation.getUUID(name, ifFetch);
|
||||
}
|
||||
|
||||
public static UUID getCachedUUID(String name, RunnableVal<UUID> ifFetch) {
|
||||
if (implementation == null) {
|
||||
return null;
|
||||
}
|
||||
return implementation.getUUIDMap().get(new StringWrapper(name));
|
||||
}
|
||||
|
||||
public static Map<String, PlotPlayer> getPlayers() {
|
||||
if (implementation == null) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
return implementation.getPlayers();
|
||||
}
|
||||
|
||||
public static void handleShutdown() {
|
||||
if (implementation == null) {
|
||||
return;
|
||||
}
|
||||
implementation.handleShutdown();
|
||||
}
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ public abstract class UUIDHandlerImplementation {
|
||||
return uuid;
|
||||
}
|
||||
// Read from disk OR convert directly to offline UUID
|
||||
if (Settings.UUID.OFFLINE) {
|
||||
if (Settings.UUID.OFFLINE && !StringMan.contains(name, ';')) {
|
||||
uuid = this.uuidWrapper.getUUID(name);
|
||||
add(new StringWrapper(name), uuid);
|
||||
return uuid;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
@ -14,6 +15,7 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
@ -66,8 +68,8 @@ public abstract class WorldUtil {
|
||||
@Override
|
||||
public void run(OutputStream output) {
|
||||
try (final ZipOutputStream zos = new ZipOutputStream(output)) {
|
||||
File dat = getDat(plot.getArea().worldname);
|
||||
Location spawn = getSpawn(plot.getArea().worldname);
|
||||
File dat = getDat(plot.getWorldName());
|
||||
Location spawn = getSpawn(plot.getWorldName());
|
||||
setSpawn(home);
|
||||
byte[] buffer = new byte[1024];
|
||||
if (dat != null) {
|
||||
@ -87,20 +89,22 @@ public abstract class WorldUtil {
|
||||
int brz = bot.getZ() >> 9;
|
||||
int trx = top.getX() >> 9;
|
||||
int trz = top.getZ() >> 9;
|
||||
for (int x = brx; x <= trx; x++) {
|
||||
for (int z = brz; z <= trz; z++) {
|
||||
File file = getMcr(plot.getArea().worldname, x, z);
|
||||
Set<ChunkLoc> files = ChunkManager.manager.getChunkChunks(bot.getWorld());
|
||||
for (ChunkLoc mca : files) {
|
||||
if (mca.x >= brx && mca.x <= trx && mca.z >= brz && mca.z <= trz) {
|
||||
final File file = getMcr(plot.getWorldName(), mca.x, mca.z);
|
||||
if (file != null) {
|
||||
//final String name = "r." + (x - cx) + "." + (z - cz) + ".mca";
|
||||
String name = file.getName();
|
||||
ZipEntry ze = new ZipEntry("world" + File.separator + "region" + File.separator + name);
|
||||
final ZipEntry ze = new ZipEntry("world" + File.separator + "region" + File.separator + name);
|
||||
zos.putNextEntry(ze);
|
||||
FileInputStream in = new FileInputStream(file);
|
||||
final FileInputStream in = new FileInputStream(file);
|
||||
int len;
|
||||
while ((len = in.read(buffer)) > 0) {
|
||||
zos.write(buffer, 0, len);
|
||||
}
|
||||
in.close();
|
||||
zos.closeEntry();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal3;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import java.util.ArrayDeque;
|
||||
@ -25,6 +26,7 @@ import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
@ -244,16 +246,17 @@ public class ExpireManager {
|
||||
ExpireManager.this.running = 0;
|
||||
return;
|
||||
}
|
||||
final Plot plot = plots.poll();
|
||||
Plot plot = plots.poll();
|
||||
PlotArea area = plot.getArea();
|
||||
final Plot newPlot = area.getPlot(plot.getId());
|
||||
final ArrayDeque<ExpiryTask> applicable = new ArrayDeque<>(tasks);
|
||||
final Collection<ExpiryTask> expired = isExpired(applicable, plot);
|
||||
final Collection<ExpiryTask> expired = isExpired(applicable, newPlot);
|
||||
if (expired.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
for (ExpiryTask expiryTask : expired) {
|
||||
if (!expiryTask.needsAnalysis()) {
|
||||
expiredTask.run(plot, new Runnable() {
|
||||
expiredTask.run(newPlot, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TaskManager.IMP.taskLaterAsync(task, 1);
|
||||
@ -268,7 +271,7 @@ public class ExpireManager {
|
||||
passesComplexity(changed, expired, new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean confirmation) {
|
||||
expiredTask.run(plot, new Runnable() {
|
||||
expiredTask.run(newPlot, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TaskManager.IMP.taskLaterAsync(task, 1);
|
||||
@ -278,7 +281,7 @@ public class ExpireManager {
|
||||
}, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FlagManager.addPlotFlag(plot, Flags.ANALYSIS, changed.asList());
|
||||
FlagManager.addPlotFlag(newPlot, Flags.ANALYSIS, changed.asList());
|
||||
TaskManager.runTaskLaterAsync(task, 20);
|
||||
}
|
||||
});
|
||||
@ -287,11 +290,11 @@ public class ExpireManager {
|
||||
final Runnable doAnalysis = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
HybridUtils.manager.analyzePlot(plot, handleAnalysis);
|
||||
HybridUtils.manager.analyzePlot(newPlot, handleAnalysis);
|
||||
}
|
||||
};
|
||||
|
||||
PlotAnalysis analysis = plot.getComplexity(null);
|
||||
PlotAnalysis analysis = newPlot.getComplexity(null);
|
||||
if (analysis != null) {
|
||||
passesComplexity(analysis, expired, new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
@ -352,11 +355,12 @@ public class ExpireManager {
|
||||
MainUtil.sendMessage(player, C.PLOT_REMOVED_USER, plot.toString());
|
||||
}
|
||||
}
|
||||
Set<Plot> plots = plot.getConnectedPlots();
|
||||
plot.deletePlot(whenDone);
|
||||
PlotAnalysis changed = plot.getComplexity(null);
|
||||
int changes = changed == null ? 0 : changed.changes_sd;
|
||||
int modified = changed == null ? 0 : changed.changes;
|
||||
PS.debug("$2[&5Expire&dManager$2] &cDeleted expired plot: " + plot + " : " + changes + " - " + modified);
|
||||
PS.debug("$2[&5Expire&dManager$2] &cDeleted expired plot: " + plot + " User:" + plot.owner + " Delta:" + changes + "/" + modified + " Connected: " + StringMan.getString(plots));
|
||||
PS.debug("$4 - Area: " + plot.getArea());
|
||||
if (plot.hasOwner()) {
|
||||
PS.debug("$4 - Owner: " + UUIDHandler.getName(plot.owner));
|
||||
|
@ -15,6 +15,8 @@ public interface CommandCaller {
|
||||
* @param permission the name of the permission
|
||||
*/
|
||||
boolean hasPermission(String permission);
|
||||
|
||||
boolean isPermissionSet(String permission);
|
||||
|
||||
RequiredType getSuperCaller();
|
||||
}
|
||||
|
@ -35,9 +35,15 @@ public class PlotListener {
|
||||
EventUtil.manager.callEntry(player, plot);
|
||||
if (plot.hasOwner()) {
|
||||
Map<Flag<?>, Object> flags = FlagManager.getPlotFlags(plot);
|
||||
boolean titles = Settings.TITLES;
|
||||
final String greeting;
|
||||
|
||||
boolean titles;
|
||||
if (!plot.getArea().DEFAULT_FLAGS.isEmpty()) {
|
||||
Boolean value = (Boolean) plot.getArea().DEFAULT_FLAGS.get(Flags.TITLES);
|
||||
titles = value != null ? value : Settings.TITLES;
|
||||
} else {
|
||||
titles = Settings.TITLES;
|
||||
}
|
||||
final String greeting;
|
||||
if (flags.isEmpty()) {
|
||||
if (titles) {
|
||||
greeting = "";
|
||||
@ -45,9 +51,7 @@ public class PlotListener {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (Settings.TITLES) {
|
||||
titles = plot.getFlag(Flags.TITLES, true);
|
||||
}
|
||||
titles = plot.getFlag(Flags.TITLES, titles);
|
||||
Optional<String> greetingFlag = plot.getFlag(Flags.GREETING);
|
||||
if (greetingFlag.isPresent()) {
|
||||
greeting = greetingFlag.get();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user