mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 06:36:44 +01:00
worldguard regions now support owner changes
This commit is contained in:
parent
a67e03fec4
commit
d2107e0176
@ -3,6 +3,7 @@ package com.intellectualcrafters.plot;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
public class Configuration {
|
public class Configuration {
|
||||||
|
@ -51,6 +51,11 @@ public class SetOwner extends SubCommand {
|
|||||||
PlotMain.updatePlot(plot);
|
PlotMain.updatePlot(plot);
|
||||||
DBFunc.setOwner(plot, plot.owner);
|
DBFunc.setOwner(plot, plot.owner);
|
||||||
PlayerFunctions.sendMessage(plr, C.SET_OWNER);
|
PlayerFunctions.sendMessage(plr, C.SET_OWNER);
|
||||||
|
|
||||||
|
if (PlotMain.worldGuardListener!=null) {
|
||||||
|
PlotMain.worldGuardListener.changeOwner(plr, plot.owner, plr.getWorld(), plot);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.intellectualcrafters.plot.listeners;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -15,6 +16,7 @@ import com.intellectualcrafters.plot.Plot;
|
|||||||
import com.intellectualcrafters.plot.PlotHelper;
|
import com.intellectualcrafters.plot.PlotHelper;
|
||||||
import com.intellectualcrafters.plot.PlotId;
|
import com.intellectualcrafters.plot.PlotId;
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
|
import com.intellectualcrafters.plot.UUIDHandler;
|
||||||
import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
|
import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
|
||||||
import com.intellectualcrafters.plot.events.PlotDeleteEvent;
|
import com.intellectualcrafters.plot.events.PlotDeleteEvent;
|
||||||
import com.intellectualcrafters.plot.events.PlotMergeEvent;
|
import com.intellectualcrafters.plot.events.PlotMergeEvent;
|
||||||
@ -41,6 +43,22 @@ public class WorldGuardListener implements Listener {
|
|||||||
this.flags.add(flag);
|
this.flags.add(flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void changeOwner(Player requester, UUID owner, World world, Plot plot) {
|
||||||
|
boolean op = requester.isOp();
|
||||||
|
requester.setOp(true);
|
||||||
|
try {
|
||||||
|
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()));
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
requester.setOp(op);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
requester.setOp(op);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void removeFlag(Player requester, World world, Plot plot, String key) {
|
public void removeFlag(Player requester, World world, Plot plot, String key) {
|
||||||
boolean op = requester.isOp();
|
boolean op = requester.isOp();
|
||||||
@ -48,7 +66,7 @@ public class WorldGuardListener implements Listener {
|
|||||||
try {
|
try {
|
||||||
RegionManager manager = PlotMain.worldGuard.getRegionManager(world);
|
RegionManager manager = PlotMain.worldGuard.getRegionManager(world);
|
||||||
manager.getRegion(plot.id.x + "-" + plot.id.y);
|
manager.getRegion(plot.id.x + "-" + plot.id.y);
|
||||||
for (Flag flag : this.flags) {
|
for (Flag<?> flag : this.flags) {
|
||||||
if (flag.getName().equalsIgnoreCase(key)) {
|
if (flag.getName().equalsIgnoreCase(key)) {
|
||||||
requester.performCommand("region flag " + (plot.id.x + "-" + plot.id.y) + " " + key);
|
requester.performCommand("region flag " + (plot.id.x + "-" + plot.id.y) + " " + key);
|
||||||
}
|
}
|
||||||
@ -68,7 +86,7 @@ public class WorldGuardListener implements Listener {
|
|||||||
try {
|
try {
|
||||||
RegionManager manager = PlotMain.worldGuard.getRegionManager(world);
|
RegionManager manager = PlotMain.worldGuard.getRegionManager(world);
|
||||||
manager.getRegion(plot.id.x + "-" + plot.id.y);
|
manager.getRegion(plot.id.x + "-" + plot.id.y);
|
||||||
for (Flag flag : this.flags) {
|
for (Flag<?> flag : this.flags) {
|
||||||
if (flag.getName().equalsIgnoreCase(key)) {
|
if (flag.getName().equalsIgnoreCase(key)) {
|
||||||
requester.performCommand("region flag " + (plot.id.x + "-" + plot.id.y) + " " + key + " " + value);
|
requester.performCommand("region flag " + (plot.id.x + "-" + plot.id.y) + " " + key + " " + value);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user