mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-09-06 04:08:03 +02:00
Fixed some flags and permissions.
This commit is contained in:
parent
989ba0103d
commit
3b9a426547
@ -196,10 +196,19 @@ public void handleBlockRightClick(PlayerInteractEvent event) {
|
||||
}
|
||||
}
|
||||
|
||||
if (wcfg.useRegions && type == Material.CAKE_BLOCK) {
|
||||
if (type == Material.CAKE_BLOCK) {
|
||||
if (!set.canBuild(localPlayer)) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You're not invited to this tea party!");
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (type == Material.RAILS
|
||||
&& (item.getType() == Material.MINECART || item.getType() == Material.BOAT)) {
|
||||
if (!set.canBuild(localPlayer)
|
||||
&& !set.allows(DefaultFlag.PLACE_VEHICLE)) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -130,7 +130,6 @@ public void onEnable() {
|
||||
(new WorldGuardPlayerListener(this)).registerEvents();
|
||||
(new WorldGuardBlockListener(this)).registerEvents();
|
||||
(new WorldGuardEntityListener(this)).registerEvents();
|
||||
(new WorldGuardVehicleListener(this)).registerEvents();
|
||||
|
||||
// 25 equals about 1s real time
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(
|
||||
|
@ -1,81 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.vehicle.VehicleCreateEvent;
|
||||
import org.bukkit.event.vehicle.VehicleListener;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import org.bukkit.Location;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author DarkLiKally
|
||||
*/
|
||||
public class WorldGuardVehicleListener extends VehicleListener {
|
||||
/**
|
||||
* Plugin.
|
||||
*/
|
||||
private WorldGuardPlugin plugin;
|
||||
/**
|
||||
* Construct the object;
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
public WorldGuardVehicleListener(WorldGuardPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void registerEvents() {
|
||||
|
||||
PluginManager pm = plugin.getServer().getPluginManager();
|
||||
|
||||
pm.registerEvent(Event.Type.VEHICLE_CREATE, this, Priority.High, plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a vehicle is created by a player.
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
@Override
|
||||
public void onVehicleCreate(VehicleCreateEvent event) {
|
||||
Vehicle vhcl = event.getVehicle();
|
||||
Location vhclLoc = vhcl.getLocation();
|
||||
Vector pt = new Vector(vhclLoc.getBlockX(), vhclLoc.getBlockY(), vhclLoc.getBlockZ());
|
||||
|
||||
if (vhcl instanceof Minecart || vhcl instanceof Boat) {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(vhcl.getWorld());
|
||||
ApplicableRegionSet applicableRegions = mgr.getApplicableRegions(pt);
|
||||
|
||||
if (!applicableRegions.allows(DefaultFlag.PLACE_VEHICLE)) {
|
||||
vhcl.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -468,11 +468,11 @@ public static void flag(CommandContext args, WorldGuardPlugin plugin,
|
||||
}
|
||||
|
||||
if (region.isOwner(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.flag.own");
|
||||
plugin.checkPermission(sender, "worldguard.region.flag.own." + id.toLowerCase());
|
||||
} else if (region.isMember(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.flag.member");
|
||||
plugin.checkPermission(sender, "worldguard.region.flag.member." + id.toLowerCase());
|
||||
} else {
|
||||
plugin.checkPermission(sender, "worldguard.region.flag");
|
||||
plugin.checkPermission(sender, "worldguard.region.flag." + id.toLowerCase());
|
||||
}
|
||||
|
||||
Flag<?> foundFlag = null;
|
||||
@ -502,6 +502,17 @@ public static void flag(CommandContext args, WorldGuardPlugin plugin,
|
||||
player.sendMessage(ChatColor.RED + "Available flags: " + list);
|
||||
return;
|
||||
}
|
||||
|
||||
if (region.isOwner(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.flag.flags."
|
||||
+ foundFlag.getName() + ".owner." + id.toLowerCase());
|
||||
} else if (region.isMember(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.flag.flags."
|
||||
+ foundFlag.getName() + ".member." + id.toLowerCase());
|
||||
} else {
|
||||
plugin.checkPermission(sender, "worldguard.region.flag.flags."
|
||||
+ foundFlag.getName() + "." + id.toLowerCase());
|
||||
}
|
||||
|
||||
if (value != null) {
|
||||
try {
|
||||
@ -559,11 +570,11 @@ public static void setPriority(CommandContext args, WorldGuardPlugin plugin,
|
||||
}
|
||||
|
||||
if (region.isOwner(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.setpriority.own");
|
||||
plugin.checkPermission(sender, "worldguard.region.setpriority.own." + id.toLowerCase());
|
||||
} else if (region.isMember(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.setpriority.member");
|
||||
plugin.checkPermission(sender, "worldguard.region.setpriority.member." + id.toLowerCase());
|
||||
} else {
|
||||
plugin.checkPermission(sender, "worldguard.region.setpriority");
|
||||
plugin.checkPermission(sender, "worldguard.region.setpriority." + id.toLowerCase());
|
||||
}
|
||||
|
||||
region.setPriority(priority);
|
||||
@ -610,19 +621,19 @@ public static void setParent(CommandContext args, WorldGuardPlugin plugin,
|
||||
}
|
||||
|
||||
if (region.isOwner(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.setparent.own");
|
||||
plugin.checkPermission(sender, "worldguard.region.setparent.own." + id.toLowerCase());
|
||||
} else if (region.isMember(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.setparent.member");
|
||||
plugin.checkPermission(sender, "worldguard.region.setparent.member." + id.toLowerCase());
|
||||
} else {
|
||||
plugin.checkPermission(sender, "worldguard.region.setparent");
|
||||
plugin.checkPermission(sender, "worldguard.region.setparent." + id.toLowerCase());
|
||||
}
|
||||
|
||||
if (parent.isOwner(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.setparent.own");
|
||||
plugin.checkPermission(sender, "worldguard.region.setparent.own." + id.toLowerCase());
|
||||
} else if (parent.isMember(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.setparent.member");
|
||||
plugin.checkPermission(sender, "worldguard.region.setparent.member." + id.toLowerCase());
|
||||
} else {
|
||||
plugin.checkPermission(sender, "worldguard.region.setparent");
|
||||
plugin.checkPermission(sender, "worldguard.region.setparent." + id.toLowerCase());
|
||||
}
|
||||
|
||||
try {
|
||||
@ -664,11 +675,11 @@ public static void remove(CommandContext args, WorldGuardPlugin plugin,
|
||||
}
|
||||
|
||||
if (region.isOwner(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.remove.own");
|
||||
plugin.checkPermission(sender, "worldguard.region.remove.own." + id.toLowerCase());
|
||||
} else if (region.isMember(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.remove.member");
|
||||
plugin.checkPermission(sender, "worldguard.region.remove.member." + id.toLowerCase());
|
||||
} else {
|
||||
plugin.checkPermission(sender, "worldguard.region.flag");
|
||||
plugin.checkPermission(sender, "worldguard.region.remove." + id.toLowerCase());
|
||||
}
|
||||
|
||||
mgr.removeRegion(id);
|
||||
|
@ -49,6 +49,10 @@ public static void addMember(CommandContext args, WorldGuardPlugin plugin,
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
String id = args.getString(0);
|
||||
|
||||
if (id.equalsIgnoreCase("__global__")) {
|
||||
throw new CommandException("The region cannot be named __global__");
|
||||
}
|
||||
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
ProtectedRegion region = mgr.getRegion(id);
|
||||
@ -58,11 +62,11 @@ public static void addMember(CommandContext args, WorldGuardPlugin plugin,
|
||||
}
|
||||
|
||||
if (region.isOwner(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.addmember.own");
|
||||
plugin.checkPermission(sender, "worldguard.region.addmember.own." + id.toLowerCase());
|
||||
} else if (region.isMember(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.addmember.member");
|
||||
plugin.checkPermission(sender, "worldguard.region.addmember.member." + id.toLowerCase());
|
||||
} else {
|
||||
plugin.checkPermission(sender, "worldguard.region.addmember");
|
||||
plugin.checkPermission(sender, "worldguard.region.addmember." + id.toLowerCase());
|
||||
}
|
||||
|
||||
RegionUtil.addToDomain(region.getMembers(), args.getPaddedSlice(2, 0), 0);
|
||||
@ -90,6 +94,10 @@ public static void addOwner(CommandContext args, WorldGuardPlugin plugin,
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
String id = args.getString(0);
|
||||
|
||||
if (id.equalsIgnoreCase("__global__")) {
|
||||
throw new CommandException("The region cannot be named __global__");
|
||||
}
|
||||
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
ProtectedRegion region = mgr.getRegion(id);
|
||||
@ -99,11 +107,11 @@ public static void addOwner(CommandContext args, WorldGuardPlugin plugin,
|
||||
}
|
||||
|
||||
if (region.isOwner(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.addowner.own");
|
||||
plugin.checkPermission(sender, "worldguard.region.addowner.own." + id.toLowerCase());
|
||||
} else if (region.isMember(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.addowner.member");
|
||||
plugin.checkPermission(sender, "worldguard.region.addowner.member." + id.toLowerCase());
|
||||
} else {
|
||||
plugin.checkPermission(sender, "worldguard.region.addowner");
|
||||
plugin.checkPermission(sender, "worldguard.region.addowner." + id.toLowerCase());
|
||||
}
|
||||
|
||||
RegionUtil.addToDomain(region.getOwners(), args.getPaddedSlice(2, 0), 0);
|
||||
@ -131,6 +139,10 @@ public static void removeMember(CommandContext args, WorldGuardPlugin plugin,
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
String id = args.getString(0);
|
||||
|
||||
if (id.equalsIgnoreCase("__global__")) {
|
||||
throw new CommandException("The region cannot be named __global__");
|
||||
}
|
||||
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
ProtectedRegion region = mgr.getRegion(id);
|
||||
@ -140,11 +152,11 @@ public static void removeMember(CommandContext args, WorldGuardPlugin plugin,
|
||||
}
|
||||
|
||||
if (region.isOwner(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.removemember.own");
|
||||
plugin.checkPermission(sender, "worldguard.region.removemember.own." + id.toLowerCase());
|
||||
} else if (region.isMember(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.removemember.member");
|
||||
plugin.checkPermission(sender, "worldguard.region.removemember.member." + id.toLowerCase());
|
||||
} else {
|
||||
plugin.checkPermission(sender, "worldguard.region.removemember");
|
||||
plugin.checkPermission(sender, "worldguard.region.removemember." + id.toLowerCase());
|
||||
}
|
||||
|
||||
RegionUtil.removeFromDomain(region.getMembers(), args.getPaddedSlice(2, 0), 0);
|
||||
@ -172,6 +184,10 @@ public static void removeOwner(CommandContext args, WorldGuardPlugin plugin,
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
String id = args.getString(0);
|
||||
|
||||
if (id.equalsIgnoreCase("__global__")) {
|
||||
throw new CommandException("The region cannot be named __global__");
|
||||
}
|
||||
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
ProtectedRegion region = mgr.getRegion(id);
|
||||
@ -181,11 +197,11 @@ public static void removeOwner(CommandContext args, WorldGuardPlugin plugin,
|
||||
}
|
||||
|
||||
if (region.isOwner(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.removeowner.own");
|
||||
plugin.checkPermission(sender, "worldguard.region.removeowner.own." + id.toLowerCase());
|
||||
} else if (region.isMember(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.removeowner.member");
|
||||
plugin.checkPermission(sender, "worldguard.region.removeowner.member." + id.toLowerCase());
|
||||
} else {
|
||||
plugin.checkPermission(sender, "worldguard.region.removeowner");
|
||||
plugin.checkPermission(sender, "worldguard.region.removeowner." + id.toLowerCase());
|
||||
}
|
||||
|
||||
RegionUtil.removeFromDomain(region.getOwners(), args.getPaddedSlice(2, 0), 0);
|
||||
|
Loading…
Reference in New Issue
Block a user