WorldGuard/src/main/java/com/sk89q/worldguard/protection/flags/Flag.java

72 lines
1.9 KiB
Java
Raw Normal View History

2011-03-02 17:24:18 +01:00
/*
* WorldGuard, a suite of tools for Minecraft
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldGuard team and contributors
2011-03-02 17:24:18 +01:00
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
2011-03-02 17:24:18 +01:00
* (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 Lesser General Public License
* for more details.
2011-03-02 17:24:18 +01:00
*
* You should have received a copy of the GNU Lesser General Public License
2011-03-02 17:24:18 +01:00
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldguard.protection.flags;
2011-03-02 17:24:18 +01:00
import org.bukkit.command.CommandSender;
2011-07-16 23:07:29 +02:00
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import javax.annotation.Nullable;
2011-03-02 17:24:18 +01:00
/**
*
* @author sk89q
2011-09-27 12:13:19 +02:00
* @param <T>
2011-03-02 17:24:18 +01:00
*/
public abstract class Flag<T> {
2011-09-27 12:13:19 +02:00
private String name;
private RegionGroupFlag regionGroup;
public Flag(String name, RegionGroup defaultGroup) {
2011-03-02 17:24:18 +01:00
this.name = name;
if (defaultGroup != null) {
this.regionGroup = new RegionGroupFlag(name + "-group", defaultGroup);
}
}
2011-09-27 12:13:19 +02:00
public Flag(String name) {
this(name, RegionGroup.NON_MEMBERS);
}
2011-09-27 12:13:19 +02:00
public String getName() {
return name;
}
public RegionGroupFlag getRegionGroupFlag() {
return regionGroup;
2011-03-02 17:24:18 +01:00
}
2011-09-27 12:13:19 +02:00
public abstract T parseInput(WorldGuardPlugin plugin, CommandSender sender,
String input) throws InvalidFlagFormat;
2011-09-27 12:13:19 +02:00
public abstract T unmarshal(@Nullable Object o);
2011-09-27 12:13:19 +02:00
2011-04-02 07:11:57 +02:00
public abstract Object marshal(T o);
@Override
public String toString() {
return getClass().getName() + "{" +
"name='" + name + '\'' +
'}';
}
2011-03-02 17:24:18 +01:00
}