mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-23 05:36:45 +01:00
Fixed setup command
This commit is contained in:
parent
5e2313a6cb
commit
702e2bf975
@ -6,7 +6,7 @@
|
|||||||
<groupId>com.intellectualcrafters</groupId>
|
<groupId>com.intellectualcrafters</groupId>
|
||||||
|
|
||||||
<artifactId>PlotSquared</artifactId>
|
<artifactId>PlotSquared</artifactId>
|
||||||
<version>2.4.0</version>
|
<version>2.4.1</version>
|
||||||
<name>PlotSquared</name>
|
<name>PlotSquared</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<build>
|
<build>
|
||||||
|
@ -902,7 +902,6 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*
|
*
|
||||||
* @param plotworld World to create the section for
|
* @param plotworld World to create the section for
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public static void createConfiguration(final PlotWorld plotworld) {
|
public static void createConfiguration(final PlotWorld plotworld) {
|
||||||
final Map<String, Object> options = new HashMap<>();
|
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>());
|
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 PlotWorld plotWorld;
|
||||||
final PlotGenerator plotGenerator;
|
final PlotGenerator plotGenerator;
|
||||||
final PlotManager plotManager;
|
final PlotManager plotManager;
|
||||||
|
@ -125,9 +125,9 @@ import org.bukkit.entity.Player;
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final int diff = PlayerFunctions.getPlayerPlotCount(world, plr) - PlayerFunctions.getAllowedPlots(plr);
|
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) {
|
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 {
|
} else {
|
||||||
PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
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.PlotGenerator;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
@ -75,7 +77,8 @@ public class Setup extends SubCommand implements Listener {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
PlotMain.config.save(PlotMain.configFile);
|
PlotMain.config.save(PlotMain.configFile);
|
||||||
} catch (final IOException e) {
|
PlotMain.config.load(PlotMain.configFile);
|
||||||
|
} catch (final IOException | InvalidConfigurationException e) {
|
||||||
e.printStackTrace();
|
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);
|
sendMessage(plr, C.SETUP_FINISHED, object.world);
|
||||||
|
|
||||||
@ -196,6 +205,7 @@ public class Setup extends SubCommand implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
plotworld = new DefaultPlotWorld(world);
|
plotworld = new DefaultPlotWorld(world);
|
||||||
}
|
}
|
||||||
|
PlotMain.removePlotWorld(world);
|
||||||
|
|
||||||
setupMap.put(plrname, new SetupObject(world, plotworld, args[1]));
|
setupMap.put(plrname, new SetupObject(world, plotworld, args[1]));
|
||||||
sendMessage(plr, C.SETUP_INIT);
|
sendMessage(plr, C.SETUP_INIT);
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
package com.intellectualcrafters.plot.config;
|
package com.intellectualcrafters.plot.config;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
|
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -165,7 +166,7 @@ import java.util.List;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object parseObject(final Object object) {
|
public Object parseObject(final Object object) {
|
||||||
return ((PlotBlock) object).id + ":" + ((PlotBlock) object).data;
|
return object;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static final SettingValue BLOCKLIST = new SettingValue("BLOCKLIST") {
|
public static final SettingValue BLOCKLIST = new SettingValue("BLOCKLIST") {
|
||||||
@ -235,11 +236,7 @@ import java.util.List;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object parseObject(final Object object) {
|
public Object parseObject(final Object object) {
|
||||||
final List<String> list = new ArrayList<>();
|
return object;
|
||||||
for (final PlotBlock block : (PlotBlock[]) object) {
|
|
||||||
list.add((block.id + ":" + (block.data)));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -22,9 +22,13 @@
|
|||||||
package com.intellectualcrafters.plot.config;
|
package com.intellectualcrafters.plot.config;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.Configuration.SettingValue;
|
import com.intellectualcrafters.plot.config.Configuration.SettingValue;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration Node
|
* Configuration Node
|
||||||
@ -71,6 +75,16 @@ public class ConfigurationNode {
|
|||||||
if (this.value instanceof String[]) {
|
if (this.value instanceof String[]) {
|
||||||
return Arrays.asList((String[]) this.value);
|
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;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,12 +159,11 @@ public class DefaultPlotWorld extends PlotWorld {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void loadConfiguration(final ConfigurationSection config) {
|
public void loadConfiguration(final ConfigurationSection config) {
|
||||||
this.PLOT_HEIGHT = config.getInt("plot.height");
|
|
||||||
|
|
||||||
if (!config.contains("plot.height")) {
|
if (!config.contains("plot.height")) {
|
||||||
PlotMain.sendConsoleSenderMessage(" - &cConfiguration is null? (" + config.getCurrentPath() + ")");
|
PlotMain.sendConsoleSenderMessage(" - &cConfiguration is null? (" + config.getCurrentPath() + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.PLOT_HEIGHT = config.getInt("plot.height");
|
||||||
this.PLOT_WIDTH = config.getInt("plot.size");
|
this.PLOT_WIDTH = config.getInt("plot.size");
|
||||||
this.MAIN_BLOCK = (PlotBlock[]) Configuration.BLOCKLIST.parseString(StringUtils.join(config.getStringList("plot.filling"), ','));
|
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"), ','));
|
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) {
|
if (this.plotworld == null) {
|
||||||
this.plotworld = (DefaultPlotWorld) PlotMain.getWorldSettings(world);
|
this.plotworld = (DefaultPlotWorld) PlotMain.getWorldSettings(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.plotsize = this.plotworld.PLOT_WIDTH;
|
this.plotsize = this.plotworld.PLOT_WIDTH;
|
||||||
|
|
||||||
this.pathsize = this.plotworld.ROAD_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.PlotMain;
|
||||||
import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
|
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.PlotDeleteEvent;
|
||||||
import com.intellectualcrafters.plot.events.PlotMergeEvent;
|
import com.intellectualcrafters.plot.events.PlotMergeEvent;
|
||||||
import com.intellectualcrafters.plot.events.PlotUnlinkEvent;
|
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.managers.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
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) {
|
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 {
|
try {
|
||||||
final RegionManager manager = PlotMain.worldGuard.getRegionManager(world);
|
final RegionManager manager = PlotMain.worldGuard.getRegionManager(world);
|
||||||
manager.getRegion(plot.id.x + "-" + plot.id.y);
|
ProtectedRegion region = manager.getRegion(plot.id.x + "-" + plot.id.y);
|
||||||
requester.performCommand("region setowner " + (plot.id.x + "-" + plot.id.y) + " " + UUIDHandler.getName(owner));
|
DefaultDomain owners = new DefaultDomain();
|
||||||
requester.performCommand("region removeowner " + (plot.id.x + "-" + plot.id.y) + " " + UUIDHandler.getName(plot.getOwner()));
|
owners.addPlayer(UUIDHandler.getName(owner));
|
||||||
|
region.setOwners(owners);
|
||||||
} catch (final Exception e) {
|
} 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)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onMerge(final PlotMergeEvent event) {
|
public void onMerge(final PlotMergeEvent event) {
|
||||||
final Plot main = event.getPlot();
|
final Plot main = event.getPlot();
|
||||||
@ -165,7 +153,6 @@ public class WorldGuardListener implements Listener {
|
|||||||
manager.addRegion(rg);
|
manager.addRegion(rg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onUnlink(final PlotUnlinkEvent event) {
|
public void onUnlink(final PlotUnlinkEvent event) {
|
||||||
try {
|
try {
|
||||||
@ -199,11 +186,9 @@ public class WorldGuardListener implements Listener {
|
|||||||
manager.addRegion(rg);
|
manager.addRegion(rg);
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
//
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlotClaim(final PlayerClaimPlotEvent event) {
|
public void onPlotClaim(final PlayerClaimPlotEvent event) {
|
||||||
try {
|
try {
|
||||||
@ -226,11 +211,9 @@ public class WorldGuardListener implements Listener {
|
|||||||
|
|
||||||
manager.addRegion(region);
|
manager.addRegion(region);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
//
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlotDelete(final PlotDeleteEvent event) {
|
public void onPlotDelete(final PlotDeleteEvent event) {
|
||||||
try {
|
try {
|
||||||
@ -240,7 +223,49 @@ public class WorldGuardListener implements Listener {
|
|||||||
final RegionManager manager = PlotMain.worldGuard.getRegionManager(world);
|
final RegionManager manager = PlotMain.worldGuard.getRegionManager(world);
|
||||||
manager.removeRegion(plot.x + "-" + plot.y);
|
manager.removeRegion(plot.x + "-" + plot.y);
|
||||||
} catch (final Exception e) {
|
} 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