[UNTESTED] Plot change owner

This commit is contained in:
boy0001 2014-12-15 23:40:31 +11:00
parent 46a00357b3
commit c8313d6cd9

View File

@ -25,10 +25,15 @@ import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.UUID; import java.util.UUID;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@ -59,14 +64,25 @@ public class SetOwner extends SubCommand {
PlayerFunctions.sendMessage(plr, C.NEED_USER); PlayerFunctions.sendMessage(plr, C.NEED_USER);
return true; return true;
} }
plot.owner = getUUID(args[0]);
PlotMain.updatePlot(plot); World world = plr.getWorld();
DBFunc.setOwner(plot, plot.owner); PlotId bot = PlayerFunctions.getBottomPlot(world, plot).id;
PlayerFunctions.sendMessage(plr, C.SET_OWNER); PlotId top = PlayerFunctions.getTopPlot(world, plot).id;
if (PlotMain.worldGuardListener != null) { ArrayList<PlotId> plots = PlayerFunctions.getPlotSelectionIds(world, bot, top);
PlotMain.worldGuardListener.changeOwner(plr, plot.owner, plr.getWorld(), plot);
for (PlotId id : plots) {
Plot current = PlotMain.getPlots(world).get(id);
current.owner = getUUID(args[0]);
PlotMain.updatePlot(current);
DBFunc.setOwner(current, current.owner);
if (PlotMain.worldGuardListener != null) {
PlotMain.worldGuardListener.changeOwner(plr, current.owner, plr.getWorld(), current);
}
} }
PlayerFunctions.sendMessage(plr, C.SET_OWNER);
return true; return true;
} }