mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
[UNTESTED] Plot change owner
This commit is contained in:
parent
46a00357b3
commit
c8313d6cd9
@ -25,10 +25,15 @@ import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -59,15 +64,26 @@ public class SetOwner extends SubCommand {
|
||||
PlayerFunctions.sendMessage(plr, C.NEED_USER);
|
||||
return true;
|
||||
}
|
||||
plot.owner = getUUID(args[0]);
|
||||
PlotMain.updatePlot(plot);
|
||||
DBFunc.setOwner(plot, plot.owner);
|
||||
PlayerFunctions.sendMessage(plr, C.SET_OWNER);
|
||||
|
||||
if (PlotMain.worldGuardListener != null) {
|
||||
PlotMain.worldGuardListener.changeOwner(plr, plot.owner, plr.getWorld(), plot);
|
||||
World world = plr.getWorld();
|
||||
PlotId bot = PlayerFunctions.getBottomPlot(world, plot).id;
|
||||
PlotId top = PlayerFunctions.getTopPlot(world, plot).id;
|
||||
|
||||
ArrayList<PlotId> plots = PlayerFunctions.getPlotSelectionIds(world, bot, top);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user