mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Sponge / Other
Fix area teleportation for type 0,1 worlds Add blockstate<>id/data resolving for sponge Finish world generation for sponge Add chat color for sponge Fix economy support for sponge Fix sponge event system Other stuff
This commit is contained in:
parent
ef5846f688
commit
f5ff82c8cc
@ -438,9 +438,14 @@ public class Area extends SubCommand {
|
|||||||
C.NOT_VALID_PLOT_WORLD.send(plr, args[1]);
|
C.NOT_VALID_PLOT_WORLD.send(plr, args[1]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Location center;
|
||||||
|
if (area.TYPE != 2) {
|
||||||
|
center = WorldUtil.IMP.getSpawn(area.worldname);
|
||||||
|
} else {
|
||||||
RegionWrapper region = area.getRegion();
|
RegionWrapper region = area.getRegion();
|
||||||
Location center = new Location(area.worldname, region.minX + (region.maxX - region.minX) / 2, 0, region.minZ + (region.maxZ - region.minZ) / 2);
|
center = new Location(area.worldname, region.minX + (region.maxX - region.minX) / 2, 0, region.minZ + (region.maxZ - region.minZ) / 2);
|
||||||
center.setY(WorldUtil.IMP.getHighestBlock(area.worldname, center.getX(), center.getZ()));
|
center.setY(WorldUtil.IMP.getHighestBlock(area.worldname, center.getX(), center.getZ()));
|
||||||
|
}
|
||||||
plr.teleport(center);
|
plr.teleport(center);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,15 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.mutable.MutableInt;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
@ -36,14 +45,6 @@ import com.intellectualcrafters.plot.util.Permissions;
|
|||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.plotsquared.general.commands.Command;
|
import com.plotsquared.general.commands.Command;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
import org.apache.commons.lang.mutable.MutableInt;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
command = "rate",
|
command = "rate",
|
||||||
@ -83,7 +84,7 @@ public class Rate extends SubCommand {
|
|||||||
});
|
});
|
||||||
final UUID uuid = player.getUUID();
|
final UUID uuid = player.getUUID();
|
||||||
for (final Plot p : plots) {
|
for (final Plot p : plots) {
|
||||||
if ((!Settings.REQUIRE_DONE || p.getFlags().containsKey("done")) && p.isBasePlot() && (p.getRatings().isEmpty() || !p.getRatings()
|
if ((!Settings.REQUIRE_DONE || p.getFlags().containsKey("done")) && p.isBasePlot() && (p.hasRatings() || !p.getRatings()
|
||||||
.containsKey(uuid)) && !p.isAdded(uuid)) {
|
.containsKey(uuid)) && !p.isAdded(uuid)) {
|
||||||
p.teleportPlayer(player);
|
p.teleportPlayer(player);
|
||||||
MainUtil.sendMessage(player, C.RATE_THIS);
|
MainUtil.sendMessage(player, C.RATE_THIS);
|
||||||
|
@ -34,8 +34,7 @@ public class plugin extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, String.format("$2>> $1&lPlotSquared $2($1Version$2: $1%s$2)", StringMan.join(PS.get().IMP.getPluginVersion(), ".")));
|
MainUtil.sendMessage(plr, String.format("$2>> $1&lPlotSquared $2($1Version$2: $1%s$2)", StringMan.join(PS.get().IMP.getPluginVersion(), ".")));
|
||||||
MainUtil.sendMessage(plr, "$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92");
|
MainUtil.sendMessage(plr, "$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92");
|
||||||
MainUtil.sendMessage(plr, "$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki");
|
MainUtil.sendMessage(plr, "$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki");
|
||||||
MainUtil.sendMessage(plr,
|
MainUtil.sendMessage(plr, "$2>> $1&lNewest Version$2: $1" + (PS.get().update == null ? StringMan.join(PS.get().IMP.getPluginVersion(), ".") : PS.get().update));
|
||||||
"$2>> $1&lNewest Version$2: $1" + (PS.get().update == null ? StringMan.join(PS.get().IMP.getPluginVersion(), ".") : PS.get().update));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,25 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.intellectualcrafters.plot.object;
|
package com.intellectualcrafters.plot.object;
|
||||||
|
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.geom.Area;
|
||||||
|
import java.awt.geom.PathIterator;
|
||||||
|
import java.io.File;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.ArrayDeque;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import com.google.common.collect.BiMap;
|
import com.google.common.collect.BiMap;
|
||||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
@ -41,25 +60,6 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
|||||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||||
import com.plotsquared.listener.PlotListener;
|
import com.plotsquared.listener.PlotListener;
|
||||||
|
|
||||||
import java.awt.Rectangle;
|
|
||||||
import java.awt.geom.Area;
|
|
||||||
import java.awt.geom.PathIterator;
|
|
||||||
import java.io.File;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.ArrayDeque;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
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
|
* The plot class
|
||||||
*/
|
*/
|
||||||
@ -1206,6 +1206,11 @@ public class Plot {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasRatings() {
|
||||||
|
Plot base = this.getBasePlot(false);
|
||||||
|
return base.settings != null && base.settings.ratings != null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resend all chunks inside the plot to nearby players<br>
|
* Resend all chunks inside the plot to nearby players<br>
|
||||||
* This should not need to be called
|
* This should not need to be called
|
||||||
|
@ -35,7 +35,6 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class ReflectionUtils {
|
public class ReflectionUtils {
|
||||||
|
|
||||||
private static String version;
|
|
||||||
/**
|
/**
|
||||||
* prefix of bukkit classes
|
* prefix of bukkit classes
|
||||||
*/
|
*/
|
||||||
@ -46,10 +45,11 @@ public class ReflectionUtils {
|
|||||||
private static String preClassM = "net.minecraft.server";
|
private static String preClassM = "net.minecraft.server";
|
||||||
|
|
||||||
public ReflectionUtils(final String version) {
|
public ReflectionUtils(final String version) {
|
||||||
ReflectionUtils.version = version;
|
if (version != null) {
|
||||||
preClassB += "." + version;
|
preClassB += "." + version;
|
||||||
preClassM += "." + version;
|
preClassM += "." + version;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static <T> List<T> getStaticFields(Class clazz) {
|
public static <T> List<T> getStaticFields(Class clazz) {
|
||||||
ArrayList<T> list = new ArrayList<T>();
|
ArrayList<T> list = new ArrayList<T>();
|
||||||
@ -68,12 +68,12 @@ public class ReflectionUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> getNmsClass(final String name) {
|
public static Class<?> getNmsClass(final String name) {
|
||||||
final String className = "net.minecraft.server." + version + "." + name;
|
final String className = preClassM + "." + name;
|
||||||
return getClass(className);
|
return getClass(className);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> getCbClass(final String name) {
|
public static Class<?> getCbClass(final String name) {
|
||||||
final String className = "org.bukkit.craftbukkit." + version + "." + name;
|
final String className = preClassB + "." + name;
|
||||||
return getClass(className);
|
return getClass(className);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,33 +1,16 @@
|
|||||||
package com.plotsquared.bukkit.listeners;
|
package com.plotsquared.bukkit.listeners;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import java.util.ArrayList;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import java.util.Arrays;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import java.util.HashSet;
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import java.util.Iterator;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import java.util.List;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import java.util.Map.Entry;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import java.util.Objects;
|
||||||
import com.intellectualcrafters.plot.object.PlotArea;
|
import java.util.Set;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import java.util.UUID;
|
||||||
import com.intellectualcrafters.plot.object.PlotHandler;
|
import java.util.regex.Pattern;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotInventory;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
|
||||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
|
||||||
import com.intellectualcrafters.plot.util.EventUtil;
|
|
||||||
import com.intellectualcrafters.plot.util.ExpireManager;
|
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
|
||||||
import com.intellectualcrafters.plot.util.MathMan;
|
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
|
||||||
import com.intellectualcrafters.plot.util.RegExUtil;
|
|
||||||
import com.intellectualcrafters.plot.util.StringMan;
|
|
||||||
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.listener.PlayerBlockEventType;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -106,16 +89,34 @@ import org.bukkit.projectiles.BlockProjectileSource;
|
|||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import java.util.Arrays;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import java.util.HashSet;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import java.util.Iterator;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import java.util.List;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import java.util.Map.Entry;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import java.util.Objects;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import java.util.Set;
|
import com.intellectualcrafters.plot.object.PlotArea;
|
||||||
import java.util.UUID;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import java.util.regex.Pattern;
|
import com.intellectualcrafters.plot.object.PlotHandler;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotInventory;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||||
|
import com.intellectualcrafters.plot.util.EventUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.ExpireManager;
|
||||||
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.MathMan;
|
||||||
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
|
import com.intellectualcrafters.plot.util.RegExUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
|
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.listener.PlayerBlockEventType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Player Events involving plots
|
* Player Events involving plots
|
||||||
@ -486,7 +487,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (lastPlot != null && now.equals(lastPlot)) {
|
} else if (now.equals(lastPlot)) {
|
||||||
return;
|
return;
|
||||||
} else if (!plotEntry(pp, now)) {
|
} else if (!plotEntry(pp, now)) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||||
@ -538,7 +539,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (lastPlot != null && now.equals(lastPlot)) {
|
} else if (now.equals(lastPlot)) {
|
||||||
return;
|
return;
|
||||||
} else if (!plotEntry(pp, now)) {
|
} else if (!plotEntry(pp, now)) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||||
|
@ -10,6 +10,7 @@ import java.util.UUID;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.spongepowered.api.Game;
|
import org.spongepowered.api.Game;
|
||||||
import org.spongepowered.api.Server;
|
import org.spongepowered.api.Server;
|
||||||
|
import org.spongepowered.api.Sponge;
|
||||||
import org.spongepowered.api.entity.living.player.Player;
|
import org.spongepowered.api.entity.living.player.Player;
|
||||||
import org.spongepowered.api.event.Listener;
|
import org.spongepowered.api.event.Listener;
|
||||||
import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent;
|
import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent;
|
||||||
@ -62,8 +63,11 @@ import com.plotsquared.sponge.util.SpongeChunkManager;
|
|||||||
import com.plotsquared.sponge.util.SpongeCommand;
|
import com.plotsquared.sponge.util.SpongeCommand;
|
||||||
import com.plotsquared.sponge.util.SpongeEconHandler;
|
import com.plotsquared.sponge.util.SpongeEconHandler;
|
||||||
import com.plotsquared.sponge.util.SpongeEventUtil;
|
import com.plotsquared.sponge.util.SpongeEventUtil;
|
||||||
|
import com.plotsquared.sponge.util.SpongeHybridUtils;
|
||||||
import com.plotsquared.sponge.util.SpongeInventoryUtil;
|
import com.plotsquared.sponge.util.SpongeInventoryUtil;
|
||||||
import com.plotsquared.sponge.util.SpongeMetrics;
|
import com.plotsquared.sponge.util.SpongeMetrics;
|
||||||
|
import com.plotsquared.sponge.util.SpongeSchematicHandler;
|
||||||
|
import com.plotsquared.sponge.util.SpongeSetupUtils;
|
||||||
import com.plotsquared.sponge.util.SpongeTaskManager;
|
import com.plotsquared.sponge.util.SpongeTaskManager;
|
||||||
import com.plotsquared.sponge.util.SpongeTitleManager;
|
import com.plotsquared.sponge.util.SpongeTitleManager;
|
||||||
import com.plotsquared.sponge.util.SpongeUtil;
|
import com.plotsquared.sponge.util.SpongeUtil;
|
||||||
@ -77,8 +81,8 @@ import com.plotsquared.sponge.uuid.SpongeUUIDHandler;
|
|||||||
* Created by robin on 01/11/2014
|
* Created by robin on 01/11/2014
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Plugin(id = "PlotSquared", name = "PlotSquared", version = "3.0.0", dependencies = "before:WorldEdit,required-after:TotalEconomy")
|
@Plugin(id = "PlotSquared", name = "PlotSquared", version = "3.3.0", dependencies = "before:WorldEdit")
|
||||||
public class SpongeMain implements IPlotMain, PluginContainer {
|
public class SpongeMain implements IPlotMain {
|
||||||
public static SpongeMain THIS;
|
public static SpongeMain THIS;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -89,7 +93,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
|
|
||||||
private GameProfileManager resolver;
|
private GameProfileManager resolver;
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public Logger getLogger() {
|
public Logger getLogger() {
|
||||||
return logger;
|
return logger;
|
||||||
}
|
}
|
||||||
@ -103,6 +107,9 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public GameProfileManager getResolver() {
|
public GameProfileManager getResolver() {
|
||||||
|
if (resolver == null) {
|
||||||
|
resolver = game.getServer().getGameProfileManager();
|
||||||
|
}
|
||||||
return resolver;
|
return resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,22 +117,22 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
return THIS;
|
return THIS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return "PlotSquared";
|
return "PlotSquared";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public Optional<Object> getInstance() {
|
public Optional<Object> getInstance() {
|
||||||
return Optional.<Object> of(THIS);
|
return Optional.<Object> of(THIS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "PlotSquared";
|
return "PlotSquared";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
final int[] version = PS.get().getVersion();
|
final int[] version = PS.get().getVersion();
|
||||||
String result = "";
|
String result = "";
|
||||||
@ -151,11 +158,9 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
public void onServerAboutToStart(final GameAboutToStartServerEvent event) {
|
public void onServerAboutToStart(final GameAboutToStartServerEvent event) {
|
||||||
log("PlotSquared: Server init");
|
log("PlotSquared: Server init");
|
||||||
THIS = this;
|
THIS = this;
|
||||||
resolver = game.getServiceManager().provide(GameProfileManager.class).get();
|
new PS(this, "Sponge");
|
||||||
server = game.getServer();
|
server = game.getServer();
|
||||||
game.getRegistry().register(WorldGeneratorModifier.class, (WorldGeneratorModifier) new HybridGen().specify());
|
game.getRegistry().register(WorldGeneratorModifier.class, (WorldGeneratorModifier) new HybridGen().specify());
|
||||||
new PS(this, "Sponge");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -212,7 +217,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
@Override
|
@Override
|
||||||
public EconHandler getEconomyHandler() {
|
public EconHandler getEconomyHandler() {
|
||||||
SpongeEconHandler econ = new SpongeEconHandler();
|
SpongeEconHandler econ = new SpongeEconHandler();
|
||||||
game.getEventManager().registerListeners(this, econ);
|
Sponge.getEventManager().registerListeners(this, econ);
|
||||||
return econ;
|
return econ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +263,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerPlayerEvents() {
|
public void registerPlayerEvents() {
|
||||||
game.getEventManager().registerListeners(this, new MainListener());
|
Sponge.getEventManager().registerListeners(this, new MainListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -312,12 +317,12 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerChunkProcessor() {
|
public void registerChunkProcessor() {
|
||||||
game.getEventManager().registerListeners(this, new ChunkProcessor());
|
Sponge.getEventManager().registerListeners(this, new ChunkProcessor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerWorldEvents() {
|
public void registerWorldEvents() {
|
||||||
game.getEventManager().registerListeners(this, new WorldEvents());
|
Sponge.getEventManager().registerListeners(this, new WorldEvents());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -328,7 +333,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
@Override
|
@Override
|
||||||
public void startMetrics() {
|
public void startMetrics() {
|
||||||
try {
|
try {
|
||||||
final SpongeMetrics metrics = new SpongeMetrics(game, this);
|
final SpongeMetrics metrics = new SpongeMetrics(game, (PluginContainer) this);
|
||||||
metrics.start();
|
metrics.start();
|
||||||
log(C.PREFIX.s() + "&6Metrics enabled.");
|
log(C.PREFIX.s() + "&6Metrics enabled.");
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
@ -398,7 +403,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNMSPackage() {
|
public String getNMSPackage() {
|
||||||
return "TODO";//TODO FIXME
|
return "";//TODO FIXME
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,72 +0,0 @@
|
|||||||
package com.plotsquared.sponge;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.spongepowered.api.world.World;
|
|
||||||
import org.spongepowered.api.world.gen.WorldGenerator;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
|
||||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
|
||||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
|
||||||
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotArea;
|
|
||||||
import com.intellectualcrafters.plot.object.SetupObject;
|
|
||||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
|
||||||
import com.plotsquared.sponge.generator.SpongePlotGenerator;
|
|
||||||
import com.plotsquared.sponge.util.SpongeUtil;
|
|
||||||
|
|
||||||
public class SpongeSetupUtils extends SetupUtils {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateGenerators() {
|
|
||||||
if (!SetupUtils.generators.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SetupUtils.generators.put("PlotSquared", new SpongePlotGenerator(new HybridGen()));
|
|
||||||
// TODO get external world generators
|
|
||||||
throw new UnsupportedOperationException("TODO FETCH EXTERNAL WorldGenerationModifiers");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getGenerator(final PlotArea plotworld) {
|
|
||||||
if (SetupUtils.generators.isEmpty()) {
|
|
||||||
updateGenerators();
|
|
||||||
}
|
|
||||||
final World world = SpongeUtil.getWorld(plotworld.worldname);
|
|
||||||
if (world == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final WorldGenerator generator = world.getWorldGenerator();
|
|
||||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String setupWorld(final SetupObject object) {
|
|
||||||
SetupUtils.manager.updateGenerators();
|
|
||||||
final ConfigurationNode[] steps = object.step;
|
|
||||||
final String world = object.world;
|
|
||||||
for (final ConfigurationNode step : steps) {
|
|
||||||
PS.get().config.set("worlds." + world + "." + step.getConstant(), step.getValue());
|
|
||||||
}
|
|
||||||
if (object.type != 0) {
|
|
||||||
PS.get().config.set("worlds." + world + "." + "generator.type", object.type);
|
|
||||||
PS.get().config.set("worlds." + world + "." + "generator.terrain", object.terrain);
|
|
||||||
PS.get().config.set("worlds." + world + "." + "generator.plugin", object.plotManager);
|
|
||||||
if ((object.setupGenerator != null) && !object.setupGenerator.equals(object.plotManager)) {
|
|
||||||
PS.get().config.set("worlds." + world + "." + "generator.init", object.setupGenerator);
|
|
||||||
}
|
|
||||||
final PlotGenerator<WorldGenerator> gen = (PlotGenerator<WorldGenerator>) generators.get(object.setupGenerator);
|
|
||||||
if ((gen != null) && (gen.generator instanceof SpongePlotGenerator)) {
|
|
||||||
object.setupGenerator = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
PS.get().config.save(PS.get().configFile);
|
|
||||||
} catch (final IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
// TODO FIXME
|
|
||||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET: Create a new world here");
|
|
||||||
// return object.world;
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,35 +4,28 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.spongepowered.api.data.DataContainer;
|
import org.spongepowered.api.data.DataContainer;
|
||||||
import org.spongepowered.api.world.World;
|
|
||||||
import org.spongepowered.api.world.WorldCreationSettings;
|
import org.spongepowered.api.world.WorldCreationSettings;
|
||||||
|
import org.spongepowered.api.world.biome.BiomeGenerationSettings;
|
||||||
import org.spongepowered.api.world.biome.BiomeType;
|
import org.spongepowered.api.world.biome.BiomeType;
|
||||||
import org.spongepowered.api.world.extent.ImmutableBiomeArea;
|
import org.spongepowered.api.world.biome.BiomeTypes;
|
||||||
import org.spongepowered.api.world.extent.MutableBiomeArea;
|
import org.spongepowered.api.world.extent.MutableBiomeArea;
|
||||||
import org.spongepowered.api.world.extent.MutableBlockVolume;
|
|
||||||
import org.spongepowered.api.world.gen.BiomeGenerator;
|
import org.spongepowered.api.world.gen.BiomeGenerator;
|
||||||
import org.spongepowered.api.world.gen.GenerationPopulator;
|
import org.spongepowered.api.world.gen.GenerationPopulator;
|
||||||
import org.spongepowered.api.world.gen.WorldGenerator;
|
import org.spongepowered.api.world.gen.WorldGenerator;
|
||||||
import org.spongepowered.api.world.gen.WorldGeneratorModifier;
|
import org.spongepowered.api.world.gen.WorldGeneratorModifier;
|
||||||
|
|
||||||
import com.flowpowered.math.vector.Vector2i;
|
import com.flowpowered.math.vector.Vector2i;
|
||||||
import com.flowpowered.math.vector.Vector3i;
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
||||||
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
||||||
import com.intellectualcrafters.plot.object.PlotArea;
|
import com.intellectualcrafters.plot.object.PlotArea;
|
||||||
import com.intellectualcrafters.plot.object.PlotManager;
|
import com.intellectualcrafters.plot.object.PlotManager;
|
||||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.SetQueue;
|
import com.intellectualcrafters.plot.util.ReflectionUtils;
|
||||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
|
||||||
import com.plotsquared.sponge.util.SpongeUtil;
|
import com.plotsquared.sponge.util.SpongeUtil;
|
||||||
import com.plotsquared.sponge.util.block.GenChunk;
|
|
||||||
|
|
||||||
public class SpongePlotGenerator implements WorldGeneratorModifier, GeneratorWrapper<WorldGeneratorModifier> {
|
public class SpongePlotGenerator implements WorldGeneratorModifier, GeneratorWrapper<WorldGeneratorModifier> {
|
||||||
|
|
||||||
private final PseudoRandom random = new PseudoRandom();
|
|
||||||
private final IndependentPlotGenerator plotGenerator;
|
private final IndependentPlotGenerator plotGenerator;
|
||||||
private final List<GenerationPopulator> populators = new ArrayList<>();
|
private final List<GenerationPopulator> populators = new ArrayList<>();
|
||||||
private final boolean loaded = false;
|
private final boolean loaded = false;
|
||||||
@ -56,59 +49,30 @@ public class SpongePlotGenerator implements WorldGeneratorModifier, GeneratorWra
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return "PlotSquared";
|
if (plotGenerator == null) {
|
||||||
|
if (platformGenerator != this) {
|
||||||
|
return platformGenerator.getId();
|
||||||
|
}
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
return plotGenerator.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "PlotSquared";
|
if (plotGenerator == null) {
|
||||||
|
if (platformGenerator != this) {
|
||||||
|
return platformGenerator.getName();
|
||||||
|
}
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
return plotGenerator.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modifyWorldGenerator(WorldCreationSettings settings, DataContainer data, WorldGenerator wg) {
|
public void modifyWorldGenerator(WorldCreationSettings settings, DataContainer data, WorldGenerator wg) {
|
||||||
if (full) {
|
|
||||||
final String worldname = settings.getWorldName();
|
final String worldname = settings.getWorldName();
|
||||||
wg.getGenerationPopulators().clear();
|
wg.setBaseGenerationPopulator(new SpongeTerrainGen(this, plotGenerator));
|
||||||
wg.getPopulators().clear();
|
|
||||||
wg.setBaseGenerationPopulator(new GenerationPopulator() {
|
|
||||||
@Override
|
|
||||||
public void populate(World world, MutableBlockVolume terrain, ImmutableBiomeArea biome) {
|
|
||||||
System.out.println("POPULATE!");
|
|
||||||
Vector3i size = terrain.getBlockSize();
|
|
||||||
if (size.getX() != 16 || size.getZ() != 16) {
|
|
||||||
throw new UnsupportedOperationException("NON CHUNK POPULATION NOT SUPPORTED");
|
|
||||||
}
|
|
||||||
String worldname = world.getName();
|
|
||||||
Vector3i min = terrain.getBlockMin();
|
|
||||||
int cx = min.getX() >> 4;
|
|
||||||
int cz = min.getZ() >> 4;
|
|
||||||
ChunkWrapper wrap = SetQueue.IMP.new ChunkWrapper(worldname, cx, cz);
|
|
||||||
// Create the result object
|
|
||||||
GenChunk result = new GenChunk(terrain, null, wrap);
|
|
||||||
// Catch any exceptions
|
|
||||||
try {
|
|
||||||
// Fill the result data if necessary
|
|
||||||
if (platformGenerator != SpongePlotGenerator.this) {
|
|
||||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET!");
|
|
||||||
} else {
|
|
||||||
// Set random seed
|
|
||||||
random.state = (cx << 16) | (cz & 0xFFFF);
|
|
||||||
// Process the chunk
|
|
||||||
result.modified = false;
|
|
||||||
ChunkManager.preProcessChunk(result);
|
|
||||||
if (result.modified) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PlotArea area = PS.get().getPlotArea(world.getName(), null);
|
|
||||||
plotGenerator.generateChunk(result, area, random);
|
|
||||||
ChunkManager.postProcessChunk(result);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
wg.setBiomeGenerator(new BiomeGenerator() {
|
wg.setBiomeGenerator(new BiomeGenerator() {
|
||||||
@Override
|
@Override
|
||||||
public void generateBiomes(MutableBiomeArea buffer) {
|
public void generateBiomes(MutableBiomeArea buffer) {
|
||||||
@ -125,9 +89,14 @@ public class SpongePlotGenerator implements WorldGeneratorModifier, GeneratorWra
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
for (BiomeType type : ReflectionUtils.<BiomeType> getStaticFields(BiomeTypes.class)) {
|
||||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
BiomeGenerationSettings biomeSettings = wg.getBiomeSettings(type);
|
||||||
|
biomeSettings.getGenerationPopulators().clear();
|
||||||
|
biomeSettings.getPopulators().clear();
|
||||||
}
|
}
|
||||||
|
wg.getGenerationPopulators().clear();
|
||||||
|
wg.getPopulators().clear();
|
||||||
|
PS.get().loadWorld(worldname, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
package com.plotsquared.sponge.generator;
|
||||||
|
|
||||||
|
import org.spongepowered.api.world.World;
|
||||||
|
import org.spongepowered.api.world.extent.ImmutableBiomeArea;
|
||||||
|
import org.spongepowered.api.world.extent.MutableBlockVolume;
|
||||||
|
import org.spongepowered.api.world.gen.GenerationPopulator;
|
||||||
|
|
||||||
|
import com.flowpowered.math.vector.Vector3i;
|
||||||
|
import com.intellectualcrafters.plot.PS;
|
||||||
|
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotArea;
|
||||||
|
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||||
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
|
import com.intellectualcrafters.plot.util.SetQueue;
|
||||||
|
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||||
|
import com.plotsquared.sponge.util.block.GenChunk;
|
||||||
|
|
||||||
|
public class SpongeTerrainGen implements GenerationPopulator {
|
||||||
|
|
||||||
|
public final SpongePlotGenerator parent;
|
||||||
|
public final IndependentPlotGenerator child;
|
||||||
|
private final PseudoRandom random = new PseudoRandom();
|
||||||
|
|
||||||
|
public SpongeTerrainGen(SpongePlotGenerator parent, IndependentPlotGenerator ipg) {
|
||||||
|
this.parent = parent;
|
||||||
|
this.child = ipg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void populate(World world, MutableBlockVolume terrain, ImmutableBiomeArea biomes) {
|
||||||
|
Vector3i size = terrain.getBlockSize();
|
||||||
|
if (size.getX() != 16 || size.getZ() != 16) {
|
||||||
|
throw new UnsupportedOperationException("NON CHUNK POPULATION NOT SUPPORTED");
|
||||||
|
}
|
||||||
|
String worldname = world.getName();
|
||||||
|
Vector3i min = terrain.getBlockMin();
|
||||||
|
int cx = min.getX() >> 4;
|
||||||
|
int cz = min.getZ() >> 4;
|
||||||
|
ChunkWrapper wrap = SetQueue.IMP.new ChunkWrapper(worldname, cx, cz);
|
||||||
|
// Create the result object
|
||||||
|
GenChunk result = new GenChunk(terrain, null, wrap);
|
||||||
|
// Catch any exceptions
|
||||||
|
try {
|
||||||
|
// Set random seed
|
||||||
|
random.state = (cx << 16) | (cz & 0xFFFF);
|
||||||
|
// Process the chunk
|
||||||
|
result.modified = false;
|
||||||
|
ChunkManager.preProcessChunk(result);
|
||||||
|
if (result.modified) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Fill the result data
|
||||||
|
PlotArea area = PS.get().getPlotArea(world.getName(), null);
|
||||||
|
child.generateChunk(result, area, random);
|
||||||
|
ChunkManager.postProcessChunk(result);
|
||||||
|
return;
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@ import java.util.Map.Entry;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
import org.spongepowered.api.block.BlockSnapshot;
|
import org.spongepowered.api.block.BlockSnapshot;
|
||||||
@ -25,12 +26,9 @@ import org.spongepowered.api.entity.living.player.Player;
|
|||||||
import org.spongepowered.api.entity.vehicle.Boat;
|
import org.spongepowered.api.entity.vehicle.Boat;
|
||||||
import org.spongepowered.api.entity.vehicle.minecart.Minecart;
|
import org.spongepowered.api.entity.vehicle.minecart.Minecart;
|
||||||
import org.spongepowered.api.event.Listener;
|
import org.spongepowered.api.event.Listener;
|
||||||
import org.spongepowered.api.event.action.LightningEvent;
|
import org.spongepowered.api.event.action.InteractEvent;
|
||||||
import org.spongepowered.api.event.block.ChangeBlockEvent;
|
import org.spongepowered.api.event.block.ChangeBlockEvent;
|
||||||
import org.spongepowered.api.event.block.GrowBlockEvent;
|
import org.spongepowered.api.event.block.NotifyNeighborBlockEvent;
|
||||||
import org.spongepowered.api.event.block.InteractBlockEvent;
|
|
||||||
import org.spongepowered.api.event.block.MoveBlockEvent;
|
|
||||||
import org.spongepowered.api.event.cause.Cause;
|
|
||||||
import org.spongepowered.api.event.command.SendCommandEvent;
|
import org.spongepowered.api.event.command.SendCommandEvent;
|
||||||
import org.spongepowered.api.event.entity.BreedEntityEvent;
|
import org.spongepowered.api.event.entity.BreedEntityEvent;
|
||||||
import org.spongepowered.api.event.entity.DisplaceEntityEvent;
|
import org.spongepowered.api.event.entity.DisplaceEntityEvent;
|
||||||
@ -38,6 +36,7 @@ import org.spongepowered.api.event.entity.SpawnEntityEvent;
|
|||||||
import org.spongepowered.api.event.message.MessageEvent;
|
import org.spongepowered.api.event.message.MessageEvent;
|
||||||
import org.spongepowered.api.event.network.ClientConnectionEvent;
|
import org.spongepowered.api.event.network.ClientConnectionEvent;
|
||||||
import org.spongepowered.api.event.world.ExplosionEvent;
|
import org.spongepowered.api.event.world.ExplosionEvent;
|
||||||
|
import org.spongepowered.api.event.world.ExplosionEvent.Detonate;
|
||||||
import org.spongepowered.api.profile.GameProfile;
|
import org.spongepowered.api.profile.GameProfile;
|
||||||
import org.spongepowered.api.text.Text;
|
import org.spongepowered.api.text.Text;
|
||||||
import org.spongepowered.api.world.World;
|
import org.spongepowered.api.world.World;
|
||||||
@ -97,70 +96,84 @@ public class MainListener {
|
|||||||
* - enderman harvest
|
* - enderman harvest
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// @Listener
|
@Listener
|
||||||
// public void onFluidSpread(final NotifyNeighborBlockEvent event) {
|
public void onCommand(final SendCommandEvent event) {
|
||||||
// onPhysics(event);
|
switch (event.getCommand().toLowerCase()) {
|
||||||
// }
|
case "plotme": {
|
||||||
//
|
Player source = SpongeUtil.<Player> getCause(event.getCause(), Player.class);
|
||||||
// @Listener
|
if (source == null) {
|
||||||
// public void onFluidSpread(final NotifyNeighborBlockEvent.Burn event) {
|
return;
|
||||||
// onPhysics(event);
|
}
|
||||||
// }
|
if (Settings.USE_PLOTME_ALIAS) {
|
||||||
//
|
SpongeMain.THIS.getGame().getCommandManager().process(source, ("plots " + event.getArguments()).trim());
|
||||||
// @Listener
|
} else {
|
||||||
// public void onFluidSpread(final NotifyNeighborBlockEvent.Ignite event) {
|
source.sendMessage(SpongeUtil.text(C.NOT_USING_PLOTME.s()));
|
||||||
// onPhysics(event);
|
}
|
||||||
// }
|
event.setCancelled(true);
|
||||||
//
|
|
||||||
// @Listener
|
|
||||||
// public void onFluidSpread(final NotifyNeighborBlockEvent.Power event) {
|
|
||||||
// // TODO redstone
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void onPhysics(final NotifyNeighborBlockEvent event) {
|
|
||||||
// final AtomicBoolean cancelled = new AtomicBoolean(false);
|
|
||||||
// final Map<Direction, org.spongepowered.api.world.Location<World>> relatives = event.getRelatives();
|
|
||||||
// event.filterDirections(new Predicate<Direction>() {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean test(Direction dir) {
|
|
||||||
// if (cancelled.get()) {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// org.spongepowered.api.world.Location<World> loc = relatives.get(dir);
|
|
||||||
// com.intellectualcrafters.plot.object.Location plotloc = SpongeUtil.getLocation(loc.getExtent().getName(), loc);
|
|
||||||
// Plot plot = MainUtil.getPlot(plotloc);
|
|
||||||
// if (plot == null) {
|
|
||||||
// if (MainUtil.isPlotAreaAbs(plotloc)) {
|
|
||||||
// cancelled.set(true);
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// cancelled.set(true);
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// org.spongepowered.api.world.Location<World> relative = loc.getRelative(dir);
|
|
||||||
// com.intellectualcrafters.plot.object.Location relLoc = SpongeUtil.getLocation(relative.getExtent().getName(), relative);
|
|
||||||
// if (plot.equals(MainUtil.getPlot(relLoc))) {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
public <T> T getCause(Cause cause, Class<T> clazz) {
|
|
||||||
Optional<?> root = Optional.of(cause.root());
|
|
||||||
if (root.isPresent()) {
|
|
||||||
Object source = root.get();
|
|
||||||
if (clazz.isInstance(source)) {
|
|
||||||
return (T) source;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void onCommand(final BreedEntityEvent.Breed event) {
|
public void onChat(final MessageEvent event) {
|
||||||
|
// TODO
|
||||||
|
Player player = SpongeUtil.<Player> getCause(event.getCause(), Player.class);
|
||||||
|
if (player == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final String world = player.getWorld().getName();
|
||||||
|
if (!PS.get().hasPlotArea(world)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final PlotArea plotworld = PS.get().getPlotAreaByString(world);
|
||||||
|
final PlotPlayer plr = SpongeUtil.getPlayer(player);
|
||||||
|
if (!plotworld.PLOT_CHAT && ((plr.getMeta("chat") == null) || !(Boolean) plr.getMeta("chat"))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Location loc = SpongeUtil.getLocation(player);
|
||||||
|
final Plot plot = loc.getPlot();
|
||||||
|
if (plot == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Text message = event.getMessage().orElse(Text.EMPTY);
|
||||||
|
|
||||||
|
// TODO use display name rather than username
|
||||||
|
// - Getting displayname currently causes NPE, so wait until sponge fixes that
|
||||||
|
|
||||||
|
final String sender = player.getName();
|
||||||
|
final PlotId id = plot.getId();
|
||||||
|
final String newMessage = StringMan.replaceAll(C.PLOT_CHAT_FORMAT.s(), "%plot_id%", id.x + ";" + id.y, "%sender%", sender);
|
||||||
|
final Text forcedMessage = event.getMessage().orElse(Text.EMPTY);
|
||||||
|
// String forcedMessage = StringMan.replaceAll(C.PLOT_CHAT_FORCED.s(), "%plot_id%", id.x + ";" + id.y, "%sender%", sender);
|
||||||
|
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
|
||||||
|
PlotPlayer user = entry.getValue();
|
||||||
|
String toSend;
|
||||||
|
if (plot.equals(user.getLocation().getPlot())) {
|
||||||
|
toSend = newMessage;
|
||||||
|
} else if (Permissions.hasPermission(user, C.PERMISSION_COMMANDS_CHAT)) {
|
||||||
|
((SpongePlayer) user).player.sendMessage(forcedMessage);
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final String[] split = (toSend + " ").split("%msg%");
|
||||||
|
final List<Text> components = new ArrayList<>();
|
||||||
|
Text prefix = null;
|
||||||
|
for (final String part : split) {
|
||||||
|
if (prefix != null) {
|
||||||
|
components.add(prefix);
|
||||||
|
} else {
|
||||||
|
prefix = message;
|
||||||
|
}
|
||||||
|
components.add(Text.of(part));
|
||||||
|
}
|
||||||
|
((SpongePlayer) user).player.sendMessage(Text.join(components));
|
||||||
|
}
|
||||||
|
event.setMessage(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Listener
|
||||||
|
public void onBreedEntity(final BreedEntityEvent.Breed event) {
|
||||||
final Location loc = SpongeUtil.getLocation(event.getTargetEntity());
|
final Location loc = SpongeUtil.getLocation(event.getTargetEntity());
|
||||||
final String world = loc.getWorld();
|
final String world = loc.getWorld();
|
||||||
final PlotArea plotworld = PS.get().getPlotAreaByString(world);
|
final PlotArea plotworld = PS.get().getPlotAreaByString(world);
|
||||||
@ -179,16 +192,13 @@ public class MainListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Listener
|
public void onSpawnEntity(SpawnEntityEvent event) throws Exception {
|
||||||
public void onMobSpawn(final SpawnEntityEvent event) {
|
|
||||||
World world = event.getTargetWorld();
|
World world = event.getTargetWorld();
|
||||||
final PlotArea plotworld = PS.get().getPlotAreaByString(world.getName());
|
final PlotArea plotworld = PS.get().getPlotAreaByString(world.getName());
|
||||||
if (plotworld == null) {
|
if (plotworld == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<Entity> entities = event.getEntities();
|
|
||||||
event.filterEntities(new Predicate<Entity>() {
|
event.filterEntities(new Predicate<Entity>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Entity entity) {
|
public boolean test(Entity entity) {
|
||||||
if (entity instanceof Player) {
|
if (entity instanceof Player) {
|
||||||
@ -303,134 +313,92 @@ public class MainListener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Listener
|
public void onNotifyNeighborBlock(NotifyNeighborBlockEvent event) throws Exception {
|
||||||
public void onCommand(final SendCommandEvent event) {
|
final AtomicBoolean cancelled = new AtomicBoolean(false);
|
||||||
switch (event.getCommand().toLowerCase()) {
|
SpongeUtil.printCause("physics", event.getCause());
|
||||||
case "plotme": {
|
// PlotArea area = plotloc.getPlotArea();
|
||||||
Player source = this.<Player> getCause(event.getCause(), Player.class);
|
// event.filterDirections(new Predicate<Direction>() {
|
||||||
if (source == null) {
|
//
|
||||||
return;
|
// @Override
|
||||||
}
|
// public boolean test(Direction dir) {
|
||||||
if (Settings.USE_PLOTME_ALIAS) {
|
// if (cancelled.get()) {
|
||||||
SpongeMain.THIS.getGame().getCommandManager().process(source, ("plots " + event.getArguments()).trim());
|
// return true;
|
||||||
} else {
|
// }
|
||||||
source.sendMessage(SpongeUtil.text(C.NOT_USING_PLOTME.s()));
|
// org.spongepowered.api.world.Location<World> loc = relatives.get(dir);
|
||||||
}
|
// com.intellectualcrafters.plot.object.Location plotloc = SpongeUtil.getLocation(loc.getExtent().getName(), loc);
|
||||||
event.setCancelled(true);
|
// if (area == null) {
|
||||||
}
|
// return true;
|
||||||
}
|
// }
|
||||||
}
|
// plot = area.get
|
||||||
|
// Plot plot = plotloc.getPlot();
|
||||||
public void onBlockChange(ChangeBlockEvent event) {
|
// if (plot == null) {
|
||||||
final World world = event.getTargetWorld();
|
// if (MainUtil.isPlotAreaAbs(plotloc)) {
|
||||||
final String worldname = world.getName();
|
// cancelled.set(true);
|
||||||
if (!PS.get().hasPlotArea(worldname)) {
|
// return false;
|
||||||
return;
|
// }
|
||||||
}
|
// cancelled.set(true);
|
||||||
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
|
// return true;
|
||||||
Transaction<BlockSnapshot> first = transactions.get(0);
|
// }
|
||||||
Location loc = SpongeUtil.getLocation(worldname, first.getOriginal().getPosition());
|
// org.spongepowered.api.world.Location<World> relative = loc.getRelative(dir);
|
||||||
Plot plot = loc.getPlot();
|
// com.intellectualcrafters.plot.object.Location relLoc = SpongeUtil.getLocation(relative.getExtent().getName(), relative);
|
||||||
if (plot == null) {
|
// if (plot.equals(MainUtil.getPlot(relLoc))) {
|
||||||
if (loc.getPlotAbs() == null ) {
|
// return true;
|
||||||
return;
|
// }
|
||||||
}
|
// return false;
|
||||||
event.setCancelled(true);
|
// }
|
||||||
return;
|
// });
|
||||||
}
|
|
||||||
event.filter(new Predicate<org.spongepowered.api.world.Location<World>>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean test(org.spongepowered.api.world.Location<World> loc) {
|
|
||||||
if (SpongeUtil.getLocation(worldname, loc).isPlotRoad()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void onBlockMove(final MoveBlockEvent event) {
|
public void onInteract(InteractEvent event) throws Exception {
|
||||||
onBlockChange(event);
|
final Player player = SpongeUtil.<Player> getCause(event.getCause(), Player.class);
|
||||||
}
|
|
||||||
|
|
||||||
@Listener
|
|
||||||
public void onFloraGrow(final GrowBlockEvent event) {
|
|
||||||
onBlockChange(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Listener
|
|
||||||
public void onLightning(final LightningEvent.Strike event) {
|
|
||||||
onBlockChange(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void printCause(String method, Cause cause) {
|
|
||||||
System.out.println(method + ": " + cause.toString());
|
|
||||||
System.out.println(method + ": " + cause.getClass());
|
|
||||||
System.out.println(method + ": " + (cause.root()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Listener
|
|
||||||
public void onChat(final MessageEvent event) {
|
|
||||||
// TODO
|
|
||||||
Player player = this.<Player> getCause(event.getCause(), Player.class);
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final String world = player.getWorld().getName();
|
Optional<Vector3d> target = event.getInteractionPoint();
|
||||||
if (!PS.get().hasPlotArea(world)) {
|
if (!target.isPresent()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlotArea plotworld = PS.get().getPlotAreaByString(world);
|
Location loc = SpongeUtil.getLocation(player.getWorld().getName(), target.get());
|
||||||
final PlotPlayer plr = SpongeUtil.getPlayer(player);
|
org.spongepowered.api.world.Location l = SpongeUtil.getLocation(loc);
|
||||||
if (!plotworld.PLOT_CHAT && ((plr.getMeta("chat") == null) || !(Boolean) plr.getMeta("chat"))) {
|
Plot plot = loc.getPlot();
|
||||||
return;
|
PlotPlayer pp = SpongeUtil.getPlayer(player);
|
||||||
}
|
|
||||||
final Location loc = SpongeUtil.getLocation(player);
|
|
||||||
final Plot plot = loc.getPlot();
|
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
|
if (loc.getPlotAbs() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Text message = event.getMessage().orElse(Text.EMPTY);
|
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD)) {
|
||||||
|
event.setCancelled(true);
|
||||||
// TODO use display name rather than username
|
return;
|
||||||
// - Getting displayname currently causes NPE, so wait until sponge fixes that
|
}
|
||||||
|
return;
|
||||||
final String sender = player.getName();
|
}
|
||||||
final PlotId id = plot.getId();
|
if (!plot.hasOwner()) {
|
||||||
final String newMessage = StringMan.replaceAll(C.PLOT_CHAT_FORMAT.s(), "%plot_id%", id.x + ";" + id.y, "%sender%", sender);
|
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
|
||||||
final Text forcedMessage = event.getMessage().orElse(Text.EMPTY);
|
return;
|
||||||
// String forcedMessage = StringMan.replaceAll(C.PLOT_CHAT_FORCED.s(), "%plot_id%", id.x + ";" + id.y, "%sender%", sender);
|
}
|
||||||
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_UNOWNED);
|
||||||
PlotPlayer user = entry.getValue();
|
event.setCancelled(true);
|
||||||
String toSend;
|
return;
|
||||||
if (plot.equals(user.getLocation().getPlot())) {
|
}
|
||||||
toSend = newMessage;
|
if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER)) {
|
||||||
} else if (Permissions.hasPermission(user, C.PERMISSION_COMMANDS_CHAT)) {
|
return;
|
||||||
((SpongePlayer) user).player.sendMessage(forcedMessage);
|
|
||||||
continue;
|
|
||||||
} else {
|
} else {
|
||||||
continue;
|
final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
|
||||||
|
if ((flag != null) && ((HashSet<PlotBlock>) flag.getValue()).contains(SpongeUtil.getPlotBlock(l.getBlock()))) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
final String[] split = (toSend + " ").split("%msg%");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_OTHER);
|
||||||
final List<Text> components = new ArrayList<>();
|
event.setCancelled(true);
|
||||||
Text prefix = null;
|
return;
|
||||||
for (final String part : split) {
|
|
||||||
if (prefix != null) {
|
|
||||||
components.add(prefix);
|
|
||||||
} else {
|
|
||||||
prefix = message;
|
|
||||||
}
|
}
|
||||||
components.add(Text.of(part));
|
|
||||||
}
|
|
||||||
((SpongePlayer) user).player.sendMessage(Text.join(components));
|
|
||||||
}
|
|
||||||
event.setMessage(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void onBigBoom(final ExplosionEvent.Detonate event) {
|
public void onExplosion(ExplosionEvent e) throws Exception {
|
||||||
|
if (e instanceof ExplosionEvent.Detonate) {
|
||||||
|
ExplosionEvent.Detonate event = (Detonate) e;
|
||||||
final World world = event.getTargetWorld();
|
final World world = event.getTargetWorld();
|
||||||
final String worldname = world.getName();
|
final String worldname = world.getName();
|
||||||
if (!PS.get().hasPlotArea(worldname)) {
|
if (!PS.get().hasPlotArea(worldname)) {
|
||||||
@ -470,41 +438,55 @@ public class MainListener {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// @Listener
|
public void onChangeBlock(ChangeBlockEvent event) {
|
||||||
// public void onChunkPreGenerator(final ChunkPreGenerateEvent event) {
|
final World world = event.getTargetWorld();
|
||||||
// final org.spongepowered.api.world.Chunk chunk = event.getChunk();
|
final String worldname = world.getName();
|
||||||
// final World world = chunk.getWorld();
|
if (!PS.get().hasPlotArea(worldname)) {
|
||||||
// final String worldname = world.getName();
|
return;
|
||||||
// if (MainUtil.worldBorder.containsKey(worldname)) {
|
}
|
||||||
// final int border = MainUtil.getBorder(worldname);
|
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
|
||||||
// final Vector3i min = world.getBlockMin();
|
Transaction<BlockSnapshot> first = transactions.get(0);
|
||||||
// final int x = Math.abs(min.getX());
|
Location loc = SpongeUtil.getLocation(worldname, first.getOriginal().getPosition());
|
||||||
// final int z = Math.abs(min.getZ());
|
Plot plot = loc.getPlot();
|
||||||
// if ((x > border) || (z > border)) {
|
if (plot == null) {
|
||||||
// // TODO cancel this chunk from loading
|
if (loc.getPlotAbs() == null) {
|
||||||
// // - Currently not possible / this event doesn't seem to be called
|
return;
|
||||||
// }
|
}
|
||||||
// }
|
event.setCancelled(true);
|
||||||
// }
|
return;
|
||||||
|
}
|
||||||
|
event.filter(new Predicate<org.spongepowered.api.world.Location<World>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean test(org.spongepowered.api.world.Location<World> loc) {
|
||||||
|
if (SpongeUtil.getLocation(worldname, loc).isPlotRoad()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void onBlockBreak(final ChangeBlockEvent.Decay event) {
|
public void onBlockBreak(final ChangeBlockEvent.Decay event) {
|
||||||
onBlockChange(event);
|
onChangeBlock(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void onBlockBreak(final ChangeBlockEvent.Grow event) {
|
public void onBlockBreak(final ChangeBlockEvent.Grow event) {
|
||||||
onBlockChange(event);
|
onChangeBlock(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void onBlockBreak(final ChangeBlockEvent.Modify event) {
|
public void onBlockBreak(final ChangeBlockEvent.Modify event) {
|
||||||
onBlockChange(event);
|
onChangeBlock(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void onBlockBreak(final ChangeBlockEvent.Break event) {
|
public void onBlockBreak(final ChangeBlockEvent.Break event) {
|
||||||
Player player = this.<Player> getCause(event.getCause(), Player.class);
|
Player player = SpongeUtil.<Player> getCause(event.getCause(), Player.class);
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -588,7 +570,7 @@ public class MainListener {
|
|||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void onBlockPlace(final ChangeBlockEvent.Place event) {
|
public void onBlockPlace(final ChangeBlockEvent.Place event) {
|
||||||
Player player = this.<Player> getCause(event.getCause(), Player.class);
|
Player player = SpongeUtil.<Player> getCause(event.getCause(), Player.class);
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -670,52 +652,6 @@ public class MainListener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Listener
|
|
||||||
public void onBlockInteract(final InteractBlockEvent.Secondary event) {
|
|
||||||
final Player player = this.<Player> getCause(event.getCause(), Player.class);
|
|
||||||
if (player == null) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Optional<org.spongepowered.api.world.Location<World>> target = event.getTargetBlock().getLocation();
|
|
||||||
if (!target.isPresent()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
org.spongepowered.api.world.Location<World> l = target.get();
|
|
||||||
Location loc = SpongeUtil.getLocation(l);
|
|
||||||
Plot plot = loc.getPlot();
|
|
||||||
PlotPlayer pp = SpongeUtil.getPlayer(player);
|
|
||||||
if (plot == null) {
|
|
||||||
if (loc.getPlotAbs() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!plot.hasOwner()) {
|
|
||||||
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_UNOWNED);
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER)) {
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
|
|
||||||
if ((flag != null) && ((HashSet<PlotBlock>) flag.getValue()).contains(SpongeUtil.getPlotBlock(l.getBlock()))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_OTHER);
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void onConnect(final ClientConnectionEvent.Login event) {
|
public void onConnect(final ClientConnectionEvent.Login event) {
|
||||||
GameProfile profile = event.getProfile();
|
GameProfile profile = event.getProfile();
|
||||||
@ -764,16 +700,12 @@ public class MainListener {
|
|||||||
pp.unregister();
|
pp.unregister();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getInt(final double value) {
|
|
||||||
return (int) (value < 0 ? value - 1 : value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void onMove(final DisplaceEntityEvent.TargetPlayer event) {
|
public void onMove(final DisplaceEntityEvent.TargetPlayer event) {
|
||||||
final org.spongepowered.api.world.Location from = event.getFromTransform().getLocation();
|
final org.spongepowered.api.world.Location from = event.getFromTransform().getLocation();
|
||||||
org.spongepowered.api.world.Location to = event.getToTransform().getLocation();
|
org.spongepowered.api.world.Location to = event.getToTransform().getLocation();
|
||||||
int x2;
|
int x2;
|
||||||
if (getInt(from.getX()) != (x2 = getInt(to.getX()))) {
|
if (MathMan.roundInt(from.getX()) != (x2 = MathMan.roundInt(to.getX()))) {
|
||||||
final Player player = event.getTargetEntity();
|
final Player player = event.getTargetEntity();
|
||||||
final PlotPlayer pp = SpongeUtil.getPlayer(player);
|
final PlotPlayer pp = SpongeUtil.getPlayer(player);
|
||||||
final Extent extent = to.getExtent();
|
final Extent extent = to.getExtent();
|
||||||
@ -789,7 +721,7 @@ public class MainListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlotManager plotManager = PS.get().getPlotManager(PS.get().getPlot(plotworld, plotworld.getMin()));
|
final PlotManager plotManager = PS.get().getPlotManager(PS.get().getPlot(plotworld, plotworld.getMin()));
|
||||||
final PlotId id = plotManager.getPlotId(plotworld, x2, 0, getInt(to.getZ()));
|
final PlotId id = plotManager.getPlotId(plotworld, x2, 0, MathMan.roundInt(to.getZ()));
|
||||||
final Plot lastPlot = (Plot) pp.getMeta("lastplot");
|
final Plot lastPlot = (Plot) pp.getMeta("lastplot");
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
if (lastPlot == null) {
|
if (lastPlot == null) {
|
||||||
@ -835,7 +767,7 @@ public class MainListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int z2;
|
int z2;
|
||||||
if (getInt(from.getZ()) != (z2 = getInt(to.getZ()))) {
|
if (MathMan.roundInt(from.getZ()) != (z2 = MathMan.roundInt(to.getZ()))) {
|
||||||
final Player player = event.getTargetEntity();
|
final Player player = event.getTargetEntity();
|
||||||
final PlotPlayer pp = SpongeUtil.getPlayer(player);
|
final PlotPlayer pp = SpongeUtil.getPlayer(player);
|
||||||
final Extent extent = to.getExtent();
|
final Extent extent = to.getExtent();
|
||||||
|
@ -1,5 +1,28 @@
|
|||||||
package com.plotsquared.sponge.listener;
|
package com.plotsquared.sponge.listener;
|
||||||
|
|
||||||
|
import org.spongepowered.api.event.Listener;
|
||||||
|
import org.spongepowered.api.event.world.LoadWorldEvent;
|
||||||
|
import org.spongepowered.api.world.World;
|
||||||
|
import org.spongepowered.api.world.gen.GenerationPopulator;
|
||||||
|
import org.spongepowered.api.world.gen.WorldGenerator;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.PS;
|
||||||
|
import com.plotsquared.sponge.generator.SpongeTerrainGen;
|
||||||
|
|
||||||
public class WorldEvents {
|
public class WorldEvents {
|
||||||
// TODO FIXME
|
|
||||||
|
@Listener
|
||||||
|
public void onLoadWorld(LoadWorldEvent event) {
|
||||||
|
final World world = event.getTargetWorld();
|
||||||
|
final String name = world.getName();
|
||||||
|
WorldGenerator generator = world.getWorldGenerator();
|
||||||
|
GenerationPopulator terrain = generator.getBaseGenerationPopulator();
|
||||||
|
if (terrain instanceof SpongeTerrainGen) {
|
||||||
|
SpongeTerrainGen stg = (SpongeTerrainGen) terrain;
|
||||||
|
PS.get().loadWorld(name, stg.parent);
|
||||||
|
}
|
||||||
|
else if (PS.get().config.contains("worlds." + name)) {
|
||||||
|
PS.get().loadWorld(name, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import org.spongepowered.api.entity.living.player.gamemode.GameModes;
|
|||||||
import org.spongepowered.api.service.ban.BanService;
|
import org.spongepowered.api.service.ban.BanService;
|
||||||
import org.spongepowered.api.text.Text;
|
import org.spongepowered.api.text.Text;
|
||||||
import org.spongepowered.api.text.chat.ChatTypes;
|
import org.spongepowered.api.text.chat.ChatTypes;
|
||||||
|
import org.spongepowered.api.text.serializer.TextSerializers;
|
||||||
|
|
||||||
import com.flowpowered.math.vector.Vector3d;
|
import com.flowpowered.math.vector.Vector3d;
|
||||||
import com.intellectualcrafters.plot.commands.RequiredType;
|
import com.intellectualcrafters.plot.commands.RequiredType;
|
||||||
@ -99,7 +100,7 @@ public class SpongePlayer extends PlotPlayer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(final String message) {
|
public void sendMessage(final String message) {
|
||||||
player.sendMessage(ChatTypes.CHAT, Text.of(message));
|
player.sendMessage(ChatTypes.CHAT, TextSerializers.LEGACY_FORMATTING_CODE.deserialize(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package com.plotsquared.sponge.util;
|
package com.plotsquared.sponge.util;
|
||||||
|
|
||||||
|
import org.spongepowered.api.text.Text;
|
||||||
|
import org.spongepowered.api.text.action.TextActions;
|
||||||
|
import org.spongepowered.api.text.serializer.TextSerializers;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||||
import com.intellectualcrafters.plot.object.PlotMessage;
|
import com.intellectualcrafters.plot.object.PlotMessage;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.ChatManager;
|
import com.intellectualcrafters.plot.util.ChatManager;
|
||||||
import com.plotsquared.sponge.object.SpongePlayer;
|
import com.plotsquared.sponge.object.SpongePlayer;
|
||||||
import org.spongepowered.api.text.Text;
|
|
||||||
import org.spongepowered.api.text.action.TextActions;
|
|
||||||
|
|
||||||
public class SpongeChatManager extends ChatManager<Text.Builder> {
|
public class SpongeChatManager extends ChatManager<Text.Builder> {
|
||||||
|
|
||||||
@ -17,7 +19,7 @@ public class SpongeChatManager extends ChatManager<Text.Builder> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void color(final PlotMessage m, final String color) {
|
public void color(final PlotMessage m, final String color) {
|
||||||
m.$(this).color(Text.of(color).getColor());
|
m.$(this).color(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(color).getColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -74,9 +74,11 @@ public class SpongeChunkManager extends ChunkManager {
|
|||||||
@Override
|
@Override
|
||||||
public void regenerateChunk(final String world, final ChunkLoc loc) {
|
public void regenerateChunk(final String world, final ChunkLoc loc) {
|
||||||
final World worldObj = SpongeUtil.getWorld(world);
|
final World worldObj = SpongeUtil.getWorld(world);
|
||||||
final Optional<Chunk> chunk = worldObj.getChunk(loc.x << 4, 0, loc.z << 4);
|
final Optional<Chunk> chunkOpt = worldObj.getChunk(loc.x << 4, 0, loc.z << 4);
|
||||||
if (chunk.isPresent()) {
|
if (chunkOpt.isPresent()) {
|
||||||
// TODO regenerate chunk
|
Chunk chunk = chunkOpt.get();
|
||||||
|
// TODO FIXME
|
||||||
|
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +116,7 @@ public class SpongeChunkManager extends ChunkManager {
|
|||||||
@Override
|
@Override
|
||||||
public void swap(Location bot1, Location top1, Location bot2, Location top2, Runnable whenDone) {
|
public void swap(Location bot1, Location top1, Location bot2, Location top2, Runnable whenDone) {
|
||||||
// TODO swap region
|
// TODO swap region
|
||||||
|
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,13 +3,13 @@ package com.plotsquared.sponge.util;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.apache.commons.lang.NotImplementedException;
|
|
||||||
import org.spongepowered.api.Sponge;
|
import org.spongepowered.api.Sponge;
|
||||||
|
import org.spongepowered.api.event.Listener;
|
||||||
import org.spongepowered.api.event.cause.Cause;
|
import org.spongepowered.api.event.cause.Cause;
|
||||||
|
import org.spongepowered.api.event.service.ChangeServiceProviderEvent;
|
||||||
import org.spongepowered.api.service.economy.EconomyService;
|
import org.spongepowered.api.service.economy.EconomyService;
|
||||||
import org.spongepowered.api.service.economy.account.UniqueAccount;
|
import org.spongepowered.api.service.economy.account.UniqueAccount;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
|
||||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.EconHandler;
|
import com.intellectualcrafters.plot.util.EconHandler;
|
||||||
@ -22,8 +22,13 @@ public class SpongeEconHandler extends EconHandler {
|
|||||||
public SpongeEconHandler() {
|
public SpongeEconHandler() {
|
||||||
if (Sponge.getServiceManager().isRegistered(EconomyService.class)) {
|
if (Sponge.getServiceManager().isRegistered(EconomyService.class)) {
|
||||||
econ = Sponge.getServiceManager().provide(EconomyService.class).get();
|
econ = Sponge.getServiceManager().provide(EconomyService.class).get();
|
||||||
} else {
|
}
|
||||||
PS.log("No economy service was registered.");
|
}
|
||||||
|
|
||||||
|
@Listener
|
||||||
|
public void onChangeServiceProvider(ChangeServiceProviderEvent event) {
|
||||||
|
if (event.getService().equals(EconomyService.class)) {
|
||||||
|
econ = (EconomyService) event.getNewProviderRegistration().getProvider();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,6 +38,7 @@ public class SpongeEconHandler extends EconHandler {
|
|||||||
Optional<UniqueAccount> accOpt = econ.getAccount(player.getUUID());
|
Optional<UniqueAccount> accOpt = econ.getAccount(player.getUUID());
|
||||||
if (accOpt.isPresent()) {
|
if (accOpt.isPresent()) {
|
||||||
UniqueAccount acc = accOpt.get();
|
UniqueAccount acc = accOpt.get();
|
||||||
|
|
||||||
acc.withdraw(econ.getDefaultCurrency(), new BigDecimal(amount), Cause.of("PlotSquared"));
|
acc.withdraw(econ.getDefaultCurrency(), new BigDecimal(amount), Cause.of("PlotSquared"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,7 +69,7 @@ public class SpongeEconHandler extends EconHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void setPermission(String world, String player, String perm, boolean value) {
|
public void setPermission(String world, String player, String perm, boolean value) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
throw new NotImplementedException("TODO/WIP/NOT IMPLEMENTED!");
|
throw new UnsupportedOperationException("TODO/WIP/NOT IMPLEMENTED!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,22 +1,19 @@
|
|||||||
package com.plotsquared.sponge;
|
package com.plotsquared.sponge.util;
|
||||||
|
|
||||||
import org.spongepowered.api.block.BlockState;
|
import org.spongepowered.api.block.BlockState;
|
||||||
import org.spongepowered.api.block.BlockTypes;
|
import org.spongepowered.api.block.BlockTypes;
|
||||||
import org.spongepowered.api.world.World;
|
import org.spongepowered.api.world.World;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
|
||||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||||
import com.intellectualcrafters.plot.object.PlotAnalysis;
|
import com.intellectualcrafters.plot.object.PlotAnalysis;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
import com.plotsquared.sponge.util.SpongeUtil;
|
|
||||||
|
|
||||||
public class SpongeHybridUtils extends HybridUtils {
|
public class SpongeHybridUtils extends HybridUtils {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int checkModified(final String worldname, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks) {
|
public int checkModified(final String worldname, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks) {
|
||||||
PS.debug("checkModified is not implemented");
|
|
||||||
final World world = SpongeUtil.getWorld(worldname);
|
final World world = SpongeUtil.getWorld(worldname);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int y = y1; y <= y2; y++) {
|
for (int y = y1; y <= y2; y++) {
|
||||||
@ -61,8 +58,7 @@ public class SpongeHybridUtils extends HybridUtils {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyzeRegion(String world, RegionWrapper region, RunnableVal<PlotAnalysis> whenDone) {
|
public void analyzeRegion(String world, RegionWrapper region, RunnableVal<PlotAnalysis> whenDone) {
|
||||||
// TODO Auto-generated method stub
|
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||||
whenDone.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,12 +1,16 @@
|
|||||||
package com.plotsquared.sponge;
|
package com.plotsquared.sponge.util;
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.spongepowered.api.block.BlockState;
|
import org.spongepowered.api.block.BlockState;
|
||||||
|
import org.spongepowered.api.item.inventory.Carrier;
|
||||||
|
import org.spongepowered.api.item.inventory.type.CarriedInventory;
|
||||||
import org.spongepowered.api.world.World;
|
import org.spongepowered.api.world.World;
|
||||||
|
|
||||||
import com.intellectualcrafters.jnbt.ByteArrayTag;
|
import com.intellectualcrafters.jnbt.ByteArrayTag;
|
||||||
@ -24,7 +28,6 @@ import com.intellectualcrafters.plot.object.RunnableVal;
|
|||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.plotsquared.sponge.util.SpongeUtil;
|
|
||||||
|
|
||||||
public class SpongeSchematicHandler extends SchematicHandler {
|
public class SpongeSchematicHandler extends SchematicHandler {
|
||||||
|
|
||||||
@ -253,8 +256,27 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
|||||||
case 33:
|
case 33:
|
||||||
case 151:
|
case 151:
|
||||||
case 178: {
|
case 178: {
|
||||||
// TODO wrap block state...
|
CompoundTag rawTag;
|
||||||
// TODO add block state to map
|
if (state instanceof Carrier) {
|
||||||
|
Carrier chest = (Carrier) state;
|
||||||
|
CarriedInventory<? extends Carrier> inv = chest.getInventory();
|
||||||
|
// TODO serialize inventory
|
||||||
|
rawTag = null;
|
||||||
|
} else {
|
||||||
|
rawTag = null;
|
||||||
|
}
|
||||||
|
if (rawTag != null) {
|
||||||
|
final Map<String, Tag> values = new HashMap<String, Tag>();
|
||||||
|
for (final Entry<String, Tag> entry : rawTag.getValue().entrySet()) {
|
||||||
|
values.put(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
values.put("id", new StringTag("id", "Chest"));
|
||||||
|
values.put("x", new IntTag("x", x));
|
||||||
|
values.put("y", new IntTag("y", y));
|
||||||
|
values.put("z", new IntTag("z", z));
|
||||||
|
final CompoundTag tileEntityTag = new CompoundTag(values);
|
||||||
|
tileEntities.add(tileEntityTag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
blockData[index] = block.data;
|
blockData[index] = block.data;
|
176
src/main/java/com/plotsquared/sponge/util/SpongeSetupUtils.java
Normal file
176
src/main/java/com/plotsquared/sponge/util/SpongeSetupUtils.java
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
package com.plotsquared.sponge.util;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import org.spongepowered.api.Sponge;
|
||||||
|
import org.spongepowered.api.world.DimensionTypes;
|
||||||
|
import org.spongepowered.api.world.GeneratorTypes;
|
||||||
|
import org.spongepowered.api.world.World;
|
||||||
|
import org.spongepowered.api.world.WorldCreationSettings;
|
||||||
|
import org.spongepowered.api.world.WorldCreationSettings.Builder;
|
||||||
|
import org.spongepowered.api.world.gen.WorldGenerator;
|
||||||
|
import org.spongepowered.api.world.gen.WorldGeneratorModifier;
|
||||||
|
import org.spongepowered.api.world.storage.WorldProperties;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||||
|
import com.intellectualcrafters.plot.PS;
|
||||||
|
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||||
|
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
||||||
|
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotArea;
|
||||||
|
import com.intellectualcrafters.plot.object.SetupObject;
|
||||||
|
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||||
|
import com.plotsquared.sponge.generator.SpongePlotGenerator;
|
||||||
|
|
||||||
|
public class SpongeSetupUtils extends SetupUtils {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateGenerators() {
|
||||||
|
if (!SetupUtils.generators.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SetupUtils.generators.put("PlotSquared", new SpongePlotGenerator(new HybridGen()));
|
||||||
|
// TODO get external world generators
|
||||||
|
Collection<WorldGeneratorModifier> wgms = Sponge.getRegistry().getAllOf(WorldGeneratorModifier.class);
|
||||||
|
for (WorldGeneratorModifier wgm : wgms) {
|
||||||
|
String id = wgm.getId();
|
||||||
|
String name = wgm.getName();
|
||||||
|
if (wgm instanceof GeneratorWrapper<?>) {
|
||||||
|
generators.put(id, (GeneratorWrapper<?>) wgm);
|
||||||
|
generators.put(name, (GeneratorWrapper<?>) wgm);
|
||||||
|
} else {
|
||||||
|
SpongePlotGenerator wrap = new SpongePlotGenerator(wgm);
|
||||||
|
generators.put(id, wrap);
|
||||||
|
generators.put(name, wrap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGenerator(final PlotArea plotworld) {
|
||||||
|
if (SetupUtils.generators.isEmpty()) {
|
||||||
|
updateGenerators();
|
||||||
|
}
|
||||||
|
final World world = SpongeUtil.getWorld(plotworld.worldname);
|
||||||
|
if (world == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final WorldGenerator generator = world.getWorldGenerator();
|
||||||
|
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String setupWorld(final SetupObject object) {
|
||||||
|
SetupUtils.manager.updateGenerators();
|
||||||
|
ConfigurationNode[] steps = object.step == null ? new ConfigurationNode[0] : object.step;
|
||||||
|
final String world = object.world;
|
||||||
|
int type = object.type;
|
||||||
|
String worldPath = "worlds." + object.world;
|
||||||
|
if (!PS.get().config.contains(worldPath)) {
|
||||||
|
PS.get().config.createSection(worldPath);
|
||||||
|
}
|
||||||
|
ConfigurationSection worldSection = PS.get().config.getConfigurationSection(worldPath);
|
||||||
|
switch (type) {
|
||||||
|
case 2: {
|
||||||
|
if (object.id != null) {
|
||||||
|
String areaname = object.id + "-" + object.min + "-" + object.max;
|
||||||
|
String areaPath = "areas." + areaname;
|
||||||
|
if (!worldSection.contains(areaPath)) {
|
||||||
|
worldSection.createSection(areaPath);
|
||||||
|
}
|
||||||
|
ConfigurationSection areaSection = worldSection.getConfigurationSection(areaPath);
|
||||||
|
HashMap<String, Object> options = new HashMap<>();
|
||||||
|
for (final ConfigurationNode step : steps) {
|
||||||
|
options.put(step.getConstant(), step.getValue());
|
||||||
|
}
|
||||||
|
options.put("generator.type", object.type);
|
||||||
|
options.put("generator.terrain", object.terrain);
|
||||||
|
options.put("generator.plugin", object.plotManager);
|
||||||
|
if ((object.setupGenerator != null) && !object.setupGenerator.equals(object.plotManager)) {
|
||||||
|
options.put("generator.init", object.setupGenerator);
|
||||||
|
}
|
||||||
|
for (Entry<String, Object> entry : options.entrySet()) {
|
||||||
|
String key = entry.getKey();
|
||||||
|
Object value = entry.getValue();
|
||||||
|
if (worldSection.contains(key)) {
|
||||||
|
Object current = worldSection.get(key);
|
||||||
|
if (!Objects.equals(value, current)) {
|
||||||
|
areaSection.set(key, value);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
worldSection.set(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GeneratorWrapper<?> gen = generators.get(object.setupGenerator);
|
||||||
|
if ((gen != null) && gen.isFull()) {
|
||||||
|
object.setupGenerator = null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: {
|
||||||
|
for (final ConfigurationNode step : steps) {
|
||||||
|
worldSection.set(step.getConstant(), step.getValue());
|
||||||
|
}
|
||||||
|
PS.get().config.set("worlds." + world + "." + "generator.type", object.type);
|
||||||
|
PS.get().config.set("worlds." + world + "." + "generator.terrain", object.terrain);
|
||||||
|
PS.get().config.set("worlds." + world + "." + "generator.plugin", object.plotManager);
|
||||||
|
if ((object.setupGenerator != null) && !object.setupGenerator.equals(object.plotManager)) {
|
||||||
|
PS.get().config.set("worlds." + world + "." + "generator.init", object.setupGenerator);
|
||||||
|
}
|
||||||
|
GeneratorWrapper<?> gen = generators.get(object.setupGenerator);
|
||||||
|
if ((gen != null) && gen.isFull()) {
|
||||||
|
object.setupGenerator = null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 0: {
|
||||||
|
for (final ConfigurationNode step : steps) {
|
||||||
|
worldSection.set(step.getConstant(), step.getValue());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
PS.get().config.save(PS.get().configFile);
|
||||||
|
} catch (final IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if (object.setupGenerator != null) {
|
||||||
|
// create world with generator
|
||||||
|
GeneratorWrapper<?> gw = generators.get(object.setupGenerator);
|
||||||
|
WorldGeneratorModifier wgm = (WorldGeneratorModifier) gw.getPlatformGenerator();
|
||||||
|
|
||||||
|
WorldCreationSettings settings = Sponge.getRegistry().createBuilder(Builder.class)
|
||||||
|
.name(object.world)
|
||||||
|
.loadsOnStartup(true)
|
||||||
|
.keepsSpawnLoaded(false)
|
||||||
|
.dimension(DimensionTypes.OVERWORLD)
|
||||||
|
.generator(GeneratorTypes.FLAT)
|
||||||
|
.usesMapFeatures(false)
|
||||||
|
.enabled(true)
|
||||||
|
.generatorModifiers(wgm)
|
||||||
|
.build();
|
||||||
|
WorldProperties properties = Sponge.getServer().createWorldProperties(settings).get();
|
||||||
|
World worldObj = Sponge.getServer().loadWorld(properties).get();
|
||||||
|
} else {
|
||||||
|
// create vanilla world
|
||||||
|
WorldCreationSettings settings = Sponge.getRegistry().createBuilder(Builder.class)
|
||||||
|
.name(object.world)
|
||||||
|
.loadsOnStartup(true)
|
||||||
|
.keepsSpawnLoaded(false)
|
||||||
|
.dimension(DimensionTypes.OVERWORLD)
|
||||||
|
.generator(GeneratorTypes.OVERWORLD)
|
||||||
|
.usesMapFeatures(true)
|
||||||
|
.enabled(true)
|
||||||
|
.build();
|
||||||
|
WorldProperties properties = Sponge.getServer().createWorldProperties(settings).get();
|
||||||
|
World worldObj = Sponge.getServer().loadWorld(properties).get();
|
||||||
|
}
|
||||||
|
return object.world;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,8 @@
|
|||||||
package com.plotsquared.sponge.util;
|
package com.plotsquared.sponge.util;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -17,6 +19,7 @@ import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData;
|
|||||||
import org.spongepowered.api.data.value.mutable.ListValue;
|
import org.spongepowered.api.data.value.mutable.ListValue;
|
||||||
import org.spongepowered.api.entity.Entity;
|
import org.spongepowered.api.entity.Entity;
|
||||||
import org.spongepowered.api.entity.living.player.Player;
|
import org.spongepowered.api.entity.living.player.Player;
|
||||||
|
import org.spongepowered.api.event.cause.Cause;
|
||||||
import org.spongepowered.api.text.Text;
|
import org.spongepowered.api.text.Text;
|
||||||
import org.spongepowered.api.text.translation.Translatable;
|
import org.spongepowered.api.text.translation.Translatable;
|
||||||
import org.spongepowered.api.text.translation.Translation;
|
import org.spongepowered.api.text.translation.Translation;
|
||||||
@ -27,6 +30,7 @@ import org.spongepowered.api.world.extent.Extent;
|
|||||||
|
|
||||||
import com.flowpowered.math.vector.Vector3d;
|
import com.flowpowered.math.vector.Vector3d;
|
||||||
import com.flowpowered.math.vector.Vector3i;
|
import com.flowpowered.math.vector.Vector3i;
|
||||||
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
@ -35,6 +39,7 @@ import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
|||||||
import com.intellectualcrafters.plot.util.MathMan;
|
import com.intellectualcrafters.plot.util.MathMan;
|
||||||
import com.intellectualcrafters.plot.util.ReflectionUtils;
|
import com.intellectualcrafters.plot.util.ReflectionUtils;
|
||||||
import com.intellectualcrafters.plot.util.StringComparison;
|
import com.intellectualcrafters.plot.util.StringComparison;
|
||||||
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||||
import com.plotsquared.sponge.SpongeMain;
|
import com.plotsquared.sponge.SpongeMain;
|
||||||
@ -59,6 +64,24 @@ public class SpongeUtil extends WorldUtil {
|
|||||||
return biomes[biomeMap.get(biome.toUpperCase())];
|
return biomes[biomeMap.get(biome.toUpperCase())];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> T getCause(Cause cause, Class<T> clazz) {
|
||||||
|
Optional<?> root = Optional.of(cause.root());
|
||||||
|
if (root.isPresent()) {
|
||||||
|
Object source = root.get();
|
||||||
|
if (clazz.isInstance(source)) {
|
||||||
|
return (T) source;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void printCause(String method, Cause cause) {
|
||||||
|
System.out.println(method + ": " + cause.toString());
|
||||||
|
System.out.println(method + ": " + cause.getClass());
|
||||||
|
System.out.println(method + ": " + StringMan.getString(cause.all()));
|
||||||
|
System.out.println(method + ": " + (cause.root()));
|
||||||
|
}
|
||||||
|
|
||||||
public static void initBiomeCache() {
|
public static void initBiomeCache() {
|
||||||
try {
|
try {
|
||||||
Field[] fields = BiomeTypes.class.getFields();
|
Field[] fields = BiomeTypes.class.getFields();
|
||||||
@ -112,12 +135,61 @@ public class SpongeUtil extends WorldUtil {
|
|||||||
}.getTranslation();
|
}.getTranslation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static HashMap<BlockState, PlotBlock> stateMap;
|
||||||
|
private static BlockState[] stateArray;
|
||||||
|
|
||||||
|
private static void initBlockCache() {
|
||||||
|
try {
|
||||||
|
PS.debug("Caching block id/data: Please wait...");
|
||||||
|
stateArray = new BlockState[Character.MAX_VALUE];
|
||||||
|
stateMap = new HashMap<>();
|
||||||
|
Class<?> classBlock = Class.forName("net.minecraft.block.Block");
|
||||||
|
Class<?> classBlockState = Class.forName("net.minecraft.block.state.IBlockState");
|
||||||
|
Method[] blockMethods = classBlock.getDeclaredMethods();
|
||||||
|
Method methodGetByCombinedId = null;
|
||||||
|
for (Method method : blockMethods) {
|
||||||
|
Class<?> result = method.getReturnType();
|
||||||
|
Class<?>[] param = method.getParameterTypes();
|
||||||
|
int paramCount = param.length;
|
||||||
|
boolean isStatic = Modifier.isStatic(method.getModifiers());
|
||||||
|
if (methodGetByCombinedId == null) {
|
||||||
|
if (isStatic && result == classBlockState && paramCount == 1 && param[0] == int.class) {
|
||||||
|
methodGetByCombinedId = method;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < Character.MAX_VALUE; i++) {
|
||||||
|
try {
|
||||||
|
BlockState state = (BlockState) methodGetByCombinedId.invoke(null, i);
|
||||||
|
if (state.getType() == BlockTypes.AIR) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int id = i & 0xFFF;
|
||||||
|
int data = i >> 12 & 0xF;
|
||||||
|
PlotBlock plotBlock = new PlotBlock((short) id, (byte) data);
|
||||||
|
stateArray[i] = state;
|
||||||
|
stateMap.put(state, plotBlock);
|
||||||
|
} catch (Throwable e) {}
|
||||||
|
}
|
||||||
|
PS.debug("Done!");
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static BlockState getBlockState(int id, int data) {
|
public static BlockState getBlockState(int id, int data) {
|
||||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
if (stateArray == null) {
|
||||||
|
initBlockCache();
|
||||||
|
}
|
||||||
|
return stateArray[id + (data << 12)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlotBlock getPlotBlock(BlockState state) {
|
public static PlotBlock getPlotBlock(BlockState state) {
|
||||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
if (stateMap == null) {
|
||||||
|
initBlockCache();
|
||||||
|
}
|
||||||
|
return stateMap.get(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location getLocation(final org.spongepowered.api.world.Location<World> block) {
|
public static Location getLocation(final org.spongepowered.api.world.Location<World> block) {
|
||||||
@ -165,7 +237,7 @@ public class SpongeUtil extends WorldUtil {
|
|||||||
if (world == last) {
|
if (world == last) {
|
||||||
return lastWorld;
|
return lastWorld;
|
||||||
}
|
}
|
||||||
final Optional<World> optional = SpongeMain.THIS.getServer().getWorld(world);
|
final Optional<World> optional = Sponge.getServer().getWorld(world);
|
||||||
if (!optional.isPresent()) {
|
if (!optional.isPresent()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
Arts
|
|
||||||
BannerPatternShapes
|
|
||||||
BigMushroomTypes
|
|
||||||
BodyParts
|
|
||||||
BrickTypes
|
|
||||||
Careers
|
|
||||||
CoalTypes
|
|
||||||
Comparisons
|
|
||||||
CookedFishes
|
|
||||||
DirtTypes
|
|
||||||
DisguisedBlockTypes
|
|
||||||
DoubleSizePlantTypes
|
|
||||||
DyeColors
|
|
||||||
Fishes
|
|
||||||
GoldenApples
|
|
||||||
Hinges
|
|
||||||
HorseColors
|
|
||||||
HorseStyles
|
|
||||||
HorseVariants
|
|
||||||
InstrumentTypes
|
|
||||||
NotePitches
|
|
||||||
OcelotTypes
|
|
||||||
PistonTypes
|
|
||||||
PlantTypes
|
|
||||||
PortionTypes
|
|
||||||
PrismarineTypes
|
|
||||||
Professions
|
|
||||||
QuartzTypes
|
|
||||||
RabbitTypes
|
|
||||||
RailDirections
|
|
||||||
SandstoneTypes
|
|
||||||
SandTypes
|
|
||||||
ShrubTypes
|
|
||||||
SkeletonTypes
|
|
||||||
SkullTypes
|
|
||||||
SlabTypes
|
|
||||||
StairShapes
|
|
||||||
StoneTypes
|
|
||||||
TreeTypes
|
|
||||||
WallTypes
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user