2011-03-02 17:24:18 +01:00
|
|
|
/*
|
2014-07-13 04:29:29 +02: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
|
|
|
*
|
2014-07-13 04:29:29 +02: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.
|
|
|
|
*
|
2014-07-13 04:29:29 +02:00
|
|
|
* 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
|
|
|
*
|
2014-07-13 04:29:29 +02: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/>.
|
|
|
|
*/
|
2014-07-13 04:29:29 +02:00
|
|
|
|
2011-03-27 00:59:06 +01:00
|
|
|
package com.sk89q.worldguard.protection.flags;
|
2011-03-02 17:24:18 +01:00
|
|
|
|
2011-04-01 22:39:29 +02:00
|
|
|
import org.bukkit.command.CommandSender;
|
2011-07-16 23:07:29 +02:00
|
|
|
|
2011-04-01 22:39:29 +02:00
|
|
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
|
|
|
|
2014-08-09 05:22:05 +02:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2011-03-02 17:24:18 +01:00
|
|
|
/**
|
|
|
|
*
|
2011-03-27 00:59:06 +01:00
|
|
|
* @author sk89q
|
2011-09-27 12:13:19 +02:00
|
|
|
* @param <T>
|
2011-03-02 17:24:18 +01:00
|
|
|
*/
|
2011-03-27 00:59:06 +01:00
|
|
|
public abstract class Flag<T> {
|
2011-09-27 12:13:19 +02:00
|
|
|
|
2011-03-27 00:59:06 +01:00
|
|
|
private String name;
|
2012-02-20 08:30:05 +01:00
|
|
|
private RegionGroupFlag regionGroup;
|
|
|
|
|
|
|
|
public Flag(String name, RegionGroup defaultGroup) {
|
2011-03-02 17:24:18 +01:00
|
|
|
this.name = name;
|
2012-02-20 08:30:05 +01:00
|
|
|
|
|
|
|
if (defaultGroup != null) {
|
|
|
|
this.regionGroup = new RegionGroupFlag(name + "-group", defaultGroup);
|
|
|
|
}
|
2011-03-27 00:59:06 +01:00
|
|
|
}
|
2011-09-27 12:13:19 +02:00
|
|
|
|
2011-03-27 00:59:06 +01:00
|
|
|
public Flag(String name) {
|
2012-02-20 08:30:05 +01:00
|
|
|
this(name, RegionGroup.NON_MEMBERS);
|
2011-03-27 00:59:06 +01:00
|
|
|
}
|
2011-09-27 12:13:19 +02:00
|
|
|
|
2011-03-27 00:59:06 +01:00
|
|
|
public String getName() {
|
|
|
|
return name;
|
|
|
|
}
|
2012-02-20 08:30:05 +01:00
|
|
|
|
|
|
|
public RegionGroupFlag getRegionGroupFlag() {
|
|
|
|
return regionGroup;
|
2011-03-02 17:24:18 +01:00
|
|
|
}
|
2011-09-27 12:13:19 +02:00
|
|
|
|
2011-04-01 22:39:29 +02:00
|
|
|
public abstract T parseInput(WorldGuardPlugin plugin, CommandSender sender,
|
|
|
|
String input) throws InvalidFlagFormat;
|
2011-09-27 12:13:19 +02:00
|
|
|
|
2014-08-09 05:22:05 +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);
|
2014-08-09 05:22:05 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return getClass().getName() + "{" +
|
|
|
|
"name='" + name + '\'' +
|
|
|
|
'}';
|
|
|
|
}
|
2011-03-02 17:24:18 +01:00
|
|
|
}
|