mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-09 09:59:48 +01:00
Fixed setup command
This commit is contained in:
parent
5e2313a6cb
commit
702e2bf975
@ -6,7 +6,7 @@
|
||||
<groupId>com.intellectualcrafters</groupId>
|
||||
|
||||
<artifactId>PlotSquared</artifactId>
|
||||
<version>2.4.0</version>
|
||||
<version>2.4.1</version>
|
||||
<name>PlotSquared</name>
|
||||
<packaging>jar</packaging>
|
||||
<build>
|
||||
|
@ -902,7 +902,6 @@ import java.util.concurrent.TimeUnit;
|
||||
*
|
||||
* @param plotworld World to create the section for
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public static void createConfiguration(final PlotWorld plotworld) {
|
||||
final Map<String, Object> options = new HashMap<>();
|
||||
|
||||
@ -930,7 +929,6 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
final Set<String> worlds = (config.contains("worlds") ? config.getConfigurationSection("worlds").getKeys(false) : new HashSet<String>());
|
||||
|
||||
// Let's create these here instead
|
||||
final PlotWorld plotWorld;
|
||||
final PlotGenerator plotGenerator;
|
||||
final PlotManager plotManager;
|
||||
|
@ -125,9 +125,9 @@ import org.bukkit.entity.Player;
|
||||
return false;
|
||||
}
|
||||
final int diff = PlayerFunctions.getPlayerPlotCount(world, plr) - PlayerFunctions.getAllowedPlots(plr);
|
||||
if ((diff + (size_x * size_z)) >= 0) {
|
||||
if ((diff + (size_x * size_z)) > 0) {
|
||||
if (diff < 0) {
|
||||
PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, (-diff - 1) + "");
|
||||
PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, (-diff) + "");
|
||||
} else {
|
||||
PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||
}
|
||||
|
@ -28,10 +28,12 @@ import com.intellectualcrafters.plot.generator.DefaultPlotWorld;
|
||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
@ -75,7 +77,8 @@ public class Setup extends SubCommand implements Listener {
|
||||
}
|
||||
try {
|
||||
PlotMain.config.save(PlotMain.configFile);
|
||||
} catch (final IOException e) {
|
||||
PlotMain.config.load(PlotMain.configFile);
|
||||
} catch (final IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@ -104,6 +107,12 @@ public class Setup extends SubCommand implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
plr.teleport(Bukkit.getWorld(world).getSpawnLocation());
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
}
|
||||
sendMessage(plr, C.SETUP_FINISHED, object.world);
|
||||
|
||||
@ -196,6 +205,7 @@ public class Setup extends SubCommand implements Listener {
|
||||
} else {
|
||||
plotworld = new DefaultPlotWorld(world);
|
||||
}
|
||||
PlotMain.removePlotWorld(world);
|
||||
|
||||
setupMap.put(plrname, new SetupObject(world, plotworld, args[1]));
|
||||
sendMessage(plr, C.SETUP_INIT);
|
||||
|
@ -22,6 +22,7 @@
|
||||
package com.intellectualcrafters.plot.config;
|
||||
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -165,7 +166,7 @@ import java.util.List;
|
||||
|
||||
@Override
|
||||
public Object parseObject(final Object object) {
|
||||
return ((PlotBlock) object).id + ":" + ((PlotBlock) object).data;
|
||||
return object;
|
||||
}
|
||||
};
|
||||
public static final SettingValue BLOCKLIST = new SettingValue("BLOCKLIST") {
|
||||
@ -235,11 +236,7 @@ import java.util.List;
|
||||
|
||||
@Override
|
||||
public Object parseObject(final Object object) {
|
||||
final List<String> list = new ArrayList<>();
|
||||
for (final PlotBlock block : (PlotBlock[]) object) {
|
||||
list.add((block.id + ":" + (block.data)));
|
||||
}
|
||||
return list;
|
||||
return object;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -22,9 +22,13 @@
|
||||
package com.intellectualcrafters.plot.config;
|
||||
|
||||
import com.intellectualcrafters.plot.config.Configuration.SettingValue;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Configuration Node
|
||||
@ -71,6 +75,16 @@ public class ConfigurationNode {
|
||||
if (this.value instanceof String[]) {
|
||||
return Arrays.asList((String[]) this.value);
|
||||
}
|
||||
else if (this.value instanceof Object[]) {
|
||||
List<String> values = new ArrayList<String>();
|
||||
for (Object value : (Object[]) this.value) {
|
||||
values.add(value.toString());
|
||||
}
|
||||
return values;
|
||||
}
|
||||
else if (this.value instanceof PlotBlock) {
|
||||
return this.value.toString();
|
||||
}
|
||||
return this.value;
|
||||
}
|
||||
|
||||
|
@ -159,12 +159,11 @@ public class DefaultPlotWorld extends PlotWorld {
|
||||
*/
|
||||
@Override
|
||||
public void loadConfiguration(final ConfigurationSection config) {
|
||||
this.PLOT_HEIGHT = config.getInt("plot.height");
|
||||
|
||||
if (!config.contains("plot.height")) {
|
||||
PlotMain.sendConsoleSenderMessage(" - &cConfiguration is null? (" + config.getCurrentPath() + ")");
|
||||
}
|
||||
|
||||
this.PLOT_HEIGHT = config.getInt("plot.height");
|
||||
this.PLOT_WIDTH = config.getInt("plot.size");
|
||||
this.MAIN_BLOCK = (PlotBlock[]) Configuration.BLOCKLIST.parseString(StringUtils.join(config.getStringList("plot.filling"), ','));
|
||||
this.TOP_BLOCK = (PlotBlock[]) Configuration.BLOCKLIST.parseString(StringUtils.join(config.getStringList("plot.floor"), ','));
|
||||
|
@ -86,7 +86,6 @@ public class WorldGenerator extends PlotGenerator {
|
||||
if (this.plotworld == null) {
|
||||
this.plotworld = (DefaultPlotWorld) PlotMain.getWorldSettings(world);
|
||||
}
|
||||
|
||||
this.plotsize = this.plotworld.PLOT_WIDTH;
|
||||
|
||||
this.pathsize = this.plotworld.ROAD_WIDTH;
|
||||
|
@ -23,6 +23,8 @@ package com.intellectualcrafters.plot.listeners;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
|
||||
import com.intellectualcrafters.plot.events.PlayerPlotHelperEvent;
|
||||
import com.intellectualcrafters.plot.events.PlayerPlotTrustedEvent;
|
||||
import com.intellectualcrafters.plot.events.PlotDeleteEvent;
|
||||
import com.intellectualcrafters.plot.events.PlotMergeEvent;
|
||||
import com.intellectualcrafters.plot.events.PlotUnlinkEvent;
|
||||
@ -37,6 +39,7 @@ import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@ -71,27 +74,13 @@ public class WorldGuardListener implements Listener {
|
||||
}
|
||||
|
||||
public void changeOwner(final Player requester, final UUID owner, final World world, final Plot plot) {
|
||||
// boolean op = requester.isOp();
|
||||
// requester.setOp(true);
|
||||
|
||||
// 10 ticks should be enough
|
||||
final PermissionAttachment add = requester.addAttachment(PlotMain.getMain(), 10);
|
||||
add.setPermission("worldguard.region.addowner.own.*", true);
|
||||
|
||||
final PermissionAttachment remove = requester.addAttachment(PlotMain.getMain(), 10);
|
||||
remove.setPermission("worldguard.region.removeowner.own.*", true);
|
||||
|
||||
try {
|
||||
final RegionManager manager = PlotMain.worldGuard.getRegionManager(world);
|
||||
manager.getRegion(plot.id.x + "-" + plot.id.y);
|
||||
requester.performCommand("region setowner " + (plot.id.x + "-" + plot.id.y) + " " + UUIDHandler.getName(owner));
|
||||
requester.performCommand("region removeowner " + (plot.id.x + "-" + plot.id.y) + " " + UUIDHandler.getName(plot.getOwner()));
|
||||
final RegionManager manager = PlotMain.worldGuard.getRegionManager(world);
|
||||
ProtectedRegion region = manager.getRegion(plot.id.x + "-" + plot.id.y);
|
||||
DefaultDomain owners = new DefaultDomain();
|
||||
owners.addPlayer(UUIDHandler.getName(owner));
|
||||
region.setOwners(owners);
|
||||
} catch (final Exception e) {
|
||||
// requester.setOp(op);
|
||||
|
||||
} finally {
|
||||
add.remove();
|
||||
remove.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,7 +120,6 @@ public class WorldGuardListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onMerge(final PlotMergeEvent event) {
|
||||
final Plot main = event.getPlot();
|
||||
@ -165,7 +153,6 @@ public class WorldGuardListener implements Listener {
|
||||
manager.addRegion(rg);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onUnlink(final PlotUnlinkEvent event) {
|
||||
try {
|
||||
@ -199,11 +186,9 @@ public class WorldGuardListener implements Listener {
|
||||
manager.addRegion(rg);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@EventHandler
|
||||
public void onPlotClaim(final PlayerClaimPlotEvent event) {
|
||||
try {
|
||||
@ -226,11 +211,9 @@ public class WorldGuardListener implements Listener {
|
||||
|
||||
manager.addRegion(region);
|
||||
} catch (final Exception e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@EventHandler
|
||||
public void onPlotDelete(final PlotDeleteEvent event) {
|
||||
try {
|
||||
@ -240,7 +223,49 @@ public class WorldGuardListener implements Listener {
|
||||
final RegionManager manager = PlotMain.worldGuard.getRegionManager(world);
|
||||
manager.removeRegion(plot.x + "-" + plot.y);
|
||||
} catch (final Exception e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
public void addUser(final Player requester, final UUID user, final World world, final Plot plot) {
|
||||
final RegionManager manager = PlotMain.worldGuard.getRegionManager(world);
|
||||
ProtectedRegion region = manager.getRegion(plot.id.x + "-" + plot.id.y);
|
||||
DefaultDomain members = region.getMembers();
|
||||
members.addPlayer(UUIDHandler.getName(user));
|
||||
region.setMembers(members);
|
||||
}
|
||||
|
||||
public void removeUser(final Player requester, final UUID user, final World world, final Plot plot) {
|
||||
final RegionManager manager = PlotMain.worldGuard.getRegionManager(world);
|
||||
ProtectedRegion region = manager.getRegion(plot.id.x + "-" + plot.id.y);
|
||||
DefaultDomain members = region.getMembers();
|
||||
members.removePlayer(UUIDHandler.getName(user));
|
||||
region.setMembers(members);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlotHelper(final PlayerPlotHelperEvent event) {
|
||||
if (event.wasAdded()) {
|
||||
addUser(event.getInitiator(), event.getPlayer(), event.getInitiator().getWorld(), event.getPlot());
|
||||
}
|
||||
else {
|
||||
removeUser(event.getInitiator(), event.getPlayer(), event.getInitiator().getWorld(), event.getPlot());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlotTrusted(final PlayerPlotTrustedEvent event) {
|
||||
if (event.wasAdded()) {
|
||||
addUser(event.getInitiator(), event.getPlayer(), event.getInitiator().getWorld(), event.getPlot());
|
||||
}
|
||||
else {
|
||||
removeUser(event.getInitiator(), event.getPlayer(), event.getInitiator().getWorld(), event.getPlot());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlotDenied(final PlayerPlotTrustedEvent event) {
|
||||
if (event.wasAdded()) {
|
||||
removeUser(event.getInitiator(), event.getPlayer(), event.getInitiator().getWorld(), event.getPlot());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user