You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
3.3 KiB
77 lines
3.3 KiB
package org.poopki.duckdns.user_db.WorldGuard; |
|
|
|
import com.sk89q.worldedit.bukkit.BukkitAdapter; |
|
import com.sk89q.worldedit.math.BlockVector3; |
|
import com.sk89q.worldguard.LocalPlayer; |
|
import com.sk89q.worldguard.WorldGuard; |
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin; |
|
import com.sk89q.worldguard.protection.managers.RegionManager; |
|
import com.sk89q.worldguard.protection.managers.storage.StorageException; |
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; |
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion; |
|
import com.sk89q.worldguard.protection.regions.RegionContainer; |
|
import org.bukkit.command.Command; |
|
import org.bukkit.command.CommandExecutor; |
|
import org.bukkit.command.CommandSender; |
|
import org.bukkit.entity.Player; |
|
import org.bukkit.plugin.Plugin; |
|
|
|
public class WG implements CommandExecutor { |
|
public WorldGuardPlugin worldGuardPlugin; |
|
private RegionManager rm; |
|
private ProtectedRegion pr; |
|
|
|
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); |
|
|
|
public WG(Plugin plugin){ |
|
worldGuardPlugin =getWorldGuard(plugin); |
|
|
|
} |
|
|
|
@Override |
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { |
|
Player p = (Player) sender; |
|
LocalPlayer pl= WorldGuardPlugin.inst().wrapPlayer(p); |
|
this.rm = container.get(pl.getWorld()); |
|
if (args.length != 0) { |
|
switch (args[0]) { |
|
case "지상":{ |
|
// [1]: radius, [2]-[4]: center point axys(x, y, z) |
|
Integer radius = Integer.parseInt(args[1]); |
|
BlockVector3 min = BlockVector3.at(Integer.parseInt(args[2])-radius/2, Integer.parseInt(args[3])-10, Integer.parseInt(args[4])+radius/2); |
|
BlockVector3 max = BlockVector3.at(Integer.parseInt(args[2])+radius/2, Integer.parseInt(args[3])+50, Integer.parseInt(args[4])-radius/2); |
|
ProtectedRegion region = new ProtectedCuboidRegion(args[5], min, max); |
|
this.rm.addRegion(region); |
|
break; |
|
} |
|
case "지하":{ |
|
Integer radius = Integer.parseInt(args[1]); |
|
BlockVector3 min = BlockVector3.at(Integer.parseInt(args[2])-radius/2, Integer.parseInt(args[3])-11, Integer.parseInt(args[4])+radius/2); |
|
BlockVector3 max = BlockVector3.at(Integer.parseInt(args[2])+radius/2, Integer.parseInt(args[3])-100, Integer.parseInt(args[4])-radius/2); |
|
ProtectedRegion region = new ProtectedCuboidRegion(args[5], min, max); |
|
this.rm.addRegion(region); |
|
break; |
|
} |
|
} |
|
} |
|
try { |
|
this.rm.save(); |
|
} catch (StorageException e) { |
|
e.printStackTrace(); |
|
p.sendMessage("region-save-error"); |
|
return false; |
|
} |
|
return true; |
|
} |
|
public WorldGuardPlugin getWorldGuard(Plugin plugin){ |
|
Plugin WGPlugin = plugin.getServer().getPluginManager().getPlugin("WorldGuard"); |
|
if(WGPlugin == null || !(WGPlugin instanceof WorldGuardPlugin)){ |
|
return null; |
|
} |
|
return (WorldGuardPlugin) WGPlugin; |
|
} |
|
public void save() throws StorageException { |
|
this.rm.addRegion(pr); |
|
this.rm.save(); |
|
} |
|
}
|
|
|