base region general working

This commit is contained in:
Jascha Starke 2013-02-10 22:12:31 +01:00
parent 414a02f77c
commit cf9449aae5
6 changed files with 43 additions and 16 deletions

5
TODO.txt Normal file
View file

@ -0,0 +1,5 @@
- Region-Config? Where are the missing options?
- Region: permanent gamemode storage? (safemode, if not permanent: region!) maybe only if regionsset empty?
- remove config.yml and plugin.yml
- cleanup localize-messages
- rework german localization

View file

@ -82,7 +82,7 @@ public class FeatureSwitchGameMode extends CoreModule<LimitedCreative> {
GameMode wgm = Hooks.DefaultWorldGameMode.get(target.getWorld());
if (!context.checkPermission(permission) && !(wgm != tgm || !context.checkPermission(SwitchGameModePermissions.BACKONLY)))
if (!context.checkPermission(permission) && (wgm != tgm || !context.checkPermission(SwitchGameModePermissions.BACKONLY)))
throw new MissingPermissionCommandException(permission);
target.setGameMode(tgm);

View file

@ -8,12 +8,16 @@ import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import de.jaschastarke.bukkit.lib.CoreModule;
import de.jaschastarke.bukkit.lib.commands.AliasHelpedCommand;
import de.jaschastarke.minecraft.limitedcreative.regions.BlockListener;
import de.jaschastarke.minecraft.limitedcreative.regions.Flags;
import de.jaschastarke.minecraft.limitedcreative.regions.PlayerData;
import de.jaschastarke.minecraft.limitedcreative.regions.PlayerListener;
import de.jaschastarke.minecraft.limitedcreative.regions.RegionConfig;
import de.jaschastarke.minecraft.limitedcreative.regions.RegionListener;
import de.jaschastarke.minecraft.limitedcreative.regions.RegionsCommand;
import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.CustomRegionManager;
import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.FlagList;
import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.PlayerRegionListener;
import de.jaschastarke.modularize.IModule;
import de.jaschastarke.modularize.ModuleEntry;
import de.jaschastarke.modularize.ModuleEntry.ModuleState;
@ -42,7 +46,12 @@ public class ModRegions extends CoreModule<LimitedCreative> {
command = new RegionsCommand(this);
plugin.getCommandHandler().registerCommand(command);
plugin.getMainCommand().registerCommand(new AliasHelpedCommand<RegionsCommand>(command, "region"));
plugin.getMainCommand().registerCommand(new AliasHelpedCommand<RegionsCommand>(command, "region", new String[]{"r"}));
listeners.registerEvents(new PlayerListener(this));
listeners.registerEvents(new BlockListener(this));
listeners.registerEvents(new RegionListener(this));
listeners.registerEvents(new PlayerRegionListener(this));
FlagList.addFlags(Flags.getList());

View file

@ -4,6 +4,7 @@ import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.World;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
import com.sk89q.worldguard.protection.managers.RegionManager;
@ -147,12 +148,14 @@ public class RegionsCommand extends BukkitCommand implements IHelpDescribed {
public boolean getInfo(CommandContext context, String... args) throws CommandException {
DefinedParameterParser params = new DefinedParameterParser(args, new String[]{"s"}, 1);
/*
* WorldEdits intercepting Servers privates commandMap via Reflections realy sucks!
* Just because they are to lazy to add all the lines commands to plugin.yml
*/
String orgCmd = ("region info " + StringUtils.join(args)).trim();
mod.getPlugin().getServer().dispatchCommand(context.getSender(), orgCmd);
if (context.isPlayer()) {
/*
* WorldEdits intercepting Servers privates commandMap via Reflections realy sucks!
* Just because they are to lazy to add all the lines commands to plugin.yml
*/
String orgCmd = ("region info " + StringUtils.join(args)).trim();
mod.getPlugin().getServer().dispatchCommand(context.getSender(), orgCmd);
}
World w = context.isPlayer() ? context.getPlayer().getWorld() : null;
if (params.getArgumentCount() > 1)
@ -160,12 +163,21 @@ public class RegionsCommand extends BukkitCommand implements IHelpDescribed {
if (w == null)
throw new CommandException(L("command.worldguard.world_not_found"));
int rpc = params.getArgumentCount() > 1 ? 2 : 1;
RegionManager mgr = mod.getWorldGuard().getGlobalRegionManager().get(w);
ProtectedRegion region = mgr.getRegion(params.getArgument(rpc));
if (region == null && params.getArgument(rpc).equalsIgnoreCase("__global__")) {
region = new GlobalProtectedRegion(params.getArgument(rpc));
mgr.addRegion(region);
ProtectedRegion region = null;
if (params.getArgumentCount() == 0 && context.isPlayer()) {
RegionManager mgr = mod.getWorldGuard().getGlobalRegionManager().get(context.getPlayer().getWorld());
ApplicableRegionSet set = mgr.getApplicableRegions(context.getPlayer().getLocation());
if (set.size() > 0) {
region = set.iterator().next();
}
} else {
int rpc = params.getArgumentCount() > 1 ? 1 : 0;
RegionManager mgr = mod.getWorldGuard().getGlobalRegionManager().get(w);
region = mgr.getRegion(params.getArgument(rpc));
if (region == null && params.getArgument(rpc).equalsIgnoreCase("__global__")) {
region = new GlobalProtectedRegion(params.getArgument(rpc));
mgr.addRegion(region);
}
}
if (region == null)
throw new CommandException(L("command.worldguard.region_not_found"));

View file

@ -32,10 +32,10 @@ import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.events.Playe
import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.events.PlayerNewLocationAreaEvent;
import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.events.PlayerSetAreaEvent;
public class PlayerListener implements Listener {
public class PlayerRegionListener implements Listener {
private ModRegions mod;
public PlayerListener(ModRegions mod) {
public PlayerRegionListener(ModRegions mod) {
this.mod = mod;
}
@ -50,6 +50,7 @@ public class PlayerListener implements Listener {
|| !event.getFrom().getWorld().equals(event.getTo().getWorld())) { // he really moved, and not just looked around
String current_hash = mod.getPlayerData(event.getPlayer()).getHash();
mod.getLog().debug(event.getPlayer().getName()+" "+current_hash);
if (current_hash == null) {
String new_hash = mod.getRegionManager().getRegionsHash(event.getTo());
Bukkit.getServer().getPluginManager().callEvent(new PlayerSetAreaEvent(mod.getRegionManager(), event.getPlayer(), new_hash, event.getTo()));