2014-09-26 14:17:52 +10:00
|
|
|
/*
|
|
|
|
* Copyright (c) IntellectualCrafters - 2014.
|
|
|
|
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
|
|
|
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
|
|
|
*
|
|
|
|
* >> File = Unlink.java
|
|
|
|
* >> Generated by: Citymonstret at 2014-08-09 01:41
|
|
|
|
*/
|
|
|
|
|
|
|
|
package com.intellectualcrafters.plot.commands;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import org.bukkit.World;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
import com.intellectualcrafters.plot.C;
|
|
|
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
|
|
|
import com.intellectualcrafters.plot.Plot;
|
|
|
|
import com.intellectualcrafters.plot.PlotHelper;
|
|
|
|
import com.intellectualcrafters.plot.PlotId;
|
|
|
|
import com.intellectualcrafters.plot.PlotMain;
|
|
|
|
import com.intellectualcrafters.plot.PlotSettings;
|
|
|
|
import com.intellectualcrafters.plot.database.DBFunc;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by Citymonstret on 2014-08-01.
|
|
|
|
*/
|
|
|
|
public class Unlink extends SubCommand {
|
|
|
|
|
|
|
|
public Unlink() {
|
|
|
|
super(Command.UNLINK, "Unlink a mega-plot", "unlink", CommandCategory.ACTIONS);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean execute(Player plr, String... args) {
|
|
|
|
if (!PlayerFunctions.isInPlot(plr)) {
|
|
|
|
PlayerFunctions.sendMessage(plr, "You're not in a plot.");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
|
|
|
if ((plot==null || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) {
|
|
|
|
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
|
|
|
PlayerFunctions.sendMessage(plr, C.UNLINK_IMPOSSIBLE);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
World world = plr.getWorld();
|
|
|
|
ArrayList<PlotId> ids = PlayerFunctions.getPlotSelectionIds(world, PlayerFunctions.getBottomPlot(world, plot).id, PlayerFunctions.getTopPlot(world, plot).id);
|
|
|
|
for (PlotId id:ids) {
|
|
|
|
Plot myplot = PlotMain.getPlots(world).get(id);
|
|
|
|
myplot.settings.setMerged(new boolean[] {false, false, false, false} );
|
|
|
|
DBFunc.setMerged(world.getName(), myplot, myplot.settings.getMerged());
|
|
|
|
}
|
2014-09-26 18:07:24 +10:00
|
|
|
PlayerFunctions.sendMessage(plr, "&cPLOT UNLINKING IS NOT FINISHED (as you can see by the lack of roads appearing)");
|
2014-09-26 14:17:52 +10:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|