Refactor Flag Definition System. Fixes #123

The flag definition system has had a major rehaul.
The following improvements have been made :
- Support for default values that can be applied on startup.
- All definitions have been moved to its own file 'flags.conf'.
- The 'enabled' setting now works as expected.
- GUI has been updated to show all relevant context/flag information.
- Admin definitions will now display the direct result of a definition.
  Note: The final active result will show on hover.
- User definitions will only display the result of the current claim.
  Note: User's can see extra info on hover.
  Note: If a user definition has been overridden, it won't be toggable.

* Add Context/Location improvements to GDDebug.
  - Users will now be able to expand location/context columns for more
  information.
* Add version check to use proper id for flag definitions.
* Move options from 'global.conf' to its own file 'options.conf'.
* Ignore suffocation for entity damage checks.
* Fix monster projectile's not checking monster source.
* Fix 'used_item' not showing up for buckets.
* Fix flag GUI sort when changing value.
* Fix town tag not showing properly on sponge. Fixes #201
* Change permission 'griefdefender.user.claim.command.flag.arg' to
  admin.
This commit is contained in:
bloodshot 2020-05-05 00:56:59 -04:00
parent 8391686828
commit f801c065f3
97 changed files with 4575 additions and 2163 deletions

@ -1 +1 @@
Subproject commit b95657786652905ed1da6cfe55db4d9eebe1881e
Subproject commit f70078d269283943ca65c20fe16c7650050932ee

View File

@ -104,11 +104,11 @@ public GDDebugData(CommandSender source, OfflinePlayer target, boolean verbose)
this.header.add("| " + PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().DEBUG_RECORD_START) + " | " + DATE_FORMAT.format(new Date(this.startTime)) + "|");
}
public void addRecord(String flag, String trust, String source, String target, String location, String user, String permission, Tristate result) {
public void addRecord(String flag, String trust, String source, String target, String location, String user, String contexts, Tristate result) {
// markdown uses '__' for strong formatting, so underscores must be escaped
user = user.replace("_", "\\_");
if (this.records.size() < MAX_LINES) {
this.records.add("| " + flag + " | " + trust + " | " + source + " | " + target + " | " + location + " | " + user + " | " + permission + " | " + result + " | ");
this.records.add("| " + flag + " | " + trust + " | " + source + " | " + target + " | " + location + " | " + user + " | " + contexts + " | " + result + " | ");
} else {
TextAdapter.sendComponent(this.source, TextComponent.builder("").append("MAX DEBUG LIMIT REACHED!").append("\n")
.append("Pasting output...", TextColor.GREEN).build());
@ -156,15 +156,15 @@ public void pasteRecords() {
final String SOURCE = PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().LABEL_SOURCE);
final String TARGET = PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().LABEL_TARGET);
final String USER = PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().LABEL_USER);
final String PERMISSION = PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().LABEL_PERMISSION);
final String CONTEXT = PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().LABEL_CONTEXT);
final String RESULT = PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().LABEL_RESULT);
debugOutput.add("| " + RECORD_END + " | " + DATE_FORMAT.format(new Date(endTime)) + "|");
long elapsed = (endTime - startTime) / 1000L;
debugOutput.add("| " + TIME_ELAPSED + " | " + elapsed + " seconds" + "|");
debugOutput.add("");
debugOutput.add("### " + OUTPUT) ;
debugOutput.add("| " + FLAG + " | " + TRUST + " | " + SOURCE + " | " + TARGET + " | " + LOCATION + " | " + USER + " | " + PERMISSION + " | " + RESULT + " |");
debugOutput.add("|------|-------|--------|--------|----------|------|------------|--------|");
debugOutput.add("| " + FLAG + " | " + TRUST + " | " + SOURCE + " | " + TARGET + " | " + LOCATION + " | " + USER + " | " + CONTEXT + " | " + RESULT + " |");
debugOutput.add("|------|-------|--------|--------|----------|------|----------|--------|");
debugOutput.addAll(this.records);

View File

@ -108,7 +108,7 @@ public class GDPlayerData implements PlayerData {
public Instant recordChatTimestamp;
public Instant commandInputTimestamp;
public String commandInput;
public Consumer<CommandSender> trustAddConsumer;
public Consumer<CommandSender> commandConsumer;
// Always ignore active contexts by default
// This prevents protection issues when other plugins call getActiveContext

View File

@ -30,10 +30,12 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.TreeMap;
import java.util.UUID;
import java.util.concurrent.Executor;
@ -67,6 +69,7 @@
import com.griefdefender.api.claim.ClaimType;
import com.griefdefender.api.claim.TrustType;
import com.griefdefender.api.economy.BankTransaction;
import com.griefdefender.api.permission.Context;
import com.griefdefender.api.permission.flag.Flag;
import com.griefdefender.api.permission.flag.FlagData;
import com.griefdefender.api.permission.flag.FlagDefinition;
@ -151,9 +154,11 @@
import com.griefdefender.command.CommandUntrustPlayerAll;
import com.griefdefender.command.gphelper.CommandAccessTrust;
import com.griefdefender.command.gphelper.CommandContainerTrust;
import com.griefdefender.configuration.FlagConfig;
import com.griefdefender.configuration.GriefDefenderConfig;
import com.griefdefender.configuration.MessageDataConfig;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.configuration.OptionConfig;
import com.griefdefender.configuration.category.BlacklistCategory;
import com.griefdefender.configuration.serializer.ClaimTypeSerializer;
import com.griefdefender.configuration.serializer.ComponentConfigSerializer;
@ -236,6 +241,8 @@ public class GriefDefenderPlugin {
public static final String IMPLEMENTATION_NAME = GriefDefenderPlugin.class.getPackage().getImplementationTitle();
public static final String IMPLEMENTATION_VERSION = GriefDefenderPlugin.class.getPackage().getImplementationVersion() == null ? "unknown" : GriefDefenderPlugin.class.getPackage().getImplementationVersion();
private Path configPath = Paths.get(".", "plugins", "GriefDefender");
public FlagConfig flagConfig;
public OptionConfig optionConfig;
public MessageStorage messageStorage;
public MessageDataConfig messageData;
public Map<UUID, Random> worldGeneratorRandoms = new HashMap<>();
@ -293,7 +300,7 @@ public Path getConfigPath() {
return this.configPath;
}
public static void addEventLogEntry(Event event, Location location, String sourceId, String targetId, GDPermissionHolder permissionSubject, String permission, String trust, Tristate result) {
public static void addEventLogEntry(Event event, Claim claim, Location location, String sourceId, String targetId, GDPermissionHolder permissionSubject, String permission, String trust, Tristate result, Set<Context> contexts) {
final String eventName = event.getClass().getSimpleName().replace('$', '.').replace(".Impl", "");
final String eventLocation = location == null ? "none" : VecHelper.toVector3i(location).toString();
for (GDDebugData debugEntry : GriefDefenderPlugin.getInstance().getDebugUserMap().values()) {
@ -339,7 +346,37 @@ public static void addEventLogEntry(Event event, Location location, String sourc
if (parts.length > 1 && parts[0].equalsIgnoreCase("minecraft")) {
messageTarget = parts[1];
}
debugEntry.addRecord(messageFlag, trust, messageSource, messageTarget, eventLocation, messageUser, permission, result);
String contextStr = "";
final List<String> contextList = new ArrayList<>();
for (Context context : contexts) {
contextList.add("<b>" + context.getKey() + "</b>=" + context.getValue());
}
final String serverName = PermissionUtil.getInstance().getServerName();
if (serverName != null) {
contextList.add("<b>server</b>=" + serverName);
} else {
contextList.add("<b>server</b>=global");
}
Collections.sort(contextList);
for (String context : contextList) {
contextStr += context + "<br />";
}
String locationStr = "";
locationStr += "<b>claim_uuid</b>=" + claim.getUniqueId() + "<br />";
locationStr += "<b>claim_type</b>=" + claim.getType().getName().toLowerCase() + "<br />";
locationStr += "<b>location</b>=" + eventLocation + "<br />";
locationStr += "<b>world</b>=" + location.getWorld().getName().toLowerCase() + "<br />";
String messageContexts = "<details>" +
" <summary><i>" + PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().DEBUG_CLICK_TO_EXPAND) + "</i></summary>" +
contextStr +
"</details>";
String messageLocation = "<details>" +
" <summary><i>" + PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().DEBUG_CLICK_TO_EXPAND) + "</i></summary>" +
locationStr +
"</details>";
debugEntry.addRecord(messageFlag, trust, messageSource, messageTarget, messageLocation, messageUser, messageContexts, result);
continue;
}
@ -417,7 +454,6 @@ public void onEnable() {
ShovelTypeRegistryModule.getInstance().registerDefaults();
TrustTypeRegistryModule.getInstance().registerDefaults();
FlagRegistryModule.getInstance().registerDefaults();
FlagDefinitionRegistryModule.getInstance().registerDefaults();
ResultTypeRegistryModule.getInstance().registerDefaults();
EntityTypeRegistryModule.getInstance().registerDefaults();
BlockTypeRegistryModule.getInstance().registerDefaults();
@ -487,7 +523,6 @@ public void onEnable() {
}
}
//this.registerBaseCommands();
Bukkit.getPluginManager().registerEvents(new BlockEventHandler(dataStore), GDBootstrap.getInstance());
Bukkit.getPluginManager().registerEvents(new BlockEventTracker(), GDBootstrap.getInstance());
Bukkit.getPluginManager().registerEvents(new CommandEventHandler(dataStore), GDBootstrap.getInstance());
@ -496,11 +531,6 @@ public void onEnable() {
Bukkit.getPluginManager().registerEvents(new WorldEventHandler(), GDBootstrap.getInstance());
Bukkit.getPluginManager().registerEvents(new NMSUtil(), GDBootstrap.getInstance());
/*PUBLIC_USER = Sponge.getServiceManager().provide(UserStorageService.class).get()
.getOrCreate(GameProfile.of(GriefDefenderPlugin.PUBLIC_UUID, GriefDefenderPlugin.PUBLIC_NAME));
WORLD_USER = Sponge.getServiceManager().provide(UserStorageService.class).get()
.getOrCreate(GameProfile.of(GriefDefenderPlugin.WORLD_USER_UUID, GriefDefenderPlugin.WORLD_USER_NAME));*/
// run cleanup task
int cleanupTaskInterval = GriefDefenderPlugin.getGlobalConfig().getConfig().claim.expirationCleanupInterval;
if (cleanupTaskInterval > 0) {
@ -508,11 +538,6 @@ public void onEnable() {
}
/*if (this.permissionService == null) {
this.getLogger().severe("Unable to initialize plugin. GriefDefender requires a permissions plugin such as LuckPerms.");
return;
}*/
final boolean resetMigration = GriefDefenderPlugin.getGlobalConfig().getConfig().playerdata.resetMigrations;
final boolean resetClaimData = GriefDefenderPlugin.getGlobalConfig().getConfig().playerdata.resetAccruedClaimBlocks;
final int migration2dRate = GriefDefenderPlugin.getGlobalConfig().getConfig().playerdata.migrateAreaRate;
@ -840,8 +865,6 @@ public void loadConfig() {
Path rootConfigPath = this.getConfigPath().resolve("worlds");
BaseStorage.globalConfig = new GriefDefenderConfig<>(GlobalConfig.class, this.getConfigPath().resolve("global.conf"), null);
BaseStorage.globalConfig.getConfig().permissionCategory.refreshFlags();
BaseStorage.globalConfig.getConfig().permissionCategory.checkOptions();
String localeString = BaseStorage.globalConfig.getConfig().message.locale;
try {
LocaleUtils.toLocale(localeString);
@ -863,7 +886,16 @@ public void loadConfig() {
messageStorage = new MessageStorage(localePath);
messageData = messageStorage.getConfig();
MessageCache.getInstance().loadCache();
BaseStorage.globalConfig.getConfig().customFlags.initDefaults();
flagConfig = new FlagConfig(this.getConfigPath().resolve("flags.conf"));
// FlagDefinition registry needs to init after config load
FlagDefinitionRegistryModule.getInstance().registerDefaults();
flagConfig.getConfig().customFlags.initDefaults();
flagConfig.save();
flagConfig.getConfig().defaultFlagCategory.refreshFlags();
flagConfig.save();
optionConfig = new OptionConfig(this.getConfigPath().resolve("options.conf"));
optionConfig.getConfig().defaultOptionCategory.checkOptions();
optionConfig.save();
BaseStorage.globalConfig.save();
BaseStorage.USE_GLOBAL_PLAYER_STORAGE = !BaseStorage.globalConfig.getConfig().playerdata.useWorldPlayerData();
GDFlags.populateFlagStatus();
@ -1119,6 +1151,23 @@ public PermissionProvider getPermissionProvider() {
return this.permissionProvider;
}
public static int getMajorMinecraftVersion() {
final String version = Bukkit.getVersion();
if (version.contains("1.8.8")) {
return 8;
} else if (version.contains("1.12")) {
return 12;
} else if (version.contains("1.13")) {
return 13;
} else if (version.contains("1.14")) {
return 14;
} else if (version.contains("1.15")) {
return 15;
}
return -1;
}
public static MCTiming timing(String name) {
return timingManager.of(name);
}

View File

@ -130,6 +130,7 @@ public static MessageCache getInstance() {
public Component CREATE_OVERLAP_SHORT;
public Component CREATE_SUBDIVISION_FAIL;
public Component CREATE_SUBDIVISION_ONLY;
public Component DEBUG_CLICK_TO_EXPAND;
public Component DEBUG_NO_RECORDS;
public Component DEBUG_PASTE_SUCCESS;
public Component DEBUG_RECORD_END;
@ -145,43 +146,16 @@ public static MessageCache getInstance() {
public Component ECONOMY_NOT_INSTALLED;
public Component ECONOMY_VIRTUAL_NOT_SUPPORTED;
public Component FEATURE_NOT_AVAILABLE;
public Component FLAG_DESCRIPTION_CUSTOM_BLOCK_BREAK;
public Component FLAG_DESCRIPTION_CUSTOM_BLOCK_GROW;
public Component FLAG_DESCRIPTION_CUSTOM_BLOCK_PLACE;
public Component FLAG_DESCRIPTION_CUSTOM_BLOCK_SPREAD;
public Component FLAG_DESCRIPTION_CUSTOM_ENDERPEARL;
public Component FLAG_DESCRIPTION_CUSTOM_EXIT_PLAYER;
public Component FLAG_DESCRIPTION_CUSTOM_EXPLOSION_BLOCK;
public Component FLAG_DESCRIPTION_CUSTOM_EXPLOSION_ENTITY;
public Component FLAG_DESCRIPTION_CUSTOM_EXP_DROP;
public Component FLAG_DESCRIPTION_CUSTOM_FALL_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_INTERACT_BLOCK;
public Component FLAG_DESCRIPTION_CUSTOM_INTERACT_ENTITY;
public Component FLAG_DESCRIPTION_CUSTOM_INTERACT_INVENTORY;
public Component FLAG_DESCRIPTION_CUSTOM_INVINCIBLE;
public Component FLAG_DESCRIPTION_CUSTOM_ITEM_DROP;
public Component FLAG_DESCRIPTION_CUSTOM_ITEM_PICKUP;
public Component FLAG_DESCRIPTION_CUSTOM_MONSTER_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_PISTONS;
public Component FLAG_DESCRIPTION_CUSTOM_PORTAL_USE;
public Component FLAG_DESCRIPTION_CUSTOM_SPAWN_AQUATIC;
public Component FLAG_DESCRIPTION_CUSTOM_SPAWN_AMBIENT;
public Component FLAG_DESCRIPTION_CUSTOM_SPAWN_ANIMAL;
public Component FLAG_DESCRIPTION_CUSTOM_SPAWN_MONSTER;
public Component FLAG_DESCRIPTION_CUSTOM_TELEPORT_FROM;
public Component FLAG_DESCRIPTION_CUSTOM_TELEPORT_TO;
public Component FLAG_DESCRIPTION_CUSTOM_USE;
public Component FLAG_DESCRIPTION_CUSTOM_VEHICLE_DESTROY;
public Component FLAG_DESCRIPTION_CUSTOM_WITHER_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_BLOCK_TRAMPLING;
public Component FLAG_DESCRIPTION_CUSTOM_CHEST_ACCESS;
public Component FLAG_DESCRIPTION_CUSTOM_CHORUS_FRUIT_TELEPORT;
public Component FLAG_DESCRIPTION_CUSTOM_CREEPER_BLOCK_EXPLOSION;
public Component FLAG_DESCRIPTION_CUSTOM_CREEPER_ENTITY_EXPLOSION;
public Component FLAG_DESCRIPTION_CUSTOM_CROP_GROWTH;
public Component FLAG_DESCRIPTION_CUSTOM_DAMAGE_ANIMALS;
public Component FLAG_DESCRIPTION_CUSTOM_ENDERMAN_GRIEF;
public Component FLAG_DESCRIPTION_CUSTOM_ENTER_PLAYER;
public Component FLAG_DESCRIPTION_CUSTOM_EXPLOSION_CREEPER;
public Component FLAG_DESCRIPTION_CUSTOM_EXPLOSION_TNT;
public Component FLAG_DESCRIPTION_CUSTOM_EXP_DROP;
public Component FLAG_DESCRIPTION_CUSTOM_FALL_PLAYER_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_FIRE_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_FIRE_SPREAD;
public Component FLAG_DESCRIPTION_CUSTOM_GRASS_GROWTH;
@ -191,8 +165,26 @@ public static MessageCache getInstance() {
public Component FLAG_DESCRIPTION_CUSTOM_LEAF_DECAY;
public Component FLAG_DESCRIPTION_CUSTOM_LIGHTNING;
public Component FLAG_DESCRIPTION_CUSTOM_LIGHTER;
public Component FLAG_DESCRIPTION_CUSTOM_MONSTER_ANIMAL_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_MONSTER_PLAYER_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_MONSTER_SPAWN;
public Component FLAG_DESCRIPTION_CUSTOM_MUSHROOM_GROWTH;
public Component FLAG_DESCRIPTION_CUSTOM_MYCELIUM_SPREAD;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_BLOCK_BREAK;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_BLOCK_INTERACT;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_BLOCK_PLACE;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_ENDERPEARL_INTERACT;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_ENTER;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_ENTITY_INTERACT;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_EXIT;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_INVENTORY_INTERACT;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_ITEM_DROP;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_ITEM_PICKUP;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_TELEPORT_FROM;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_TELEPORT_TO;
public Component FLAG_DESCRIPTION_CUSTOM_PISTON_USE;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_PORTAL_USE;
public Component FLAG_DESCRIPTION_CUSTOM_PVP;
public Component FLAG_DESCRIPTION_CUSTOM_RIDE;
public Component FLAG_DESCRIPTION_CUSTOM_SLEEP;
@ -200,6 +192,15 @@ public static MessageCache getInstance() {
public Component FLAG_DESCRIPTION_CUSTOM_SNOW_MELT;
public Component FLAG_DESCRIPTION_CUSTOM_SNOWMAN_TRAIL;
public Component FLAG_DESCRIPTION_CUSTOM_SOIL_DRY;
public Component FLAG_DESCRIPTION_CUSTOM_SPAWN_AQUATIC;
public Component FLAG_DESCRIPTION_CUSTOM_SPAWN_AMBIENT;
public Component FLAG_DESCRIPTION_CUSTOM_SPAWN_ANIMAL;
public Component FLAG_DESCRIPTION_CUSTOM_TNT_BLOCK_EXPLOSION;
public Component FLAG_DESCRIPTION_CUSTOM_TNT_ENTITY_EXPLOSION;
public Component FLAG_DESCRIPTION_CUSTOM_USE;
public Component FLAG_DESCRIPTION_CUSTOM_VEHICLE_USE;
public Component FLAG_DESCRIPTION_CUSTOM_WITHER_BLOCK_BREAK;
public Component FLAG_DESCRIPTION_CUSTOM_WITHER_ENTITY_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_VEHICLE_PLACE;
public Component FLAG_DESCRIPTION_CUSTOM_VINE_GROWTH;
public Component FLAG_DESCRIPTION_CUSTOM_WATER_FLOW;
@ -262,6 +263,7 @@ public static MessageCache getInstance() {
public Component LABEL_CONTAINERS;
public Component LABEL_CONTEXT;
public Component LABEL_CREATED;
public Component LABEL_DEFAULT;
public Component LABEL_DISPLAYING;
public Component LABEL_EXPIRED;
public Component LABEL_FAREWELL;
@ -503,6 +505,7 @@ public void loadCache() {
CREATE_OVERLAP_SHORT = MessageStorage.MESSAGE_DATA.getMessage("create-overlap-short");
CREATE_SUBDIVISION_FAIL = MessageStorage.MESSAGE_DATA.getMessage("create-subdivision-fail");
CREATE_SUBDIVISION_ONLY = MessageStorage.MESSAGE_DATA.getMessage("create-subdivision-only");
DEBUG_CLICK_TO_EXPAND = MessageStorage.MESSAGE_DATA.getMessage("debug-click-to-expand");
DEBUG_NO_RECORDS = MessageStorage.MESSAGE_DATA.getMessage("debug-no-records");
DEBUG_PASTE_SUCCESS = MessageStorage.MESSAGE_DATA.getMessage("debug-paste-success");
DEBUG_RECORD_END = MessageStorage.MESSAGE_DATA.getMessage("debug-record-end");
@ -518,43 +521,16 @@ public void loadCache() {
ECONOMY_NOT_INSTALLED = MessageStorage.MESSAGE_DATA.getMessage("economy-not-installed");
ECONOMY_VIRTUAL_NOT_SUPPORTED = MessageStorage.MESSAGE_DATA.getMessage("economy-virtual-not-supported");
FEATURE_NOT_AVAILABLE = MessageStorage.MESSAGE_DATA.getMessage("feature-not-available");
FLAG_DESCRIPTION_CUSTOM_BLOCK_BREAK = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-block-break");
FLAG_DESCRIPTION_CUSTOM_BLOCK_GROW = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-block-grow");
FLAG_DESCRIPTION_CUSTOM_BLOCK_PLACE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-block-place");
FLAG_DESCRIPTION_CUSTOM_BLOCK_SPREAD = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-block-spread");
FLAG_DESCRIPTION_CUSTOM_ENDERPEARL = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-enderpearl");
FLAG_DESCRIPTION_CUSTOM_EXIT_PLAYER = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-exit-player");
FLAG_DESCRIPTION_CUSTOM_EXPLOSION_BLOCK = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-explosion-block");
FLAG_DESCRIPTION_CUSTOM_EXPLOSION_ENTITY = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-explosion-entity");
FLAG_DESCRIPTION_CUSTOM_EXP_DROP = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-exp-drop");
FLAG_DESCRIPTION_CUSTOM_FALL_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-fall-damage");
FLAG_DESCRIPTION_CUSTOM_INTERACT_BLOCK = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-interact-block");
FLAG_DESCRIPTION_CUSTOM_INTERACT_ENTITY = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-interact-entity");
FLAG_DESCRIPTION_CUSTOM_INTERACT_INVENTORY = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-interact-inventory");
FLAG_DESCRIPTION_CUSTOM_INVINCIBLE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-invincible");
FLAG_DESCRIPTION_CUSTOM_ITEM_DROP = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-item-drop");
FLAG_DESCRIPTION_CUSTOM_ITEM_PICKUP = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-item-pickup");
FLAG_DESCRIPTION_CUSTOM_MONSTER_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-monster-damage");
FLAG_DESCRIPTION_CUSTOM_PISTONS = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-pistons");
FLAG_DESCRIPTION_CUSTOM_PORTAL_USE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-portal-use");
FLAG_DESCRIPTION_CUSTOM_SPAWN_AMBIENT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-spawn-ambient");
FLAG_DESCRIPTION_CUSTOM_SPAWN_ANIMAL = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-spawn-animal");
FLAG_DESCRIPTION_CUSTOM_SPAWN_AQUATIC = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-spawn-aquatic");
FLAG_DESCRIPTION_CUSTOM_SPAWN_MONSTER = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-spawn-monster");
FLAG_DESCRIPTION_CUSTOM_TELEPORT_FROM = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-teleport-from");
FLAG_DESCRIPTION_CUSTOM_TELEPORT_TO = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-teleport-to");
FLAG_DESCRIPTION_CUSTOM_USE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-use");
FLAG_DESCRIPTION_CUSTOM_VEHICLE_DESTROY = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-vehicle-destroy");
FLAG_DESCRIPTION_CUSTOM_WITHER_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-wither-damage");
FLAG_DESCRIPTION_CUSTOM_BLOCK_TRAMPLING = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-block-trampling");
FLAG_DESCRIPTION_CUSTOM_CHEST_ACCESS = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-chest-access");
FLAG_DESCRIPTION_CUSTOM_CHORUS_FRUIT_TELEPORT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-chorus-fruit-teleport");
FLAG_DESCRIPTION_CUSTOM_CREEPER_BLOCK_EXPLOSION = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-creeper-block-explosion");
FLAG_DESCRIPTION_CUSTOM_CREEPER_ENTITY_EXPLOSION = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-creeper-entity-explosion");
FLAG_DESCRIPTION_CUSTOM_CROP_GROWTH = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-crop-growth");
FLAG_DESCRIPTION_CUSTOM_DAMAGE_ANIMALS = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-damage-animals");
FLAG_DESCRIPTION_CUSTOM_ENDERMAN_GRIEF = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-enderman-grief");
FLAG_DESCRIPTION_CUSTOM_ENTER_PLAYER = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-enter-player");
FLAG_DESCRIPTION_CUSTOM_EXPLOSION_CREEPER = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-explosion-creeper");
FLAG_DESCRIPTION_CUSTOM_EXPLOSION_TNT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-explosion-tnt");
FLAG_DESCRIPTION_CUSTOM_EXP_DROP = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-exp-drop");
FLAG_DESCRIPTION_CUSTOM_FALL_PLAYER_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-fall-player-damage");
FLAG_DESCRIPTION_CUSTOM_FIRE_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-fire-damage");
FLAG_DESCRIPTION_CUSTOM_FIRE_SPREAD = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-fire-spread");
FLAG_DESCRIPTION_CUSTOM_GRASS_GROWTH = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-grass-growth");
@ -562,10 +538,28 @@ public void loadCache() {
FLAG_DESCRIPTION_CUSTOM_ICE_MELT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-ice-melt");
FLAG_DESCRIPTION_CUSTOM_LAVA_FLOW = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-lava-flow");
FLAG_DESCRIPTION_CUSTOM_LEAF_DECAY = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-leaf-decay");
FLAG_DESCRIPTION_CUSTOM_LIGHTNING = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-lightning");
FLAG_DESCRIPTION_CUSTOM_LIGHTER = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-lighter");
FLAG_DESCRIPTION_CUSTOM_LIGHTNING = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-lightning");
FLAG_DESCRIPTION_CUSTOM_MONSTER_ANIMAL_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-monster-animal-damage");
FLAG_DESCRIPTION_CUSTOM_MONSTER_PLAYER_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-monster-player-damage");
FLAG_DESCRIPTION_CUSTOM_MONSTER_SPAWN = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-monster-spawn");
FLAG_DESCRIPTION_CUSTOM_MUSHROOM_GROWTH = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-mushroom-growth");
FLAG_DESCRIPTION_CUSTOM_MYCELIUM_SPREAD = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-mycelium-spread");
FLAG_DESCRIPTION_CUSTOM_PISTON_USE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-piston-use");
FLAG_DESCRIPTION_CUSTOM_PLAYER_BLOCK_BREAK = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-block-break");
FLAG_DESCRIPTION_CUSTOM_PLAYER_BLOCK_PLACE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-block-place");
FLAG_DESCRIPTION_CUSTOM_PLAYER_BLOCK_INTERACT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-block-interact");
FLAG_DESCRIPTION_CUSTOM_PLAYER_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-damage");
FLAG_DESCRIPTION_CUSTOM_PLAYER_ENDERPEARL_INTERACT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-enderpearl-interact");
FLAG_DESCRIPTION_CUSTOM_PLAYER_ENTER = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-enter");
FLAG_DESCRIPTION_CUSTOM_PLAYER_ENTITY_INTERACT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-entity-interact");
FLAG_DESCRIPTION_CUSTOM_PLAYER_EXIT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-exit");
FLAG_DESCRIPTION_CUSTOM_PLAYER_INVENTORY_INTERACT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-inventory-interact");
FLAG_DESCRIPTION_CUSTOM_PLAYER_ITEM_DROP = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-item-drop");
FLAG_DESCRIPTION_CUSTOM_PLAYER_ITEM_PICKUP = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-item-pickup");
FLAG_DESCRIPTION_CUSTOM_PLAYER_PORTAL_USE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-portal-use");
FLAG_DESCRIPTION_CUSTOM_PLAYER_TELEPORT_FROM = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-teleport-from");
FLAG_DESCRIPTION_CUSTOM_PLAYER_TELEPORT_TO = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-teleport-to");
FLAG_DESCRIPTION_CUSTOM_PVP = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-pvp");
FLAG_DESCRIPTION_CUSTOM_RIDE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-ride");
FLAG_DESCRIPTION_CUSTOM_SLEEP = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-sleep");
@ -573,9 +567,17 @@ public void loadCache() {
FLAG_DESCRIPTION_CUSTOM_SNOW_MELT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-snow-melt");
FLAG_DESCRIPTION_CUSTOM_SNOWMAN_TRAIL = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-snowman-trail");
FLAG_DESCRIPTION_CUSTOM_SOIL_DRY = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-soil-dry");
FLAG_DESCRIPTION_CUSTOM_VEHICLE_PLACE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-vehicle-place");
FLAG_DESCRIPTION_CUSTOM_SPAWN_AMBIENT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-spawn-ambient");
FLAG_DESCRIPTION_CUSTOM_SPAWN_ANIMAL = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-spawn-animal");
FLAG_DESCRIPTION_CUSTOM_SPAWN_AQUATIC = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-spawn-aquatic");
FLAG_DESCRIPTION_CUSTOM_TNT_BLOCK_EXPLOSION = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-tnt-block-explosion");
FLAG_DESCRIPTION_CUSTOM_TNT_ENTITY_EXPLOSION = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-tnt-entity-explosion");
FLAG_DESCRIPTION_CUSTOM_USE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-use");
FLAG_DESCRIPTION_CUSTOM_VEHICLE_USE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-vehicle-use");
FLAG_DESCRIPTION_CUSTOM_VINE_GROWTH = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-vine-growth");
FLAG_DESCRIPTION_CUSTOM_WATER_FLOW = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-water-flow");
FLAG_DESCRIPTION_CUSTOM_WITHER_BLOCK_BREAK = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-wither-block-break");
FLAG_DESCRIPTION_CUSTOM_WITHER_ENTITY_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-wither-entity-damage");
FLAG_DESCRIPTION_BLOCK_BREAK = MessageStorage.MESSAGE_DATA.getMessage("flag-description-block-break");
FLAG_DESCRIPTION_BLOCK_GROW = MessageStorage.MESSAGE_DATA.getMessage("flag-description-block-grow");
FLAG_DESCRIPTION_BLOCK_MODIFY = MessageStorage.MESSAGE_DATA.getMessage("flag-description-block-modify");
@ -634,6 +636,7 @@ public void loadCache() {
LABEL_CONTAINERS = MessageStorage.MESSAGE_DATA.getMessage("label-containers");
LABEL_CONTEXT = MessageStorage.MESSAGE_DATA.getMessage("label-context");
LABEL_CREATED = MessageStorage.MESSAGE_DATA.getMessage("label-created");
LABEL_DEFAULT = MessageStorage.MESSAGE_DATA.getMessage("label-default");
LABEL_DISPLAYING = MessageStorage.MESSAGE_DATA.getMessage("label-displaying");
LABEL_EXPIRED = MessageStorage.MESSAGE_DATA.getMessage("label-expired");
LABEL_FAREWELL = MessageStorage.MESSAGE_DATA.getMessage("label-farewell");

View File

@ -170,7 +170,7 @@ public void execute(Player player, String[] args) throws InvalidCommandArgument
if (claim != null) {
if (flag == null && value == null && player.hasPermission(GDPermissions.COMMAND_LIST_CLAIM_FLAGS)) {
String defaultGroup = "";
for (Entry<String, CustomFlagGroupCategory> groupEntry : GriefDefenderPlugin.getGlobalConfig().getConfig().customFlags.getGroups().entrySet()) {
for (Entry<String, CustomFlagGroupCategory> groupEntry : GriefDefenderPlugin.getInstance().flagConfig.getConfig().customFlags.getGroups().entrySet()) {
final String permission = groupEntry.getValue().isAdminGroup() ? GDPermissions.FLAG_CUSTOM_ADMIN_BASE : GDPermissions.FLAG_CUSTOM_USER_BASE;
if (!player.hasPermission(permission + "." + groupEntry.getKey()) && !src.getInternalPlayerData().canIgnoreClaim(claim)) {
continue;
@ -203,16 +203,16 @@ public void execute(Player player, String[] args) throws InvalidCommandArgument
}
}
protected void showCustomFlags(GDPermissionUser src, GDClaim claim, String displayGroup) {
protected void showCustomFlags(GDPermissionUser src, GDClaim claim, String flagGroup) {
final Player player = src.getOnlinePlayer();
final String lastPermissionMenuType = this.lastActivePresetMenuMap.getIfPresent(player.getUniqueId());
if (lastPermissionMenuType != null && !lastPermissionMenuType.equalsIgnoreCase(displayGroup.toLowerCase())) {
if (lastPermissionMenuType != null && !lastPermissionMenuType.equalsIgnoreCase(flagGroup.toLowerCase())) {
PaginationUtil.getInstance().resetActivePage(player.getUniqueId());
}
TextComponent.Builder flagHeadBuilder = TextComponent.builder()
.append(" Displaying :", TextColor.AQUA);
final Map<String, CustomFlagGroupCategory> flagGroups = GriefDefenderPlugin.getGlobalConfig().getConfig().customFlags.getGroups();
final Map<String, CustomFlagGroupCategory> flagGroups = GriefDefenderPlugin.getInstance().flagConfig.getConfig().customFlags.getGroups();
List<String> groups = new ArrayList<>();
for (Map.Entry<String, CustomFlagGroupCategory> flagGroupEntry : flagGroups.entrySet()) {
final CustomFlagGroupCategory flagGroupCat = flagGroupEntry.getValue();
@ -220,7 +220,7 @@ protected void showCustomFlags(GDPermissionUser src, GDClaim claim, String displ
continue;
}
final String groupName = flagGroupEntry.getKey();
final boolean isAdminGroup = GriefDefenderPlugin.getGlobalConfig().getConfig().customFlags.getGroups().get(groupName).isAdminGroup();
final boolean isAdminGroup = GriefDefenderPlugin.getInstance().flagConfig.getConfig().customFlags.getGroups().get(groupName).isAdminGroup();
final String permission = isAdminGroup ? GDPermissions.FLAG_CUSTOM_ADMIN_BASE : GDPermissions.FLAG_CUSTOM_USER_BASE;
if (!player.hasPermission(permission + "." + groupName) && !src.getInternalPlayerData().canIgnoreClaim(claim)) {
continue;
@ -229,15 +229,15 @@ protected void showCustomFlags(GDPermissionUser src, GDClaim claim, String displ
groups.add(groupName);
}
final CustomFlagGroupCategory flagGroupCat = flagGroups.get(displayGroup);
final CustomFlagGroupCategory flagGroupCat = flagGroups.get(flagGroup);
if (flagGroupCat == null || flagGroupCat.getFlagDefinitions().isEmpty()) {
TextAdapter.sendComponent(player, TextComponent.of("No custom flag definitions were found for group '" + displayGroup + "'."));
TextAdapter.sendComponent(player, TextComponent.of("No custom flag definitions were found for group '" + flagGroup + "'."));
return;
}
Collections.sort(groups);
for (String group : groups) {
flagHeadBuilder.append(" ").append(displayGroup.equalsIgnoreCase(group) ? TextComponent.builder()
flagHeadBuilder.append(" ").append(flagGroup.equalsIgnoreCase(group) ? TextComponent.builder()
.append(whiteOpenBracket)
.append(group.toUpperCase(), flagGroups.get(group).isAdminGroup() ? TextColor.RED : TextColor.GOLD)
.append(whiteCloseBracket).build() :
@ -248,12 +248,14 @@ protected void showCustomFlags(GDPermissionUser src, GDClaim claim, String displ
List<Component> textComponents = new ArrayList<>();
for (GDFlagDefinition customFlag : flagGroupCat.getFlagDefinitions().values()) {
Component flagText = TextComponent.builder()
.append(getCustomFlagText(customFlag))
.append(" ")
.append(this.getCustomClickableText(src, claim, customFlag, displayGroup))
.build();
textComponents.add(flagText);
if (customFlag.isEnabled()) {
Component flagText = TextComponent.builder()
.append(getCustomFlagText(customFlag))
.append(" ")
.append(this.getCustomClickableText(src, claim, customFlag, flagGroup))
.build();
textComponents.add(flagText);
}
}
@ -298,7 +300,7 @@ protected void showCustomFlags(GDPermissionUser src, GDClaim claim, String displ
if (activePage == null) {
activePage = 1;
}
this.lastActivePresetMenuMap.put(player.getUniqueId(), displayGroup.toLowerCase());
this.lastActivePresetMenuMap.put(player.getUniqueId(), flagGroup.toLowerCase());
paginationList.sendTo(player, activePage);
}
@ -543,27 +545,29 @@ private void addFilteredContexts(Map<String, UIFlagData> filteredContextMap, Set
private Component getCustomFlagText(GDFlagDefinition customFlag) {
TextComponent definitionType = TextComponent.empty();
TextColor flagColor = TextColor.YELLOW;
for (Context context : customFlag.getContexts()) {
if (context.getKey().contains("default")) {
definitionType = TextComponent.builder()
.append("\n")
.append(MessageCache.getInstance().LABEL_TYPE.color(TextColor.AQUA))
.append(" : ", TextColor.WHITE)
.append("DEFAULT", TextColor.LIGHT_PURPLE)
.append(" ")
.append(context.getValue().toUpperCase(), TextColor.GRAY)
.build();
flagColor = TextColor.LIGHT_PURPLE;
} else if (context.getKey().contains("override")) {
definitionType = TextComponent.builder()
.append("\n")
.append(MessageCache.getInstance().LABEL_TYPE.color(TextColor.AQUA))
.append(" : ", TextColor.WHITE)
.append("OVERRIDE", TextColor.RED)
.append(" ")
.append(context.getValue().toUpperCase(), TextColor.GRAY)
.build();
flagColor = TextColor.RED;
if (customFlag.isAdmin()) {
for (Context context : customFlag.getContexts()) {
if (context.getKey().contains("default")) {
definitionType = TextComponent.builder()
.append("\n")
.append(MessageCache.getInstance().LABEL_TYPE.color(TextColor.AQUA))
.append(" : ", TextColor.WHITE)
.append("DEFAULT", TextColor.LIGHT_PURPLE)
.append(" ")
.append(context.getValue().toUpperCase(), TextColor.GRAY)
.build();
flagColor = TextColor.LIGHT_PURPLE;
} else if (context.getKey().contains("override")) {
definitionType = TextComponent.builder()
.append("\n")
.append(MessageCache.getInstance().LABEL_TYPE.color(TextColor.AQUA))
.append(" : ", TextColor.WHITE)
.append("OVERRIDE", TextColor.RED)
.append(" ")
.append(context.getValue().toUpperCase(), TextColor.GRAY)
.build();
flagColor = TextColor.RED;
}
}
}
if (definitionType == TextComponent.empty()) {
@ -584,20 +588,6 @@ private Component getCustomFlagText(GDFlagDefinition customFlag) {
return baseFlagText;
}
private TextColor getCustomFlagColor(GDFlagDefinition customFlag) {
TextColor flagColor = TextColor.GREEN;
for (Context context : customFlag.getContexts()) {
if (context.getKey().contains("default")) {
flagColor = TextColor.LIGHT_PURPLE;
break;
} else if (context.getKey().contains("override")) {
flagColor = TextColor.RED;
break;
}
}
return flagColor;
}
private Component getFlagText(Flag flag, Set<Context> contexts) {
boolean customContext = UIHelper.containsCustomContext(contexts);
@ -620,7 +610,7 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
hasHover = true;
}
final boolean isAdminGroup = GriefDefenderPlugin.getGlobalConfig().getConfig().customFlags.getGroups().get(flagGroup).isAdminGroup();
final boolean isAdminGroup = GriefDefenderPlugin.getInstance().flagConfig.getConfig().customFlags.getGroups().get(flagGroup).isAdminGroup();
final String permission = isAdminGroup ? GDPermissions.FLAG_CUSTOM_ADMIN_BASE : GDPermissions.FLAG_CUSTOM_USER_BASE;
// check flag perm
if (!player.hasPermission(permission + "." + flagGroup + "." + customFlag.getName())) {
@ -629,70 +619,42 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
hasHover = true;
}
List<GDActiveFlagData> dataResults = new ArrayList<>();
boolean hasGDContext = false;
final List<GDActiveFlagData> definitionResults = new ArrayList<>();
boolean hasClaimContext = false;
Set<Context> definitionContexts = new HashSet<>(customFlag.getContexts());
for (Context context : customFlag.getContexts()) {
for (Context context : definitionContexts) {
if (context.getKey().contains("gd_claim")) {
hasGDContext = true;
break;
// Admins can set 'gd_claim' context value to 'claim' to represent it should be replaced with each claim UUID
if (context.getValue().equalsIgnoreCase("claim")) {
definitionContexts.remove(context);
hasClaimContext = true;
break;
}
}
}
if (!hasGDContext) {
if (hasClaimContext) {
definitionContexts.add(claim.getContext());
}
boolean hasOverride = false;
for (FlagData flagData : customFlag.getFlagData()) {
final Set<Context> filteredContexts = new HashSet<>();
for (Context context : definitionContexts) {
if (context.getKey().contains("gd_claim")) {
continue;
if (customFlag.isAdmin()) {
definitionResults.add(this.getSpecificDefinitionResult(claim, customFlag, flagData));
} else {
final GDActiveFlagData activeData = this.getActiveDefinitionResult(claim, customFlag, flagData);
definitionResults.add(activeData);
if (activeData.getType() == GDActiveFlagData.Type.OVERRIDE) {
hasOverride = true;
hasEditPermission = false;
}
filteredContexts.add(context);
}
// Check override
filteredContexts.addAll(flagData.getContexts());
Set<Context> newContexts = new HashSet<>(filteredContexts);
newContexts.add(ClaimContexts.GLOBAL_OVERRIDE_CONTEXT);
newContexts.add(claim.getWorldContext());
newContexts.add(claim.getOverrideTypeContext());
newContexts.add(claim.getOverrideClaimContext());
Tristate result = PermissionUtil.getInstance().getPermissionValue(claim, GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), newContexts);
if (result != Tristate.UNDEFINED) {
dataResults.add(new GDActiveFlagData(flagData, result, GDActiveFlagData.Type.OVERRIDE));
continue;
}
// Check claim
newContexts = new HashSet<>(filteredContexts);
newContexts.add(claim.getWorldContext());
newContexts.add(claim.getContext());
result = PermissionUtil.getInstance().getPermissionValue(claim, GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), newContexts);
if (result != Tristate.UNDEFINED) {
dataResults.add(new GDActiveFlagData(flagData, result, GDActiveFlagData.Type.CLAIM));
continue;
}
// Check default
newContexts = new HashSet<>(filteredContexts);
newContexts.add(claim.getWorldContext());
newContexts.add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
newContexts.add(claim.getDefaultTypeContext());
result = PermissionUtil.getInstance().getPermissionValue(claim, GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), newContexts);
if (result != Tristate.UNDEFINED) {
dataResults.add(new GDActiveFlagData(flagData, result, GDActiveFlagData.Type.DEFAULT));
continue;
}
dataResults.add(new GDActiveFlagData(flagData, result, GDActiveFlagData.Type.UNDEFINED));
}
boolean properResult = true;
Tristate lastResult = null;
for (GDActiveFlagData activeFlagData : dataResults) {
final Tristate result = activeFlagData.getValue();
if (lastResult == null) {
lastResult = result;
} else if (lastResult != result) {
Tristate defaultResult = null;
for (GDActiveFlagData definitionFlagData : definitionResults) {
final Tristate result = definitionFlagData.getValue();
if (defaultResult == null) {
defaultResult = result;
} else if (defaultResult != result) {
properResult = false;
break;
}
@ -701,53 +663,108 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
TextComponent.Builder valueBuilder = TextComponent.builder();
if (!properResult) {
if (hasEditPermission) {
hoverBuilder.append("Active Data : \n");
for (GDActiveFlagData activeFlagData : dataResults) {
hoverBuilder.append(activeFlagData.getComponent())
.append("\n");
hoverBuilder.append("Conflict Data : \n");
for (GDActiveFlagData definitionFlagData : definitionResults) {
hoverBuilder.append(definitionFlagData.getComponent())
.append("\n");
}
hasHover = true;
}
valueBuilder.append("partial");
lastResult = null;
defaultResult = null;
} else {
TextColor valueColor = TextColor.GRAY;
if (lastResult == Tristate.TRUE) {
if (defaultResult == Tristate.TRUE) {
valueColor = TextColor.GREEN;
} else if (lastResult == Tristate.FALSE) {
} else if (defaultResult == Tristate.FALSE) {
valueColor = TextColor.RED;
}
valueBuilder.append(String.valueOf(lastResult).toLowerCase(), valueColor);
valueBuilder.append(String.valueOf(defaultResult).toLowerCase(), valueColor);
}
if (hasEditPermission) {
if (lastResult == Tristate.TRUE) {
if (defaultResult == Tristate.TRUE) {
hoverBuilder.append(MessageCache.getInstance().FLAG_UI_CLICK_DENY);
} else {
hoverBuilder.append(MessageCache.getInstance().FLAG_UI_CLICK_ALLOW);
}
if (!customFlag.getContexts().isEmpty()) {
hoverBuilder.append("\nContexts: ");
}
for (Context context : customFlag.getContexts()) {
hoverBuilder.append("\n");
final String key = context.getKey();
final String value = context.getValue();
TextColor keyColor = TextColor.AQUA;
if (key.contains("default")) {
keyColor = TextColor.LIGHT_PURPLE;
} else if (key.contains("override")) {
keyColor = TextColor.RED;
} else if (key.contains("server")) {
keyColor = TextColor.GRAY;
if (properResult) {
hoverBuilder.append("\nDefault Value: ", TextColor.AQUA);
final Tristate defaultValue = customFlag.getDefaultValue();
if (defaultValue == Tristate.UNDEFINED) {
hoverBuilder.append(customFlag.getDefaultValue().toString().toLowerCase(), TextColor.GRAY);
} else if (defaultValue == Tristate.TRUE) {
hoverBuilder.append(customFlag.getDefaultValue().toString().toLowerCase(), TextColor.GREEN);
} else {
hoverBuilder.append(customFlag.getDefaultValue().toString().toLowerCase(), TextColor.RED);
}
hoverBuilder.append(key, keyColor)
if (!customFlag.getContexts().isEmpty()) {
hoverBuilder.append("\nDefinition Contexts: ");
if (!customFlag.isAdmin()) {
hoverBuilder.append("gd_claim", TextColor.AQUA)
.append("=", TextColor.WHITE)
.append(value.replace("minecraft:", ""), TextColor.GRAY);
.append(claim.getUniqueId().toString(), TextColor.GRAY);
}
for (Context context : customFlag.getContexts()) {
if (!customFlag.isAdmin() && context.getKey().contains("gd_claim")) {
continue;
}
hoverBuilder.append("\n");
final String key = context.getKey();
final String value = context.getValue();
TextColor keyColor = TextColor.AQUA;
if (key.contains("default")) {
keyColor = TextColor.LIGHT_PURPLE;
} else if (key.contains("override")) {
keyColor = TextColor.RED;
} else if (key.contains("server")) {
keyColor = TextColor.GRAY;
}
hoverBuilder.append(key, keyColor)
.append("=", TextColor.WHITE)
.append(value.replace("minecraft:", ""), TextColor.GRAY);
}
}
for (FlagData flagData : customFlag.getFlagData()) {
hoverBuilder.append("\nFlag: ")
.append(flagData.getFlag().getName(), TextColor.GREEN);
if (!flagData.getContexts().isEmpty()) {
hoverBuilder.append("\nContexts: ");
}
for (Context context : flagData.getContexts()) {
if (!customFlag.isAdmin() && context.getKey().contains("gd_claim")) {
continue;
}
hoverBuilder.append("\n");
final String key = context.getKey();
final String value = context.getValue();
TextColor keyColor = TextColor.AQUA;
hoverBuilder.append(key, keyColor)
.append("=", TextColor.WHITE)
.append(value.replace("minecraft:", ""), TextColor.GRAY);
}
if (customFlag.isAdmin()) {
// show active value
final GDActiveFlagData activeData = this.getActiveDefinitionResult(claim, customFlag, flagData);
hoverBuilder.append("\n\nActive Result", TextColor.AQUA)
.append("\nvalue=", TextColor.WHITE)
.append(activeData.getValue().name().toLowerCase(), TextColor.GOLD)
.append("\ntype=", TextColor.WHITE)
.append(activeData.getType().name(), activeData.getColor());
}
}
hasHover = true;
}
} else {
if (hasOverride) {
hoverBuilder.append(MessageCache.getInstance().FLAG_UI_OVERRIDE_NO_PERMISSION);
hasHover = true;
}
hasHover = true;
}
if (hasHover) {
@ -757,7 +774,7 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
if (hasEditPermission) {
textBuilder = TextComponent.builder()
.append(valueBuilder
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createCustomFlagConsumer(src, claim, customFlag, lastResult, flagGroup))))
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createCustomFlagConsumer(src, claim, customFlag, defaultResult, flagGroup))))
.build());
} else {
textBuilder = TextComponent.builder()
@ -768,6 +785,144 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
return textBuilder.build();
}
public GDActiveFlagData getSpecificDefinitionResult(GDClaim claim, GDFlagDefinition flagDefinition, FlagData flagData) {
Set<Context> contexts = new HashSet<>(flagData.getContexts());
contexts.addAll(flagDefinition.getContexts());
boolean hasClaimContext = false;
boolean hasOverrideClaimContext = false;
boolean hasDefaultClaimContext = false;
boolean replaceClaimContext = false;
final Iterator<Context> iterator = contexts.iterator();
while (iterator.hasNext()) {
final Context context = iterator.next();
if (context.getKey().equalsIgnoreCase("gd_claim")) {
hasClaimContext = true;
if (context.getValue().equalsIgnoreCase("claim")) {
iterator.remove();
replaceClaimContext = true;
}
} else if (context.getKey().equalsIgnoreCase("gd_claim_default")) {
hasDefaultClaimContext = true;
} else if (context.getKey().equalsIgnoreCase("gd_claim_override")) {
hasOverrideClaimContext = true;
}
}
GDActiveFlagData.Type type = GDActiveFlagData.Type.DEFAULT;
if (hasClaimContext) {
type = GDActiveFlagData.Type.CLAIM;
} else if (hasOverrideClaimContext) {
type = GDActiveFlagData.Type.OVERRIDE;
}
if (replaceClaimContext || !flagDefinition.isAdmin()) {
contexts.add(claim.getContext());
}
Tristate result = PermissionUtil.getInstance().getPermissionValue(claim, GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), contexts);
if (result != Tristate.UNDEFINED) {
return new GDActiveFlagData(flagDefinition, flagData, result, contexts, type);
}
return new GDActiveFlagData(flagDefinition, flagData, result, contexts, GDActiveFlagData.Type.UNDEFINED);
}
public GDActiveFlagData getActiveDefinitionResult(GDClaim claim, GDFlagDefinition flagDefinition, FlagData flagData) {
Set<Context> contexts = new HashSet<>(flagData.getContexts());
contexts.addAll(flagDefinition.getContexts());
// check if admin definition has gd_claim contex
boolean hasClaimContext = false;
boolean hasOverrideClaimContext = false;
boolean hasDefaultClaimContext = false;
boolean replaceClaimContext = false;
final Iterator<Context> iterator = contexts.iterator();
Context claimContext = claim.getContext();
while (iterator.hasNext()) {
final Context context = iterator.next();
if (!flagDefinition.isAdmin()) {
hasClaimContext = true;
if (context.getKey().contains("gd_claim")) {
iterator.remove();
}
} else {
if (context.getKey().equalsIgnoreCase("gd_claim")) {
claimContext = context;
hasClaimContext = true;
if (context.getValue().equalsIgnoreCase("claim")) {
iterator.remove();
replaceClaimContext = true;
}
} else if (context.getKey().equalsIgnoreCase("gd_claim_default")) {
hasDefaultClaimContext = true;
} else if (context.getKey().equalsIgnoreCase("gd_claim_override")) {
hasOverrideClaimContext = true;
}
}
}
if (!flagDefinition.isAdmin() || hasClaimContext) {
// First check if this permission has been overridden by admin
// Check override
contexts.remove(claimContext);
contexts.add(ClaimContexts.GLOBAL_OVERRIDE_CONTEXT);
contexts.add(claim.getWorldContext());
contexts.add(claim.getOverrideTypeContext());
contexts.add(claim.getOverrideClaimContext());
Tristate result = PermissionUtil.getInstance().getPermissionValue(claim, GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), contexts);
if (result != Tristate.UNDEFINED) {
return new GDActiveFlagData(flagDefinition, flagData, result, contexts, GDActiveFlagData.Type.OVERRIDE);
}
// Check claim
contexts = new HashSet<>(flagData.getContexts());
contexts.addAll(flagDefinition.getContexts());
if (flagDefinition.isAdmin()) {
if (replaceClaimContext) {
contexts.remove(claimContext);
contexts.add(claim.getContext());
} else {
contexts.add(claimContext);
}
} else {
contexts.add(claimContext);
}
result = PermissionUtil.getInstance().getPermissionValue(claim, GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), contexts);
if (result != Tristate.UNDEFINED) {
return new GDActiveFlagData(flagDefinition, flagData, result, contexts, GDActiveFlagData.Type.CLAIM);
}
}
if (!hasClaimContext && !hasOverrideClaimContext) {
// Direct lookup
contexts = new HashSet<>(flagData.getContexts());
contexts.addAll(flagDefinition.getContexts());
Tristate result = PermissionUtil.getInstance().getPermissionValue(claim, GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), contexts);
if (result != Tristate.UNDEFINED) {
return new GDActiveFlagData(flagDefinition, flagData, result, contexts, GDActiveFlagData.Type.DEFAULT);
}
}
if (!hasDefaultClaimContext) {
contexts = new HashSet<>(flagData.getContexts());
contexts.addAll(flagDefinition.getContexts());
contexts.remove(claimContext);
contexts.add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
contexts.add(claim.getWorldContext());
contexts.add(claim.getDefaultTypeContext());
Tristate result = PermissionUtil.getInstance().getPermissionValue(claim, GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), contexts);
if (result != Tristate.UNDEFINED) {
return new GDActiveFlagData(flagDefinition, flagData, result, contexts, GDActiveFlagData.Type.DEFAULT);
}
}
return new GDActiveFlagData(flagDefinition, flagData,Tristate.UNDEFINED, contexts, GDActiveFlagData.Type.UNDEFINED);
}
private Component getClickableText(GDPermissionUser src, GDClaim claim, Flag flag, FlagContextHolder flagHolder, Set<Context> contexts, MenuType displayType) {
Component hoverEventText = TextComponent.empty();
final MenuType flagType = flagHolder.getType();
@ -916,19 +1071,28 @@ public int compare(Context o1, Context o2) {
return textBuilder.build();
}
private Consumer<CommandSender> createCustomFlagConsumer(GDPermissionUser src, GDClaim claim, GDFlagDefinition customFlag, Tristate currentValue, String displayType) {
private Consumer<CommandSender> createCustomFlagConsumer(GDPermissionUser src, GDClaim claim, GDFlagDefinition customFlag, Tristate currentValue, String flagGroup) {
final Player player = src.getOnlinePlayer();
return consumer -> {
GDCauseStackManager.getInstance().pushCause(player);
boolean hasGDContext = false;
Set<Context> definitionContexts = new HashSet<>(customFlag.getContexts());
for (Context context : customFlag.getContexts()) {
if (context.getKey().contains("gd_claim")) {
hasGDContext = true;
boolean addClaimContext = false;
final Iterator<Context> iterator = definitionContexts.iterator();
while (iterator.hasNext()) {
final Context context = iterator.next();
if (!customFlag.isAdmin()) {
if (context.getKey().contains("gd_claim")) {
iterator.remove();
}
addClaimContext = true;
break;
} else if (context.getKey().equalsIgnoreCase("gd_claim") && context.getValue().equalsIgnoreCase("claim")) {
iterator.remove();
addClaimContext = true;
break;
}
}
if (!hasGDContext) {
if (addClaimContext) {
definitionContexts.add(claim.getContext());
}
for (FlagData flagData : customFlag.getFlagData()) {
@ -954,7 +1118,7 @@ private Consumer<CommandSender> createCustomFlagConsumer(GDPermissionUser src, G
// Save after all permission changes have been made
GriefDefenderPlugin.getInstance().getPermissionProvider().save(GriefDefenderPlugin.DEFAULT_HOLDER);
GDCauseStackManager.getInstance().popCause();
showCustomFlags(src, claim, displayType);
showCustomFlags(src, claim, flagGroup);
};
}
@ -963,7 +1127,7 @@ private Consumer<CommandSender> createFlagConsumer(GDPermissionUser src, GDClaim
return consumer -> {
GDCauseStackManager.getInstance().pushCause(player);
Set<Context> newContexts = new HashSet<>(contexts);
if (displayType == MenuType.CLAIM) {
if (displayType == MenuType.CLAIM && newValue != Tristate.UNDEFINED) {
final Iterator<Context> iterator = newContexts.iterator();
while (iterator.hasNext()) {
final Context context = iterator.next();
@ -1001,6 +1165,13 @@ private Consumer<CommandSender> createFlagConsumer(GDPermissionUser src, GDClaim
return;
}
if (displayType == MenuType.DEFAULT) {
PermissionResult result = PermissionUtil.getInstance().setTransientPermission(this.subject, flag.getPermission(), newValue, newContexts);
if (result.successful()) {
showFlagPermissions(src, claim, displayType);
return;
}
}
PermissionResult result = PermissionUtil.getInstance().setPermissionValue(this.subject, flag, newValue, newContexts);
if (!result.successful()) {
// Try again without server context

View File

@ -191,10 +191,6 @@ private static boolean validateBlockTarget(String target) {
return true;
}
/*Optional<BlockState> blockState = Sponge.getRegistry().getType(BlockState.class, target);
if (blockState.isPresent()) {
return true;
}*/
return false;
}
@ -230,22 +226,8 @@ public static PermissionResult addFlagPermission(CommandSender src, GDPermission
if (parts.length == 1) {
addFlagContexts(contexts, flag, target);
} else if (parts.length > 1 && !parts[1].equalsIgnoreCase("any")) {
// check for meta
parts = target.split("\\.");
String targetId = parts[0];
/*if (parts.length > 1) {
try {
Integer.parseInt(parts[1]);
} catch (NumberFormatException e) {
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PERMISSION_CLAIM_MANAGE, ImmutableMap.of(
"meta", parts[1],
"flag", flag.getName().toLowerCase()));
GriefDefenderPlugin.sendMessage(src, message);
return new GDPermissionResult(ResultTypes.TARGET_NOT_VALID);
}
}*/
addFlagContexts(contexts, flag, targetId);
if (!targetId.contains("#") && !CommandHelper.validateFlagTarget(flag, targetId)) {
addFlagContexts(contexts, flag, target);
if (!target.contains("#") && !CommandHelper.validateFlagTarget(flag, target)) {
return new GDPermissionResult(ResultTypes.TARGET_NOT_VALID);
}
}

View File

@ -320,7 +320,7 @@ private static Consumer<CommandSender> createInputConsumer(Player src, GDClaim c
return consumer -> {
if (messages == null || messages.isEmpty()) {
playerData.commandInputTimestamp = Instant.now();
playerData.trustAddConsumer = createAddConsumer(src, claim, playerData, type, returnCommand);
playerData.commandConsumer = createAddConsumer(src, claim, playerData, type, returnCommand);
}
messages.add(TextComponent.builder()
.append(TextComponent.of("Do you want to add a ")
@ -384,7 +384,7 @@ private static Consumer<CommandSender> createAddConsumer(Player src, GDClaim cla
}
CommandHelper.executeCommand(src, "trust", name + " " + type.getName().toLowerCase());
playerData.commandInputTimestamp = null;
playerData.trustAddConsumer = null;
playerData.commandConsumer = null;
showTrustList(src, claim, playerData, type, messages, returnCommand);
};
}
@ -392,7 +392,7 @@ private static Consumer<CommandSender> createAddConsumer(Player src, GDClaim cla
private static Consumer<CommandSender> createCancelConsumer(Player src, GDClaim claim, GDPlayerData playerData, TrustType type, Component returnCommand) {
return consumer -> {
playerData.commandInputTimestamp = null;
playerData.trustAddConsumer = null;
playerData.commandConsumer = null;
showTrustList(src, claim, playerData, type, new ArrayList<>(), returnCommand);
};
}

View File

@ -0,0 +1,96 @@
/*
* This file is part of GriefDefender, licensed under the MIT License (MIT).
*
* Copyright (c) bloodmc
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.griefdefender.configuration;
import com.griefdefender.GriefDefenderPlugin;
import ninja.leaping.configurate.ConfigurationOptions;
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
import ninja.leaping.configurate.commented.SimpleCommentedConfigurationNode;
import ninja.leaping.configurate.hocon.HoconConfigurationLoader;
import ninja.leaping.configurate.objectmapping.ObjectMapper;
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.logging.Level;
public class FlagConfig {
private HoconConfigurationLoader loader;
private CommentedConfigurationNode root = SimpleCommentedConfigurationNode.root(ConfigurationOptions.defaults());
private ObjectMapper<FlagStorage>.BoundInstance configMapper;
private FlagStorage configBase;
@SuppressWarnings({"unchecked", "rawtypes"})
public FlagConfig(Path path) {
try {
if (Files.notExists(path.getParent())) {
Files.createDirectories(path.getParent());
}
if (Files.notExists(path)) {
Files.createFile(path);
}
this.loader = HoconConfigurationLoader.builder().setPath(path).build();
this.configMapper = (ObjectMapper.BoundInstance) ObjectMapper.forClass(FlagStorage.class).bindToNew();
if (reload()) {
save();
}
} catch (Exception e) {
GriefDefenderPlugin.getInstance().getLogger().log(Level.SEVERE, "Failed to initialize configuration", e);
}
}
public FlagStorage getConfig() {
return this.configBase;
}
public void save() {
try {
this.configMapper.serialize(this.root.getNode(GriefDefenderPlugin.MOD_ID));
this.loader.save(this.root);
} catch (IOException | ObjectMappingException e) {
GriefDefenderPlugin.getInstance().getLogger().log(Level.SEVERE, "Failed to save configuration", e);
}
}
public boolean reload() {
try {
this.root = this.loader.load(ConfigurationOptions.defaults());
this.configBase = this.configMapper.populate(this.root.getNode(GriefDefenderPlugin.MOD_ID));
} catch (Exception e) {
GriefDefenderPlugin.getInstance().getLogger().log(Level.SEVERE, "Failed to load configuration", e);
return false;
}
return true;
}
public CommentedConfigurationNode getRootNode() {
return this.root.getNode(GriefDefenderPlugin.MOD_ID);
}
}

View File

@ -0,0 +1,71 @@
/*
* This file is part of GriefDefender, licensed under the MIT License (MIT).
*
* Copyright (c) bloodmc
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.griefdefender.configuration;
import com.griefdefender.configuration.category.ConfigCategory;
import com.griefdefender.configuration.category.CustomFlagGroupDefinitionCategory;
import com.griefdefender.configuration.category.DefaultFlagCategory;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class FlagStorage extends ConfigCategory {
@Setting(value = "default-flags")
public DefaultFlagCategory defaultFlagCategory = new DefaultFlagCategory();
@Setting(value = "custom-flags", comment = "Used to define a group of custom flags for players/admins."
+ "\nEach group defined will be displayed in the flag GUI for users."
+ "\nGroups can have the following settings : "
+ "\n enabled=<true|false>: Whether the group is enabled."
+ "\n admin-group=<true|false>: Whether this group is considered for admin use only."
+ "\n Note: GUI toggles in admin groups will always use configured definition contexts."
+ "\n However, non-admin groups, such as 'user', will always apply to current claim only."
+ "\n Note: If you assign users the permission 'griefdefender.admin.advanced-flags', they will be able to access admin presets within the claim tab."
+ "\n It is recommended not to assign this permission to users for best experience."
+ "\n hover=<text>: The hover text to be displayed when hovering over group name in GUI."
+ "\n title=<text>: The title text to be used for TAB display."
+ "\n value=<true|false>: This is used to set a default value for the flag definition. It is only used in conjunction with 'override=<type>, default=<type> settings."
+ "\n contexts=[\"key=value\"]: A list of definition contexts that will be applied to all permissions."
+ "\nNote: This is primary used with 'default' and 'override' contexts. Ex. contexts=[\"default=global\"]"
+ "\nNote: You must specify one of the following contexts :'gd_claim_default=<type>' , 'gd_claim_override=<type>', or 'gd_claim=claim'"
+ "\nEach group will have an associated permission in order to be viewable."
+ "\nThe 'user' group will use the permission : 'griefdefender.custom.flag.group.user'"
+ "\nThe 'admin' group will use the permission : 'griefdefender.custom.flag.group.admin'"
+ "\nWithin each group, you can define flag definitions."
+ "\nEach flag definition must be defined in the following format:"
+ "\nenabled: Controls whether the definition is enabled. Accepts a value of 'true' or 'false'"
+ "\ndefault-value: The default value to assign flag definition."
+ "\ndescription: The flag description to display on hover. Uses the legacy text format."
+ "\npermissions: The list of permissions to link to definition. Each permission accepts the following contexts :"
+ "\n flag=<linked-flag>: This context is used to link the permission to a GD specific flag. Ex. 'flag=block-break' would link permission to GD's block-break flag"
+ "\n source=<id>: This context is used to specify a source id such as 'minecraft:creeper'."
+ "\n target=<id>: This context is used to specify a target id such as 'minecraft:chest'."
+ "\n state=<properties>: This context is used to specify a blockstate property such as 'state=lit:true'."
+ "\nNote: All flag definitions that contain a definition context of 'gd_claim_default' or 'gd_claim_override' will be applied to permissions during server startup."
+ "\nNote: Required if no source or target context is specified, the permission will default to ALL."
+ "\nNote: Available contexts are : flag, source, target, state, used_item, item_name"
+ "\nThese contexts may change, See https://github.com/bloodmc/GriefDefender/wiki for latest information.")
public CustomFlagGroupDefinitionCategory customFlags = new CustomFlagGroupDefinitionCategory();
}

View File

@ -42,6 +42,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.logging.Level;
public class GriefDefenderConfig<T extends ConfigBase> {
@ -100,8 +101,7 @@ public GriefDefenderConfig(Class<T> clazz, Path path, GriefDefenderConfig<?> par
save();
}
} catch (Exception e) {
GriefDefenderPlugin.getInstance().getLogger().severe("Failed to load configuration at path " + path.toAbsolutePath());
e.printStackTrace();
GriefDefenderPlugin.getInstance().getLogger().log(Level.SEVERE, "Failed to load configuration at path " + path.toAbsolutePath(), e);
}
}
@ -133,8 +133,7 @@ public boolean save() {
}
return true;
} catch (IOException | ObjectMappingException e) {
GriefDefenderPlugin.getInstance().getLogger().severe("Failed to save configuration");
e.printStackTrace();
GriefDefenderPlugin.getInstance().getLogger().log(Level.SEVERE, "Failed to save configuration", e);
return false;
}
}

View File

@ -0,0 +1,96 @@
/*
* This file is part of GriefDefender, licensed under the MIT License (MIT).
*
* Copyright (c) bloodmc
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.griefdefender.configuration;
import com.griefdefender.GriefDefenderPlugin;
import ninja.leaping.configurate.ConfigurationOptions;
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
import ninja.leaping.configurate.commented.SimpleCommentedConfigurationNode;
import ninja.leaping.configurate.hocon.HoconConfigurationLoader;
import ninja.leaping.configurate.objectmapping.ObjectMapper;
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.logging.Level;
public class OptionConfig {
private HoconConfigurationLoader loader;
private CommentedConfigurationNode root = SimpleCommentedConfigurationNode.root(ConfigurationOptions.defaults());
private ObjectMapper<OptionStorage>.BoundInstance configMapper;
private OptionStorage configBase;
@SuppressWarnings({"unchecked", "rawtypes"})
public OptionConfig(Path path) {
try {
if (Files.notExists(path.getParent())) {
Files.createDirectories(path.getParent());
}
if (Files.notExists(path)) {
Files.createFile(path);
}
this.loader = HoconConfigurationLoader.builder().setPath(path).build();
this.configMapper = (ObjectMapper.BoundInstance) ObjectMapper.forClass(OptionStorage.class).bindToNew();
if (reload()) {
save();
}
} catch (Exception e) {
GriefDefenderPlugin.getInstance().getLogger().log(Level.SEVERE, "Failed to initialize configuration", e);
}
}
public OptionStorage getConfig() {
return this.configBase;
}
public void save() {
try {
this.configMapper.serialize(this.root.getNode(GriefDefenderPlugin.MOD_ID));
this.loader.save(this.root);
} catch (IOException | ObjectMappingException e) {
GriefDefenderPlugin.getInstance().getLogger().log(Level.SEVERE, "Failed to save configuration", e);
}
}
public boolean reload() {
try {
this.root = this.loader.load(ConfigurationOptions.defaults());
this.configBase = this.configMapper.populate(this.root.getNode(GriefDefenderPlugin.MOD_ID));
} catch (Exception e) {
GriefDefenderPlugin.getInstance().getLogger().log(Level.SEVERE, "Failed to load configuration", e);
return false;
}
return true;
}
public CommentedConfigurationNode getRootNode() {
return this.root.getNode(GriefDefenderPlugin.MOD_ID);
}
}

View File

@ -0,0 +1,37 @@
/*
* This file is part of GriefDefender, licensed under the MIT License (MIT).
*
* Copyright (c) bloodmc
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.griefdefender.configuration;
import com.griefdefender.configuration.category.ConfigCategory;
import com.griefdefender.configuration.category.DefaultOptionCategory;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class OptionStorage extends ConfigCategory {
@Setting(value = "default-options")
public DefaultOptionCategory defaultOptionCategory = new DefaultOptionCategory();
}

View File

@ -37,7 +37,7 @@
@ConfigSerializable
public class CustomFlagGroupCategory extends ConfigCategory {
@Setting
@Setting(value = "enabled", comment = "Whether flag definition group is enabled.")
boolean enabled = true;
@Setting(value = "admin-group", comment = "Set to true if this flag group is for admin use only."
+ "\nNote: If admin group, the permission is 'griefdefender.admin.custom.flag.<groupname>"

View File

@ -25,11 +25,17 @@
package com.griefdefender.configuration.category;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.permission.Context;
import com.griefdefender.api.permission.flag.FlagData;
import com.griefdefender.api.permission.flag.FlagDefinition;
import com.griefdefender.permission.flag.GDFlagDefinition;
import com.griefdefender.permission.flag.GDFlagDefinitions;
import com.griefdefender.registry.FlagDefinitionRegistryModule;
import com.griefdefender.util.PermissionUtil;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ -50,8 +56,10 @@ public void initDefaults() {
userGroup = new CustomFlagGroupCategory();
}
if (userGroup.isEnabled() && userGroup.getFlagDefinitions().isEmpty()) {
for (GDFlagDefinition definition : GDFlagDefinitions.USER_FLAGS) {
userGroup.getFlagDefinitions().put(definition.getName(), definition);
for (FlagDefinition definition : FlagDefinitionRegistryModule.getInstance().getAll()) {
if (definition.getGroupName().equalsIgnoreCase("user")) {
userGroup.getFlagDefinitions().put(definition.getName(), (GDFlagDefinition) definition);
}
}
this.groups.put("user", userGroup);
}
@ -59,11 +67,47 @@ public void initDefaults() {
adminGroup = new CustomFlagGroupCategory();
}
if (adminGroup.isEnabled() && adminGroup.getFlagDefinitions().isEmpty()) {
for (GDFlagDefinition definition : GDFlagDefinitions.ADMIN_FLAGS) {
adminGroup.getFlagDefinitions().put(definition.getName(), definition);
for (FlagDefinition definition : FlagDefinitionRegistryModule.getInstance().getAll()) {
if (definition.getGroupName().equalsIgnoreCase("admin")) {
adminGroup.getFlagDefinitions().put(definition.getName(), (GDFlagDefinition) definition);
}
}
adminGroup.isAdmin = true;
this.groups.put("admin", adminGroup);
}
for (CustomFlagGroupCategory group : this.groups.values()) {
if (!group.isEnabled()) {
continue;
}
for (FlagDefinition flagDefinition : group.definitions.values()) {
if (!flagDefinition.isEnabled()) {
continue;
}
Set<Context> contexts = new HashSet<>(flagDefinition.getContexts());
for (FlagData flagData : flagDefinition.getFlagData()) {
Set<Context> permissionContexts = new HashSet<>(contexts);
permissionContexts.addAll(flagData.getContexts());
boolean shouldApply = false;
boolean isOverride = false;
for (Context context : permissionContexts) {
if (context.getKey().equalsIgnoreCase("gd_claim_default")) {
shouldApply = true;
break;
} else if (context.getKey().equalsIgnoreCase("gd_claim_override")) {
shouldApply = true;
isOverride = true;
}
}
if (shouldApply) {
if (isOverride) {
PermissionUtil.getInstance().setPermissionValue(GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), flagDefinition.getDefaultValue(), permissionContexts);
} else {
PermissionUtil.getInstance().setTransientPermission(GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), flagDefinition.getDefaultValue(), permissionContexts);
}
}
}
}
}
}
}

View File

@ -0,0 +1,85 @@
/*
* This file is part of GriefDefender, licensed under the MIT License (MIT).
*
* Copyright (c) bloodmc
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.griefdefender.configuration.category;
import com.google.common.collect.Maps;
import com.griefdefender.api.claim.ClaimType;
import com.griefdefender.api.claim.ClaimTypes;
import com.griefdefender.api.permission.flag.Flag;
import com.griefdefender.registry.ClaimTypeRegistryModule;
import com.griefdefender.registry.FlagRegistryModule;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import java.util.HashMap;
import java.util.Map;
@ConfigSerializable
public class DefaultFlagCategory extends ConfigCategory {
@Setting(value = "default-claim-flags", comment = "The default flag settings used by claims. The group name represents the claim type."
+ "\nEx: The group admin will ONLY affect admin claims."
+ "\nSupported groups are : global, admin, basic, subdivision, town, and wilderness."
+ "\nNote: Global represents all claim types."
+ "\nNote: Specific types, such as wilderness, have higher priority than global."
+ "\nNote: Defaults do not force flags onto user claims. A newly created claim will have no flags set and use these default settings until a claim owner sets flags.")
private Map<String, Map<String, Boolean>> defaultClaimFlags = Maps.newHashMap();
public DefaultFlagCategory() {
Map<String, Boolean> globalFlagMap = new HashMap<>();
for (Flag flag : FlagRegistryModule.getInstance().getAll()) {
globalFlagMap.put(flag.getName(), flag.getDefaultClaimTypeValue(null));
}
this.defaultClaimFlags.put("global", globalFlagMap);
Map<String, Boolean> wildernessFlagMap = new HashMap<>();
for (Flag flag : FlagRegistryModule.getInstance().getAll()) {
wildernessFlagMap.put(flag.getName(), flag.getDefaultClaimTypeValue(ClaimTypes.WILDERNESS));
}
this.defaultClaimFlags.put(ClaimTypes.WILDERNESS.getName().toLowerCase(), wildernessFlagMap);
}
public void refreshFlags() {
for (ClaimType type : ClaimTypeRegistryModule.getInstance().getAll()) {
final Map<String, Boolean> flagTypeMap = this.defaultClaimFlags.get(type.getName().toLowerCase());
if (flagTypeMap != null) {
for (Flag flag : FlagRegistryModule.getInstance().getAll()) {
if (!flagTypeMap.containsKey(flag.getName())) {
flagTypeMap.put(flag.getName(), flag.getDefaultClaimTypeValue(type));
}
}
}
}
final Map<String, Boolean> globalFlagMap = this.defaultClaimFlags.get("global");
for (Flag flag : FlagRegistryModule.getInstance().getAll()) {
if (!globalFlagMap.containsKey(flag.getName())) {
globalFlagMap.put(flag.getName(), flag.getDefaultClaimTypeValue(null));
}
}
}
public Map<String, Boolean> getFlagDefaults(String type) {
return this.defaultClaimFlags.get(type.toLowerCase());
}
}

View File

@ -24,15 +24,9 @@
*/
package com.griefdefender.configuration.category;
import com.google.common.collect.Maps;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.claim.ClaimBlockSystem;
import com.griefdefender.api.claim.ClaimType;
import com.griefdefender.api.claim.ClaimTypes;
import com.griefdefender.api.permission.flag.Flag;
import com.griefdefender.api.permission.option.Options;
import com.griefdefender.registry.ClaimTypeRegistryModule;
import com.griefdefender.registry.FlagRegistryModule;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ -40,15 +34,7 @@
import java.util.Map;
@ConfigSerializable
public class DefaultPermissionCategory extends ConfigCategory {
@Setting(value = "default-claim-flags", comment = "The default flag settings used by claims. The group name represents the claim type."
+ "\nEx: The group admin will ONLY affect admin claims."
+ "\nSupported groups are : global, admin, basic, subdivision, town, and wilderness."
+ "\nNote: Global represents all claim types."
+ "\nNote: Specific types, such as wilderness, have higher priority than global."
+ "\nNote: Defaults do not force flags onto user claims. A newly created claim will have no flags set and use these default settings until a claim owner sets flags.")
private Map<String, Map<String, Boolean>> defaultClaimFlags = Maps.newHashMap();
public class DefaultOptionCategory extends ConfigCategory {
@Setting(value = "default-user-options", comment = "The default user options for all players.\nNote: Setting default claim type options will override this.")
private Map<String, String> defaultUserOptions = new HashMap<>();
@ -62,18 +48,7 @@ public class DefaultPermissionCategory extends ConfigCategory {
@Setting(value = "default-user-town-options", comment = "The default options applied to users for towns.\nNote: These options override default global options.")
private Map<String, String> defaultTownOptions = new HashMap<>();
public DefaultPermissionCategory() {
Map<String, Boolean> globalFlagMap = new HashMap<>();
for (Flag flag : FlagRegistryModule.getInstance().getAll()) {
globalFlagMap.put(flag.getName(), flag.getDefaultClaimTypeValue(null));
}
this.defaultClaimFlags.put("global", globalFlagMap);
Map<String, Boolean> wildernessFlagMap = new HashMap<>();
for (Flag flag : FlagRegistryModule.getInstance().getAll()) {
wildernessFlagMap.put(flag.getName(), flag.getDefaultClaimTypeValue(ClaimTypes.WILDERNESS));
}
this.defaultClaimFlags.put(ClaimTypes.WILDERNESS.getName().toLowerCase(), wildernessFlagMap);
public DefaultOptionCategory() {
final int maxAccruedBlocks = GriefDefenderPlugin.CLAIM_BLOCK_SYSTEM == ClaimBlockSystem.VOLUME ? 20480000 : 80000;
this.defaultUserOptions.put(Options.ABANDON_DELAY.getName(), "0");
this.defaultUserOptions.put(Options.ABANDON_RETURN_RATIO.getName(), "1.0");
@ -170,29 +145,6 @@ public void checkOptions() {
}
}
public void refreshFlags() {
for (ClaimType type : ClaimTypeRegistryModule.getInstance().getAll()) {
final Map<String, Boolean> flagTypeMap = this.defaultClaimFlags.get(type.getName().toLowerCase());
if (flagTypeMap != null) {
for (Flag flag : FlagRegistryModule.getInstance().getAll()) {
if (!flagTypeMap.containsKey(flag.getName())) {
flagTypeMap.put(flag.getName(), flag.getDefaultClaimTypeValue(type));
}
}
}
}
final Map<String, Boolean> globalFlagMap = this.defaultClaimFlags.get("global");
for (Flag flag : FlagRegistryModule.getInstance().getAll()) {
if (!globalFlagMap.containsKey(flag.getName())) {
globalFlagMap.put(flag.getName(), flag.getDefaultClaimTypeValue(null));
}
}
}
public Map<String, Boolean> getFlagDefaults(String type) {
return this.defaultClaimFlags.get(type.toLowerCase());
}
public Map<String, String> getBasicOptionDefaults() {
return this.defaultBasicOptions;
}

View File

@ -1,64 +0,0 @@
/*
* This file is part of GriefDefender, licensed under the MIT License (MIT).
*
* Copyright (c) bloodmc
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.griefdefender.configuration.category;
import com.griefdefender.api.permission.option.Options;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import java.util.ArrayList;
import java.util.List;
@ConfigSerializable
public class OptionCategory extends ConfigCategory {
@Setting(value = "user-town-options", comment = "A list of options standard users can manage in their towns with the /co commands.")
private List<String> userTownOptions = new ArrayList<>();
public OptionCategory() {
this.userTownOptions.add(Options.ABANDON_RETURN_RATIO.toString());
this.userTownOptions.add(Options.BLOCKS_ACCRUED_PER_HOUR.toString());
this.userTownOptions.add(Options.EXPIRATION.toString());
this.userTownOptions.add(Options.CREATE_LIMIT.toString());
this.userTownOptions.add(Options.EXPIRATION.toString());
this.userTownOptions.add(Options.INITIAL_BLOCKS.toString());
this.userTownOptions.add(Options.MAX_ACCRUED_BLOCKS.toString());
this.userTownOptions.add(Options.MAX_LEVEL.toString());
this.userTownOptions.add(Options.MAX_SIZE_X.toString());
this.userTownOptions.add(Options.MAX_SIZE_Y.toString());
this.userTownOptions.add(Options.MAX_SIZE_Z.toString());
this.userTownOptions.add(Options.MIN_LEVEL.toString());
this.userTownOptions.add(Options.MIN_SIZE_X.toString());
this.userTownOptions.add(Options.MIN_SIZE_Y.toString());
this.userTownOptions.add(Options.MIN_SIZE_Z.toString());
this.userTownOptions.add(Options.TAX_EXPIRATION.toString());
this.userTownOptions.add(Options.TAX_EXPIRATION_DAYS_KEEP.toString());
this.userTownOptions.add(Options.TAX_RATE.toString());
}
public List<String> getUserTownOptions() {
return this.userTownOptions;
}
}

View File

@ -31,6 +31,7 @@
import java.util.UUID;
import com.google.common.reflect.TypeToken;
import com.griefdefender.api.Tristate;
import com.griefdefender.api.permission.Context;
import com.griefdefender.api.permission.ContextKeys;
import com.griefdefender.api.permission.flag.Flag;
@ -39,7 +40,6 @@
import com.griefdefender.permission.flag.GDFlagData;
import com.griefdefender.permission.flag.GDFlagDefinition;
import com.griefdefender.registry.FlagRegistryModule;
import com.griefdefender.util.PermissionUtil;
import net.kyori.text.Component;
import net.kyori.text.TextComponent;
import net.kyori.text.serializer.legacy.LegacyComponentSerializer;
@ -53,13 +53,22 @@ public class FlagDefinitionSerializer implements TypeSerializer<FlagDefinition>
public FlagDefinition deserialize(TypeToken<?> type, ConfigurationNode node) throws ObjectMappingException {
final String flagDisplayName = node.getKey().toString();
final boolean enabled = node.getNode("enabled").getBoolean();
final boolean adminGroup = node.getParent().getParent().getNode("admin-group").getBoolean();
final String groupName = (String) node.getParent().getParent().getKey();
final String descr = node.getNode("description").getString();
Component description = TextComponent.empty();
if (descr != null) {
description = LegacyComponentSerializer.legacy().deserialize(descr, '&');
}
if (node.getNode("default-value").isVirtual()) {
throw new ObjectMappingException("No 'default-value' found for flag definition '" + flagDisplayName + "' in group '" + groupName + "'. A default value is required and needs to be set to either 'true' or 'false'.");
}
final boolean defaultValue = node.getNode("default-value").getBoolean();
List<String> contextList = node.getNode("contexts").getList(TypeToken.of(String.class));
if (adminGroup && (contextList == null || contextList.isEmpty())) {
throw new ObjectMappingException("No contexts found for admin flag definition '" + flagDisplayName + "' in group '" + groupName + "'. You must specify one of the following contexts :'gd_claim_default=<type>' , 'gd_claim_override=<type>', or 'gd_claim=claim'.");
}
List<String> permissionList = node.getNode("permissions").getList(TypeToken.of(String.class));
if (permissionList == null) {
throw new ObjectMappingException("No permissions found for flag definition '" + flagDisplayName + "'. You must specify at least 1 or more permissions.");
@ -94,11 +103,15 @@ public FlagDefinition deserialize(TypeToken<?> type, ConfigurationNode node) thr
break;
case "used_item":
case "item_name":
case ContextKeys.CLAIM_DEFAULT:
case ContextKeys.CLAIM_OVERRIDE:
case ContextKeys.STATE:
flagContexts.add(new Context(key, value));
break;
case "server":
case "world":
case ContextKeys.CLAIM_DEFAULT:
case ContextKeys.CLAIM_OVERRIDE:
// gd_claim contexts should always be set at the definition level
throw new ObjectMappingException("Invalid context '" + key + "' with value '" + value + "'.\nContext '" + key + "' can only be used for the definition.");
default:
throw new ObjectMappingException("Invalid context '" + key + "' with value '" + value + "'.");
}
@ -108,10 +121,10 @@ public FlagDefinition deserialize(TypeToken<?> type, ConfigurationNode node) thr
throw new ObjectMappingException("No linked flag specified. You need to specify 'flag=<flagname>'.");
}
flagDataList.add(new GDFlagData(linkedFlag, flagContexts));
final GDFlagData flagData = new GDFlagData(linkedFlag, flagContexts);
flagDataList.add(flagData);
}
final GDFlagDefinition flagDefinition = new GDFlagDefinition(flagDataList, flagDisplayName, description);
flagDefinition.setIsEnabled(enabled);
Set<Context> contexts = new HashSet<>();
if (contextList != null) {
for (String context : contextList) {
@ -146,26 +159,18 @@ public FlagDefinition deserialize(TypeToken<?> type, ConfigurationNode node) thr
contexts.add(new Context(key, value));
}
}
// Check for required server context and add if not found
boolean hasServerContext = false;
for (Context context : contexts) {
if (context.getKey().equalsIgnoreCase("server")) {
hasServerContext = true;
break;
}
}
if (!hasServerContext) {
final String serverName = PermissionUtil.getInstance().getServerName() == null ? "global" : PermissionUtil.getInstance().getServerName();
contexts.add(new Context("server", serverName));
}
flagDefinition.setContexts(contexts);
}
final GDFlagDefinition flagDefinition = new GDFlagDefinition(flagDataList, flagDisplayName, description, groupName, adminGroup, contexts);
flagDefinition.setIsEnabled(enabled);
flagDefinition.setDefaultValue(Tristate.fromBoolean(defaultValue));
return flagDefinition;
}
@Override
public void serialize(TypeToken<?> type, FlagDefinition obj, ConfigurationNode node) throws ObjectMappingException {
node.getNode("enabled").setValue(obj.isEnabled());
node.getNode("default-value").setValue(obj.getDefaultValue().asBoolean());
String description = "";
if (obj.getDescription() != TextComponent.empty()) {
description = LegacyComponentSerializer.legacy().serialize((Component) obj.getDescription(), '&');

View File

@ -27,7 +27,6 @@
import com.griefdefender.configuration.category.BanCategory;
import com.griefdefender.configuration.category.BlacklistCategory;
import com.griefdefender.configuration.category.ClaimCategory;
import com.griefdefender.configuration.category.OptionCategory;
import com.griefdefender.configuration.category.TownCategory;
import com.griefdefender.configuration.category.VisualCategory;
@ -52,9 +51,6 @@ public class ConfigBase {
@Setting
public ClaimCategory claim = new ClaimCategory();
@Setting
public OptionCategory options = new OptionCategory();
@Setting
public TownCategory town = new TownCategory();

View File

@ -25,8 +25,6 @@
package com.griefdefender.configuration.type;
import com.griefdefender.configuration.category.GuiCategory;
import com.griefdefender.configuration.category.CustomFlagGroupDefinitionCategory;
import com.griefdefender.configuration.category.DefaultPermissionCategory;
import com.griefdefender.configuration.category.DynmapCategory;
import com.griefdefender.configuration.category.EconomyCategory;
import com.griefdefender.configuration.category.MessageCategory;
@ -39,32 +37,6 @@
public class GlobalConfig extends ConfigBase {
@Setting(value = "custom-flags", comment = "Used to define a group of custom flags for players/admins."
+ "\nEach group defined will be displayed in the flag GUI for users."
+ "\nGroups can have the following settings : "
+ "\n enabled=<true|false>: Whether the group is enabled."
+ "\n admin-group=<true|false>: Whether this group is considered for admin use only."
+ "\n hover=<text>: The hover text to be displayed when hovering over group name in GUI."
+ "\n title=<text>: The title text to be used for TAB display."
+ "\n value=<true|false>: This is used to set a default value for the flag definition. It is only used in conjunction with 'override=<type>, default=<type> settings."
+ "\n contexts=[\"key=value\"]: A list of optional definition contexts that will be applied to all permissions."
+ "\nNote: This is primary used with 'default' and 'override' contexts. Ex. contexts=[\"default=global\"]"
+ "\nEach group will have an associated permission in order to be viewable."
+ "\nThe 'user' group will use the permission : 'griefdefender.custom.flag.group.user'"
+ "\nThe 'admin' group will use the permission : 'griefdefender.custom.flag.group.admin'"
+ "\nWithin each group, you can define flag definitions."
+ "\nEach flag definition must be defined in the following format:"
+ "\nenabled: Controls whether the definition is enabled. Accepts a value of 'true' or 'false'"
+ "\ndescription: The flag description to display on hover. Uses the legacy text format."
+ "\npermissions: The list of permissions to link to definition. Each permission accepts the following contexts :"
+ "\n flag=<linked-flag>: This context is used to link the permission to a GD specific flag. Ex. 'flag=block-break' would link permission to GD's block-break flag"
+ "\n source=<id>: This context is used to specify a source id such as 'minecraft:creeper'."
+ "\n target=<id>: This context is used to specify a target id such as 'minecraft:chest'."
+ "\n state=<properties>: This context is used to specify a blockstate property such as 'state=lit:true'."
+ "\nNote: Required if no source or target context is specified, the permission will default to ALL."
+ "\nNote: Available contexts are : flag, source, target, state, used_item, item_name"
+ "\nThese contexts may change, See https://github.com/bloodmc/GriefDefender/wiki for latest information.")
public CustomFlagGroupDefinitionCategory customFlags = new CustomFlagGroupDefinitionCategory();
@Setting
public DynmapCategory dynmap = new DynmapCategory();
@Setting
@ -81,8 +53,6 @@ public class GlobalConfig extends ConfigBase {
public MigratorCategory migrator = new MigratorCategory();
@Setting(value = "modules")
public ModuleCategory modules = new ModuleCategory();
@Setting(value = "default-permissions")
public DefaultPermissionCategory permissionCategory = new DefaultPermissionCategory();
@Setting
public ThreadCategory thread = new ThreadCategory();

View File

@ -89,7 +89,7 @@ public void onPlayerChatPost(AsyncPlayerChatEvent event) {
// check for command input
if (playerData.isWaitingForInput()) {
playerData.commandInput = event.getMessage();
playerData.trustAddConsumer.accept(player);
playerData.commandConsumer.accept(player);
event.setCancelled(true);
return;
}

View File

@ -39,6 +39,7 @@
import com.griefdefender.api.claim.TrustTypes;
import com.griefdefender.api.permission.flag.Flags;
import com.griefdefender.claim.GDClaim;
import com.griefdefender.event.GDCauseStackManager;
import com.griefdefender.permission.GDPermissionManager;
import com.griefdefender.permission.GDPermissionUser;
import com.griefdefender.permission.flag.GDFlags;
@ -108,14 +109,18 @@ public void handleBlockModify(Event event, Object source, BlockState newState) {
return;
}
if (newState.getBlock().isEmpty()) {
// Block -> Air should always be recorded as break
handleBlockBreak(event, source, newState);
return;
}
final World world = newState.getWorld();
if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) {
return;
}
final Location sourceLocation = fromBlock != null ? fromBlock.getLocation() : null;
final GDPermissionUser user = CauseContextHelper.getEventUser(sourceLocation);
final GDPermissionUser user = GDCauseStackManager.getInstance().getCurrentCause().first(GDPermissionUser.class).orElse(null);
Location location = newState.getLocation();
GDClaim targetClaim = this.storage.getClaimAt(location);
@ -155,29 +160,29 @@ public void handleBlockPlace(Event event, Object source, BlockState newState) {
}
}
public void handleBlockBreak(Event event, Object source, Block block) {
public void handleBlockBreak(Event event, Object source, BlockState blockState) {
if (!GDFlags.BLOCK_BREAK) {
return;
}
// Ignore air blocks
if (block.isEmpty()) {
if (blockState.getBlock().isEmpty()) {
return;
}
Player player = source instanceof Player ? (Player) source : null;
final Location location = block.getLocation();
final Location location = blockState.getLocation();
if (location == null) {
return;
}
final World world = block.getWorld();
final World world = blockState.getWorld();
if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) {
return;
}
GDClaim targetClaim = this.storage.getClaimAt(location);
final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.BLOCK_BREAK, source, block, player, TrustTypes.BUILDER, true);
final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.BLOCK_BREAK, source, blockState, player, TrustTypes.BUILDER, true);
if (result == Tristate.FALSE) {
((Cancellable) event).setCancelled(true);
}

View File

@ -64,6 +64,7 @@
import org.bukkit.entity.ExperienceOrb;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Item;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.TNTPrimed;
@ -118,7 +119,7 @@ public void onEntityBlockFormEvent(EntityBlockFormEvent event) {
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityBreakDoorEvent(EntityBreakDoorEvent event) {
CommonBlockEventHandler.getInstance().handleBlockBreak(event, event.getEntity(), event.getBlock());
CommonBlockEventHandler.getInstance().handleBlockBreak(event, event.getEntity(), event.getBlock().getState());
}
@EventHandler(priority = EventPriority.LOWEST)
@ -303,6 +304,9 @@ public void onEntityDamage(EntityCombustByEntityEvent event) {
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamage(EntityDamageByBlockEvent event) {
if (event.getCause() == DamageCause.SUFFOCATION) {
return;
}
GDTimings.ENTITY_DAMAGE_EVENT.startTiming();
if (protectEntity(event, event.getDamager(), event.getEntity())) {
event.setCancelled(true);
@ -373,6 +377,9 @@ public void onEntityDamage(EntityDamageEvent event) {
// Ignore as this is handled above
return;
}
if (event.getCause() == DamageCause.SUFFOCATION || event.getCause() == DamageCause.SUICIDE) {
return;
}
GDTimings.ENTITY_DAMAGE_EVENT.startTiming();
if (protectEntity(event, event.getCause(), event.getEntity())) {
event.setCancelled(true);
@ -472,11 +479,21 @@ public boolean protectEntity(Event event, Object source, Entity targetEntity) {
}
}
}
// Always allow damage against monsters
if (!GriefDefenderPlugin.isEntityProtected(targetEntity)) {
return false;
}
final TrustType trustType = TrustTypes.BUILDER;
if (projectileSource != null && projectileSource instanceof Monster) {
// check monster source damage first
final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, targetEntity.getLocation(), claim, flag, projectileSource, targetEntity, user, trustType, true);
if (result != Tristate.UNDEFINED) {
return !result.asBoolean();
}
}
if (GDPermissionManager.getInstance().getFinalPermission(event, targetEntity.getLocation(), claim, flag, source, targetEntity, user, trustType, true) == Tristate.FALSE) {
if (source != null && source instanceof Player) {
final Player player = (Player) source;
@ -498,17 +515,9 @@ public boolean protectEntity(Event event, Object source, Entity targetEntity) {
return false;
}
if (GDPermissionManager.getInstance().getFinalPermission(event, targetEntity.getLocation(), claim, flag, source, targetEntity, user, trustType, true) == Tristate.FALSE) {
return true;
}
return false;
}
if (GDPermissionManager.getInstance().getFinalPermission(event, targetEntity.getLocation(), claim, flag, source, targetEntity, user, trustType, true) == Tristate.FALSE) {
return true;
}
return false;
}

View File

@ -642,7 +642,7 @@ public void onPlayerInteractBlockPrimary(PlayerInteractEvent event, Player playe
final ItemStack itemInHand = event.getItem();
final Location location = clickedBlock == null ? null : clickedBlock.getLocation();
final GDPlayerData playerData = this.dataStore.getOrCreateGlobalPlayerData(player.getUniqueId());
final Object source = itemInHand != null ? itemInHand : player;
final Object source = itemInHand != null && !event.isBlockInHand() ? itemInHand : player;
if (playerData.claimMode) {
return;
}

View File

@ -396,7 +396,11 @@ private static void migrateGpFlags(World world) {
PermissionUtil.getInstance().setPermissionValue(DEFAULT_HOLDER, Flags.ENTITY_DAMAGE.getPermission(), Tristate.FALSE, contexts);
break;
case FLAG_NO_SNOW_FORM :
contexts.add(FlagContexts.TARGET_SNOW_LAYER);
if (GriefDefenderPlugin.getMajorMinecraftVersion() > 12) {
contexts.add(FlagContexts.TARGET_SNOW);
} else {
contexts.add(FlagContexts.TARGET_SNOW_1_12);
}
PermissionUtil.getInstance().setPermissionValue(DEFAULT_HOLDER, Flags.BLOCK_MODIFY.getPermission(), Tristate.FALSE, contexts);
break;
case FLAG_NO_VEHICLE :

View File

@ -490,7 +490,11 @@ public static void migrate(World world) throws FileNotFoundException, ClassNotFo
}
break;
case "lava-fire":
contexts.add(FlagContexts.SOURCE_LAVA);
if (GriefDefenderPlugin.getMajorMinecraftVersion() > 12) {
contexts.add(FlagContexts.SOURCE_LAVA);
} else {
contexts.add(FlagContexts.SOURCE_LAVA_1_12);
}
if (valueNode.getString().equals("deny")) {
PERMISSION_MANAGER.setFlagPermission(Flags.BLOCK_SPREAD, Tristate.FALSE, contexts);
} else {
@ -506,7 +510,11 @@ public static void migrate(World world) throws FileNotFoundException, ClassNotFo
}
break;
case "water-flow":
contexts.add(FlagContexts.SOURCE_WATER);
if (GriefDefenderPlugin.getMajorMinecraftVersion() > 12) {
contexts.add(FlagContexts.SOURCE_WATER);
} else {
contexts.add(FlagContexts.SOURCE_WATER_1_12);
}
if (valueNode.getString().equals("deny")) {
PERMISSION_MANAGER.setFlagPermission(Flags.LIQUID_FLOW, Tristate.FALSE, contexts);
} else {
@ -514,7 +522,11 @@ public static void migrate(World world) throws FileNotFoundException, ClassNotFo
}
break;
case "lava-flow":
contexts.add(FlagContexts.SOURCE_LAVA);
if (GriefDefenderPlugin.getMajorMinecraftVersion() > 12) {
contexts.add(FlagContexts.SOURCE_LAVA);
} else {
contexts.add(FlagContexts.SOURCE_LAVA_1_12);
}
if (valueNode.getString().equals("deny")) {
PERMISSION_MANAGER.setFlagPermission(Flags.LIQUID_FLOW, Tristate.FALSE, contexts);
} else {
@ -522,7 +534,11 @@ public static void migrate(World world) throws FileNotFoundException, ClassNotFo
}
break;
case "snow-fall":
contexts.add(FlagContexts.TARGET_SNOW_LAYER);
if (GriefDefenderPlugin.getMajorMinecraftVersion() > 12) {
contexts.add(FlagContexts.TARGET_SNOW);
} else {
contexts.add(FlagContexts.TARGET_SNOW_1_12);
}
if (valueNode.getString().equals("deny")) {
PERMISSION_MANAGER.setFlagPermission(Flags.BLOCK_PLACE, Tristate.FALSE, contexts);
} else {
@ -530,7 +546,11 @@ public static void migrate(World world) throws FileNotFoundException, ClassNotFo
}
break;
case "snow-melt":
contexts.add(FlagContexts.TARGET_SNOW_LAYER);
if (GriefDefenderPlugin.getMajorMinecraftVersion() > 12) {
contexts.add(FlagContexts.TARGET_SNOW);
} else {
contexts.add(FlagContexts.TARGET_SNOW_1_12);
}
if (valueNode.getString().equals("deny")) {
PERMISSION_MANAGER.setFlagPermission(Flags.BLOCK_BREAK, Tristate.FALSE, contexts);
} else {

View File

@ -94,11 +94,11 @@
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerBucketEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@ -126,11 +126,6 @@ public class GDPermissionManager implements PermissionManager {
private Set<Context> eventContexts = new HashSet<>();
private Component eventMessage;
private static final Pattern PATTERN_META = Pattern.compile("\\.[\\d+]*$");
private static final List<Context> CONTEXT_LIST = Arrays.asList(
ClaimContexts.ADMIN_DEFAULT_CONTEXT, ClaimContexts.ADMIN_OVERRIDE_CONTEXT,
ClaimContexts.BASIC_DEFAULT_CONTEXT, ClaimContexts.BASIC_OVERRIDE_CONTEXT,
ClaimContexts.TOWN_DEFAULT_CONTEXT, ClaimContexts.TOWN_OVERRIDE_CONTEXT,
ClaimContexts.WILDERNESS_OVERRIDE_CONTEXT, ClaimContexts.WILDERNESS_DEFAULT_CONTEXT);
private enum BanType {
BLOCK,
@ -193,16 +188,7 @@ public Tristate getFinalPermission(Event event, Location location, Set<Context>
this.eventLocation = location;
// refresh contexts
this.eventContexts = new HashSet<>();
/*final ItemStackSnapshot usedItem = event.getContext().get(EventContextKeys.USED_ITEM).orElse(null);
final DamageType damageType = event.getContext().get(EventContextKeys.DAMAGE_TYPE).orElse(null);
if (usedItem != null) {
//final String id = getPermissionIdentifier(usedItem);
this.eventContexts.add(new Context("used_item", usedItem.getType().getId()));
}
if (damageType != null) {
//final String id = getPermissionIdentifier(damageType);
this.eventContexts.add(new Context("damage_type", damageType.getId()));
}*/
if (user != null) {
if (user.getOnlinePlayer() != null) {
this.addPlayerContexts(user.getOnlinePlayer(), contexts);
@ -224,21 +210,6 @@ public Tristate getFinalPermission(Event event, Location location, Set<Context>
this.eventContexts = contexts;
this.eventPlayerData = playerData;
final String targetPermission = flag.getPermission();
/* if (!targetId.isEmpty()) {
String[] parts = targetId.split(":");
String targetMod = parts[0];
// move target meta to end of permission
Matcher m = PATTERN_META.matcher(targetId);
String targetMeta = "";
if (!flagPermission.contains("command-execute")) {
if (m.find()) {
targetMeta = m.group(0);
targetId = StringUtils.replace(targetId, targetMeta, "");
}
}
targetId += targetMeta;
// targetPermission += "." + targetId + targetMeta;
}*/
if (flag == Flags.ENTITY_SPAWN) {
// Check spawn limit
@ -455,7 +426,7 @@ public Tristate processResult(Claim claim, String permission, String trust, Tris
}
}
GriefDefenderPlugin.addEventLogEntry(this.currentEvent, this.eventLocation, this.eventSourceId, this.eventTargetId, this.eventSubject == null ? permissionHolder : this.eventSubject, permission, trust, permissionValue);
GriefDefenderPlugin.addEventLogEntry(this.currentEvent, claim, this.eventLocation, this.eventSourceId, this.eventTargetId, this.eventSubject == null ? permissionHolder : this.eventSubject, permission, trust, permissionValue, this.eventContexts);
}
@ -761,17 +732,23 @@ private void checkPetContext(Entity targetEntity, String id, Set<Context> contex
}
private void addPlayerContexts(Player player, Set<Context> contexts) {
if(!PermissionUtil.getInstance().containsKey(contexts, "used_item") && NMSUtil.getInstance().getActiveItem(player, this.currentEvent) != null) {
final ItemStack stack = NMSUtil.getInstance().getActiveItem(player, this.currentEvent);
if (stack.getType() != Material.AIR) {
contexts.add(new Context("used_item", getPermissionIdentifier(stack)));
if (stack.getItemMeta() != null && stack.getItemMeta().getDisplayName() != null) {
String itemName = stack.getItemMeta().getDisplayName().replaceAll("[^A-Za-z0-9]", "").toLowerCase();
if (itemName != null && !itemName.isEmpty()) {
if (!itemName.contains(":")) {
itemName = "minecraft:" + itemName;
if(!PermissionUtil.getInstance().containsKey(contexts, "used_item")) {
// special case
if (this.currentEvent instanceof PlayerBucketEvent) {
final PlayerBucketEvent bucketEvent = (PlayerBucketEvent) this.currentEvent;
contexts.add(new Context("used_item", "minecraft:" + bucketEvent.getBucket().name().toLowerCase()));
} else {
final ItemStack stack = NMSUtil.getInstance().getActiveItem(player, this.currentEvent);
if (stack != null && stack.getType() != Material.AIR) {
contexts.add(new Context("used_item", getPermissionIdentifier(stack)));
if (stack.getItemMeta() != null && stack.getItemMeta().getDisplayName() != null) {
String itemName = stack.getItemMeta().getDisplayName().replaceAll("[^A-Za-z0-9]", "").toLowerCase();
if (itemName != null && !itemName.isEmpty()) {
if (!itemName.contains(":")) {
itemName = "minecraft:" + itemName;
}
contexts.add(new Context("item_name", itemName));
}
contexts.add(new Context("item_name", itemName));
}
}
}

View File

@ -97,7 +97,7 @@ public class GDPermissions {
// flags
public static final String USER_CLAIM_FLAGS = "griefdefender.user.claim.flag";
public static final String COMMAND_FLAGS_CLAIM = "griefdefender.user.claim.command.flag.base";
public static final String COMMAND_FLAGS_CLAIM_ARG = "griefdefender.user.claim.command.flag.arg";
public static final String COMMAND_FLAGS_CLAIM_ARG = "griefdefender.admin.claim.command.flag.arg";
public static final String COMMAND_FLAGS_CLAIM_GUI = "griefdefender.user.claim.command.flag.gui";
public static final String COMMAND_FLAGS_DEBUG = "griefdefender.user.claim.command.flag.debug";
public static final String COMMAND_FLAGS_PLAYER = "griefdefender.user.claim.command.flag.player";

View File

@ -37,13 +37,16 @@ public class FlagContexts {
public static final Context SOURCE_ENDERMAN = new Context(ContextKeys.SOURCE, "minecraft:enderman");
public static final Context SOURCE_SNOWMAN = new Context(ContextKeys.SOURCE, "minecraft:snowman");
public static final Context SOURCE_WITHER = new Context(ContextKeys.SOURCE, "minecraft:wither");
public static final Context SOURCE_LAVA = new Context(ContextKeys.SOURCE, "minecraft:flowing_lava");
public static final Context SOURCE_WATER = new Context(ContextKeys.SOURCE, "minecraft:flowing_water");
public static final Context SOURCE_LAVA_1_12 = new Context(ContextKeys.SOURCE, "minecraft:flowing_lava");
public static final Context SOURCE_WATER_1_12 = new Context(ContextKeys.SOURCE, "minecraft:flowing_water");
public static final Context SOURCE_LAVA = new Context(ContextKeys.SOURCE, "minecraft:lava");
public static final Context SOURCE_WATER = new Context(ContextKeys.SOURCE, "minecraft:water");
public static final Context SOURCE_LIGHTNING_BOLT = new Context(ContextKeys.SOURCE, "minecraft:lightning_bolt");
public static final Context SOURCE_FALL = new Context(ContextKeys.SOURCE, "minecraft:fall");
public static final Context SOURCE_FIRE = new Context(ContextKeys.SOURCE, "minecraft:fire");
public static final Context SOURCE_FIREWORKS = new Context(ContextKeys.SOURCE, "minecraft:fireworks");
public static final Context SOURCE_PISTON = new Context(ContextKeys.TARGET, "minecraft:piston");
public static final Context SOURCE_ICE = new Context(ContextKeys.SOURCE, "minecraft:ice");
public static final Context SOURCE_PISTON = new Context(ContextKeys.SOURCE, "minecraft:piston");
public static final Context SOURCE_VINE = new Context(ContextKeys.SOURCE, "minecraft:vine");
public static final Context SOURCE_TYPE_MONSTER = new Context(ContextKeys.SOURCE, "#monster");
@ -51,6 +54,7 @@ public class FlagContexts {
public static final Context STATE_FARMLAND_DRY = new Context("state", "moisture:0");
// Targets
public static final Context TARGET_AIR = new Context(ContextKeys.TARGET, "minecraft:air");
public static final Context TARGET_BED = new Context(ContextKeys.TARGET, "minecraft:bed");
public static final Context TARGET_BOAT = new Context(ContextKeys.TARGET, "minecraft:boat");
public static final Context TARGET_CHEST = new Context(ContextKeys.TARGET, "minecraft:chest");
@ -60,6 +64,7 @@ public class FlagContexts {
public static final Context TARGET_FLINTANDSTEEL = new Context(ContextKeys.TARGET, "minecraft:flint_and_steel");
public static final Context TARGET_GRASS= new Context(ContextKeys.TARGET, "minecraft:grass");
public static final Context TARGET_ITEM_FRAME = new Context(ContextKeys.TARGET, "minecraft:item_frame");
public static final Context TARGET_LAVA_BUCKET = new Context(ContextKeys.TARGET, "minecraft:lava_bucket");
public static final Context TARGET_MINECART = new Context(ContextKeys.TARGET, "minecraft:minecart");
public static final Context TARGET_MYCELIUM = new Context(ContextKeys.TARGET, "minecraft:mycelium");
public static final Context TARGET_PAINTING = new Context(ContextKeys.TARGET, "minecraft:painting");
@ -67,9 +72,11 @@ public class FlagContexts {
public static final Context TARGET_PLAYER = new Context(ContextKeys.TARGET, "minecraft:player");
public static final Context TARGET_ICE_FORM = new Context(ContextKeys.TARGET, "minecraft:ice");
public static final Context TARGET_ICE_MELT = new Context(ContextKeys.TARGET, "minecraft:water");
public static final Context TARGET_SNOW_LAYER = new Context(ContextKeys.TARGET, "minecraft:snow_layer");
public static final Context TARGET_SNOW_1_12 = new Context(ContextKeys.TARGET, "minecraft:snow_layer");
public static final Context TARGET_SNOW = new Context(ContextKeys.TARGET, "minecraft:snow");
public static final Context TARGET_TURTLE_EGG = new Context(ContextKeys.TARGET, "minecraft:turtle_egg");
public static final Context TARGET_VINE = new Context(ContextKeys.TARGET, "minecraft:vine");
public static final Context TARGET_WATER_BUCKET = new Context(ContextKeys.TARGET, "minecraft:water_bucket");
public static final Context TARGET_XP_ORB = new Context(ContextKeys.TARGET, "minecraft:xp_orb");
public static final Context TARGET_TYPE_ANIMAL = new Context(ContextKeys.TARGET, "#animal");
public static final Context TARGET_TYPE_CROP = new Context(ContextKeys.TARGET, "#crop");
@ -79,4 +86,7 @@ public class FlagContexts {
public static final Context TARGET_TYPE_MUSHROOM = new Context(ContextKeys.TARGET, "#mushroom");
public static final Context TARGET_TYPE_PORTAL = new Context(ContextKeys.TARGET, "#portal");
public static final Context TARGET_TYPE_VEHICLE = new Context(ContextKeys.TARGET, "#vehicle");
public static final Context USED_ITEM_LAVA_BUCKET = new Context(ContextKeys.USED_ITEM, "minecraft:lava_bucket");
public static final Context USED_ITEM_WATER_BUCKET = new Context(ContextKeys.USED_ITEM, "minecraft:water_bucket");
}

View File

@ -27,10 +27,12 @@
import com.griefdefender.api.Tristate;
import com.griefdefender.api.permission.Context;
import com.griefdefender.api.permission.flag.FlagData;
import net.kyori.text.Component;
import net.kyori.text.TextComponent;
import net.kyori.text.format.TextColor;
import net.kyori.text.format.TextDecoration;
import java.util.Set;
public class GDActiveFlagData {
@ -41,14 +43,18 @@ public enum Type {
UNDEFINED
}
private final GDFlagDefinition flagDefinition;
private final FlagData flagData;
private final Tristate value;
private final Type type;
private final Set<Context> contexts;
public GDActiveFlagData(FlagData flagData, Tristate value, Type type) {
public GDActiveFlagData(GDFlagDefinition flagDefinition, FlagData flagData, Tristate value, Set<Context> contexts, Type type) {
this.flagDefinition = flagDefinition;
this.flagData = flagData;
this.value = value;
this.type = type;
this.contexts = contexts;
}
public FlagData getFlagData() {
@ -72,24 +78,44 @@ public TextColor getColor() {
return TextColor.GRAY;
}
public Type getType() {
return this.type;
}
public Component getComponent() {
TextComponent.Builder contextBuilder = TextComponent.builder();
int count = 0;
for (Context context : this.flagData.getContexts()) {
if (count > 0) {
contextBuilder.append(", ");
}
contextBuilder.append(context.getKey().replace("gd_claim_", "").replace("gd_claim", ""), TextColor.GREEN)
.append("=")
.append(context.getValue(), TextColor.GRAY);
String descr = "Active Claim Result: ";
final TextColor valueColor = this.getColor();
TextComponent valueComponent = TextComponent.of(this.value.toString().toLowerCase()).color(valueColor);
if (this.type == Type.OVERRIDE) {
descr = "Active Override Result: ";
valueComponent = TextComponent.of(this.value.toString().toLowerCase()).color(valueColor).decoration(TextDecoration.ITALIC, true).decoration(TextDecoration.UNDERLINED, true);
} else if (this.type == Type.DEFAULT) {
descr = "Active Default Result: ";
} else {
descr = "No Result: ";
}
TextComponent.Builder builder = TextComponent.builder();
builder
.append(this.flagData.getFlag().getName().toLowerCase(), this.getColor())
.append("=", TextColor.WHITE)
.append(this.value.toString().toLowerCase(), TextColor.GOLD)
.append(" ")
.append(contextBuilder.build());
builder.append("\n" + descr, TextColor.AQUA);
builder.append(valueComponent);
builder.append("\nFlag: ")
.append(this.flagData.getFlag().getName(), TextColor.GREEN);
if (!this.flagData.getContexts().isEmpty()) {
builder.append("\nContexts: ");
}
for (Context context : this.contexts) {
if (!this.flagDefinition.isAdmin() && context.getKey().contains("gd_claim")) {
continue;
}
builder.append("\n");
final String key = context.getKey();
final String value = context.getValue();
TextColor keyColor = TextColor.AQUA;
builder.append(key, keyColor)
.append("=", TextColor.WHITE)
.append(value.replace("minecraft:", ""), TextColor.GRAY);
}
return builder.build();
}
}

View File

@ -91,7 +91,6 @@ public boolean getDefaultClaimTypeValue(ClaimType type) {
case "entity-damage" :
case "explosion-block" :
case "explosion-entity" :
case "fire-spread" :
case "interact-block-primary" :
case "interact-block-secondary" :
case "interact-entity-primary" :
@ -104,15 +103,6 @@ public boolean getDefaultClaimTypeValue(ClaimType type) {
return true;
}
}
if (type == ClaimTypes.WILDERNESS) {
switch (this.name) {
case "fire-spread" :
return false;
default :
return true;
}
}
return true;
}

View File

@ -81,6 +81,12 @@ public Builder flag(Flag flag) {
return this;
}
@Override
public Builder context(Context context) {
this.contexts.add(context);
return this;
}
@Override
public Builder contexts(Set<Context> contexts) {
this.contexts = contexts;

View File

@ -37,7 +37,6 @@
import com.griefdefender.api.permission.flag.Flag;
import com.griefdefender.api.permission.flag.FlagData;
import com.griefdefender.api.permission.flag.FlagDefinition;
import com.griefdefender.registry.FlagDefinitionRegistryModule;
import net.kyori.text.Component;
import net.kyori.text.TextComponent;
@ -46,6 +45,7 @@
public class GDFlagDefinition implements FlagDefinition {
private boolean enabled = true;
private boolean adminDefinition = false;
private Set<Context> definitionContexts = new HashSet<>();
private List<FlagData> data = new ArrayList<>();
private String displayName;
@ -53,18 +53,13 @@ public class GDFlagDefinition implements FlagDefinition {
private Tristate defaultValue = Tristate.UNDEFINED;
private Component description;
public GDFlagDefinition(Flag flag, Set<Context> contexts, String displayName, Component description) {
this.data.add(new GDFlagData(flag, contexts));
this.displayName = displayName;
this.description = description;
FlagDefinitionRegistryModule.getInstance().registerCustomType(this);
}
public GDFlagDefinition(List<FlagData> flagData, String displayName, Component description) {
public GDFlagDefinition(List<FlagData> flagData, String displayName, Component description, String groupName, boolean isAdmin, Set<Context> contexts) {
this.data = flagData;
this.displayName = displayName;
this.description = description;
FlagDefinitionRegistryModule.getInstance().registerCustomType(this);
this.groupName = groupName;
this.definitionContexts = contexts;
this.adminDefinition = isAdmin;
}
public void addFlagData(Flag flag, Set<Context> contexts) {
@ -109,11 +104,6 @@ public Set<Context> getContexts() {
return this.definitionContexts;
}
@Override
public void setContexts(Set<Context> contexts) {
this.definitionContexts = contexts;
}
@Override
public boolean isEnabled() {
return this.enabled;
@ -124,6 +114,11 @@ public void setIsEnabled(boolean val) {
this.enabled = val;
}
@Override
public boolean isAdmin() {
return this.adminDefinition;
}
@Override
public String getId() {
return GriefDefenderPlugin.MOD_ID + ":" + this.displayName;
@ -139,11 +134,6 @@ public String getGroupName() {
return this.groupName;
}
@Override
public void setGroupName(String group) {
this.groupName = group;
}
@Override
public Tristate getDefaultValue() {
return this.defaultValue;
@ -157,7 +147,8 @@ public void setDefaultValue(Tristate value) {
public static class FlagDefinitionBuilder implements Builder {
private boolean enabled = true;
private Set<Context> definitionContexts = new HashSet<>();
private boolean isAdmin = false;
private Set<Context> contexts = new HashSet<>();
private List<FlagData> data = new ArrayList<>();
private String displayName;
private String groupName;
@ -170,21 +161,45 @@ public Builder enabled(boolean enabled) {
return this;
}
@Override
public Builder admin(boolean value) {
this.isAdmin = value;
return this;
}
@Override
public Builder group(String group) {
this.groupName = group;
return this;
}
@Override
public Builder defaultValue(Tristate value) {
this.defaultValue = value;
return this;
}
@Override
public Builder flagData(FlagData data) {
this.data.add(data);
return this;
}
@Override
public Builder flagData(List<FlagData> data) {
this.data = data;
return this;
}
@Override
public Builder context(Context context) {
this.contexts.add(context);
return this;
}
@Override
public Builder contexts(Set<Context> contexts) {
this.definitionContexts = contexts;
this.contexts = contexts;
return this;
}
@ -203,7 +218,8 @@ public Builder description(Component description) {
@Override
public Builder reset() {
this.enabled = true;
this.definitionContexts = new HashSet<>();
this.isAdmin = false;
this.contexts = new HashSet<>();
this.data = new ArrayList<>();
this.displayName = "";
this.groupName = "";
@ -218,11 +234,9 @@ public FlagDefinition build() {
checkNotNull(this.displayName);
checkNotNull(this.groupName);
checkNotNull(this.description);
final GDFlagDefinition definition = new GDFlagDefinition(this.data, this.displayName, this.description);
definition.setContexts(this.definitionContexts);
final GDFlagDefinition definition = new GDFlagDefinition(this.data, this.displayName, this.description, this.groupName, this.isAdmin, this.contexts);
definition.setIsEnabled(this.enabled);
definition.setDefaultValue(this.defaultValue);
definition.setGroupName(this.groupName);
return definition;
}

View File

@ -1,412 +0,0 @@
/*
* This file is part of GriefDefender, licensed under the MIT License (MIT).
*
* Copyright (c) bloodmc
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.griefdefender.permission.flag;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.griefdefender.api.claim.ClaimContexts;
import com.griefdefender.api.permission.Context;
import com.griefdefender.api.permission.flag.Flags;
import com.griefdefender.cache.MessageCache;
public class GDFlagDefinitions {
// ADMIN
public static final GDFlagDefinition BLOCK_BREAK;
public static final GDFlagDefinition BLOCK_GROW;
public static final GDFlagDefinition BLOCK_PLACE;
public static final GDFlagDefinition BLOCK_SPREAD;
public static final GDFlagDefinition ENDERPEARL;
public static final GDFlagDefinition EXIT_PLAYER;
public static final GDFlagDefinition EXPLOSION_BLOCK;
public static final GDFlagDefinition EXPLOSION_ENTITY;
public static final GDFlagDefinition EXP_DROP;
public static final GDFlagDefinition FALL_DAMAGE;
public static final GDFlagDefinition INTERACT_BLOCK;
public static final GDFlagDefinition INTERACT_ENTITY;
public static final GDFlagDefinition INTERACT_INVENTORY;
public static final GDFlagDefinition INVINCIBLE;
public static final GDFlagDefinition ITEM_DROP;
public static final GDFlagDefinition ITEM_PICKUP;
public static final GDFlagDefinition MONSTER_DAMAGE;
public static final GDFlagDefinition PISTONS;
public static final GDFlagDefinition PORTAL_USE;
public static final GDFlagDefinition SPAWN_MONSTER;
public static final GDFlagDefinition TELEPORT_FROM;
public static final GDFlagDefinition TELEPORT_TO;
public static final GDFlagDefinition USE;
public static final GDFlagDefinition VEHICLE_DESTROY;
public static final GDFlagDefinition WITHER_DAMAGE;
// USER
public static final GDFlagDefinition BLOCK_TRAMPLING;
public static final GDFlagDefinition CHEST_ACCESS;
public static final GDFlagDefinition CHORUS_FRUIT_TELEPORT;
public static final GDFlagDefinition CROP_GROWTH;
public static final GDFlagDefinition DAMAGE_ANIMALS;
public static final GDFlagDefinition ENDERMAN_GRIEF;
public static final GDFlagDefinition ENTER_PLAYER;
public static final GDFlagDefinition EXPLOSION_CREEPER;
public static final GDFlagDefinition EXPLOSION_TNT;
public static final GDFlagDefinition FIRE_DAMAGE;
public static final GDFlagDefinition FIRE_SPREAD;
public static final GDFlagDefinition GRASS_GROWTH;
public static final GDFlagDefinition ICE_FORM;
public static final GDFlagDefinition ICE_MELT;
public static final GDFlagDefinition LAVA_FLOW;
public static final GDFlagDefinition LEAF_DECAY;
public static final GDFlagDefinition LIGHTNING;
public static final GDFlagDefinition LIGHTER;
public static final GDFlagDefinition MUSHROOM_GROWTH;
public static final GDFlagDefinition MYCELIUM_SPREAD;
public static final GDFlagDefinition PVP;
public static final GDFlagDefinition RIDE;
public static final GDFlagDefinition SLEEP;
public static final GDFlagDefinition SNOW_FALL;
public static final GDFlagDefinition SNOW_MELT;
public static final GDFlagDefinition SNOWMAN_TRAIL;
public static final GDFlagDefinition SOIL_DRY;
public static final GDFlagDefinition SPAWN_AMBIENT;
public static final GDFlagDefinition SPAWN_ANIMAL;
public static final GDFlagDefinition SPAWN_AQUATIC;
public static final GDFlagDefinition VEHICLE_DESTROY_CLAIM;
public static final GDFlagDefinition VEHICLE_PLACE;
public static final GDFlagDefinition VINE_GROWTH;
public static final GDFlagDefinition WATER_FLOW;
public static final List<GDFlagDefinition> ADMIN_FLAGS = new ArrayList<>();
public static final List<GDFlagDefinition> USER_FLAGS = new ArrayList<>();
static {
Set<Context> contexts = new HashSet<>();
contexts = new HashSet<>();
BLOCK_BREAK = new GDFlagDefinition(Flags.BLOCK_BREAK, contexts, "block-break", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_BREAK);
contexts = new HashSet<>();
BLOCK_PLACE = new GDFlagDefinition(Flags.BLOCK_PLACE, contexts, "block-place", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_PLACE);
contexts = new HashSet<>();
BLOCK_GROW = new GDFlagDefinition(Flags.BLOCK_GROW, contexts, "block-grow", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_GROW);
contexts = new HashSet<>();
BLOCK_SPREAD = new GDFlagDefinition(Flags.BLOCK_SPREAD, contexts, "block-spread", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_SPREAD);
// ADMIN
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
ENDERPEARL = new GDFlagDefinition(Flags.INTERACT_ITEM_SECONDARY, contexts, "enderpearl", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ENDERPEARL);
ENDERPEARL.getContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
ENTER_PLAYER = new GDFlagDefinition(Flags.ENTER_CLAIM, contexts, "enter-player", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ENTER_PLAYER);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
EXIT_PLAYER = new GDFlagDefinition(Flags.ENTER_CLAIM, contexts, "exit-player", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXIT_PLAYER);
contexts = new HashSet<>();
EXPLOSION_BLOCK = new GDFlagDefinition(Flags.EXPLOSION_BLOCK, contexts, "explosion-block", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_BLOCK);
EXPLOSION_BLOCK.getContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_CREEPER);
EXPLOSION_CREEPER = new GDFlagDefinition(Flags.EXPLOSION_BLOCK, contexts, "explosion-creeper", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_CREEPER);
EXPLOSION_CREEPER.addFlagData(Flags.EXPLOSION_ENTITY, contexts);
contexts = new HashSet<>();
EXPLOSION_ENTITY = new GDFlagDefinition(Flags.EXPLOSION_ENTITY, contexts, "explosion-entity", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_ENTITY);
EXPLOSION_ENTITY.getContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_TNT);
EXPLOSION_TNT = new GDFlagDefinition(Flags.EXPLOSION_BLOCK, contexts, "explosion-tnt", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_TNT);
EXPLOSION_TNT.addFlagData(Flags.EXPLOSION_ENTITY, contexts);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_XP_ORB);
EXP_DROP = new GDFlagDefinition(Flags.ENTITY_SPAWN, contexts, "exp-drop", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXP_DROP);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_FALL);
contexts.add(FlagContexts.TARGET_PLAYER);
FALL_DAMAGE = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "fall-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FALL_DAMAGE);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
INTERACT_BLOCK = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "interact-block", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INTERACT_BLOCK);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
INTERACT_ENTITY = new GDFlagDefinition(Flags.INTERACT_ENTITY_SECONDARY, contexts, "interact-entity", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INTERACT_ENTITY);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
INTERACT_INVENTORY = new GDFlagDefinition(Flags.INTERACT_INVENTORY, contexts, "interact-inventory", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INTERACT_INVENTORY);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_PLAYER);
INVINCIBLE = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "invincible", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INVINCIBLE);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
ITEM_DROP = new GDFlagDefinition(Flags.ITEM_DROP, contexts, "item-drop", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ITEM_DROP);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
ITEM_PICKUP = new GDFlagDefinition(Flags.ITEM_PICKUP, contexts, "item-pickup", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ITEM_PICKUP);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_TYPE_MONSTER);
MONSTER_DAMAGE = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "monster-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MONSTER_DAMAGE);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_PISTON);
PISTONS = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "pistons", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PISTONS);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
contexts.add(FlagContexts.TARGET_TYPE_PORTAL);
PORTAL_USE = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "portal-use", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PORTAL_USE);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_TYPE_MONSTER);
SPAWN_MONSTER = new GDFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-monster", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_MONSTER);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_PLAYER);
TELEPORT_FROM = new GDFlagDefinition(Flags.ENTITY_TELEPORT_FROM, contexts, "teleport-from", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_TELEPORT_FROM);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_PLAYER);
TELEPORT_TO = new GDFlagDefinition(Flags.ENTITY_TELEPORT_TO, contexts, "teleport-to", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_TELEPORT_TO);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
VEHICLE_DESTROY = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "vehicle-destroy", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VEHICLE_DESTROY);
VEHICLE_DESTROY.getContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_WITHER);
WITHER_DAMAGE = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "wither-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_WITHER_DAMAGE);
WITHER_DAMAGE.getContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
ADMIN_FLAGS.add(BLOCK_BREAK);
ADMIN_FLAGS.add(BLOCK_PLACE);
ADMIN_FLAGS.add(BLOCK_GROW);
ADMIN_FLAGS.add(BLOCK_SPREAD);
ADMIN_FLAGS.add(ENDERPEARL);
ADMIN_FLAGS.add(ENTER_PLAYER);
ADMIN_FLAGS.add(EXIT_PLAYER);
ADMIN_FLAGS.add(EXPLOSION_BLOCK);
ADMIN_FLAGS.add(EXPLOSION_CREEPER);
ADMIN_FLAGS.add(EXPLOSION_ENTITY);
ADMIN_FLAGS.add(EXPLOSION_TNT);
ADMIN_FLAGS.add(EXP_DROP);
ADMIN_FLAGS.add(FALL_DAMAGE);
ADMIN_FLAGS.add(INTERACT_BLOCK);
ADMIN_FLAGS.add(INTERACT_ENTITY);
ADMIN_FLAGS.add(INTERACT_INVENTORY);
ADMIN_FLAGS.add(INVINCIBLE);
ADMIN_FLAGS.add(ITEM_DROP);
ADMIN_FLAGS.add(ITEM_PICKUP);
ADMIN_FLAGS.add(MONSTER_DAMAGE);
ADMIN_FLAGS.add(PISTONS);
ADMIN_FLAGS.add(SPAWN_MONSTER);
ADMIN_FLAGS.add(TELEPORT_FROM);
ADMIN_FLAGS.add(TELEPORT_TO);
ADMIN_FLAGS.add(VEHICLE_DESTROY);
ADMIN_FLAGS.add(WITHER_DAMAGE);
// USER
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_FARMLAND);
contexts.add(FlagContexts.TARGET_TURTLE_EGG);
BLOCK_TRAMPLING = new GDFlagDefinition(Flags.COLLIDE_BLOCK, contexts, "block-trampling", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_TRAMPLING);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
contexts.add(FlagContexts.TARGET_CHEST);
CHEST_ACCESS = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "chest-access", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CHEST_ACCESS);
CHEST_ACCESS.addFlagData(Flags.INTERACT_INVENTORY, contexts);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_CHORUS_FRUIT);
CHORUS_FRUIT_TELEPORT = new GDFlagDefinition(Flags.INTERACT_ITEM_SECONDARY, contexts, "chorus-fruit-teleport", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CHORUS_FRUIT_TELEPORT);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_TYPE_CROP);
CROP_GROWTH = new GDFlagDefinition(Flags.BLOCK_GROW, contexts, "crop-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CROP_GROWTH);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_TYPE_ANIMAL);
DAMAGE_ANIMALS = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "damage-animals", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_DAMAGE_ANIMALS);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_ENDERMAN);
ENDERMAN_GRIEF = new GDFlagDefinition(Flags.BLOCK_BREAK, contexts, "enderman-grief", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ENDERMAN_GRIEF);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_FIRE);
FIRE_DAMAGE = new GDFlagDefinition(Flags.BLOCK_MODIFY, contexts, "fire-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FIRE_DAMAGE);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_FIRE);
FIRE_SPREAD = new GDFlagDefinition(Flags.BLOCK_SPREAD, contexts, "fire-spread", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FIRE_SPREAD);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_GRASS);
GRASS_GROWTH = new GDFlagDefinition(Flags.BLOCK_GROW, contexts, "grass-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_GRASS_GROWTH);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_ICE_FORM);
ICE_FORM = new GDFlagDefinition(Flags.BLOCK_MODIFY, contexts, "ice-form", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ICE_FORM);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_ICE_MELT);
ICE_MELT = new GDFlagDefinition(Flags.BLOCK_MODIFY, contexts, "ice-melt", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ICE_MELT);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_LAVA);
LAVA_FLOW = new GDFlagDefinition(Flags.LIQUID_FLOW, contexts, "lava-flow", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LAVA_FLOW);
contexts = new HashSet<>();
LEAF_DECAY = new GDFlagDefinition(Flags.LEAF_DECAY, contexts, "leaf-decay", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LEAF_DECAY);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_LIGHTNING_BOLT);
LIGHTNING = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "lightning", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LIGHTNING);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_FLINTANDSTEEL);
LIGHTER = new GDFlagDefinition(Flags.INTERACT_ITEM_SECONDARY, contexts, "lighter", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LIGHTER);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_TYPE_MUSHROOM);
MUSHROOM_GROWTH = new GDFlagDefinition(Flags.BLOCK_GROW, contexts, "mushroom-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MUSHROOM_GROWTH);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_MYCELIUM);
MYCELIUM_SPREAD = new GDFlagDefinition(Flags.BLOCK_SPREAD, contexts, "mycelium-spread", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MYCELIUM_SPREAD);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
contexts.add(FlagContexts.TARGET_PLAYER);
PVP = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "pvp", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PVP);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
RIDE = new GDFlagDefinition(Flags.ENTITY_RIDING, contexts, "ride", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_RIDE);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
contexts.add(FlagContexts.TARGET_BED);
SLEEP = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "sleep", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SLEEP);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_SNOW_LAYER);
SNOW_FALL = new GDFlagDefinition(Flags.BLOCK_PLACE, contexts, "snow-fall", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SNOW_FALL);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_SNOW_LAYER);
SNOW_MELT = new GDFlagDefinition(Flags.BLOCK_BREAK, contexts, "snow-melt", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SNOW_MELT);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_SNOWMAN);
SNOWMAN_TRAIL = new GDFlagDefinition(Flags.BLOCK_MODIFY, contexts, "snowman-trail", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SNOWMAN_TRAIL);
contexts = new HashSet<>();
contexts.add(FlagContexts.STATE_FARMLAND_DRY);
SOIL_DRY = new GDFlagDefinition(Flags.BLOCK_MODIFY, contexts, "soil-dry", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SOIL_DRY);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_TYPE_AMBIENT);
SPAWN_AMBIENT = new GDFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-ambient", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_AMBIENT);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_TYPE_ANIMAL);
SPAWN_ANIMAL = new GDFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-animal", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_ANIMAL);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_TYPE_AQUATIC);
SPAWN_AQUATIC = new GDFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-aquatic", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_AQUATIC);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
USE = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "use", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_USE);
USE.addFlagData(Flags.INTERACT_ENTITY_SECONDARY, new HashSet<>(contexts));
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
VEHICLE_DESTROY_CLAIM = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "vehicle-destroy", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VEHICLE_DESTROY);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
VEHICLE_PLACE = new GDFlagDefinition(Flags.INTERACT_ITEM_SECONDARY, contexts, "vehicle-place", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VEHICLE_PLACE);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_VINE);
VINE_GROWTH = new GDFlagDefinition(Flags.BLOCK_GROW, contexts, "vine-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VINE_GROWTH);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_WATER);
WATER_FLOW = new GDFlagDefinition(Flags.LIQUID_FLOW, contexts, "water-flow", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_WATER_FLOW);
USER_FLAGS.add(CHEST_ACCESS);
USER_FLAGS.add(CHORUS_FRUIT_TELEPORT);
USER_FLAGS.add(CROP_GROWTH);
USER_FLAGS.add(DAMAGE_ANIMALS);
USER_FLAGS.add(ENDERMAN_GRIEF);
USER_FLAGS.add(FIRE_DAMAGE);
USER_FLAGS.add(FIRE_SPREAD);
USER_FLAGS.add(GRASS_GROWTH);
USER_FLAGS.add(ICE_FORM);
USER_FLAGS.add(ICE_MELT);
USER_FLAGS.add(LAVA_FLOW);
USER_FLAGS.add(LEAF_DECAY);
USER_FLAGS.add(LIGHTER);
USER_FLAGS.add(LIGHTNING);
USER_FLAGS.add(MYCELIUM_SPREAD);
USER_FLAGS.add(PVP);
USER_FLAGS.add(RIDE);
USER_FLAGS.add(SLEEP);
USER_FLAGS.add(SNOW_FALL);
USER_FLAGS.add(SNOW_MELT);
USER_FLAGS.add(SOIL_DRY);
USER_FLAGS.add(SPAWN_AMBIENT);
USER_FLAGS.add(SPAWN_ANIMAL);
USER_FLAGS.add(SPAWN_AQUATIC);
USER_FLAGS.add(USE);
USER_FLAGS.add(VEHICLE_DESTROY_CLAIM);
USER_FLAGS.add(VEHICLE_PLACE);
USER_FLAGS.add(WATER_FLOW);
}
}

View File

@ -49,7 +49,9 @@
public class UIHelper {
public static Comparator<Component> PLAIN_COMPARATOR = (text1, text2) -> PlainComponentSerializer.INSTANCE.serialize(text1).compareTo(PlainComponentSerializer.INSTANCE.serialize(text2));
public static Comparator<Component> PLAIN_COMPARATOR = (text1, text2) ->
PlainComponentSerializer.INSTANCE.serialize(text1).replace("true", "").replace("false", "")
.compareTo(PlainComponentSerializer.INSTANCE.serialize(text2).replace("true", "").replace("false", ""));
public static List<Component> stripeText(List<Component> texts) {
Collections.sort(texts, PLAIN_COMPARATOR);

View File

@ -815,30 +815,52 @@ public PermissionResult setPermissionValue(GDPermissionHolder holder, String per
return new GDPermissionResult(ResultTypes.FAILURE, TextComponent.builder().append(result.name()).build());
}
public void setTransientOption(GDPermissionHolder holder, String permission, String value, Set<Context> contexts) {
public PermissionResult setTransientOption(GDPermissionHolder holder, String permission, String value, Set<Context> contexts) {
// If no server context exists, add global
this.checkServerContext(contexts);
MutableContextSet contextSet = this.getLPContexts(contexts);
final PermissionHolder permissionHolder = this.getLuckPermsHolder(holder);
if (permissionHolder == null) {
return;
return new GDPermissionResult(ResultTypes.FAILURE, TextComponent.builder().append("invalid").build());
}
final Node node = this.luckPermsApi.getNodeBuilderRegistry().forMeta().key(permission).value(value).context(contextSet).build();
permissionHolder.transientData().add(node);
DataMutateResult result = null;
if (value == null) {
final Node node = this.luckPermsApi.getNodeBuilderRegistry().forMeta().key(permission).context(contextSet).build();
result = permissionHolder.transientData().remove(node);
} else {
final Node node = this.luckPermsApi.getNodeBuilderRegistry().forMeta().key(permission).value(value).context(contextSet).build();
result = permissionHolder.transientData().add(node);
}
if (result.wasSuccessful()) {
return new GDPermissionResult(ResultTypes.SUCCESS, TextComponent.builder().append(result.name()).build());
}
return new GDPermissionResult(ResultTypes.FAILURE, TextComponent.builder().append(result.name()).build());
}
public void setTransientPermission(GDPermissionHolder holder, String permission, Boolean value, Set<Context> contexts) {
public PermissionResult setTransientPermission(GDPermissionHolder holder, String permission, Tristate value, Set<Context> contexts) {
// If no server context exists, add global
this.checkServerContext(contexts);
MutableContextSet contextSet = this.getLPContexts(contexts);
final PermissionHolder permissionHolder = this.getLuckPermsHolder(holder);
if (permissionHolder == null) {
return;
return new GDPermissionResult(ResultTypes.FAILURE, TextComponent.builder().append("invalid").build());
}
final PermissionNode node = this.luckPermsApi.getNodeBuilderRegistry().forPermission().permission(permission).value(value).context(contextSet).build();
permissionHolder.transientData().add(node);
DataMutateResult result = null;
if (value == Tristate.UNDEFINED) {
final Node node = this.luckPermsApi.getNodeBuilderRegistry().forPermission().permission(permission).value(value.asBoolean()).context(contextSet).build();
result = permissionHolder.transientData().remove(node);
} else {
final PermissionNode node = this.luckPermsApi.getNodeBuilderRegistry().forPermission().permission(permission).value(value.asBoolean()).context(contextSet).build();
result = permissionHolder.transientData().add(node);
}
if (result.wasSuccessful()) {
return new GDPermissionResult(ResultTypes.SUCCESS, TextComponent.builder().append(result.name()).build());
}
return new GDPermissionResult(ResultTypes.FAILURE, TextComponent.builder().append(result.name()).build());
}
public void savePermissionHolder(PermissionHolder holder) {

View File

@ -382,7 +382,7 @@ default PermissionResult setPermissionValue(GDPermissionHolder holder, String pe
* @param contexts The contexts
* @return Whether the set permission operation was successful
*/
void setTransientOption(GDPermissionHolder holder, String permission, String value, Set<Context> contexts);
PermissionResult setTransientOption(GDPermissionHolder holder, String permission, String value, Set<Context> contexts);
/**
* Sets a transient permission and value with contexts to a holder.
@ -393,7 +393,7 @@ default PermissionResult setPermissionValue(GDPermissionHolder holder, String pe
* @param contexts The contexts
* @return Whether the set permission operation was successful
*/
void setTransientPermission(GDPermissionHolder holder, String permission, Boolean value, Set<Context> contexts);
PermissionResult setTransientPermission(GDPermissionHolder holder, String permission, Tristate value, Set<Context> contexts);
/**
* Refreshes all cached permission data of holder.

View File

@ -412,13 +412,13 @@ public PermissionResult setOptionValue(GDPermissionHolder holder, String permiss
}
@Override
public void setTransientOption(GDPermissionHolder holder, String permission, String value, Set<Context> contexts) {
holderToPEXSubject(holder).transientData().update(data -> data.setOption(contextsGDToPEX(contexts), permission, value));
public PermissionResult setTransientOption(GDPermissionHolder holder, String permission, String value, Set<Context> contexts) {
return convertResult(holderToPEXSubject(holder).transientData().update(data -> data.setOption(contextsGDToPEX(contexts), permission, value))).join();
}
@Override
public void setTransientPermission(GDPermissionHolder holder, String permission, Boolean value, Set<Context> contexts) {
holderToPEXSubject(holder).transientData().update(data -> data.setPermission(contextsGDToPEX(contexts), permission, pValFromBool(value)));
public PermissionResult setTransientPermission(GDPermissionHolder holder, String permission, Tristate value, Set<Context> contexts) {
return convertResult(holderToPEXSubject(holder).transientData().update(data -> data.setPermission(contextsGDToPEX(contexts), permission, pValFromBool(value.asBoolean())))).join();
}
@Override

View File

@ -82,7 +82,7 @@ public void registerDefaults() {
@Override
public void registerCustomType(Flag type) {
this.registryMap.put(type.getId().toLowerCase(Locale.ENGLISH), type);
GriefDefenderPlugin.getGlobalConfig().getConfig().permissionCategory.refreshFlags();
GriefDefenderPlugin.getInstance().flagConfig.getConfig().defaultFlagCategory.refreshFlags();
GriefDefenderPlugin.getInstance().dataStore.setDefaultGlobalPermissions();
}

View File

@ -31,6 +31,7 @@
import com.griefdefender.GDPlayerData;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.GriefDefender;
import com.griefdefender.api.Tristate;
import com.griefdefender.api.claim.Claim;
import com.griefdefender.api.claim.ClaimContexts;
import com.griefdefender.api.claim.ClaimResult;
@ -45,8 +46,10 @@
import com.griefdefender.claim.GDClaimManager;
import com.griefdefender.claim.GDClaimResult;
import com.griefdefender.configuration.ClaimTemplateStorage;
import com.griefdefender.configuration.FlagConfig;
import com.griefdefender.configuration.GriefDefenderConfig;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.configuration.OptionConfig;
import com.griefdefender.configuration.type.ConfigBase;
import com.griefdefender.configuration.type.GlobalConfig;
import com.griefdefender.event.GDCauseStackManager;
@ -319,8 +322,9 @@ public void setDefaultGlobalPermissions() {
// Admin defaults
Set<Context> contexts = new HashSet<>();
contexts.add(ClaimContexts.ADMIN_DEFAULT_CONTEXT);
final GriefDefenderConfig<GlobalConfig> activeConfig = GriefDefenderPlugin.getGlobalConfig();
final Map<String, Boolean> adminDefaultFlags = activeConfig.getConfig().permissionCategory.getFlagDefaults(ClaimTypes.ADMIN.getName().toLowerCase());
final FlagConfig flagConfig = GriefDefenderPlugin.getInstance().flagConfig;
final OptionConfig optionConfig = GriefDefenderPlugin.getInstance().optionConfig;
final Map<String, Boolean> adminDefaultFlags = flagConfig.getConfig().defaultFlagCategory.getFlagDefaults(ClaimTypes.ADMIN.getName().toLowerCase());
if (adminDefaultFlags != null && !adminDefaultFlags.isEmpty()) {
this.setDefaultFlags(contexts, adminDefaultFlags);
}
@ -328,11 +332,11 @@ public void setDefaultGlobalPermissions() {
// Basic defaults
contexts = new HashSet<>();
contexts.add(ClaimContexts.BASIC_DEFAULT_CONTEXT);
final Map<String, Boolean> basicDefaultFlags = activeConfig.getConfig().permissionCategory.getFlagDefaults(ClaimTypes.BASIC.getName().toLowerCase());
final Map<String, Boolean> basicDefaultFlags = flagConfig.getConfig().defaultFlagCategory.getFlagDefaults(ClaimTypes.BASIC.getName().toLowerCase());
if (basicDefaultFlags != null && !basicDefaultFlags.isEmpty()) {
this.setDefaultFlags(contexts, basicDefaultFlags);
}
final Map<String, String> basicDefaultOptions = activeConfig.getConfig().permissionCategory.getBasicOptionDefaults();
final Map<String, String> basicDefaultOptions = optionConfig.getConfig().defaultOptionCategory.getBasicOptionDefaults();
contexts = new HashSet<>();
contexts.add(ClaimTypes.BASIC.getDefaultContext());
this.setDefaultOptions(ClaimTypes.BASIC.toString(), contexts, new HashMap<>(basicDefaultOptions));
@ -340,8 +344,8 @@ public void setDefaultGlobalPermissions() {
// Town defaults
contexts = new HashSet<>();
contexts.add(ClaimContexts.TOWN_DEFAULT_CONTEXT);
final Map<String, Boolean> townDefaultFlags = activeConfig.getConfig().permissionCategory.getFlagDefaults(ClaimTypes.TOWN.getName().toLowerCase());
final Map<String, String> townDefaultOptions = activeConfig.getConfig().permissionCategory.getTownOptionDefaults();
final Map<String, Boolean> townDefaultFlags = flagConfig.getConfig().defaultFlagCategory.getFlagDefaults(ClaimTypes.TOWN.getName().toLowerCase());
final Map<String, String> townDefaultOptions = optionConfig.getConfig().defaultOptionCategory.getTownOptionDefaults();
if (townDefaultFlags != null && !townDefaultFlags.isEmpty()) {
this.setDefaultFlags(contexts, townDefaultFlags);
}
@ -352,24 +356,25 @@ public void setDefaultGlobalPermissions() {
// Subdivision defaults
contexts = new HashSet<>();
contexts.add(ClaimTypes.SUBDIVISION.getDefaultContext());
final Map<String, String> subdivisionDefaultOptions = activeConfig.getConfig().permissionCategory.getSubdivisionOptionDefaults();
final Map<String, String> subdivisionDefaultOptions = optionConfig.getConfig().defaultOptionCategory.getSubdivisionOptionDefaults();
this.setDefaultOptions(ClaimTypes.SUBDIVISION.toString(), contexts, new HashMap<>(subdivisionDefaultOptions));
// Wilderness defaults
contexts = new HashSet<>();
contexts.add(ClaimContexts.WILDERNESS_DEFAULT_CONTEXT);
final Map<String, Boolean> wildernessDefaultFlags = activeConfig.getConfig().permissionCategory.getFlagDefaults(ClaimTypes.WILDERNESS.getName().toLowerCase());
final Map<String, Boolean> wildernessDefaultFlags = flagConfig.getConfig().defaultFlagCategory.getFlagDefaults(ClaimTypes.WILDERNESS.getName().toLowerCase());
this.setDefaultFlags(contexts, wildernessDefaultFlags);
// Global default options
contexts = new HashSet<>();
contexts.add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
final Map<String, Boolean> globalDefaultFlags = activeConfig.getConfig().permissionCategory.getFlagDefaults("global");
final Map<String, Boolean> globalDefaultFlags = flagConfig.getConfig().defaultFlagCategory.getFlagDefaults("global");
this.setDefaultFlags(contexts, globalDefaultFlags);
final Map<String, String> globalDefaultOptions = activeConfig.getConfig().permissionCategory.getUserOptionDefaults();
final Map<String, String> globalDefaultOptions = optionConfig.getConfig().defaultOptionCategory.getUserOptionDefaults();
this.setDefaultOptions(ClaimContexts.GLOBAL_DEFAULT_CONTEXT.getName(), contexts, new HashMap<>(globalDefaultOptions));
GriefDefenderPlugin.getInstance().getPermissionProvider().setTransientPermission(GriefDefenderPlugin.DEFAULT_HOLDER, "griefdefender", false, new HashSet<>());
activeConfig.save();
GriefDefenderPlugin.getInstance().getPermissionProvider().setTransientPermission(GriefDefenderPlugin.DEFAULT_HOLDER, "griefdefender", Tristate.FALSE, new HashSet<>());
flagConfig.save();
optionConfig.save();
}
private void setDefaultFlags(Set<Context> contexts, Map<String, Boolean> defaultFlags) {
@ -383,13 +388,7 @@ private void setDefaultFlags(Set<Context> contexts, Map<String, Boolean> default
if (flag == null) {
continue;
}
PermissionUtil.getInstance().setTransientPermission(GriefDefenderPlugin.DEFAULT_HOLDER, flag.getPermission(), mapEntry.getValue(), contexts);
if (flag == Flags.ENTITY_DAMAGE) {
// allow monsters to be attacked by default
contexts.add(FlagContexts.TARGET_TYPE_MONSTER);
PermissionUtil.getInstance().setTransientPermission(GriefDefenderPlugin.DEFAULT_HOLDER, flag.getPermission(), true, contexts);
contexts.remove(FlagContexts.TARGET_TYPE_MONSTER);
}
PermissionUtil.getInstance().setTransientPermission(GriefDefenderPlugin.DEFAULT_HOLDER, flag.getPermission(), Tristate.fromBoolean(mapEntry.getValue()), contexts);
}
PermissionUtil.getInstance().refreshCachedData(GriefDefenderPlugin.DEFAULT_HOLDER);
});

View File

@ -226,12 +226,12 @@ public PermissionResult setPermissionValue(GDPermissionHolder holder, String per
return PERMISSION_PROVIDER.setPermissionValue(holder, permission, value, contexts, check, save);
}
public void setTransientOption(GDPermissionHolder holder, String permission, String value, Set<Context> contexts) {
PERMISSION_PROVIDER.setTransientOption(holder, permission, value, contexts);
public PermissionResult setTransientOption(GDPermissionHolder holder, String permission, String value, Set<Context> contexts) {
return PERMISSION_PROVIDER.setTransientOption(holder, permission, value, contexts);
}
public void setTransientPermission(GDPermissionHolder holder, String permission, Boolean value, Set<Context> contexts) {
PERMISSION_PROVIDER.setTransientPermission(holder, permission, value, contexts);
public PermissionResult setTransientPermission(GDPermissionHolder holder, String permission, Tristate value, Set<Context> contexts) {
return PERMISSION_PROVIDER.setTransientPermission(holder, permission, value, contexts);
}
public void refreshCachedData(GDPermissionHolder holder) {

View File

@ -9,9 +9,9 @@
},
{
"name": "com.griefdefender:api:1.0.0",
"sha1": "08d8fa30e0f8bbb43a2100e712bed2a815a8fd87",
"path": "com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200125.004205-14.jar",
"url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200125.004205-14.jar"
"sha1": "0bb7ec5bb796298ed269e1cd642e6dd29704698d",
"path": "com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200505.043120-15.jar",
"url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200505.043120-15.jar"
},
{
"name": "com.griefdefender:reflect-helper:1.0",

View File

@ -9,9 +9,9 @@
},
{
"name": "com.griefdefender:api:1.0.0",
"sha1": "08d8fa30e0f8bbb43a2100e712bed2a815a8fd87",
"path": "com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200125.004205-14.jar",
"url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200125.004205-14.jar"
"sha1": "0bb7ec5bb796298ed269e1cd642e6dd29704698d",
"path": "com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200505.043120-15.jar",
"url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200505.043120-15.jar"
},
{
"name": "com.griefdefender:reflect-helper:1.0",

View File

@ -9,9 +9,9 @@
},
{
"name": "com.griefdefender:api:1.0.0",
"sha1": "08d8fa30e0f8bbb43a2100e712bed2a815a8fd87",
"path": "com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200125.004205-14.jar",
"url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200125.004205-14.jar"
"sha1": "0bb7ec5bb796298ed269e1cd642e6dd29704698d",
"path": "com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200505.043120-15.jar",
"url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200505.043120-15.jar"
},
{
"name": "com.griefdefender:reflect-helper:1.0",

View File

@ -9,9 +9,9 @@
},
{
"name": "com.griefdefender:api:1.0.0",
"sha1": "08d8fa30e0f8bbb43a2100e712bed2a815a8fd87",
"path": "com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200125.004205-14.jar",
"url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200125.004205-14.jar"
"sha1": "0bb7ec5bb796298ed269e1cd642e6dd29704698d",
"path": "com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200505.043120-15.jar",
"url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200505.043120-15.jar"
},
{
"name": "com.griefdefender:reflect-helper:1.0",

View File

@ -9,9 +9,9 @@
},
{
"name": "com.griefdefender:api:1.0.0",
"sha1": "08d8fa30e0f8bbb43a2100e712bed2a815a8fd87",
"path": "com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200125.004205-14.jar",
"url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200125.004205-14.jar"
"sha1": "0bb7ec5bb796298ed269e1cd642e6dd29704698d",
"path": "com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200505.043120-15.jar",
"url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200505.043120-15.jar"
},
{
"name": "com.griefdefender:reflect-helper:1.0",

View File

@ -9,9 +9,9 @@
},
{
"name": "com.griefdefender:api:1.0.0",
"sha1": "08d8fa30e0f8bbb43a2100e712bed2a815a8fd87",
"path": "com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200125.004205-14.jar",
"url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200125.004205-14.jar"
"sha1": "0bb7ec5bb796298ed269e1cd642e6dd29704698d",
"path": "com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200505.043120-15.jar",
"url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200505.043120-15.jar"
},
{
"name": "com.griefdefender:reflect-helper:1.0",

View File

@ -9,9 +9,9 @@
},
{
"name": "com.griefdefender:api:1.0.0",
"sha1": "08d8fa30e0f8bbb43a2100e712bed2a815a8fd87",
"path": "com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200125.004205-14.jar",
"url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200125.004205-14.jar"
"sha1": "0bb7ec5bb796298ed269e1cd642e6dd29704698d",
"path": "com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200505.043120-15.jar",
"url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200505.043120-15.jar"
},
{
"name": "com.griefdefender:reflect-helper:1.0",

View File

@ -9,9 +9,9 @@
},
{
"name": "com.griefdefender:api:1.0.0",
"sha1": "08d8fa30e0f8bbb43a2100e712bed2a815a8fd87",
"path": "com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200125.004205-14.jar",
"url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200125.004205-14.jar"
"sha1": "0bb7ec5bb796298ed269e1cd642e6dd29704698d",
"path": "com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200505.043120-15.jar",
"url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200505.043120-15.jar"
},
{
"name": "com.griefdefender:reflect-helper:1.0",

View File

@ -216,6 +216,7 @@ GriefDefender {
create-subdivision-fail="&cAn dieser Ecke existiert kein Grundstück. Klicke auf einen Block in einem Grundstück, um das Teilgrundstück zu erstellen."
create-subdivision-only="&cFehler beim Erstellen. Nur Teilgrundstücke können in einem Block erstellt werden."
create-success="{type}&a Grundstück erstellt! Benutze &f/trust&a um es mit Freunden zu teilen."
debug-click-to-expand="Zum Erweitern klicken!"
debug-error-upload="&cFehler beim Hochladen von {content}&c."
debug-no-records="&cKeine Debug Aufzeichnung zum hochladen!"
debug-paste-success="&aErfolgreich hochgeladen!"
@ -276,45 +277,47 @@ GriefDefender {
flag-description-collide-entity="Kontrolliert, ob eine Entität mit einer anderen kollidieren kann.\n&dBeispiel&f : Um das Kollidieren mit Rahmen zu verhindern, nutze\n&a/cf collide-entity minecraft:item_frame false\n&bNote&f : minecraft steht für die ModID und item_frame für die BlockID.\nGibst du keine ModID an, wird standardmäßig minecraft benutzt."
flag-description-command-execute="Kontrolliert, ob ein Befehl ausgeführt werden kann.\n&dBeispiel&f : Um den Pixelmon Befehl '/shop select' zu blockieren, nutze\n&a/cf command-execute pixelmon:shop[select] false\n&bNote&f : &o&6pixelmon&f steht für die ModID &o&6shop&f für den Befehl und &o&6select&f für das Argument.\nGibst du keine ModID an, wird standardmäßig minecraft benutzt."
flag-description-command-execute-pvp="Kontrolliert, ob ein Befehl während PvP benutzt werden kann.\n&dBeispiel&f : Um den Pixelmon Befehl '/shop select' zu blockieren, nutze\n&a/cf command-execute pixelmon:shop[select] false\n&bBeispiel&f : &o&6pixelmon&f steht für die ModID &o&6shop&f für den Befehl und &o&6select&f für das Argument.\nGibst du keine ModID an, wird standardmäßig minecraft benutzt."
flag-description-custom-block-break="Kontrolliert, ob ein Block kaputtgehen kann."
flag-description-custom-block-grow="Kontrolliert, ob ein Block wachsen kann."
flag-description-custom-block-place="Kontrolliert, ob ein Block platziert werden kann."
flag-description-custom-block-spread="Kontrolliert, ob ein Block sich ausbreiten kann."
flag-description-custom-build="Kontrolliert, ob Aktionen gegen Blöcke möglich sind, wie Abbauen, Platzieren und Interagieren."
flag-description-custom-chest-access="Kontrolliert, ob Spieler die Inventare von Kisten nutzen können."
flag-description-custom-build="Kontrolliert, ob Aktionen mit Blöcken möglich sind, wie Abbauen, Platzieren und Interagieren."
flag-description-custom-chest-access="Kontrolliert, ob Spieler auf Kisten zugreifen können."
flag-description-custom-chorus-fruit-teleport="Kontrolliert, ob Chorus Früchte zum Teleportieren genutzt werden können."
flag-description-custom-crop-growth="Kontrolliert, ob Pflanzen wachsen können."
flag-description-custom-creeper-block-explosion="Kontrolliert, ob Creeper Blöcke zerstören können."
flag-description-custom-creeper-entity-explosion="Kontrolliert, ob Creeper Schaden verursachen können."
flag-description-custom-crop-growth="Kontrolliert, ob Weizensamen wachsen können."
flag-description-custom-damage-animals="Kontrolliert, ob Tiere geschädigt werden können."
flag-description-custom-enderman-grief="Kontrolliert, ob Enderman Blöcke stehlen können."
flag-description-custom-enderpearl="Kontrolliert, ob Enderperlen genutzt werden können."
flag-description-custom-enter-player="Kontrolliert, ob ein Spieler das Grundstück betreten kann."
flag-description-custom-exit-player="Kontrolliert, ob ein Spieler das Grundstück verlassen kann."
flag-description-custom-exp-drop="Kontrolliert, ob EXP droppt."
flag-description-custom-explosion-block="Kontrolliert, ob Explosionen Blöcke beeinflussen."
flag-description-custom-explosion-creeper="Kontrolliert, ob Creeper explodieren können."
flag-description-custom-explosion-entity="Kontrolliert, ob Explosionen Entitäten beeinflussen."
flag-description-custom-explosion-tnt="Kontrolliert, ob TNT explodieren kann."
flag-description-custom-fall-damage="Kontrolliert, ob man Fallschaden nimmt."
flag-description-custom-fall-player-damage="Kontrolliert, ob man Fallschaden nimmt."
flag-description-custom-fire-damage="Kontrolliert, ob Feuer Schaden anrichtet."
flag-description-custom-fire-spread="Kontrolliert, ob Feuer sich ausbreiten kann."
flag-description-custom-grass-growth="Kontrolliert, ob Gras wachsen kann."
flag-description-custom-ice-form="Kontrolliert, ob sich Eis bilden kann."
flag-description-custom-ice-melt="Kontrolliert, ob Eis schmelzen kann."
flag-description-custom-interact-block="Kontrolliert, ob Spieler mit Blöcken interagieren können.\n&bBeispiel&f: Hat keine Wirkung auf Inventarblöcke, bspw. Kisten."
flag-description-custom-interact-entity="Kontrolliert, ob Spieler mit Entitäten interagieren können.\n&bBeispiel&f: Hat keinen Einfluss auf Entitäten mit Inventarplätzen, bspw. Pferde."
flag-description-custom-interact-inventory="Kontrolliert, ob ein Spieler mit Inventaren interagieren kann."
flag-description-custom-invincible="Kontrolliert, ob Spieler überhaupt Schaden nehmen."
flag-description-custom-item-drop="Kontrolliert, ob Spieler Gegenstände fallen lassen können."
flag-description-custom-item-pickup="Kontrolliert, ob Spieler Gegenstände aufheben können."
flag-description-custom-lava-flow="Kontrolliert, ob Lava fließen kann."
flag-description-custom-leaf-decay="Kontrolliert, ob Blätter verschwinden."
flag-description-custom-lighter="Kontrolliert, ob Feuerzeuge benutzt werden können."
flag-description-custom-lightning="Kontrolliert, ob Blitze Schaden anrichten."
flag-description-custom-monster-damage="Kontrolliert, ob Monster Schaden verursachen."
flag-description-custom-monster-animal-damage="Kontrolliert, ob Monster Schaden an Tieren verursachen."
flag-description-custom-monster-player-damage="Kontrolliert, ob Monster Schaden an Spielern verursachen."
flag-description-custom-monster-spawn="Kontrolliert, ob Monster - Zombies, Creeper, usw. - spawnen."
flag-description-custom-mushroom-growth="Kontrolliert, ob Pilze wachsen."
flag-description-custom-mycelium-spread="Kontrolliert, ob Myzelium sich verbreitet."
flag-description-custom-pistons="Kontrolliert, ob Pistions benutzbar sind."
flag-description-custom-portal-use="Kontrolliert, ob Portale nutzbar sind."
flag-description-custom-piston-use="Kontrolliert, ob Pistions benutzbar sind."
flag-description-custom-player-block-break="Kontrolliert, ob Spieler Blöcke abbauen können."
flag-description-custom-player-block-interact="Kontrolliert, ob Spieler mit Blöcken interagieren können.\n&bBeispiel&f: Hat keine Wirkung auf Inventarblöcke, bspw. Kisten."
flag-description-custom-player-block-place="Kontrolliert, ob ein Block platziert werden kann."
flag-description-custom-player-damage="Kontrolliert, ob Spieler überhaupt Schaden nehmen können."
flag-description-custom-player-enderpearl-interact="Kontrolliert, ob Enderperlen genutzt werden können."
flag-description-custom-player-enter="Kontrolliert, ob ein Spieler das Grundstück betreten kann."
flag-description-custom-player-entity-interact="Kontrolliert, ob Spieler mit Entitäten interagieren können.\n&bBeispiel&f: Hat keinen Einfluss auf Entitäten mit Inventarplätzen, bspw. Pferde."
flag-description-custom-player-exit="Kontrolliert, ob ein Spieler das Grundstück verlassen kann."
flag-description-custom-player-inventory-interact="Kontrolliert, ob ein Spieler mit Inventaren interagieren kann."
flag-description-custom-player-item-drop="Kontrolliert, ob Spieler Gegenstände fallen lassen können."
flag-description-custom-player-item-pickup="Kontrolliert, ob Spieler Gegenstände aufheben können."
flag-description-custom-player-portal-use="Kontrolliert, ob Spieler Portale nutzen können."
flag-description-custom-player-teleport-from="Kontrolliert, ob sich Spieler aus dem Grundstück rausteleportieren können."
flag-description-custom-player-teleport-to="Kontrolliert, ob sich Spieler zu diesem Grundstück teleportieren können."
flag-description-custom-pvp="Kontrolliert, ob PVP erlaubt ist."
flag-description-custom-ride="Kontrolliert, ob das Aufsitzen und Fortbewegen mit Tieren und Fortbewegungsmitteln möglich ist."
flag-description-custom-sleep="Kontrolliert, ob Spieler in Betten schlafen können."
@ -322,18 +325,17 @@ GriefDefender {
flag-description-custom-snow-melt="Kontrolliert, ob Schnee schmilzt."
flag-description-custom-snowman-trail="Kontrolliert, ob Schneemänner eine Schneespur hinterlassen."
flag-description-custom-soil-dry="Kontrolliert, ob Erde trocknen kann."
flag-description-custom-spawn-ambient="Kontrolliert, ob Umgebungsmonster - etwa Fledermäuse - spawnen."
flag-description-custom-spawn-animal="Kontrolliert, ob Tiere - etwa Kühe und Schafe - spawnen."
flag-description-custom-spawn-ambient="Kontrolliert, ob Umgebungsmonster - bspw. Fledermäuse - spawnen."
flag-description-custom-spawn-animal="Kontrolliert, ob Tiere - bspw. Kühe und Schafe - spawnen."
flag-description-custom-spawn-aquatic="Kontrolliert, ob Lebewesen im Wasser - etwa Tintenfische - spawnen."
flag-description-custom-spawn-monster="Kontrolliert, ob Monster - Zombies, Creeper, usw. - spawnen."
flag-description-custom-teleport-from="Kontrolliert, ob sich Spieler aus dem Grundstück rausteleportieren können."
flag-description-custom-teleport-to="Kontrolliert, ob sich Spieler zu diesem Grundstück teleportieren können."
flag-description-custom-tnt-block-explosion="Kontrolliert, ob TNT Blöcke zerstören kann."
flag-description-custom-tnt-entity-explosion="Kontrolliert, ob TNT Schaden anrichtet."
flag-description-custom-use="Kontrolliert, ob Spieler nicht-Inventarblöcke auf dem Grundstück benutzen können."
flag-description-custom-vehicle-destroy="Kontrolliert, ob Fahrzeuge zerstört werden können."
flag-description-custom-vehicle-place="Kontrolliert, ob Fahrzeuge platziert werden können."
flag-description-custom-vine-growth="Kontrolliert, ob Pflanzen wie Lianen wachsen können."
flag-description-custom-vehicle-use="Kontrolliert, ob Fahrzeuge platziert, zerstört und benutzt werden können."
flag-description-custom-vine-growth="Kontrolliert, ob Pflanzen bspw. Lianen wachsen können."
flag-description-custom-water-flow="Kontrolliert, ob Wasser fließen kann."
flag-description-custom-wither-damage="Kontrolliert, ob Wither Schaden anrichten können."
flag-description-custom-wither-block-break="Kontrolliert, ob Wither Blöcke zerstören können."
flag-description-custom-wither-entity-damage="Kontrolliert, ob Wither Schaden anrichten können."
flag-description-enter-claim="Kontrolliert, ob Entitäten das Grundstück betreten können.\n&dBeispiel&f : Damit Spieler das Grundstück nicht mehr betreten können, nutze:\n&a/cf enter-claim player false\n&Hinweis&f : Um Gruppen einzustellen, nutze den /cfg Befehl."
flag-description-entity-chunk-spawn="Kontrolliert, ob gespeicherte Entitäten beim Laden des Chunks spawnen.\n&dBeispiel&f : Damit Pferde nicht beim Laden des Chunks spawnen:\n&a/cf entity-chunk-spawn minecraft:horse false\n&bHinweis&f : Dies entfernt &cALLE&f gespeicherten Entitäten. Ist der Chunk bereits geladen, ist es erst beim Neuladen effektiv. Mit Vorsicht benutzen."
flag-description-entity-damage="Kontrolliert, ob Enitäten Schaden erledigen können.\n&dBeispiel&f : Damit Tiere keinen Schaden erleiden können, nutze:\n&a/cf entity-damage minecraft:animal false."
@ -394,6 +396,7 @@ GriefDefender {
label-containers=Container
label-context=Kontext
label-created=Erstellt
label=Standard
label-displaying=Anzeigend
label-expired=Abgelaufen
label-farewell=Verlassen
@ -615,18 +618,18 @@ GriefDefender {
teleport-move-cancel="&cTeleport abgebrochen! Du kannst dich nicht bewegen während des Teleports."
teleport-no-safe-location="&cKeine sichere Position gefunden!\n&aNutze '&f/claiminfo&a' um einen sicheren Spawnpunkt auf dem Grundstück zu setzen."
teleport-success="&aDu wurdest zu {name}&a teleportiert."
title-accessor=ZUGRIFFSBERECHTIGT
title-advanced=ADVANCED
title-accessor=BENUTZER
title-advanced=ERWEITERT
title-all=ALLE
title-builder=BAUBERECHTIGT
title-claim=GRUNDSTÜCK
title-container=CONTAINER
title-container=BEHÄLTNISSE
title-default=STANDARD
title-inherit=VERERBET
title-inherit=VERERBUNG
title-manager=MANAGER
title-override=ÜBERGEORDNET
title-own=EIGENE
title-preset=PRESET
title-preset=VORLAGE
tool-not-equipped="&cDu hast {tool}&c nicht ausgerüstet."
town-chat-disabled="&aStadt Chat ausgestellt."
town-chat-enabled="&aStadt Chat aktiviert."
@ -648,13 +651,13 @@ GriefDefender {
trust-plugin-cancel="&cKonnte {target}&c keine Erlaubnis erteilen. Ein Plugin hat dies verhindert."
trust-self="&cDu kannst dir selbst Rechte für Grundstücke erteilen."
tutorial-claim-basic="&eTutorial Video zum Thema Grundstücke: &ahttp://bit.ly/mcgpuser"
ui-click-add="Click here to add"
ui-click-add-target="Click here to add &6{target}&f"
ui-click-add="Klicke, zum Hinzuzufügen"
ui-click-add-target="Klicke hier, um &6{target}&f hinzuzufügen"
ui-click-confirm="Bestätigen"
ui-click-filter-type="Filtern nach: {type}&f"
ui-click-remove="Klicke hier, um den Eintrag zu entfernen"
ui-click-return-command="&bReturn to &6{command}"
ui-click-view="Click here to view {target}"
ui-click-return-command="&bZurück zu &6{command}"
ui-click-view="Zum Anzeigen von {target} hier klicken"
untrust-individual-all-claims="&6{target}&a Erlaubnisse für deine Grundstücke zurückgenommen. Um Berechtigungen einzelner Grundstücke zu entfernen, stelle dich drauf und nutze: &f/untrust&a."
untrust-individual-single-claim="&6{target}&a Erlaubnis für dieses Grundstück entfernt. Um Berechtigungen für alle Grundstücke zu entfernen, nutze: &f/untrustall&a."
untrust-no-claims="&cDu hast keine Grundstücke mit Rechten für andere Spieler."

View File

@ -216,6 +216,7 @@ GriefDefender {
create-subdivision-fail="&cNo claim exists at selected corner. Please click a valid block location within parent claim in order to create your subdivision."
create-subdivision-only="&cUnable to create claim. Only subdivisions can be created at a single block location."
create-success="{type}&a created! Use &f/trust&a to share it with friends."
debug-click-to-expand="Click to expand!"
debug-error-upload="&cError uploading content {content}&c."
debug-no-records="&cNo debug records to paste!"
debug-paste-success="&aPaste success!"
@ -276,45 +277,47 @@ GriefDefender {
flag-description-collide-entity="Controls whether an entity can collide with an entity.\n&dExample&f : To prevent entity collisions with item frames, enter\n&a/cf collide-entity minecraft:item_frame false\n&bNote&f : minecraft represents the modid and item_frame represents the entity id.\nSpecifying no modid will always default to minecraft."
flag-description-command-execute="Controls whether a command can be executed.\n&dExample&f : To prevent pixelmon's command '/shop select' from being run, enter\n&a/cf command-execute pixelmon:shop[select] false\n&bNote&f : &o&6pixelmon&f represents the modid and &o&6shop&f represents the base command, and &o&6select&f represents the argument.\nSpecifying no modid will always default to minecraft."
flag-description-command-execute-pvp="Controls whether a command can be executed while engaged in PvP.\n&dExample&f : To prevent pixelmon's command '/shop select' from being run, enter\n&a/cf command-execute pixelmon:shop[select] false\n&bNote&f : &o&6pixelmon&f represents the modid and &o&6shop&f represents the base command, and &o&6select&f represents the argument.\nSpecifying no modid will always default to minecraft."
flag-description-custom-block-break="Controls whether blocks can be broken."
flag-description-custom-block-grow="Controls whether blocks can grow."
flag-description-custom-block-place="Controls whether blocks can be placed."
flag-description-custom-block-spread="Controls whether blocks can spread."
flag-description-custom-build="Controls whether actions are allowed against blocks and entities such as mining, placement, and interactions."
flag-description-custom-chest-access="Controls whether a player can access chest inventories."
flag-description-custom-chorus-fruit-teleport="Controls whether a player can use chorus fruit to teleport."
flag-description-custom-creeper-block-explosion="Controls whether a creeper can explode blocks."
flag-description-custom-creeper-entity-explosion="Controls whether a creeper can explode entities."
flag-description-custom-crop-growth="Controls whether crops can grow."
flag-description-custom-damage-animals="Controls whether animals can be damaged."
flag-description-custom-enderman-grief="Controls whether enderman can grief."
flag-description-custom-enderpearl="Controls whether enderpearl can be used."
flag-description-custom-enter-player="Controls whether a player can enter this claim."
flag-description-custom-exit-player="Controls whether a player can exit this claim."
flag-description-custom-exp-drop="Controls whether experience orbs can drop."
flag-description-custom-explosion-block="Controls whether explosions affect blocks."
flag-description-custom-explosion-creeper="Controls whether a creeper can explode."
flag-description-custom-explosion-entity="Controls whether explosions affect entities."
flag-description-custom-explosion-tnt="Controls whether tnt can explode."
flag-description-custom-fall-damage="Controls whether players can take fall damage."
flag-description-custom-fall-player-damage="Controls whether players can take fall damage."
flag-description-custom-fire-damage="Controls whether fire can cause damage."
flag-description-custom-fire-spread="Controls whether fire can spread."
flag-description-custom-grass-growth="Controls whether grass can grow."
flag-description-custom-ice-form="Controls whether ice can form."
flag-description-custom-ice-melt="Controls whether ice can melt."
flag-description-custom-interact-block="Controls whether players can interact with blocks.\n&bNote&f: This does not include inventory blocks such as chests."
flag-description-custom-interact-entity="Controls whether players can interact with entities.\n&bNote&f: This does not include chest access with entities such as horses."
flag-description-custom-interact-inventory="Controls whether players can interact with inventory."
flag-description-custom-invincible="Controls whether players are invincible against damage."
flag-description-custom-item-drop="Controls whether players can drop items."
flag-description-custom-item-pickup="Controls whether players can pickup items."
flag-description-custom-lava-flow="Controls whether lava can flow."
flag-description-custom-leaf-decay="Controls whether leaves can decay."
flag-description-custom-lighter="Controls whether a player can use flint and steel."
flag-description-custom-lightning="Controls whether lightning can cause harm."
flag-description-custom-monster-damage="Controls whether monsters can deal damage."
flag-description-custom-monster-animal-damage="Controls whether monsters can deal damage to animals."
flag-description-custom-monster-player-damage="Controls whether monsters can deal damage to players."
flag-description-custom-monster-spawn="Controls whether monsters, such as creepers and skeletons, can spawn."
flag-description-custom-mushroom-growth="Controls whether mushrooms can grow."
flag-description-custom-mycelium-spread="Controls whether mycelium can spread."
flag-description-custom-pistons="Controls whether pistons can be used."
flag-description-custom-portal-use="Controls whether portals can be used."
flag-description-custom-piston-use="Controls whether pistons can be used."
flag-description-custom-player-block-break="Controls whether players can break blocks."
flag-description-custom-player-block-interact="Controls whether players can interact with blocks.\n&bNote&f: This does not include inventory blocks such as chests."
flag-description-custom-player-block-place="Controls whether players can place blocks."
flag-description-custom-player-damage="Controls whether players can be damaged."
flag-description-custom-player-enderpearl-interact="Controls whether players can use an enderpearl."
flag-description-custom-player-enter="Controls whether a player can enter this claim."
flag-description-custom-player-entity-interact="Controls whether players can interact with entities.\n&bNote&f: This does not include chest access with entities such as horses."
flag-description-custom-player-exit="Controls whether a player can exit this claim."
flag-description-custom-player-inventory-interact="Controls whether players can interact with inventory."
flag-description-custom-player-item-drop="Controls whether players can drop items."
flag-description-custom-player-item-pickup="Controls whether players can pickup items."
flag-description-custom-player-portal-use="Controls whether players can use portals."
flag-description-custom-player-teleport-from="Controls whether players can teleport from this claim."
flag-description-custom-player-teleport-to="Controls whether players can teleport to this claim."
flag-description-custom-pvp="Controls whether PvP combat is allowed."
flag-description-custom-ride="Controls whether vehicles(including animals) can be mounted."
flag-description-custom-sleep="Controls whether players can sleep in beds."
@ -325,15 +328,14 @@ GriefDefender {
flag-description-custom-spawn-ambient="Controls whether ambients, such as bats, can spawn."
flag-description-custom-spawn-animal="Controls whether animals, such as cows and pigs, can spawn."
flag-description-custom-spawn-aquatic="Controls whether aquatics, such as squids and guardians, can spawn."
flag-description-custom-spawn-monster="Controls whether monsters, such as creepers and skeletons, can spawn."
flag-description-custom-teleport-from="Controls whether players can teleport from this claim."
flag-description-custom-teleport-to="Controls whether players can teleport to this claim."
flag-description-custom-tnt-block-explosion="Controls whether tnt can explode blocks."
flag-description-custom-tnt-entity-explosion="Controls whether tnt can explode entities."
flag-description-custom-use="Controls whether players can use non-inventory blocks in this claim."
flag-description-custom-vehicle-destroy="Controls whether vehicles can be destroyed."
flag-description-custom-vehicle-place="Controls whether vehicles(boats, minecarts, etc.) can be placed."
flag-description-custom-vehicle-use="Controls whether vehicles(boats, minecarts, etc.) can be placed, ridden and broken."
flag-description-custom-vine-growth="Controls whether vines(and kelp) can grow."
flag-description-custom-water-flow="Controls whether water can flow."
flag-description-custom-wither-damage="Controls whether withers can do damage."
flag-description-custom-wither-block-break="Controls whether withers can break blocks."
flag-description-custom-wither-entity-damage="Controls whether withers can damage entities."
flag-description-enter-claim="Controls whether an entity can enter a claim.\n&dExample&f : To prevent players from entering a claim, enter\n&a/cf enter-claim player false\n&bNote&f : If you want to use this for groups, use the /cfg command."
flag-description-entity-chunk-spawn="Controls whether a saved entity can be spawned during chunk load.\n&dExample&f : To prevent horses from spawning during chunk load, enter\n&a/cf entity-chunk-spawn minecraft:horse false\n&bNote&f : This will remove &cALL&f saved entities when a chunk loads. If a chunk is already loaded, it will take affect after it reloads. Use with extreme caution."
flag-description-entity-damage="Controls whether an entity can be damaged.\n&dExample&f : To prevent animals from being damaged, enter\n&a/cf entity-damage minecraft:animal false."
@ -394,6 +396,7 @@ GriefDefender {
label-containers=Containers
label-context=Context
label-created=Created
label-default=Default
label-displaying=Displaying
label-expired=Expired
label-farewell=Farewell

View File

@ -216,7 +216,8 @@ GriefDefender {
create-subdivision-fail="&4&l[ERROR] &cNo existe un Claim en la esquina seleccionada. Porfavor haz click en un bloque en una localización válida y sin ningún &lParent Claim&c activo para crear tu &c&lSubdivisión&c."
create-subdivision-only="&4&l[ERROR] &c&lImposible crear un Claim. &cSolo las &l&nSubdivisiones&c pueden ser creadas en un mismo bloque.\n&3&l---------------------------------------------"
create-success="&2&l[TERRENO {type} &2&lRECLAMADO] &a&lAhora este terreno te pertenece y nadie podrá grifearte la zona reclamada. &aPara permitir que tus amigos entren a tu terreno usa los siguientes comandos:\n\n&6&l'/trust Nombre &naccesor'\n&6&oDa acceso a tus Claims y utilizar tu cama.\n\n&6&l'/trust Nombre &ncontainer'\n&6 Da acceso a utilizar tus cofres, cultivos, animales, botones, palancas.\n\n&6&l'/trust Nombre &nbuilder'\n&6Da acceso a construir, colocar y destruir bloques.\n\n&6&l'/trust Nombre &nmanager'\n&6Da acceso a todo lo anterior incluyendo las opciones de Claim.\n\n&4&l[NOTA]&c Si quieres eliminar un jugador de la lista de confianza usa &6&l'/trust player Nombre &nnone'&c."
debug-error-upload="&4&l[ERROR] &c&lAl cargar el contenido ➜ &6&o'{content}'&c."
debug-click-to-expand="&f&l[MODO-DEBUG] ➜ &a&lClick para expandir!"
debug-error-upload="&4&l[ERROR] &c&lAl cargar el contenido ➜ &6&o'{content}'&c."
debug-no-records="&4&l[ERROR] ➜ &f&l[MODO-DEBUG] &cNO se ha encontrado ninguna grabación para pegar el &nLog&c."
debug-paste-success="&f&l[MODO-DEBUG] ➜ &2&l¡LOG copiado con éxito!"
debug-record-end="&3&l[&f&lMODO-DEBUG&3&l] &f&l➜ &6GRABACION &c&lOFF●"
@ -276,64 +277,65 @@ GriefDefender {
flag-description-collide-entity="Controla si una entidad puede COLISIONAR con otra entidad.\n&2&lEJEMPLO: &aPara prevenir colisionar con item frames, usa...\n&6&o'/cf collide-entity minecraft:item_frame &c&ofalse&6&o'\n&4&l[NOTA] &6&o'minecraft'&f&l=&d&lModID&f&l / &6&o'item_frame'&f&l=&d&lEntityID.\n&aSin especificar el &d&lModID &asiempre será por default &6&o'minecraft'&a."
flag-description-command-execute="Controlar si un comando puede ser EJECUTADO.\n&2&lEJEMPLO: &aPara prevenir que los jugadores usen el comando &6&o'/sethome'&a, usa...\n&6&o'/cf command-execute nucleus:sethome &c&ofalse&6&o'\n&4&l[NOTA] &6&o'nucleus'&f&l=&d&lPluginID&f&l / &6&o'sethome'&f&l=&d&lBaseCommand\n&aSin especificar el &d&lPluginID &asiempre será por default &6&o'minecraft'&a."
flag-description-command-execute-pvp="Controla si un comando puede ser EJECUTADO.\n&2&lEJEMPLO: &aPara prevenir que los jugadores usen el comando &6&o'/home'&a durante una pelea, usa...\n&6&o'/cf command-execute nucleus:home &c&ofalse&6&o'\n&4&l[NOTA] &6&o'nucleus'&f&l=&d&lPluginID&f&l / &6&o'home'&f&l=&d&lBaseCommand\n&aSin especificar el &d&lPluginID &asiempre será por default &6&o'minecraft'&a."
flag-description-custom-block-break="Controla si un bloque puede ser destruido."
flag-description-custom-block-grow="Controla si un bloque puede crecer."
flag-description-custom-block-place="Controla si un bloque puede ser colocado."
flag-description-custom-block-spread="Controla si un bloque puede propagarse."
flag-description-custom-build="Controla si cualquier acción esta permitida contra bloques y entidades como por ejemplo, minar, colocar, interaccionar."
flag-description-custom-chest-access="Controla si cualquier jugador puede acceder a los Cofres."
flag-description-custom-build="Controla si cualquier acción está permitida contra bloques y entidades como por ejemplo, minar, colocar, interactuar."
flag-description-custom-chest-access="Controla si cualquier jugador puede acceder a los cofres."
flag-description-custom-chorus-fruit-teleport="Controla si cualquier jugador puede usar una ChorusFruit para teletransportarse."
flag-description-custom-creeper-block-explosion="Controla si un Creeper puede romper bloques al explotar."
flag-description-custom-creeper-entity-explosion="Controla si un Creeper puede dañar entidades al explotar."
flag-description-custom-crop-growth="Controla si cualquier cultivo puede crecer."
flag-description-custom-damage-animals="Controla si los animales puedes ser dañados."
flag-description-custom-enderman-grief="Controla si cualquier Enderman puede grifear bloques."
flag-description-custom-enderpearl="Controla si la EnderPearls puede ser usada."
flag-description-custom-enter-player="Controla si un jugador puede entrar a este terreno."
flag-description-custom-exit-player="Controla si un jugador puede salir de este terreno."
flag-description-custom-exp-drop="Controla si los orbes de experiencia pueden ser dropeados."
flag-description-custom-explosion-block="Controla si la explosion puede afectar a los bloques."
flag-description-custom-explosion-creeper="Controla si un Creeper puede explotar."
flag-description-custom-explosion-entity="Controla si las explosiones afectan a entidades."
flag-description-custom-explosion-tnt="Controla si la TNT puede explotar."
flag-description-custom-fall-damage="Controla si los jugadores pueden recibir daño por caida."
flag-description-custom-explosion-block="Controla si las explosiones pueden dañar bloques."
flag-description-custom-explosion-entity="Controla si las explosiones pueden dañar entidades."
flag-description-custom-fall-player-damage="Controla si los jugadores pueden recibir daño por caida."
flag-description-custom-fire-damage="Controla si el fuego puede causar daños."
flag-description-custom-fire-spread="Controla si el fuego puede propagarse."
flag-description-custom-grass-growth="Controla si la Hierba puede crecer."
flag-description-custom-ice-form="Controla si el Hielo puede formarse."
flag-description-custom-ice-melt="Controla si el Hielo puede fundirse."
flag-description-custom-interact-block="Controla si un jugador puede interactuar con bloques.\n&4&l[NOTA] &cEsto NO incluye los bloques de inventairo como los Cofres."
flag-description-custom-interact-entity="Controla si un jugador puede interactuar con las entidades.\n&4&l[NOTA] &c Esto NO incluye el acceso a un Cofre en las entidades como los Caballos."
flag-description-custom-interact-inventory="Controla si un jugador puede interactuar con su inventario."
flag-description-custom-invincible="Controla si los jugadores son invenciables contra cualquier daño."
flag-description-custom-item-drop="Controla si un jugador puede dropear objetos."
flag-description-custom-item-pickup="Controla si un jugador puede recoger objetos."
flag-description-custom-lava-flow="Controla si la Lava puede fluir."
flag-description-custom-leaf-decay="Controla si las Hojas se caen solas cuando talas un árbol."
flag-description-custom-lighter="Controla si un jugador puede usar un Yesca y Pedernal (Flint and Steel)."
flag-description-custom-grass-growth="Controla si la hierba puede crecer."
flag-description-custom-ice-form="Controla si el hielo puede formarse."
flag-description-custom-ice-melt="Controla si el hielo puede derretirse."
flag-description-custom-lava-flow="Controla si la lava puede fluir."
flag-description-custom-leaf-decay="Controla si las hojas se caen solas cuando talas un árbol."
flag-description-custom-lighter="Controla si un jugador puede usar un mechero (Flint and Steel)."
flag-description-custom-lightning="Controla si un rayo puede hacer daño."
flag-description-custom-monster-damage="Controla si los monstruos puede hacer daño."
flag-description-custom-mushroom-growth="Controla si los Champiñones pueden crecer."
flag-description-custom-mycelium-spread="Controla si el Micelio puede esparcirse."
flag-description-custom-pistons="Controla si los Pistones pueden ser usados."
flag-description-custom-portal-use="Controla si los Portales pueden ser usados."
flag-description-custom-monster-animal-damage="Controla si los monstruos pueden dañar animales."
flag-description-custom-monster-player-damage="Controla si los monstruos puede dañar jugadores."
flag-description-custom-monster-spawn="Controla si los monstruos, como creepers y esqueletos, pueden aparecer."
flag-description-custom-mushroom-growth="Controla si los champiñones pueden crecer."
flag-description-custom-mycelium-spread="Controla si el micelio puede esparcirse."
flag-description-custom-piston-use="Controla si los pistones pueden ser usados."
flag-description-custom-player-block-break="Controla si se pueden destruir bloques."
flag-description-custom-player-block-interact="Controla si un jugador puede interactuar con bloques.\n&4&l[NOTA] &cEsto NO incluye los bloques de inventario como los cofres."
flag-description-custom-player-block-place="Controla si se pueden colocar bloques."
flag-description-custom-player-damage="Controla si los jugadores son inmunes ante cualquier daño."
flag-description-custom-player-enderpearl-interact="Controla si las perlas de Ender pueden ser usadas."
flag-description-custom-player-enter="Controla si un jugador puede entrar a este terreno."
flag-description-custom-player-entity-interact="Controla si un jugador puede interactuar con las entidades.\n&4&l[NOTA] &cEsto NO incluye el acceso a los cofres en entidades como los Caballos."
flag-description-custom-player-exit="Controla si un jugador puede salir de este terreno."
flag-description-custom-player-inventory-interact="Controla si un jugador puede interactuar con su inventario."
flag-description-custom-player-item-drop="Controla si un jugador puede tirar objetos al suelo."
flag-description-custom-player-item-pickup="Controla si un jugador puede recoger objetos del suelo."
flag-description-custom-player-portal-use="Controla si los portales pueden ser usados."
flag-description-custom-player-teleport-from="Controla si los jugadores puede ser teletransportados desde este terreno."
flag-description-custom-player-teleport-to="Controla si los jugadores pueden teletransportarse a este terreno."
flag-description-custom-pvp="Controla si el combate PvP está permitido."
flag-description-custom-ride="Controla si los vehiculos(incluyendo animales) pueden ser montados."
flag-description-custom-sleep="Controla si un jugador puede dormir en Camas."
flag-description-custom-sleep="Controla si un jugador puede dormir en camas."
flag-description-custom-snow-fall="Controla si puede nevar."
flag-description-custom-snow-melt="Controla si la nieve puede derretirse."
flag-description-custom-snowman-trail="Controla si un Muñeco de Nieve puede dejar un rastro de nieve cuando se mueve."
flag-description-custom-snowman-trail="Controla si un muñeco de nieve puede dejar un rastro de nieve cuando se mueve."
flag-description-custom-soil-dry="Controla si el suelo puede secarse."
flag-description-custom-spawn-ambient="Controla si EntitiesAmbients, como los murciélagos, pueden Spawnear."
flag-description-custom-spawn-animal="Controla si EntitiesAnimals, como las vacas y cerdos, pueden Spawnear."
flag-description-custom-spawn-aquatic="Controla si EntitiesAquatics, como los calamares y guardianes, pueden Spawnear."
flag-description-custom-spawn-monster="Controla si EntitiesMonsters, como creepers y esqueletos, pueden Spawnear."
flag-description-custom-teleport-from="Controla si los jugadores puede ser teletransportados desde este terreno."
flag-description-custom-teleport-to="Controla si los jugadores pueden teletransportarse a este terreno."
flag-description-custom-spawn-ambient="Controla si las entidades ambientales, como los murciélagos, pueden aparecer."
flag-description-custom-spawn-animal="Controla si los animales, como las vacas y cerdos, pueden aparecer."
flag-description-custom-spawn-aquatic="Controla si las entidades acuáticas, como los calamares y guardianes, pueden aparecer."
flag-description-custom-tnt-block-explosion="Controla si la TNT puede explotar."
flag-description-custom-tnt-entity-explosion="Controla si la TNT puede explotar."
flag-description-custom-use="Controla si los jugadores pueden usar bloques de no-inventario en este terreno (Palancas, Botones, Placas de presión)"
flag-description-custom-vehicle-destroy="Controla si los vehiculos pueden ser destruidos."
flag-description-custom-vehicle-place="Controla si los vehiculos(Barcos, Minecarts, etc) pueden ser colocados."
flag-description-custom-vehicle-use="Controla si los vehiculos(Barcos, Minecarts, etc) pueden ser colocados."
flag-description-custom-vine-growth="Controla si las Vides(Enredaderas) y Algas marinas puede crecer."
flag-description-custom-water-flow="Controla si el Agua puede fluir."
flag-description-custom-wither-damage="Controla si el Wither puede causar daño."
flag-description-custom-wither-block-break="Controla si el Wither puede causar daño."
flag-description-custom-wither-entity-damage="Controla si el Wither puede causar daño."
flag-description-enter-claim="Controla si una entidad puede ENTRAR en un terreno.\n&2&lEJEMPLO: &aPara prevenir que los Jugadores entren a una zona Vip, usa...\n&6&o'/cf enter-claim player &c&ofalse&6&o'\n&4&l[NOTA] &aSi quieres que se use para Grupos usa el comando&6&o '/cfg'"
flag-description-entity-chunk-spawn="Controla si una entidad puede ser guardada durante la carga de Chunks.\n&2&lEJEMPLO: &a:Para prevenir que los caballos spawneen durante la carga de un Chunk, usa...\n&6&o'/cf entity-chunk-spawn minecraft:horse false'\n&4&l[NOTA] &aEsto eliminará &c&lTODAS&a las entidades guardadas cuando carga un Chunk. Si el Chunk ya está cargado, hará efecto cuando se recargue. &c&lUSAR CON EXTREMA PRECAUCION."
flag-description-entity-damage="Controla si una entidad puede ser DAÑADA.\n&2&lEJEMPLO: &aPara prevenir que los Animales sean dañados, usa...\n&6&o'/cf entity-damage minecraft:animal &c&ofalse&6&o'"
@ -394,6 +396,7 @@ GriefDefender {
label-containers=CONTENEDORES
label-context=Contexto
label-created=Creado
label-default=Default
label-displaying=Mostrando
label-expired=Expirado
label-farewell=Despedida

View File

@ -216,6 +216,7 @@ GriefDefender {
create-subdivision-fail="&cPas de terrain existant au coin sélectionné. Cliques sur un bloc valide dans une zone à l'intérieur du terrain parent pour créer la sous-division."
create-subdivision-only="&cImpossible de créer le terrain. Seulement les sous-divisions peuvent être créées à l'endroit d'un bloc unique."
create-success="{type}&a créée ! Utilises &f/trust&a pour la partager avec tes amis."
debug-click-to-expand="Clique pour étendre !"
debug-error-upload="&cErreur d'envoi du contenu {content}&c."
debug-no-records="&cPas d'enregistrement de débug à coller !"
debug-paste-success="&aCollage avec succès !"
@ -276,45 +277,47 @@ GriefDefender {
flag-description-collide-entity="Contrôle si une entité peut entrer en collision avec une entité.\n&dExemple&f : Pour prévenir une entité d'entrer en collision avec un cadre, entre\n&a/cf collide-entity minecraft:item_frame false\n&bNote&f : minecraft représente le modID et item_frame représente le blockID.\nNe pas spécifier de modID prendra toujours minecraft par défaut."
flag-description-command-execute="Contrôle si une commande peut être exécutée.\n&dExemple&f : Pour prévenir la commandes pixelmon '/shop select' d'être exécutée, entre\n&a/cf command-execute pixelmon:shop[select] false\n&bNote&f : &o&6pixelmon&f représente le modID et &o&6shop&f représente la commande de base, et &o&6select&f représente l'argument.\nNe pas spécifier de modID prendra toujours minecraft par défaut."
flag-description-command-execute-pvp="Contrôle si une commande peut être exécutée en état PvP.\n&dExemple&f : Pour prévenir la commandes pixelmon '/shop select' d'être exécutée, entre\n&a/cf command-execute pixelmon:shop[select] false\n&bNote&f : &o&6pixelmon&f représente le modID et &o&6shop&f représente la commande de base, et &o&6select&f représente l'argument.\nNe pas spécifier de modID prendra toujours minecraft par défaut."
flag-description-custom-block-break="Contrôle si un bloc peut être cassé."
flag-description-custom-block-grow="Contrôle si un bloc peut pousser."
flag-description-custom-block-place="Contrôle si un bloc peut être placé."
flag-description-custom-block-spread="Contrôle si un bloc peut s'étendre."
flag-description-custom-build="Contrôle les actions autorisées contre les blocs comme le minage, placement et intéraction."
flag-description-custom-chest-access="Contrôle si un joueur peut accéder à l'inventaire d'un coffre."
flag-description-custom-chorus-fruit-teleport="Contrôle si un joueur peut se téléporter en utilisant un fruit chorus."
flag-description-custom-creeper-block-explosion="Contrôle si un creeper peut exploser des blocs."
flag-description-custom-creeper-entity-explosion="Contrôle si un creeper peut exploser des entités."
flag-description-custom-crop-growth="Contrôle si les pousses peuvent grandir."
flag-description-custom-damage-animals="Contrôle si les animaux peuvent prendre des dégâts."
flag-description-custom-enderman-grief="Contrôle si les enderman peuvent grief."
flag-description-custom-enderpearl="Contrôle si une enderpearl peut être utilisée."
flag-description-custom-enter-player="Contrôle si un joueur peut entrer dans une protection."
flag-description-custom-exit-player="Contrôle si un joueur peut sortir de la protection."
flag-description-custom-enderman-grief="Contrôle si les enderman peuvent prendre des blocs."
flag-description-custom-exp-drop="Contrôle si les orbes d'expériences peuvent apparaîtres."
flag-description-custom-explosion-block="Contrôle si les explosions affectent les blocs."
flag-description-custom-explosion-creeper="Contrôle si un creeper peut exploser."
flag-description-custom-explosion-entity="Contrôle si les explosions affectent les entités."
flag-description-custom-explosion-tnt="Contrôle si une TnT peut exploser."
flag-description-custom-fall-damage="Contrôle si le joueur peut prendre des dégâts de chute."
flag-description-custom-fall-player-damage="Contrôle si le joueur peut prendre des dégâts de chute."
flag-description-custom-fire-damage="Contrôle si le feu fait des dégâts."
flag-description-custom-fire-spread="Contrôle si le feu peut se répandre."
flag-description-custom-grass-growth="Contrôle si l'herbe peut pousser."
flag-description-custom-ice-form="Contrôle si la glace peut se former."
flag-description-custom-ice-melt="Contrôle si la glace peut fondre."
flag-description-custom-interact-block="Contrôle si un joueur peut intéragir avec les blocs.\n&bNote&f: Cela n'inclut PAS les blocs avec inventaire comme les coffres."
flag-description-custom-interact-entity="Contrôle si un joueur peut intéragir avec une entité.\n&bNote&f: Cela n'inclut PAS l'accès au coffre des entités comme les chevaux."
flag-description-custom-interact-inventory="Contrôle si un joueur peut intéragir avec un inventaire."
flag-description-custom-invincible="Contrôle si un joueur est invincible contre les dégâts."
flag-description-custom-item-drop="Contrôle si un joueur peut jeter un objet."
flag-description-custom-item-pickup="Contrôle si un joueur peut ramasser un objet."
flag-description-custom-lava-flow="Contrôle si la lave peut couler."
flag-description-custom-leaf-decay="Contrôle si les feuilles peuvent dépérir."
flag-description-custom-lighter="Contrôle si un joueur peut utiliser un briquet."
flag-description-custom-lightning="Contrôle si un éclair peut causer des dégâts."
flag-description-custom-monster-damage="Contrôle si un monstre peut faire des dégâts."
flag-description-custom-monster-animal-damage="Contrôle si un monstre peut faire des dégâts aux animaux."
flag-description-custom-monster-player-damage="Contrôle si un monstre peut faire des dégâts au joueur."
flag-description-custom-monster-spawn="Contrôle si les monstres, comme les creepers ou les squelettes, peuvent apparaître."
flag-description-custom-mushroom-growth="Contrôle si les champignons peuvent grandir."
flag-description-custom-mycelium-spread="Contrôle si le mycelium peut s'étendre."
flag-description-custom-pistons="Contrôle si un piston peut être utilisé."
flag-description-custom-portal-use="Contrôle si un portail peut être utilisé."
flag-description-custom-piston-use="Contrôle si un piston peut être utilisé."
flag-description-custom-player-block-break="Contrôle si un bloc peut être cassé par un joueur."
flag-description-custom-player-block-interact="Contrôle si un joueur peut intéragir avec les blocs.\n&bNote&f: Cela n'inclut PAS les blocs avec inventaire comme les coffres."
flag-description-custom-player-block-place="Contrôle si un bloc peut être placé par un joueur."
flag-description-custom-player-damage="Contrôle si un joueur peut prendre des dégâts."
flag-description-custom-player-enderpearl-interact="Contrôle si une enderpearl peut être utilisée par un joueur."
flag-description-custom-player-enter="Contrôle si un joueur peut entrer dans une protection."
flag-description-custom-player-entity-interact="Contrôle si un joueur peut intéragir avec une entité.\n&bNote&f: Cela n'inclut PAS l'accès au coffre des entités comme les chevaux."
flag-description-custom-player-exit="Contrôle si un joueur peut sortir de la protection."
flag-description-custom-player-inventory-interact="Contrôle si un joueur peut intéragir avec un inventaire."
flag-description-custom-player-item-drop="Contrôle si un joueur peut jeter un objet."
flag-description-custom-player-item-pickup="Contrôle si un joueur peut ramasser un objet."
flag-description-custom-player-portal-use="Contrôle si un portail peut être utilisé par un joueur."
flag-description-custom-player-teleport-from="Contrôle si les joueurs peuvent se téléporter depuis la protection."
flag-description-custom-player-teleport-to="Contrôle si les joueur peuvent se téléporter vers la protection."
flag-description-custom-pvp="Contrôle si le combat Joueur contre Joueur est autorisé."
flag-description-custom-ride="Contrôle si les véhicules (incluant les animaux) peuvent être montés."
flag-description-custom-sleep="Contrôle si les joueurs peuvent dormir dans les lits."
@ -325,15 +328,14 @@ GriefDefender {
flag-description-custom-spawn-ambient="Contrôle si les environnementaux, comme les chauves-souris, peuvent apparaître."
flag-description-custom-spawn-animal="Contrôle si les animaux, comme les vaches ou cochons, peuvent apparaître."
flag-description-custom-spawn-aquatic="Contrôle si les aquatiques, comme les poulpes et gardiens, peuvent apparaître."
flag-description-custom-spawn-monster="Contrôle si les monstres, comme les creepers ou les squelettes, peuvent apparaître."
flag-description-custom-teleport-from="Contrôle si les joueurs peuvent se téléporter depuis la protection."
flag-description-custom-teleport-to="Contrôle si les joueur peuvent se téléporter vers la protection."
flag-description-custom-tnt-block-explosion="Contrôle si une TnT peut exploser les blocs."
flag-description-custom-tnt-entity-explosion="Contrôle si une TnT peut exploser les entités."
flag-description-custom-use="Contrôle si les joueurs peuvent utiliser des blocs sans inventaire dans la protection."
flag-description-custom-vehicle-destroy="Contrôle si un vehicule peut être détruit."
flag-description-custom-vehicle-place="Contrôle si un véhicule (bateau, minecart) peut être placé."
flag-description-custom-vehicle-use="Contrôle si un véhicule (bateau, minecart) peut être placé, montés ou détruit."
flag-description-custom-vine-growth="Contrôle si les vignes (et les algues) peuvent grandir."
flag-description-custom-water-flow="Contrôle si l'eau peut couler."
flag-description-custom-wither-damage="Contrôle si un Withers peut faire des dégâts."
flag-description-custom-wither-block-break="Contrôle si un Withers peut faire détruire des blocs."
flag-description-custom-wither-entity-damage="Contrôle si un Withers peut faire des dégâts au entité."
flag-description-enter-claim="Contrôle si une entité peut rentrer dans une protection.\n&dExemple&f : Pour prévenir les joueurs de rentrer dans une protection, entre\n&a/cf enter-claim player false\n&bNote&f : Si tu veux utiliser ça sur un groupe, utilises la commande /cfg."
flag-description-entity-chunk-spawn="Contrôle si une entité sauvegardée peut apparaître pendant le chargement d'un chunk.\n&dExemple&f : Pour prévenir les chevaux d'apparaître pendant le chargement du chunk, entre\n&a/cf entity-chunk-spawn minecraft:horse false\n&bNote&f : Cela va supprimer l'ENSEMBLE des entités sauvegardées quand le chunk va charger. Si le chunk est déjà chargé, l'effet aura lieu après le rechargement. À utiliser avec une extrême prudence."
flag-description-entity-damage="Contrôle si une entité peut prendre des dégâts.\n&dExemple&f : Pour prévenir les animaux de prendre des dégâts, entre\n&a/cf entity-damage minecraft:animal false."
@ -394,6 +396,7 @@ GriefDefender {
label-containers=Conteneur
label-context=Contexte
label-created=Créé
label-default=Default
label-displaying=Affiche
label-expired=Expiré
label-farewell="Message de sortie"

View File

@ -216,6 +216,7 @@ GriefDefender {
create-subdivision-fail="&cВ выбранной точке нет ни одного региона. Пожалуйста, кликните по блоку, находящемуся в родительском регионе, чтобы создать суб-регион."
create-subdivision-only="&cНе удалось создать регион. Только суб-регионы могут быть объёмом в один блок."
create-success="{type}&a регион создан! Используйте &f/trust&a, чтобы впустить в него друзей."
debug-click-to-expand="Нажмите, чтобы развернуть!"
debug-error-upload="&cОшибка загрузки контента {content}&c."
debug-no-records="&cНет отладочной записи!"
debug-paste-success="&aВставка успешна!"
@ -267,35 +268,6 @@ GriefDefender {
economy-virtual-not-supported="&cПлагин на экономику не поддерживает виртуальные счета. Воспользуйтесь другим плагином или свяжитесь с разработчиком вашего плагина, чтобы он добавил в него поддержку виртуальных счетов."
economy-withdraw-error="&cНе удалось списать средства: &f{reason}&c."
feature-not-available="&cДанный функционал не закончен и будет доступен в новой версии."
flag-description-custom-block-break="Управляет возможностью ломать блоки."
flag-description-custom-block-grow="Управляет возможностью блоков к росту."
flag-description-custom-block-place="Управляет возможностью установки блоков."
flag-description-custom-block-spread="Управляет возможностью блока распространяться."
flag-description-custom-build="Управляет возможностью совершения действий с блоками и сущностями, таких, как поломка, установка и взаимодействие."
flag-description-custom-enderpearl="Управляет возможностью пользоваться Жемчугом Края."
flag-description-custom-exit-player="Управляет возможностью игрока выйти из региона."
flag-description-custom-exp-drop="Управляет возможностью выпадения сфер опыта."
flag-description-custom-explosion-block="Управляет возможностью взрывов влиять на блоки."
flag-description-custom-explosion-entity="Управляет возможностью взрывов влиять на сущности."
flag-description-custom-fall-damage="Управляет возможностью игроков получать урон от падения."
flag-description-custom-interact-block="Управляет возможностью игроков взаимодействовать с блоками.\n&bПримечание&f: сюда не входят блоки с инвентарём, такие, как сундуки."
flag-description-custom-interact-entity="Управляет возможностью игроков взаимодействовать с сущностями.\n&bПримечание&f: сюда не входит доступ к сущностям с инвентарём, таким, как лошади."
flag-description-custom-interact-inventory="Управляет возможностью игроков взаимодействовать с инвентарями."
flag-description-custom-invincible="Управляет неуязвимостью игроков."
flag-description-custom-item-drop="Управляет возможностью игроков выбрасывать предметы."
flag-description-custom-item-pickup="Управляет возможностью игроков подбирать предметы."
flag-description-custom-monster-damage="Управляет возможностью монстров наносить урон."
flag-description-custom-pistons="Управляет возможностью использования поршней."
flag-description-custom-portal-use="Управляет возможностью использования порталов."
flag-description-custom-spawn-ambient="Управляет возможностью появления мобов окружения, таких, как летучие мыши."
flag-description-custom-spawn-animal="Управляет возможностью появления животных, таких, как коровы и свиньи."
flag-description-custom-spawn-aquatic="Управляет возможностью появления подводных мобов, таких, как спруты и стражи."
flag-description-custom-spawn-monster="Управляет возможностью появления враждебных мобов, таких, как криперы и скелеты."
flag-description-custom-teleport-from="Управляет возможностью игроков телепортироваться из региона."
flag-description-custom-teleport-to="Управляет возможностью игроков телепортироваться в регион."
flag-description-custom-use="Управляет возможностью игроков пользоваться блоками без инвентаря."
flag-description-custom-vehicle-destroy="Управляет возможностью поломки транспорта."
flag-description-custom-wither-damage="Управляет возможностью Иссушителя наносить урон."
flag-description-block-break="Управляет возможностью сломать блок.\n&dПример&f : чтобы запретить любому источнику ломать блоки земли, введите\n&a/cf block-break minecraft:dirt false\n&bПримечание&f : minecraft - это id мода, а dirt - id блока.\nЕсли id мода не указан - будет использоваться minecraft."
flag-description-block-grow="Управляет возможностью блока вырастать.\n&dПример&f : чтобы запретить кактусу расти, введите\n&a/cf block-grow minecraft:cactus false\n&bПримечание&f : minecraft - это id мода, а cactus - id блока.\nЕсли id мода не указан - будет использоваться minecraft."
flag-description-block-modify="Управляет возможностью изменения блоков.\n&dПример&f : чтобы запретить любому источнику поджигать блок, введите\n&a/cf block-modify minecraft:fire false\n&bПримечание&f : minecraft - это id мода, а fire - id блока.\nЕсли id мода не указан - будет использоваться minecraft."
@ -305,6 +277,65 @@ GriefDefender {
flag-description-collide-entity="Управляет возможностью столкновения сущности с другой сущностью.\n&dПример&f : чтобы отключить столкновение сущностей с рамками, введите\n&a/cf collide-entity minecraft:item_frame false\n&bПримечание&f : minecraft - это id мода, а item_frame - id сущности.\nЕсли id мода не указан - будет использоваться minecraft."
flag-description-command-execute="Управляет возможностью выполнять команды.\n&dПример&f : чтобы запретить команду '/shop select' из Pixelmon, введите\n&a/cf command-execute pixelmon:shop[select] false\n&bПримечание&f : &o&6pixelmon&f - это id мода, &o&6shop&f - базовая команда, а &o&6select&f - аргумент.\nЕсли id мода не указан - будет использоваться minecraft."
flag-description-command-execute-pvp="Управляет возможностью выполнять команды во время сражения с другим игроком.\n&dПример&f : чтобы запретить команду '/shop select' из Pixelmon, введите \n&a/cf command-execute-pvp pixelmon:shop[select] false\n&bПримечание&f : &o&6pixelmon&f - это id модв, &o&6shop&f - базовая команда, а &o&6select&f - аргумент.\nЕсли id мода не указан - будет использоваться minecraft."
flag-description-custom-build="Управляет возможностью совершения действий с блоками и сущностями, таких, как поломка, установка и взаимодействие."
flag-description-custom-chest-access="Управляет возможностью игрока взаимодействовать с инвентарями сундуков."
flag-description-custom-chorus-fruit-teleport="Управляет возможностью игрока телепортироваться при помощи плодов коруса."
flag-description-custom-creeper-block-explosion="Управляет способностью лианы взрывать блоки."
flag-description-custom-creeper-entity-explosion="Управляет способностью лианы взрывать сущности."
flag-description-custom-crop-growth="Управляет возможностью культур расти."
flag-description-custom-damage-animals="Управляет возможностью животных получать урон."
flag-description-custom-enderman-grief="Управляет возможностью Странников Края ломать и ставить блоки."
flag-description-custom-exp-drop="Управляет возможностью выпадения сфер опыта."
flag-description-custom-explosion-block="Управляет возможностью взрывов влиять на блоки."
flag-description-custom-explosion-entity="Управляет возможностью взрывов влиять на сущности."
flag-description-custom-fall-player-damage="Управляет возможностью игроков получать урон от падения."
flag-description-custom-fire-damage="Управляет возможностью огня наносить урон."
flag-description-custom-fire-spread="Управляет возможностью огня распространяться."
flag-description-custom-grass-growth="Управляет возможностью травы расти."
flag-description-custom-ice-form="Управляет возможностью замерзания льда."
flag-description-custom-ice-melt="Управляет возможностью таяния льда."
flag-description-custom-lava-flow="Управляет возможностью лавы растекаться."
flag-description-custom-leaf-decay="Управляет возможностью листвы опадать."
flag-description-custom-lighter="Управляет возможностью игрока использовать огниво."
flag-description-custom-lightning="Управляет возможностью молнии наносить урон."
flag-description-custom-monster-animal-damage="Управляет возможностью монстров наносить урон животному."
flag-description-custom-monster-player-damage="Управляет возможностью монстров наносить урон игроку."
flag-description-custom-monster-spawn="Управляет возможностью появления враждебных мобов, таких, как криперы и скелеты."
flag-description-custom-mushroom-growth="Управляет возможностью грибов вырастать."
flag-description-custom-mycelium-spread="Управляет возможностью мицелия распространяться."
flag-description-custom-piston-use="Управляет возможностью использования поршней."
flag-description-custom-player-block-break="Управляет возможностью игрока ломать блоки."
flag-description-custom-player-block-interact="Управляет возможностью игроков взаимодействовать с блоками.\n&bПримечание&f: сюда не входят блоки с инвентарём, такие, как сундуки."
flag-description-custom-player-block-place="Управляет возможностью игрока установки блоков."
flag-description-custom-player-damage="Управляет неуязвимостью игроков."
flag-description-custom-player-enderpearl-interact="Управляет возможностью пользоваться Жемчугом Края."
flag-description-custom-player-enter="Управляет возможностью входа сущности в регион."
flag-description-custom-player-entity-interact="Управляет возможностью игроков взаимодействовать с сущностями.\n&bПримечание&f: сюда не входит доступ к сущностям с инвентарём, таким, как лошади."
flag-description-custom-player-exit="Управляет возможностью игрока выйти из региона."
flag-description-custom-player-inventory-interact="Управляет возможностью игроков взаимодействовать с инвентарями."
flag-description-custom-player-item-drop="Управляет возможностью игроков выбрасывать предметы."
flag-description-custom-player-item-pickup="Управляет возможностью игроков подбирать предметы."
flag-description-custom-player-portal-use="Управляет возможностью использования порталов."
flag-description-custom-player-teleport-from="Управляет возможностью игроков телепортироваться из региона."
flag-description-custom-player-teleport-to="Управляет возможностью игроков телепортироваться в регион."
flag-description-custom-pvp="Управляет возможностью сражений между игроками."
flag-description-custom-ride="Управляет возможностью садиться на транспорт (включая животных)."
flag-description-custom-sleep="Управляет возможностью игрока спать в кроватях."
flag-description-custom-snow-fall="Управляет возможностью появления снега."
flag-description-custom-snow-melt="Управляет возможностью таяния снега."
flag-description-custom-snowman-trail="Управляет возможностью снежных големов оставлять след из снега."
flag-description-custom-soil-dry="Управляет возможностью почвы высыхать."
flag-description-custom-spawn-ambient="Управляет возможностью появления мобов окружения, таких, как летучие мыши."
flag-description-custom-spawn-animal="Управляет возможностью появления животных, таких, как коровы и свиньи."
flag-description-custom-spawn-aquatic="Управляет возможностью появления подводных мобов, таких, как спруты и стражи."
flag-description-custom-tnt-block-explosion="Управляет способностью динамита взрывать блоки."
flag-description-custom-tnt-entity-explosion="Управляет способностью динамита взрывать сущностями."
flag-description-custom-use="Управляет возможностью игроков пользоваться блоками без инвентаря."
flag-description-custom-vehicle-use="Управляет возможностью ставить транспорт (лодки, вагонетки и т.п.)."
flag-description-custom-vine-growth="Управляет возможностью роста лиан (и ламинарий)."
flag-description-custom-water-flow="Управляет возможностью воды растекаться."
flag-description-custom-wither-block-break="Управляет способностью Искателя разбивать блоки."
flag-description-custom-wither-entity-damage="Управляет возможностью Иссушителя наносить урон."
flag-description-enter-claim="Управляет возможностью входа сущности в регион.\n&dПример&f : чтобы запретить игрокам входить в регион, введите\n&a/cf enter-claim player false\n&bПримечание&f : если вы хотите изменить разрешение для групп, используйте команду /cfg."
flag-description-entity-chunk-spawn="Управляет возможностью появления сохранённой сущности при загрузке чанка.\n&dПример&f : чтобы запретить лошадям появляться при загрузке чанка, введите\n&a/cf entity-chunk-spawn minecraft:horse false\n&bПримечание&f : это удалит &cВСЕ&f сохранённые сущности, когда чанк будет загружен. Если чанк уже загружен - сущности будут удалены при его перезагрузке. Используйте с большой осторожностью."
flag-description-entity-damage="Управляет возможностью сущности получить урон.\n&dПример&f : чтобы запретить животным получать урон, введите\n&a/cf entity-damage minecraft:animal false."
@ -332,35 +363,6 @@ GriefDefender {
flag-description-portal-use="Управляет возможностью пользоваться порталом.\n&dПример&f : чтобы запретить только игрокам проходить в порталы без влияния на не-игроков, введите\n&a/cf portal-use any false context[source=player]"
flag-description-projectile-impact-block="Управляет возможностью снаряда попадать (сталкиваться) с блоком.\n&dПример&f : чтобы запретить покеболам из Pixelmon сталкиваться с блоками, введите\n&a/cf projectile-impact-block any false[source=pixelmon:occupiedpokeball]\n&bПримечание&f : сюда входят такие вещи, как зелья, стрелы, снежки, покеболы из Pixelmon и т.д."
flag-description-projectile-impact-entity="Управляет возможностью снаряда попадать (сталкиваться) с сущностью.\n&dПример&f : чтобы запретить стрелам попадать в сущности, введите\n&a/cf projectile-impact-entity minecraft:arrow false[source=player]\n&bПримечание&f : сюда входят такие вещи, как зелья, стрелы, снежки, покеболы из Pixelmon и т.д."
flag-description-custom-chest-access="Управляет возможностью игрока взаимодействовать с инвентарями сундуков."
flag-description-custom-chorus-fruit-teleport="Управляет возможностью игрока телепортироваться при помощи плодов коруса."
flag-description-custom-crop-growth="Управляет возможностью культур расти."
flag-description-custom-damage-animals="Управляет возможностью животных получать урон."
flag-description-custom-enderman-grief="Управляет возможностью Странников Края ломать и ставить блоки."
flag-description-custom-enter-player="Управляет возможностью игрока входить в этот регион."
flag-description-custom-explosion-creeper="Управляет возможностью крипера взрываться."
flag-description-custom-explosion-tnt="Управляет возможностью динамита взрываться."
flag-description-custom-fire-damage="Управляет возможностью огня наносить урон."
flag-description-custom-fire-spread="Управляет возможностью огня распространяться."
flag-description-custom-grass-growth="Управляет возможностью травы расти."
flag-description-custom-ice-form="Управляет возможностью замерзания льда."
flag-description-custom-ice-melt="Управляет возможностью таяния льда."
flag-description-custom-lava-flow="Управляет возможностью лавы растекаться."
flag-description-custom-leaf-decay="Управляет возможностью листвы опадать."
flag-description-custom-lighter="Управляет возможностью игрока использовать огниво."
flag-description-custom-lightning="Управляет возможностью молнии наносить урон."
flag-description-custom-mushroom-growth="Управляет возможностью грибов вырастать."
flag-description-custom-mycelium-spread="Управляет возможностью мицелия распространяться."
flag-description-custom-pvp="Управляет возможностью сражений между игроками."
flag-description-custom-ride="Управляет возможностью садиться на транспорт (включая животных)."
flag-description-custom-sleep="Управляет возможностью игрока спать в кроватях."
flag-description-custom-snow-fall="Управляет возможностью появления снега."
flag-description-custom-snow-melt="Управляет возможностью таяния снега."
flag-description-custom-snowman-trail="Управляет возможностью снежных големов оставлять след из снега."
flag-description-custom-soil-dry="Управляет возможностью почвы высыхать."
flag-description-custom-vehicle-place="Управляет возможностью ставить транспорт (лодки, вагонетки и т.п.)."
flag-description-custom-vine-growth="Управляет возможностью роста лиан (и ламинарий)."
flag-description-custom-water-flow="Управляет возможностью воды растекаться."
flag-invalid-context="&cВведён неверный контекст '&f{context}&c' для базового флага &f{flag}&c."
flag-invalid-meta="&cВведены неверные метаданные цели '&f{value}&c' для базового флага &f{flag}&c."
flag-invalid-target="&cВведена неверная цель '&f{target}&c' для базового флага &f{flag}&c."
@ -394,6 +396,7 @@ GriefDefender {
label-containers=Контейнеры
label-context=Контекст
label-created=Создан
label-default=стандарт
label-displaying=Отображение
label-expired=Истекло
label-farewell=Прощание

View File

@ -102,11 +102,11 @@ public GDDebugData(CommandSource source, User target, boolean verbose) {
this.header.add("| " + PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().DEBUG_RECORD_START) + " | " + DATE_FORMAT.format(new Date(this.startTime)) + "|");
}
public void addRecord(String flag, String trust, String source, String target, String location, String user, String permission, Tristate result) {
public void addRecord(String flag, String trust, String source, String target, String location, String user, String contexts, Tristate result) {
// markdown uses '__' for strong formatting, so underscores must be escaped
user = user.replace("_", "\\_");
if (this.records.size() < MAX_LINES) {
this.records.add("| " + flag + " | " + trust + " | " + source + " | " + target + " | " + location + " | " + user + " | " + permission + " | " + result + " | ");
this.records.add("| " + flag + " | " + trust + " | " + source + " | " + target + " | " + location + " | " + user + " | " + contexts + " | " + result + " | ");
} else {
TextAdapter.sendComponent(this.source, TextComponent.builder("").append("MAX DEBUG LIMIT REACHED!").append("\n")
.append("Pasting output...", TextColor.GREEN).build());
@ -154,15 +154,15 @@ public void pasteRecords() {
final String SOURCE = PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().LABEL_SOURCE);
final String TARGET = PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().LABEL_TARGET);
final String USER = PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().LABEL_USER);
final String PERMISSION = PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().LABEL_PERMISSION);
final String CONTEXT = PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().LABEL_CONTEXT);
final String RESULT = PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().LABEL_RESULT);
debugOutput.add("| " + RECORD_END + " | " + DATE_FORMAT.format(new Date(endTime)) + "|");
long elapsed = (endTime - startTime) / 1000L;
debugOutput.add("| " + TIME_ELAPSED + " | " + elapsed + " seconds" + "|");
debugOutput.add("");
debugOutput.add("### " + OUTPUT) ;
debugOutput.add("| " + FLAG + " | " + TRUST + " | " + SOURCE + " | " + TARGET + " | " + LOCATION + " | " + USER + " | " + PERMISSION + " | " + RESULT + " |");
debugOutput.add("|------|-------|--------|--------|----------|------|------------|--------|");
debugOutput.add("| " + FLAG + " | " + TRUST + " | " + SOURCE + " | " + TARGET + " | " + LOCATION + " | " + USER + " | " + CONTEXT + " | " + RESULT + " |");
debugOutput.add("|------|-------|--------|--------|----------|------|----------|--------|");
debugOutput.addAll(this.records);

View File

@ -106,7 +106,7 @@ public class GDPlayerData implements PlayerData {
public Instant recordChatTimestamp;
public Instant commandInputTimestamp;
public String commandInput;
public Consumer<CommandSource> trustAddConsumer;
public Consumer<CommandSource> commandConsumer;
// Always ignore active contexts by default
// This prevents protection issues when other plugins call getActiveContext
@ -252,7 +252,8 @@ public void revertActiveVisual(Player player) {
for (int i = 0; i < this.visualBlocks.size(); i++) {
BlockSnapshot snapshot = this.visualBlocks.get(i).getOriginal();
// If original block does not exist, do not send to player
if (snapshot.getState().getType() != snapshot.getLocation().get().getBlockType()) {
final Location<World> location = snapshot.getLocation().orElse(null);
if (location != null && (snapshot.getState().getType() != location.getBlockType())) {
if (claim != null) {
claim.markVisualDirty = true;
}

View File

@ -40,6 +40,7 @@
import com.griefdefender.api.claim.ClaimType;
import com.griefdefender.api.claim.TrustType;
import com.griefdefender.api.economy.BankTransaction;
import com.griefdefender.api.permission.Context;
import com.griefdefender.api.permission.flag.Flag;
import com.griefdefender.api.permission.flag.FlagData;
import com.griefdefender.api.permission.flag.FlagDefinition;
@ -126,9 +127,11 @@
import com.griefdefender.command.CommandUntrustPlayerAll;
import com.griefdefender.command.gphelper.CommandAccessTrust;
import com.griefdefender.command.gphelper.CommandContainerTrust;
import com.griefdefender.configuration.FlagConfig;
import com.griefdefender.configuration.GriefDefenderConfig;
import com.griefdefender.configuration.MessageDataConfig;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.configuration.OptionConfig;
import com.griefdefender.configuration.category.BlacklistCategory;
import com.griefdefender.configuration.serializer.ClaimTypeSerializer;
import com.griefdefender.configuration.serializer.ComponentConfigSerializer;
@ -170,6 +173,7 @@
import com.griefdefender.registry.ChatTypeRegistryModule;
import com.griefdefender.registry.ClaimTypeRegistryModule;
import com.griefdefender.registry.CreateModeTypeRegistryModule;
import com.griefdefender.registry.FlagDefinitionRegistryModule;
import com.griefdefender.registry.FlagRegistryModule;
import com.griefdefender.registry.GameModeTypeRegistryModule;
import com.griefdefender.registry.OptionRegistryModule;
@ -225,10 +229,12 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.TreeMap;
import java.util.UUID;
import java.util.concurrent.Executor;
@ -251,6 +257,8 @@ public class GriefDefenderPlugin {
protected Logger logger;
//@Inject private Metrics2 metrics;
protected Path configPath;
public FlagConfig flagConfig;
public OptionConfig optionConfig;
public MessageStorage messageStorage;
public MessageDataConfig messageData;
//public Map<UUID, Random> worldGeneratorRandoms = new HashMap<>();
@ -313,7 +321,7 @@ public Logger getLogger() {
return this.logger;
}
public static void addEventLogEntry(Event event, Location<World> location, String sourceId, String targetId, GDPermissionHolder permissionSubject, String permission, String trust, Tristate result) {
public static void addEventLogEntry(Event event, Claim claim, Location<World> location, String sourceId, String targetId, GDPermissionHolder permissionSubject, String permission, String trust, Tristate result, Set<Context> contexts) {
final String eventName = event.getClass().getSimpleName().replace('$', '.').replace(".Impl", "");
final String eventLocation = location == null ? "none" : location.getBlockPosition().toString();
for (GDDebugData debugEntry : GriefDefenderPlugin.getInstance().getDebugUserMap().values()) {
@ -359,7 +367,37 @@ public static void addEventLogEntry(Event event, Location<World> location, Strin
if (parts.length > 1 && parts[0].equalsIgnoreCase("minecraft")) {
messageTarget = parts[1];
}
debugEntry.addRecord(messageFlag, trust, messageSource, messageTarget, eventLocation, messageUser, permission, result);
String contextStr = "";
final List<String> contextList = new ArrayList<>();
for (Context context : contexts) {
contextList.add("<b>" + context.getKey() + "</b>=" + context.getValue());
}
final String serverName = PermissionUtil.getInstance().getServerName();
if (serverName != null) {
contextList.add("<b>server</b>=" + serverName);
} else {
contextList.add("<b>server</b>=global");
}
Collections.sort(contextList);
for (String context : contextList) {
contextStr += context + "<br />";
}
String locationStr = "";
locationStr += "<b>claim_uuid</b>=" + claim.getUniqueId() + "<br />";
locationStr += "<b>claim_type</b>=" + claim.getType().getName().toLowerCase() + "<br />";
locationStr += "<b>location</b>=" + eventLocation + "<br />";
locationStr += "<b>world</b>=" + location.getExtent().getName().toLowerCase() + "<br />";
String messageContexts = "<details>" +
" <summary><i>" + PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().DEBUG_CLICK_TO_EXPAND) + "</i></summary>" +
contextStr +
"</details>";
String messageLocation = "<details>" +
" <summary><i>" + PlainComponentSerializer.INSTANCE.serialize(MessageCache.getInstance().DEBUG_CLICK_TO_EXPAND) + "</i></summary>" +
locationStr +
"</details>";
debugEntry.addRecord(messageFlag, trust, messageSource, messageTarget, messageLocation, messageUser, messageContexts, result);
continue;
}
@ -911,8 +949,6 @@ public void loadConfig() {
Path rootConfigPath = this.getConfigPath().resolve("worlds");
BaseStorage.globalConfig = new GriefDefenderConfig<>(GlobalConfig.class, this.getConfigPath().resolve("global.conf"), null);
BaseStorage.globalConfig.getConfig().permissionCategory.refreshFlags();
BaseStorage.globalConfig.getConfig().permissionCategory.checkOptions();
String localeString = BaseStorage.globalConfig.getConfig().message.locale;
try {
LocaleUtils.toLocale(localeString);
@ -939,7 +975,16 @@ public void loadConfig() {
messageStorage = new MessageStorage(localePath);
messageData = messageStorage.getConfig();
MessageCache.getInstance().loadCache();
BaseStorage.globalConfig.getConfig().customFlags.initDefaults();
flagConfig = new FlagConfig(this.getConfigPath().resolve("flags.conf"));
// FlagDefinition registry needs to init after config load
FlagDefinitionRegistryModule.getInstance().registerDefaults();
flagConfig.getConfig().customFlags.initDefaults();
flagConfig.save();
flagConfig.getConfig().defaultFlagCategory.refreshFlags();
flagConfig.save();
optionConfig = new OptionConfig(this.getConfigPath().resolve("options.conf"));
optionConfig.getConfig().defaultOptionCategory.checkOptions();
optionConfig.save();
BaseStorage.globalConfig.save();
BaseStorage.USE_GLOBAL_PLAYER_STORAGE = !BaseStorage.globalConfig.getConfig().playerdata.useWorldPlayerData();
GDFlags.populateFlagStatus();
@ -1180,4 +1225,21 @@ public WorldEditProvider getWorldEditProvider() {
public PermissionProvider getPermissionProvider() {
return this.permissionProvider;
}
public static int getMajorMinecraftVersion() {
final String version = Sponge.getPlatform().getMinecraftVersion().getName();
if (version.contains("1.8.8")) {
return 8;
} else if (version.contains("1.12")) {
return 12;
} else if (version.contains("1.13")) {
return 13;
} else if (version.contains("1.14")) {
return 14;
} else if (version.contains("1.15")) {
return 15;
}
return -1;
}
}

View File

@ -130,6 +130,7 @@ public static MessageCache getInstance() {
public Component CREATE_OVERLAP_SHORT;
public Component CREATE_SUBDIVISION_FAIL;
public Component CREATE_SUBDIVISION_ONLY;
public Component DEBUG_CLICK_TO_EXPAND;
public Component DEBUG_NO_RECORDS;
public Component DEBUG_PASTE_SUCCESS;
public Component DEBUG_RECORD_END;
@ -145,43 +146,16 @@ public static MessageCache getInstance() {
public Component ECONOMY_NOT_INSTALLED;
public Component ECONOMY_VIRTUAL_NOT_SUPPORTED;
public Component FEATURE_NOT_AVAILABLE;
public Component FLAG_DESCRIPTION_CUSTOM_BLOCK_BREAK;
public Component FLAG_DESCRIPTION_CUSTOM_BLOCK_GROW;
public Component FLAG_DESCRIPTION_CUSTOM_BLOCK_PLACE;
public Component FLAG_DESCRIPTION_CUSTOM_BLOCK_SPREAD;
public Component FLAG_DESCRIPTION_CUSTOM_ENDERPEARL;
public Component FLAG_DESCRIPTION_CUSTOM_EXIT_PLAYER;
public Component FLAG_DESCRIPTION_CUSTOM_EXPLOSION_BLOCK;
public Component FLAG_DESCRIPTION_CUSTOM_EXPLOSION_ENTITY;
public Component FLAG_DESCRIPTION_CUSTOM_EXP_DROP;
public Component FLAG_DESCRIPTION_CUSTOM_FALL_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_INTERACT_BLOCK;
public Component FLAG_DESCRIPTION_CUSTOM_INTERACT_ENTITY;
public Component FLAG_DESCRIPTION_CUSTOM_INTERACT_INVENTORY;
public Component FLAG_DESCRIPTION_CUSTOM_INVINCIBLE;
public Component FLAG_DESCRIPTION_CUSTOM_ITEM_DROP;
public Component FLAG_DESCRIPTION_CUSTOM_ITEM_PICKUP;
public Component FLAG_DESCRIPTION_CUSTOM_MONSTER_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_PISTONS;
public Component FLAG_DESCRIPTION_CUSTOM_PORTAL_USE;
public Component FLAG_DESCRIPTION_CUSTOM_SPAWN_AQUATIC;
public Component FLAG_DESCRIPTION_CUSTOM_SPAWN_AMBIENT;
public Component FLAG_DESCRIPTION_CUSTOM_SPAWN_ANIMAL;
public Component FLAG_DESCRIPTION_CUSTOM_SPAWN_MONSTER;
public Component FLAG_DESCRIPTION_CUSTOM_TELEPORT_FROM;
public Component FLAG_DESCRIPTION_CUSTOM_TELEPORT_TO;
public Component FLAG_DESCRIPTION_CUSTOM_USE;
public Component FLAG_DESCRIPTION_CUSTOM_VEHICLE_DESTROY;
public Component FLAG_DESCRIPTION_CUSTOM_WITHER_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_BLOCK_TRAMPLING;
public Component FLAG_DESCRIPTION_CUSTOM_CHEST_ACCESS;
public Component FLAG_DESCRIPTION_CUSTOM_CHORUS_FRUIT_TELEPORT;
public Component FLAG_DESCRIPTION_CUSTOM_CREEPER_BLOCK_EXPLOSION;
public Component FLAG_DESCRIPTION_CUSTOM_CREEPER_ENTITY_EXPLOSION;
public Component FLAG_DESCRIPTION_CUSTOM_CROP_GROWTH;
public Component FLAG_DESCRIPTION_CUSTOM_DAMAGE_ANIMALS;
public Component FLAG_DESCRIPTION_CUSTOM_ENDERMAN_GRIEF;
public Component FLAG_DESCRIPTION_CUSTOM_ENTER_PLAYER;
public Component FLAG_DESCRIPTION_CUSTOM_EXPLOSION_CREEPER;
public Component FLAG_DESCRIPTION_CUSTOM_EXPLOSION_TNT;
public Component FLAG_DESCRIPTION_CUSTOM_EXP_DROP;
public Component FLAG_DESCRIPTION_CUSTOM_FALL_PLAYER_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_FIRE_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_FIRE_SPREAD;
public Component FLAG_DESCRIPTION_CUSTOM_GRASS_GROWTH;
@ -191,8 +165,26 @@ public static MessageCache getInstance() {
public Component FLAG_DESCRIPTION_CUSTOM_LEAF_DECAY;
public Component FLAG_DESCRIPTION_CUSTOM_LIGHTNING;
public Component FLAG_DESCRIPTION_CUSTOM_LIGHTER;
public Component FLAG_DESCRIPTION_CUSTOM_MONSTER_ANIMAL_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_MONSTER_PLAYER_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_MONSTER_SPAWN;
public Component FLAG_DESCRIPTION_CUSTOM_MUSHROOM_GROWTH;
public Component FLAG_DESCRIPTION_CUSTOM_MYCELIUM_SPREAD;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_BLOCK_BREAK;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_BLOCK_INTERACT;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_BLOCK_PLACE;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_ENDERPEARL_INTERACT;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_ENTER;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_ENTITY_INTERACT;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_EXIT;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_INVENTORY_INTERACT;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_ITEM_DROP;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_ITEM_PICKUP;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_TELEPORT_FROM;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_TELEPORT_TO;
public Component FLAG_DESCRIPTION_CUSTOM_PISTON_USE;
public Component FLAG_DESCRIPTION_CUSTOM_PLAYER_PORTAL_USE;
public Component FLAG_DESCRIPTION_CUSTOM_PVP;
public Component FLAG_DESCRIPTION_CUSTOM_RIDE;
public Component FLAG_DESCRIPTION_CUSTOM_SLEEP;
@ -200,6 +192,15 @@ public static MessageCache getInstance() {
public Component FLAG_DESCRIPTION_CUSTOM_SNOW_MELT;
public Component FLAG_DESCRIPTION_CUSTOM_SNOWMAN_TRAIL;
public Component FLAG_DESCRIPTION_CUSTOM_SOIL_DRY;
public Component FLAG_DESCRIPTION_CUSTOM_SPAWN_AQUATIC;
public Component FLAG_DESCRIPTION_CUSTOM_SPAWN_AMBIENT;
public Component FLAG_DESCRIPTION_CUSTOM_SPAWN_ANIMAL;
public Component FLAG_DESCRIPTION_CUSTOM_TNT_BLOCK_EXPLOSION;
public Component FLAG_DESCRIPTION_CUSTOM_TNT_ENTITY_EXPLOSION;
public Component FLAG_DESCRIPTION_CUSTOM_USE;
public Component FLAG_DESCRIPTION_CUSTOM_VEHICLE_USE;
public Component FLAG_DESCRIPTION_CUSTOM_WITHER_BLOCK_BREAK;
public Component FLAG_DESCRIPTION_CUSTOM_WITHER_ENTITY_DAMAGE;
public Component FLAG_DESCRIPTION_CUSTOM_VEHICLE_PLACE;
public Component FLAG_DESCRIPTION_CUSTOM_VINE_GROWTH;
public Component FLAG_DESCRIPTION_CUSTOM_WATER_FLOW;
@ -262,6 +263,7 @@ public static MessageCache getInstance() {
public Component LABEL_CONTAINERS;
public Component LABEL_CONTEXT;
public Component LABEL_CREATED;
public Component LABEL_DEFAULT;
public Component LABEL_DISPLAYING;
public Component LABEL_EXPIRED;
public Component LABEL_FAREWELL;
@ -503,6 +505,7 @@ public void loadCache() {
CREATE_OVERLAP_SHORT = MessageStorage.MESSAGE_DATA.getMessage("create-overlap-short");
CREATE_SUBDIVISION_FAIL = MessageStorage.MESSAGE_DATA.getMessage("create-subdivision-fail");
CREATE_SUBDIVISION_ONLY = MessageStorage.MESSAGE_DATA.getMessage("create-subdivision-only");
DEBUG_CLICK_TO_EXPAND = MessageStorage.MESSAGE_DATA.getMessage("debug-click-to-expand");
DEBUG_NO_RECORDS = MessageStorage.MESSAGE_DATA.getMessage("debug-no-records");
DEBUG_PASTE_SUCCESS = MessageStorage.MESSAGE_DATA.getMessage("debug-paste-success");
DEBUG_RECORD_END = MessageStorage.MESSAGE_DATA.getMessage("debug-record-end");
@ -518,43 +521,16 @@ public void loadCache() {
ECONOMY_NOT_INSTALLED = MessageStorage.MESSAGE_DATA.getMessage("economy-not-installed");
ECONOMY_VIRTUAL_NOT_SUPPORTED = MessageStorage.MESSAGE_DATA.getMessage("economy-virtual-not-supported");
FEATURE_NOT_AVAILABLE = MessageStorage.MESSAGE_DATA.getMessage("feature-not-available");
FLAG_DESCRIPTION_CUSTOM_BLOCK_BREAK = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-block-break");
FLAG_DESCRIPTION_CUSTOM_BLOCK_GROW = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-block-grow");
FLAG_DESCRIPTION_CUSTOM_BLOCK_PLACE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-block-place");
FLAG_DESCRIPTION_CUSTOM_BLOCK_SPREAD = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-block-spread");
FLAG_DESCRIPTION_CUSTOM_ENDERPEARL = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-enderpearl");
FLAG_DESCRIPTION_CUSTOM_EXIT_PLAYER = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-exit-player");
FLAG_DESCRIPTION_CUSTOM_EXPLOSION_BLOCK = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-explosion-block");
FLAG_DESCRIPTION_CUSTOM_EXPLOSION_ENTITY = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-explosion-entity");
FLAG_DESCRIPTION_CUSTOM_EXP_DROP = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-exp-drop");
FLAG_DESCRIPTION_CUSTOM_FALL_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-fall-damage");
FLAG_DESCRIPTION_CUSTOM_INTERACT_BLOCK = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-interact-block");
FLAG_DESCRIPTION_CUSTOM_INTERACT_ENTITY = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-interact-entity");
FLAG_DESCRIPTION_CUSTOM_INTERACT_INVENTORY = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-interact-inventory");
FLAG_DESCRIPTION_CUSTOM_INVINCIBLE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-invincible");
FLAG_DESCRIPTION_CUSTOM_ITEM_DROP = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-item-drop");
FLAG_DESCRIPTION_CUSTOM_ITEM_PICKUP = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-item-pickup");
FLAG_DESCRIPTION_CUSTOM_MONSTER_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-monster-damage");
FLAG_DESCRIPTION_CUSTOM_PISTONS = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-pistons");
FLAG_DESCRIPTION_CUSTOM_PORTAL_USE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-portal-use");
FLAG_DESCRIPTION_CUSTOM_SPAWN_AMBIENT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-spawn-ambient");
FLAG_DESCRIPTION_CUSTOM_SPAWN_ANIMAL = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-spawn-animal");
FLAG_DESCRIPTION_CUSTOM_SPAWN_AQUATIC = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-spawn-aquatic");
FLAG_DESCRIPTION_CUSTOM_SPAWN_MONSTER = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-spawn-monster");
FLAG_DESCRIPTION_CUSTOM_TELEPORT_FROM = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-teleport-from");
FLAG_DESCRIPTION_CUSTOM_TELEPORT_TO = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-teleport-to");
FLAG_DESCRIPTION_CUSTOM_USE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-use");
FLAG_DESCRIPTION_CUSTOM_VEHICLE_DESTROY = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-vehicle-destroy");
FLAG_DESCRIPTION_CUSTOM_WITHER_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-wither-damage");
FLAG_DESCRIPTION_CUSTOM_BLOCK_TRAMPLING = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-block-trampling");
FLAG_DESCRIPTION_CUSTOM_CHEST_ACCESS = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-chest-access");
FLAG_DESCRIPTION_CUSTOM_CHORUS_FRUIT_TELEPORT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-chorus-fruit-teleport");
FLAG_DESCRIPTION_CUSTOM_CREEPER_BLOCK_EXPLOSION = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-creeper-block-explosion");
FLAG_DESCRIPTION_CUSTOM_CREEPER_ENTITY_EXPLOSION = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-creeper-entity-explosion");
FLAG_DESCRIPTION_CUSTOM_CROP_GROWTH = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-crop-growth");
FLAG_DESCRIPTION_CUSTOM_DAMAGE_ANIMALS = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-damage-animals");
FLAG_DESCRIPTION_CUSTOM_ENDERMAN_GRIEF = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-enderman-grief");
FLAG_DESCRIPTION_CUSTOM_ENTER_PLAYER = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-enter-player");
FLAG_DESCRIPTION_CUSTOM_EXPLOSION_CREEPER = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-explosion-creeper");
FLAG_DESCRIPTION_CUSTOM_EXPLOSION_TNT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-explosion-tnt");
FLAG_DESCRIPTION_CUSTOM_EXP_DROP = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-exp-drop");
FLAG_DESCRIPTION_CUSTOM_FALL_PLAYER_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-fall-player-damage");
FLAG_DESCRIPTION_CUSTOM_FIRE_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-fire-damage");
FLAG_DESCRIPTION_CUSTOM_FIRE_SPREAD = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-fire-spread");
FLAG_DESCRIPTION_CUSTOM_GRASS_GROWTH = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-grass-growth");
@ -562,10 +538,28 @@ public void loadCache() {
FLAG_DESCRIPTION_CUSTOM_ICE_MELT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-ice-melt");
FLAG_DESCRIPTION_CUSTOM_LAVA_FLOW = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-lava-flow");
FLAG_DESCRIPTION_CUSTOM_LEAF_DECAY = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-leaf-decay");
FLAG_DESCRIPTION_CUSTOM_LIGHTNING = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-lightning");
FLAG_DESCRIPTION_CUSTOM_LIGHTER = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-lighter");
FLAG_DESCRIPTION_CUSTOM_LIGHTNING = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-lightning");
FLAG_DESCRIPTION_CUSTOM_MONSTER_ANIMAL_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-monster-animal-damage");
FLAG_DESCRIPTION_CUSTOM_MONSTER_PLAYER_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-monster-player-damage");
FLAG_DESCRIPTION_CUSTOM_MONSTER_SPAWN = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-monster-spawn");
FLAG_DESCRIPTION_CUSTOM_MUSHROOM_GROWTH = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-mushroom-growth");
FLAG_DESCRIPTION_CUSTOM_MYCELIUM_SPREAD = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-mycelium-spread");
FLAG_DESCRIPTION_CUSTOM_PISTON_USE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-piston-use");
FLAG_DESCRIPTION_CUSTOM_PLAYER_BLOCK_BREAK = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-block-break");
FLAG_DESCRIPTION_CUSTOM_PLAYER_BLOCK_PLACE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-block-place");
FLAG_DESCRIPTION_CUSTOM_PLAYER_BLOCK_INTERACT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-block-interact");
FLAG_DESCRIPTION_CUSTOM_PLAYER_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-damage");
FLAG_DESCRIPTION_CUSTOM_PLAYER_ENDERPEARL_INTERACT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-enderpearl-interact");
FLAG_DESCRIPTION_CUSTOM_PLAYER_ENTER = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-enter");
FLAG_DESCRIPTION_CUSTOM_PLAYER_ENTITY_INTERACT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-entity-interact");
FLAG_DESCRIPTION_CUSTOM_PLAYER_EXIT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-exit");
FLAG_DESCRIPTION_CUSTOM_PLAYER_INVENTORY_INTERACT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-inventory-interact");
FLAG_DESCRIPTION_CUSTOM_PLAYER_ITEM_DROP = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-item-drop");
FLAG_DESCRIPTION_CUSTOM_PLAYER_ITEM_PICKUP = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-item-pickup");
FLAG_DESCRIPTION_CUSTOM_PLAYER_PORTAL_USE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-portal-use");
FLAG_DESCRIPTION_CUSTOM_PLAYER_TELEPORT_FROM = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-teleport-from");
FLAG_DESCRIPTION_CUSTOM_PLAYER_TELEPORT_TO = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-player-teleport-to");
FLAG_DESCRIPTION_CUSTOM_PVP = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-pvp");
FLAG_DESCRIPTION_CUSTOM_RIDE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-ride");
FLAG_DESCRIPTION_CUSTOM_SLEEP = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-sleep");
@ -573,9 +567,17 @@ public void loadCache() {
FLAG_DESCRIPTION_CUSTOM_SNOW_MELT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-snow-melt");
FLAG_DESCRIPTION_CUSTOM_SNOWMAN_TRAIL = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-snowman-trail");
FLAG_DESCRIPTION_CUSTOM_SOIL_DRY = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-soil-dry");
FLAG_DESCRIPTION_CUSTOM_VEHICLE_PLACE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-vehicle-place");
FLAG_DESCRIPTION_CUSTOM_SPAWN_AMBIENT = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-spawn-ambient");
FLAG_DESCRIPTION_CUSTOM_SPAWN_ANIMAL = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-spawn-animal");
FLAG_DESCRIPTION_CUSTOM_SPAWN_AQUATIC = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-spawn-aquatic");
FLAG_DESCRIPTION_CUSTOM_TNT_BLOCK_EXPLOSION = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-tnt-block-explosion");
FLAG_DESCRIPTION_CUSTOM_TNT_ENTITY_EXPLOSION = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-tnt-entity-explosion");
FLAG_DESCRIPTION_CUSTOM_USE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-use");
FLAG_DESCRIPTION_CUSTOM_VEHICLE_USE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-vehicle-use");
FLAG_DESCRIPTION_CUSTOM_VINE_GROWTH = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-vine-growth");
FLAG_DESCRIPTION_CUSTOM_WATER_FLOW = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-water-flow");
FLAG_DESCRIPTION_CUSTOM_WITHER_BLOCK_BREAK = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-wither-block-break");
FLAG_DESCRIPTION_CUSTOM_WITHER_ENTITY_DAMAGE = MessageStorage.MESSAGE_DATA.getMessage("flag-description-custom-wither-entity-damage");
FLAG_DESCRIPTION_BLOCK_BREAK = MessageStorage.MESSAGE_DATA.getMessage("flag-description-block-break");
FLAG_DESCRIPTION_BLOCK_GROW = MessageStorage.MESSAGE_DATA.getMessage("flag-description-block-grow");
FLAG_DESCRIPTION_BLOCK_MODIFY = MessageStorage.MESSAGE_DATA.getMessage("flag-description-block-modify");
@ -634,6 +636,7 @@ public void loadCache() {
LABEL_CONTAINERS = MessageStorage.MESSAGE_DATA.getMessage("label-containers");
LABEL_CONTEXT = MessageStorage.MESSAGE_DATA.getMessage("label-context");
LABEL_CREATED = MessageStorage.MESSAGE_DATA.getMessage("label-created");
LABEL_DEFAULT = MessageStorage.MESSAGE_DATA.getMessage("label-default");
LABEL_DISPLAYING = MessageStorage.MESSAGE_DATA.getMessage("label-displaying");
LABEL_EXPIRED = MessageStorage.MESSAGE_DATA.getMessage("label-expired");
LABEL_FAREWELL = MessageStorage.MESSAGE_DATA.getMessage("label-farewell");

View File

@ -170,7 +170,7 @@ public void execute(Player player, String[] args) throws InvalidCommandArgument
if (claim != null) {
if (flag == null && value == null && player.hasPermission(GDPermissions.COMMAND_LIST_CLAIM_FLAGS)) {
String defaultGroup = "";
for (Entry<String, CustomFlagGroupCategory> groupEntry : GriefDefenderPlugin.getGlobalConfig().getConfig().customFlags.getGroups().entrySet()) {
for (Entry<String, CustomFlagGroupCategory> groupEntry : GriefDefenderPlugin.getInstance().flagConfig.getConfig().customFlags.getGroups().entrySet()) {
final String permission = groupEntry.getValue().isAdminGroup() ? GDPermissions.FLAG_CUSTOM_ADMIN_BASE : GDPermissions.FLAG_CUSTOM_USER_BASE;
if (!player.hasPermission(permission + "." + groupEntry.getKey()) && !src.getInternalPlayerData().canIgnoreClaim(claim)) {
continue;
@ -203,16 +203,16 @@ public void execute(Player player, String[] args) throws InvalidCommandArgument
}
}
protected void showCustomFlags(GDPermissionUser src, GDClaim claim, String displayGroup) {
protected void showCustomFlags(GDPermissionUser src, GDClaim claim, String flagGroup) {
final Player player = src.getOnlinePlayer();
final String lastPermissionMenuType = this.lastActivePresetMenuMap.getIfPresent(player.getUniqueId());
if (lastPermissionMenuType != null && !lastPermissionMenuType.equalsIgnoreCase(displayGroup.toLowerCase())) {
if (lastPermissionMenuType != null && !lastPermissionMenuType.equalsIgnoreCase(flagGroup.toLowerCase())) {
PaginationUtil.getInstance().resetActivePage(player.getUniqueId());
}
TextComponent.Builder flagHeadBuilder = TextComponent.builder()
.append(" Displaying :", TextColor.AQUA);
final Map<String, CustomFlagGroupCategory> flagGroups = GriefDefenderPlugin.getGlobalConfig().getConfig().customFlags.getGroups();
final Map<String, CustomFlagGroupCategory> flagGroups = GriefDefenderPlugin.getInstance().flagConfig.getConfig().customFlags.getGroups();
List<String> groups = new ArrayList<>();
for (Map.Entry<String, CustomFlagGroupCategory> flagGroupEntry : flagGroups.entrySet()) {
final CustomFlagGroupCategory flagGroupCat = flagGroupEntry.getValue();
@ -220,7 +220,7 @@ protected void showCustomFlags(GDPermissionUser src, GDClaim claim, String displ
continue;
}
final String groupName = flagGroupEntry.getKey();
final boolean isAdminGroup = GriefDefenderPlugin.getGlobalConfig().getConfig().customFlags.getGroups().get(groupName).isAdminGroup();
final boolean isAdminGroup = GriefDefenderPlugin.getInstance().flagConfig.getConfig().customFlags.getGroups().get(groupName).isAdminGroup();
final String permission = isAdminGroup ? GDPermissions.FLAG_CUSTOM_ADMIN_BASE : GDPermissions.FLAG_CUSTOM_USER_BASE;
if (!player.hasPermission(permission + "." + groupName) && !src.getInternalPlayerData().canIgnoreClaim(claim)) {
continue;
@ -229,15 +229,15 @@ protected void showCustomFlags(GDPermissionUser src, GDClaim claim, String displ
groups.add(groupName);
}
final CustomFlagGroupCategory flagGroupCat = flagGroups.get(displayGroup);
final CustomFlagGroupCategory flagGroupCat = flagGroups.get(flagGroup);
if (flagGroupCat == null || flagGroupCat.getFlagDefinitions().isEmpty()) {
TextAdapter.sendComponent(player, TextComponent.of("No custom flag definitions were found for group '" + displayGroup + "'."));
TextAdapter.sendComponent(player, TextComponent.of("No custom flag definitions were found for group '" + flagGroup + "'."));
return;
}
Collections.sort(groups);
for (String group : groups) {
flagHeadBuilder.append(" ").append(displayGroup.equalsIgnoreCase(group) ? TextComponent.builder()
flagHeadBuilder.append(" ").append(flagGroup.equalsIgnoreCase(group) ? TextComponent.builder()
.append(whiteOpenBracket)
.append(group.toUpperCase(), flagGroups.get(group).isAdminGroup() ? TextColor.RED : TextColor.GOLD)
.append(whiteCloseBracket).build() :
@ -248,12 +248,14 @@ protected void showCustomFlags(GDPermissionUser src, GDClaim claim, String displ
List<Component> textComponents = new ArrayList<>();
for (GDFlagDefinition customFlag : flagGroupCat.getFlagDefinitions().values()) {
Component flagText = TextComponent.builder()
.append(getCustomFlagText(customFlag))
.append(" ")
.append(this.getCustomClickableText(src, claim, customFlag, displayGroup))
.build();
textComponents.add(flagText);
if (customFlag.isEnabled()) {
Component flagText = TextComponent.builder()
.append(getCustomFlagText(customFlag))
.append(" ")
.append(this.getCustomClickableText(src, claim, customFlag, flagGroup))
.build();
textComponents.add(flagText);
}
}
@ -298,7 +300,7 @@ protected void showCustomFlags(GDPermissionUser src, GDClaim claim, String displ
if (activePage == null) {
activePage = 1;
}
this.lastActivePresetMenuMap.put(player.getUniqueId(), displayGroup.toLowerCase());
this.lastActivePresetMenuMap.put(player.getUniqueId(), flagGroup.toLowerCase());
paginationList.sendTo(player, activePage);
}
@ -543,27 +545,29 @@ private void addFilteredContexts(Map<String, UIFlagData> filteredContextMap, Set
private Component getCustomFlagText(GDFlagDefinition customFlag) {
TextComponent definitionType = TextComponent.empty();
TextColor flagColor = TextColor.YELLOW;
for (Context context : customFlag.getContexts()) {
if (context.getKey().contains("default")) {
definitionType = TextComponent.builder()
.append("\n")
.append(MessageCache.getInstance().LABEL_TYPE.color(TextColor.AQUA))
.append(" : ", TextColor.WHITE)
.append("DEFAULT", TextColor.LIGHT_PURPLE)
.append(" ")
.append(context.getValue().toUpperCase(), TextColor.GRAY)
.build();
flagColor = TextColor.LIGHT_PURPLE;
} else if (context.getKey().contains("override")) {
definitionType = TextComponent.builder()
.append("\n")
.append(MessageCache.getInstance().LABEL_TYPE.color(TextColor.AQUA))
.append(" : ", TextColor.WHITE)
.append("OVERRIDE", TextColor.RED)
.append(" ")
.append(context.getValue().toUpperCase(), TextColor.GRAY)
.build();
flagColor = TextColor.RED;
if (customFlag.isAdmin()) {
for (Context context : customFlag.getContexts()) {
if (context.getKey().contains("default")) {
definitionType = TextComponent.builder()
.append("\n")
.append(MessageCache.getInstance().LABEL_TYPE.color(TextColor.AQUA))
.append(" : ", TextColor.WHITE)
.append("DEFAULT", TextColor.LIGHT_PURPLE)
.append(" ")
.append(context.getValue().toUpperCase(), TextColor.GRAY)
.build();
flagColor = TextColor.LIGHT_PURPLE;
} else if (context.getKey().contains("override")) {
definitionType = TextComponent.builder()
.append("\n")
.append(MessageCache.getInstance().LABEL_TYPE.color(TextColor.AQUA))
.append(" : ", TextColor.WHITE)
.append("OVERRIDE", TextColor.RED)
.append(" ")
.append(context.getValue().toUpperCase(), TextColor.GRAY)
.build();
flagColor = TextColor.RED;
}
}
}
if (definitionType == TextComponent.empty()) {
@ -584,20 +588,6 @@ private Component getCustomFlagText(GDFlagDefinition customFlag) {
return baseFlagText;
}
private TextColor getCustomFlagColor(GDFlagDefinition customFlag) {
TextColor flagColor = TextColor.GREEN;
for (Context context : customFlag.getContexts()) {
if (context.getKey().contains("default")) {
flagColor = TextColor.LIGHT_PURPLE;
break;
} else if (context.getKey().contains("override")) {
flagColor = TextColor.RED;
break;
}
}
return flagColor;
}
private Component getFlagText(Flag flag, Set<Context> contexts) {
boolean customContext = UIHelper.containsCustomContext(contexts);
@ -620,7 +610,7 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
hasHover = true;
}
final boolean isAdminGroup = GriefDefenderPlugin.getGlobalConfig().getConfig().customFlags.getGroups().get(flagGroup).isAdminGroup();
final boolean isAdminGroup = GriefDefenderPlugin.getInstance().flagConfig.getConfig().customFlags.getGroups().get(flagGroup).isAdminGroup();
final String permission = isAdminGroup ? GDPermissions.FLAG_CUSTOM_ADMIN_BASE : GDPermissions.FLAG_CUSTOM_USER_BASE;
// check flag perm
if (!player.hasPermission(permission + "." + flagGroup + "." + customFlag.getName())) {
@ -629,70 +619,42 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
hasHover = true;
}
List<GDActiveFlagData> dataResults = new ArrayList<>();
boolean hasGDContext = false;
final List<GDActiveFlagData> definitionResults = new ArrayList<>();
boolean hasClaimContext = false;
Set<Context> definitionContexts = new HashSet<>(customFlag.getContexts());
for (Context context : customFlag.getContexts()) {
for (Context context : definitionContexts) {
if (context.getKey().contains("gd_claim")) {
hasGDContext = true;
break;
// Admins can set 'gd_claim' context value to 'claim' to represent it should be replaced with each claim UUID
if (context.getValue().equalsIgnoreCase("claim")) {
definitionContexts.remove(context);
hasClaimContext = true;
break;
}
}
}
if (!hasGDContext) {
if (hasClaimContext) {
definitionContexts.add(claim.getContext());
}
boolean hasOverride = false;
for (FlagData flagData : customFlag.getFlagData()) {
final Set<Context> filteredContexts = new HashSet<>();
for (Context context : definitionContexts) {
if (context.getKey().contains("gd_claim")) {
continue;
if (customFlag.isAdmin()) {
definitionResults.add(this.getSpecificDefinitionResult(claim, customFlag, flagData));
} else {
final GDActiveFlagData activeData = this.getActiveDefinitionResult(claim, customFlag, flagData);
definitionResults.add(activeData);
if (activeData.getType() == GDActiveFlagData.Type.OVERRIDE) {
hasOverride = true;
hasEditPermission = false;
}
filteredContexts.add(context);
}
// Check override
filteredContexts.addAll(flagData.getContexts());
Set<Context> newContexts = new HashSet<>(filteredContexts);
newContexts.add(ClaimContexts.GLOBAL_OVERRIDE_CONTEXT);
newContexts.add(claim.getWorldContext());
newContexts.add(claim.getOverrideTypeContext());
newContexts.add(claim.getOverrideClaimContext());
Tristate result = PermissionUtil.getInstance().getPermissionValue(claim, GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), newContexts);
if (result != Tristate.UNDEFINED) {
dataResults.add(new GDActiveFlagData(flagData, result, GDActiveFlagData.Type.OVERRIDE));
continue;
}
// Check claim
newContexts = new HashSet<>(filteredContexts);
newContexts.add(claim.getWorldContext());
newContexts.add(claim.getContext());
result = PermissionUtil.getInstance().getPermissionValue(claim, GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), newContexts);
if (result != Tristate.UNDEFINED) {
dataResults.add(new GDActiveFlagData(flagData, result, GDActiveFlagData.Type.CLAIM));
continue;
}
// Check default
newContexts = new HashSet<>(filteredContexts);
newContexts.add(claim.getWorldContext());
newContexts.add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
newContexts.add(claim.getDefaultTypeContext());
result = PermissionUtil.getInstance().getPermissionValue(claim, GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), newContexts);
if (result != Tristate.UNDEFINED) {
dataResults.add(new GDActiveFlagData(flagData, result, GDActiveFlagData.Type.DEFAULT));
continue;
}
dataResults.add(new GDActiveFlagData(flagData, result, GDActiveFlagData.Type.UNDEFINED));
}
boolean properResult = true;
Tristate lastResult = null;
for (GDActiveFlagData activeFlagData : dataResults) {
final Tristate result = activeFlagData.getValue();
if (lastResult == null) {
lastResult = result;
} else if (lastResult != result) {
Tristate defaultResult = null;
for (GDActiveFlagData definitionFlagData : definitionResults) {
final Tristate result = definitionFlagData.getValue();
if (defaultResult == null) {
defaultResult = result;
} else if (defaultResult != result) {
properResult = false;
break;
}
@ -701,53 +663,108 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
TextComponent.Builder valueBuilder = TextComponent.builder();
if (!properResult) {
if (hasEditPermission) {
hoverBuilder.append("Active Data : \n");
for (GDActiveFlagData activeFlagData : dataResults) {
hoverBuilder.append(activeFlagData.getComponent())
.append("\n");
hoverBuilder.append("Conflict Data : \n");
for (GDActiveFlagData definitionFlagData : definitionResults) {
hoverBuilder.append(definitionFlagData.getComponent())
.append("\n");
}
hasHover = true;
}
valueBuilder.append("partial");
lastResult = null;
defaultResult = null;
} else {
TextColor valueColor = TextColor.GRAY;
if (lastResult == Tristate.TRUE) {
if (defaultResult == Tristate.TRUE) {
valueColor = TextColor.GREEN;
} else if (lastResult == Tristate.FALSE) {
} else if (defaultResult == Tristate.FALSE) {
valueColor = TextColor.RED;
}
valueBuilder.append(String.valueOf(lastResult).toLowerCase(), valueColor);
valueBuilder.append(String.valueOf(defaultResult).toLowerCase(), valueColor);
}
if (hasEditPermission) {
if (lastResult == Tristate.TRUE) {
if (defaultResult == Tristate.TRUE) {
hoverBuilder.append(MessageCache.getInstance().FLAG_UI_CLICK_DENY);
} else {
hoverBuilder.append(MessageCache.getInstance().FLAG_UI_CLICK_ALLOW);
}
if (!customFlag.getContexts().isEmpty()) {
hoverBuilder.append("\nContexts: ");
}
for (Context context : customFlag.getContexts()) {
hoverBuilder.append("\n");
final String key = context.getKey();
final String value = context.getValue();
TextColor keyColor = TextColor.AQUA;
if (key.contains("default")) {
keyColor = TextColor.LIGHT_PURPLE;
} else if (key.contains("override")) {
keyColor = TextColor.RED;
} else if (key.contains("server")) {
keyColor = TextColor.GRAY;
if (properResult) {
hoverBuilder.append("\nDefault Value: ", TextColor.AQUA);
final Tristate defaultValue = customFlag.getDefaultValue();
if (defaultValue == Tristate.UNDEFINED) {
hoverBuilder.append(customFlag.getDefaultValue().toString().toLowerCase(), TextColor.GRAY);
} else if (defaultValue == Tristate.TRUE) {
hoverBuilder.append(customFlag.getDefaultValue().toString().toLowerCase(), TextColor.GREEN);
} else {
hoverBuilder.append(customFlag.getDefaultValue().toString().toLowerCase(), TextColor.RED);
}
hoverBuilder.append(key, keyColor)
if (!customFlag.getContexts().isEmpty()) {
hoverBuilder.append("\nDefinition Contexts: ");
if (!customFlag.isAdmin()) {
hoverBuilder.append("gd_claim", TextColor.AQUA)
.append("=", TextColor.WHITE)
.append(value.replace("minecraft:", ""), TextColor.GRAY);
.append(claim.getUniqueId().toString(), TextColor.GRAY);
}
for (Context context : customFlag.getContexts()) {
if (!customFlag.isAdmin() && context.getKey().contains("gd_claim")) {
continue;
}
hoverBuilder.append("\n");
final String key = context.getKey();
final String value = context.getValue();
TextColor keyColor = TextColor.AQUA;
if (key.contains("default")) {
keyColor = TextColor.LIGHT_PURPLE;
} else if (key.contains("override")) {
keyColor = TextColor.RED;
} else if (key.contains("server")) {
keyColor = TextColor.GRAY;
}
hoverBuilder.append(key, keyColor)
.append("=", TextColor.WHITE)
.append(value.replace("minecraft:", ""), TextColor.GRAY);
}
}
for (FlagData flagData : customFlag.getFlagData()) {
hoverBuilder.append("\nFlag: ")
.append(flagData.getFlag().getName(), TextColor.GREEN);
if (!flagData.getContexts().isEmpty()) {
hoverBuilder.append("\nContexts: ");
}
for (Context context : flagData.getContexts()) {
if (!customFlag.isAdmin() && context.getKey().contains("gd_claim")) {
continue;
}
hoverBuilder.append("\n");
final String key = context.getKey();
final String value = context.getValue();
TextColor keyColor = TextColor.AQUA;
hoverBuilder.append(key, keyColor)
.append("=", TextColor.WHITE)
.append(value.replace("minecraft:", ""), TextColor.GRAY);
}
if (customFlag.isAdmin()) {
// show active value
final GDActiveFlagData activeData = this.getActiveDefinitionResult(claim, customFlag, flagData);
hoverBuilder.append("\n\nActive Result", TextColor.AQUA)
.append("\nvalue=", TextColor.WHITE)
.append(activeData.getValue().name().toLowerCase(), TextColor.GOLD)
.append("\ntype=", TextColor.WHITE)
.append(activeData.getType().name(), activeData.getColor());
}
}
hasHover = true;
}
} else {
if (hasOverride) {
hoverBuilder.append(MessageCache.getInstance().FLAG_UI_OVERRIDE_NO_PERMISSION);
hasHover = true;
}
hasHover = true;
}
if (hasHover) {
@ -757,7 +774,7 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
if (hasEditPermission) {
textBuilder = TextComponent.builder()
.append(valueBuilder
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createCustomFlagConsumer(src, claim, customFlag, lastResult, flagGroup))))
.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createCustomFlagConsumer(src, claim, customFlag, defaultResult, flagGroup))))
.build());
} else {
textBuilder = TextComponent.builder()
@ -768,6 +785,144 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
return textBuilder.build();
}
public GDActiveFlagData getSpecificDefinitionResult(GDClaim claim, GDFlagDefinition flagDefinition, FlagData flagData) {
Set<Context> contexts = new HashSet<>(flagData.getContexts());
contexts.addAll(flagDefinition.getContexts());
boolean hasClaimContext = false;
boolean hasOverrideClaimContext = false;
boolean hasDefaultClaimContext = false;
boolean replaceClaimContext = false;
final Iterator<Context> iterator = contexts.iterator();
while (iterator.hasNext()) {
final Context context = iterator.next();
if (context.getKey().equalsIgnoreCase("gd_claim")) {
hasClaimContext = true;
if (context.getValue().equalsIgnoreCase("claim")) {
iterator.remove();
replaceClaimContext = true;
}
} else if (context.getKey().equalsIgnoreCase("gd_claim_default")) {
hasDefaultClaimContext = true;
} else if (context.getKey().equalsIgnoreCase("gd_claim_override")) {
hasOverrideClaimContext = true;
}
}
GDActiveFlagData.Type type = GDActiveFlagData.Type.DEFAULT;
if (hasClaimContext) {
type = GDActiveFlagData.Type.CLAIM;
} else if (hasOverrideClaimContext) {
type = GDActiveFlagData.Type.OVERRIDE;
}
if (replaceClaimContext || !flagDefinition.isAdmin()) {
contexts.add(claim.getContext());
}
Tristate result = PermissionUtil.getInstance().getPermissionValue(claim, GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), contexts);
if (result != Tristate.UNDEFINED) {
return new GDActiveFlagData(flagDefinition, flagData, result, contexts, type);
}
return new GDActiveFlagData(flagDefinition, flagData, result, contexts, GDActiveFlagData.Type.UNDEFINED);
}
public GDActiveFlagData getActiveDefinitionResult(GDClaim claim, GDFlagDefinition flagDefinition, FlagData flagData) {
Set<Context> contexts = new HashSet<>(flagData.getContexts());
contexts.addAll(flagDefinition.getContexts());
// check if admin definition has gd_claim contex
boolean hasClaimContext = false;
boolean hasOverrideClaimContext = false;
boolean hasDefaultClaimContext = false;
boolean replaceClaimContext = false;
final Iterator<Context> iterator = contexts.iterator();
Context claimContext = claim.getContext();
while (iterator.hasNext()) {
final Context context = iterator.next();
if (!flagDefinition.isAdmin()) {
hasClaimContext = true;
if (context.getKey().contains("gd_claim")) {
iterator.remove();
}
} else {
if (context.getKey().equalsIgnoreCase("gd_claim")) {
claimContext = context;
hasClaimContext = true;
if (context.getValue().equalsIgnoreCase("claim")) {
iterator.remove();
replaceClaimContext = true;
}
} else if (context.getKey().equalsIgnoreCase("gd_claim_default")) {
hasDefaultClaimContext = true;
} else if (context.getKey().equalsIgnoreCase("gd_claim_override")) {
hasOverrideClaimContext = true;
}
}
}
if (!flagDefinition.isAdmin() || hasClaimContext) {
// First check if this permission has been overridden by admin
// Check override
contexts.remove(claimContext);
contexts.add(ClaimContexts.GLOBAL_OVERRIDE_CONTEXT);
contexts.add(claim.getWorldContext());
contexts.add(claim.getOverrideTypeContext());
contexts.add(claim.getOverrideClaimContext());
Tristate result = PermissionUtil.getInstance().getPermissionValue(claim, GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), contexts);
if (result != Tristate.UNDEFINED) {
return new GDActiveFlagData(flagDefinition, flagData, result, contexts, GDActiveFlagData.Type.OVERRIDE);
}
// Check claim
contexts = new HashSet<>(flagData.getContexts());
contexts.addAll(flagDefinition.getContexts());
if (flagDefinition.isAdmin()) {
if (replaceClaimContext) {
contexts.remove(claimContext);
contexts.add(claim.getContext());
} else {
contexts.add(claimContext);
}
} else {
contexts.add(claimContext);
}
result = PermissionUtil.getInstance().getPermissionValue(claim, GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), contexts);
if (result != Tristate.UNDEFINED) {
return new GDActiveFlagData(flagDefinition, flagData, result, contexts, GDActiveFlagData.Type.CLAIM);
}
}
if (!hasClaimContext && !hasOverrideClaimContext) {
// Direct lookup
contexts = new HashSet<>(flagData.getContexts());
contexts.addAll(flagDefinition.getContexts());
Tristate result = PermissionUtil.getInstance().getPermissionValue(claim, GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), contexts);
if (result != Tristate.UNDEFINED) {
return new GDActiveFlagData(flagDefinition, flagData, result, contexts, GDActiveFlagData.Type.DEFAULT);
}
}
if (!hasDefaultClaimContext) {
contexts = new HashSet<>(flagData.getContexts());
contexts.addAll(flagDefinition.getContexts());
contexts.remove(claimContext);
contexts.add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
contexts.add(claim.getWorldContext());
contexts.add(claim.getDefaultTypeContext());
Tristate result = PermissionUtil.getInstance().getPermissionValue(claim, GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), contexts);
if (result != Tristate.UNDEFINED) {
return new GDActiveFlagData(flagDefinition, flagData, result, contexts, GDActiveFlagData.Type.DEFAULT);
}
}
return new GDActiveFlagData(flagDefinition, flagData,Tristate.UNDEFINED, contexts, GDActiveFlagData.Type.UNDEFINED);
}
private Component getClickableText(GDPermissionUser src, GDClaim claim, Flag flag, FlagContextHolder flagHolder, Set<Context> contexts, MenuType displayType) {
Component hoverEventText = TextComponent.empty();
final MenuType flagType = flagHolder.getType();
@ -916,19 +1071,28 @@ public int compare(Context o1, Context o2) {
return textBuilder.build();
}
private Consumer<CommandSource> createCustomFlagConsumer(GDPermissionUser src, GDClaim claim, GDFlagDefinition customFlag, Tristate currentValue, String displayType) {
private Consumer<CommandSource> createCustomFlagConsumer(GDPermissionUser src, GDClaim claim, GDFlagDefinition customFlag, Tristate currentValue, String flagGroup) {
final Player player = src.getOnlinePlayer();
return consumer -> {
GDCauseStackManager.getInstance().pushCause(player);
boolean hasGDContext = false;
Set<Context> definitionContexts = new HashSet<>(customFlag.getContexts());
for (Context context : customFlag.getContexts()) {
if (context.getKey().contains("gd_claim")) {
hasGDContext = true;
boolean addClaimContext = false;
final Iterator<Context> iterator = definitionContexts.iterator();
while (iterator.hasNext()) {
final Context context = iterator.next();
if (!customFlag.isAdmin()) {
if (context.getKey().contains("gd_claim")) {
iterator.remove();
}
addClaimContext = true;
break;
} else if (context.getKey().equalsIgnoreCase("gd_claim") && context.getValue().equalsIgnoreCase("claim")) {
iterator.remove();
addClaimContext = true;
break;
}
}
if (!hasGDContext) {
if (addClaimContext) {
definitionContexts.add(claim.getContext());
}
for (FlagData flagData : customFlag.getFlagData()) {
@ -954,7 +1118,7 @@ private Consumer<CommandSource> createCustomFlagConsumer(GDPermissionUser src, G
// Save after all permission changes have been made
GriefDefenderPlugin.getInstance().getPermissionProvider().save(GriefDefenderPlugin.DEFAULT_HOLDER);
GDCauseStackManager.getInstance().popCause();
showCustomFlags(src, claim, displayType);
showCustomFlags(src, claim, flagGroup);
};
}
@ -963,7 +1127,7 @@ private Consumer<CommandSource> createFlagConsumer(GDPermissionUser src, GDClaim
return consumer -> {
GDCauseStackManager.getInstance().pushCause(player);
Set<Context> newContexts = new HashSet<>(contexts);
if (displayType == MenuType.CLAIM) {
if (displayType == MenuType.CLAIM && newValue != Tristate.UNDEFINED) {
final Iterator<Context> iterator = newContexts.iterator();
while (iterator.hasNext()) {
final Context context = iterator.next();
@ -1001,6 +1165,13 @@ private Consumer<CommandSource> createFlagConsumer(GDPermissionUser src, GDClaim
return;
}
if (displayType == MenuType.DEFAULT) {
PermissionResult result = PermissionUtil.getInstance().setTransientPermission(this.subject, flag.getPermission(), newValue, newContexts);
if (result.successful()) {
showFlagPermissions(src, claim, displayType);
return;
}
}
PermissionResult result = PermissionUtil.getInstance().setPermissionValue(this.subject, flag, newValue, newContexts);
if (!result.successful()) {
// Try again without server context

View File

@ -40,7 +40,7 @@
@CommandPermission(GDPermissions.COMMAND_TOWN_MODE)
public class CommandClaimTown extends BaseCommand {
@CommandAlias("modetown")
@CommandAlias("modetown|townclaims")
@Description("Switches the shovel tool to town claims mode.")
@Subcommand("mode town")
public void execute(Player player) {

View File

@ -319,7 +319,7 @@ private static Consumer<CommandSource> createInputConsumer(Player src, GDClaim c
return consumer -> {
if (messages == null || messages.isEmpty()) {
playerData.commandInputTimestamp = Instant.now();
playerData.trustAddConsumer = createAddConsumer(src, claim, playerData, type, returnCommand);
playerData.commandConsumer = createAddConsumer(src, claim, playerData, type, returnCommand);
}
messages.add(TextComponent.builder()
.append(TextComponent.of("Do you want to add a ")
@ -383,7 +383,7 @@ private static Consumer<CommandSource> createAddConsumer(Player src, GDClaim cla
}
CommandHelper.executeCommand(src, "trust", name + " " + type.getName().toLowerCase());
playerData.commandInputTimestamp = null;
playerData.trustAddConsumer = null;
playerData.commandConsumer = null;
showTrustList(src, claim, playerData, type, messages, returnCommand);
};
}
@ -391,7 +391,7 @@ private static Consumer<CommandSource> createAddConsumer(Player src, GDClaim cla
private static Consumer<CommandSource> createCancelConsumer(Player src, GDClaim claim, GDPlayerData playerData, TrustType type, Component returnCommand) {
return consumer -> {
playerData.commandInputTimestamp = null;
playerData.trustAddConsumer = null;
playerData.commandConsumer = null;
showTrustList(src, claim, playerData, type, new ArrayList<>(), returnCommand);
};
}

View File

@ -0,0 +1,95 @@
/*
* This file is part of GriefDefender, licensed under the MIT License (MIT).
*
* Copyright (c) bloodmc
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.griefdefender.configuration;
import com.griefdefender.GriefDefenderPlugin;
import ninja.leaping.configurate.ConfigurationOptions;
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
import ninja.leaping.configurate.commented.SimpleCommentedConfigurationNode;
import ninja.leaping.configurate.hocon.HoconConfigurationLoader;
import ninja.leaping.configurate.objectmapping.ObjectMapper;
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
public class FlagConfig {
private HoconConfigurationLoader loader;
private CommentedConfigurationNode root = SimpleCommentedConfigurationNode.root(ConfigurationOptions.defaults());
private ObjectMapper<FlagStorage>.BoundInstance configMapper;
private FlagStorage configBase;
@SuppressWarnings({"unchecked", "rawtypes"})
public FlagConfig(Path path) {
try {
if (Files.notExists(path.getParent())) {
Files.createDirectories(path.getParent());
}
if (Files.notExists(path)) {
Files.createFile(path);
}
this.loader = HoconConfigurationLoader.builder().setPath(path).build();
this.configMapper = (ObjectMapper.BoundInstance) ObjectMapper.forClass(FlagStorage.class).bindToNew();
if (reload()) {
save();
}
} catch (Exception e) {
GriefDefenderPlugin.getInstance().getLogger().error("Failed to initialize configuration", e);
}
}
public FlagStorage getConfig() {
return this.configBase;
}
public void save() {
try {
this.configMapper.serialize(this.root.getNode(GriefDefenderPlugin.MOD_ID));
this.loader.save(this.root);
} catch (IOException | ObjectMappingException e) {
GriefDefenderPlugin.getInstance().getLogger().error("Failed to save configuration", e);
}
}
public boolean reload() {
try {
this.root = this.loader.load(ConfigurationOptions.defaults());
this.configBase = this.configMapper.populate(this.root.getNode(GriefDefenderPlugin.MOD_ID));
} catch (Exception e) {
GriefDefenderPlugin.getInstance().getLogger().error("Failed to load configuration", e);
return false;
}
return true;
}
public CommentedConfigurationNode getRootNode() {
return this.root.getNode(GriefDefenderPlugin.MOD_ID);
}
}

View File

@ -0,0 +1,71 @@
/*
* This file is part of GriefDefender, licensed under the MIT License (MIT).
*
* Copyright (c) bloodmc
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.griefdefender.configuration;
import com.griefdefender.configuration.category.ConfigCategory;
import com.griefdefender.configuration.category.CustomFlagGroupDefinitionCategory;
import com.griefdefender.configuration.category.DefaultFlagCategory;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class FlagStorage extends ConfigCategory {
@Setting(value = "default-flags")
public DefaultFlagCategory defaultFlagCategory = new DefaultFlagCategory();
@Setting(value = "custom-flags", comment = "Used to define a group of custom flags for players/admins."
+ "\nEach group defined will be displayed in the flag GUI for users."
+ "\nGroups can have the following settings : "
+ "\n enabled=<true|false>: Whether the group is enabled."
+ "\n admin-group=<true|false>: Whether this group is considered for admin use only."
+ "\n Note: GUI toggles in admin groups will always use configured definition contexts."
+ "\n However, non-admin groups, such as 'user', will always apply to current claim only."
+ "\n Note: If you assign users the permission 'griefdefender.admin.advanced-flags', they will be able to access admin presets within the claim tab."
+ "\n It is recommended not to assign this permission to users for best experience."
+ "\n hover=<text>: The hover text to be displayed when hovering over group name in GUI."
+ "\n title=<text>: The title text to be used for TAB display."
+ "\n value=<true|false>: This is used to set a default value for the flag definition. It is only used in conjunction with 'override=<type>, default=<type> settings."
+ "\n contexts=[\"key=value\"]: A list of definition contexts that will be applied to all permissions."
+ "\nNote: This is primary used with 'default' and 'override' contexts. Ex. contexts=[\"default=global\"]"
+ "\nNote: You must specify one of the following contexts :'gd_claim_default=<type>' , 'gd_claim_override=<type>', or 'gd_claim=claim'"
+ "\nEach group will have an associated permission in order to be viewable."
+ "\nThe 'user' group will use the permission : 'griefdefender.custom.flag.group.user'"
+ "\nThe 'admin' group will use the permission : 'griefdefender.custom.flag.group.admin'"
+ "\nWithin each group, you can define flag definitions."
+ "\nEach flag definition must be defined in the following format:"
+ "\nenabled: Controls whether the definition is enabled. Accepts a value of 'true' or 'false'"
+ "\ndefault-value: The default value to assign flag definition."
+ "\ndescription: The flag description to display on hover. Uses the legacy text format."
+ "\npermissions: The list of permissions to link to definition. Each permission accepts the following contexts :"
+ "\n flag=<linked-flag>: This context is used to link the permission to a GD specific flag. Ex. 'flag=block-break' would link permission to GD's block-break flag"
+ "\n source=<id>: This context is used to specify a source id such as 'minecraft:creeper'."
+ "\n target=<id>: This context is used to specify a target id such as 'minecraft:chest'."
+ "\n state=<properties>: This context is used to specify a blockstate property such as 'state=lit:true'."
+ "\nNote: All flag definitions that contain a definition context of 'gd_claim_default' or 'gd_claim_override' will be applied to permissions during server startup."
+ "\nNote: Required if no source or target context is specified, the permission will default to ALL."
+ "\nNote: Available contexts are : flag, source, target, state, used_item, item_name"
+ "\nThese contexts may change, See https://github.com/bloodmc/GriefDefender/wiki for latest information.")
public CustomFlagGroupDefinitionCategory customFlags = new CustomFlagGroupDefinitionCategory();
}

View File

@ -100,8 +100,7 @@ public GriefDefenderConfig(Class<T> clazz, Path path, GriefDefenderConfig<?> par
save();
}
} catch (Exception e) {
GriefDefenderPlugin.getInstance().getLogger().error("Failed to load configuration at path " + path.toAbsolutePath());
e.printStackTrace();
GriefDefenderPlugin.getInstance().getLogger().error("Failed to load configuration at path " + path.toAbsolutePath(), e);
}
}
@ -133,8 +132,7 @@ public boolean save() {
}
return true;
} catch (IOException | ObjectMappingException e) {
GriefDefenderPlugin.getInstance().getLogger().error("Failed to save configuration");
e.printStackTrace();
GriefDefenderPlugin.getInstance().getLogger().error("Failed to save configuration", e);
return false;
}
}

View File

@ -0,0 +1,95 @@
/*
* This file is part of GriefDefender, licensed under the MIT License (MIT).
*
* Copyright (c) bloodmc
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.griefdefender.configuration;
import com.griefdefender.GriefDefenderPlugin;
import ninja.leaping.configurate.ConfigurationOptions;
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
import ninja.leaping.configurate.commented.SimpleCommentedConfigurationNode;
import ninja.leaping.configurate.hocon.HoconConfigurationLoader;
import ninja.leaping.configurate.objectmapping.ObjectMapper;
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
public class OptionConfig {
private HoconConfigurationLoader loader;
private CommentedConfigurationNode root = SimpleCommentedConfigurationNode.root(ConfigurationOptions.defaults());
private ObjectMapper<OptionStorage>.BoundInstance configMapper;
private OptionStorage configBase;
@SuppressWarnings({"unchecked", "rawtypes"})
public OptionConfig(Path path) {
try {
if (Files.notExists(path.getParent())) {
Files.createDirectories(path.getParent());
}
if (Files.notExists(path)) {
Files.createFile(path);
}
this.loader = HoconConfigurationLoader.builder().setPath(path).build();
this.configMapper = (ObjectMapper.BoundInstance) ObjectMapper.forClass(OptionStorage.class).bindToNew();
if (reload()) {
save();
}
} catch (Exception e) {
GriefDefenderPlugin.getInstance().getLogger().error("Failed to initialize configuration", e);
}
}
public OptionStorage getConfig() {
return this.configBase;
}
public void save() {
try {
this.configMapper.serialize(this.root.getNode(GriefDefenderPlugin.MOD_ID));
this.loader.save(this.root);
} catch (IOException | ObjectMappingException e) {
GriefDefenderPlugin.getInstance().getLogger().error("Failed to save configuration", e);
}
}
public boolean reload() {
try {
this.root = this.loader.load(ConfigurationOptions.defaults());
this.configBase = this.configMapper.populate(this.root.getNode(GriefDefenderPlugin.MOD_ID));
} catch (Exception e) {
GriefDefenderPlugin.getInstance().getLogger().error("Failed to load configuration", e);
return false;
}
return true;
}
public CommentedConfigurationNode getRootNode() {
return this.root.getNode(GriefDefenderPlugin.MOD_ID);
}
}

View File

@ -0,0 +1,37 @@
/*
* This file is part of GriefDefender, licensed under the MIT License (MIT).
*
* Copyright (c) bloodmc
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.griefdefender.configuration;
import com.griefdefender.configuration.category.ConfigCategory;
import com.griefdefender.configuration.category.DefaultOptionCategory;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class OptionStorage extends ConfigCategory {
@Setting(value = "default-options")
public DefaultOptionCategory defaultOptionCategory = new DefaultOptionCategory();
}

View File

@ -59,7 +59,7 @@ public class ClaimCategory extends ConfigCategory {
comment = "Whether claiming is enabled or not. (0 = Disabled, 1 = Enabled)")
public int claimsEnabled = 1;
@Setting(value = "protect-tamed-entities", comment = "Whether tamed entities should be protected in claims. Default: true")
public boolean protectedTamedEntities = true;
public boolean protectTamedEntities = true;
@Setting(value = "reserved-claim-names", comment = "A list of reserved claim names for use only by administrators."
+ "\nNote: Names support wildcards '?' and '*' by using Apache's wildcard matcher."
+ "\nThe wildcard '?' represents a single character."

View File

@ -37,7 +37,7 @@
@ConfigSerializable
public class CustomFlagGroupCategory extends ConfigCategory {
@Setting
@Setting(value = "enabled", comment = "Whether flag definition group is enabled.")
boolean enabled = true;
@Setting(value = "admin-group", comment = "Set to true if this flag group is for admin use only."
+ "\nNote: If admin group, the permission is 'griefdefender.admin.custom.flag.<groupname>"

View File

@ -25,11 +25,17 @@
package com.griefdefender.configuration.category;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.permission.Context;
import com.griefdefender.api.permission.flag.FlagData;
import com.griefdefender.api.permission.flag.FlagDefinition;
import com.griefdefender.permission.flag.GDFlagDefinition;
import com.griefdefender.permission.flag.GDFlagDefinitions;
import com.griefdefender.registry.FlagDefinitionRegistryModule;
import com.griefdefender.util.PermissionUtil;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ -50,8 +56,10 @@ public void initDefaults() {
userGroup = new CustomFlagGroupCategory();
}
if (userGroup.isEnabled() && userGroup.getFlagDefinitions().isEmpty()) {
for (GDFlagDefinition definition : GDFlagDefinitions.USER_FLAGS) {
userGroup.getFlagDefinitions().put(definition.getName(), definition);
for (FlagDefinition definition : FlagDefinitionRegistryModule.getInstance().getAll()) {
if (definition.getGroupName().equalsIgnoreCase("user")) {
userGroup.getFlagDefinitions().put(definition.getName(), (GDFlagDefinition) definition);
}
}
this.groups.put("user", userGroup);
}
@ -59,11 +67,47 @@ public void initDefaults() {
adminGroup = new CustomFlagGroupCategory();
}
if (adminGroup.isEnabled() && adminGroup.getFlagDefinitions().isEmpty()) {
for (GDFlagDefinition definition : GDFlagDefinitions.ADMIN_FLAGS) {
adminGroup.getFlagDefinitions().put(definition.getName(), definition);
for (FlagDefinition definition : FlagDefinitionRegistryModule.getInstance().getAll()) {
if (definition.getGroupName().equalsIgnoreCase("admin")) {
adminGroup.getFlagDefinitions().put(definition.getName(), (GDFlagDefinition) definition);
}
}
adminGroup.isAdmin = true;
this.groups.put("admin", adminGroup);
}
for (CustomFlagGroupCategory group : this.groups.values()) {
if (!group.isEnabled()) {
continue;
}
for (FlagDefinition flagDefinition : group.definitions.values()) {
if (!flagDefinition.isEnabled()) {
continue;
}
Set<Context> contexts = new HashSet<>(flagDefinition.getContexts());
for (FlagData flagData : flagDefinition.getFlagData()) {
Set<Context> permissionContexts = new HashSet<>(contexts);
permissionContexts.addAll(flagData.getContexts());
boolean shouldApply = false;
boolean isOverride = false;
for (Context context : permissionContexts) {
if (context.getKey().equalsIgnoreCase("gd_claim_default")) {
shouldApply = true;
break;
} else if (context.getKey().equalsIgnoreCase("gd_claim_override")) {
shouldApply = true;
isOverride = true;
}
}
if (shouldApply) {
if (isOverride) {
PermissionUtil.getInstance().setPermissionValue(GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), flagDefinition.getDefaultValue(), permissionContexts);
} else {
PermissionUtil.getInstance().setTransientPermission(GriefDefenderPlugin.DEFAULT_HOLDER, flagData.getFlag().getPermission(), flagDefinition.getDefaultValue(), permissionContexts);
}
}
}
}
}
}
}

View File

@ -0,0 +1,85 @@
/*
* This file is part of GriefDefender, licensed under the MIT License (MIT).
*
* Copyright (c) bloodmc
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.griefdefender.configuration.category;
import com.google.common.collect.Maps;
import com.griefdefender.api.claim.ClaimType;
import com.griefdefender.api.claim.ClaimTypes;
import com.griefdefender.api.permission.flag.Flag;
import com.griefdefender.registry.ClaimTypeRegistryModule;
import com.griefdefender.registry.FlagRegistryModule;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import java.util.HashMap;
import java.util.Map;
@ConfigSerializable
public class DefaultFlagCategory extends ConfigCategory {
@Setting(value = "default-claim-flags", comment = "The default flag settings used by claims. The group name represents the claim type."
+ "\nEx: The group admin will ONLY affect admin claims."
+ "\nSupported groups are : global, admin, basic, subdivision, town, and wilderness."
+ "\nNote: Global represents all claim types."
+ "\nNote: Specific types, such as wilderness, have higher priority than global."
+ "\nNote: Defaults do not force flags onto user claims. A newly created claim will have no flags set and use these default settings until a claim owner sets flags.")
private Map<String, Map<String, Boolean>> defaultClaimFlags = Maps.newHashMap();
public DefaultFlagCategory() {
Map<String, Boolean> globalFlagMap = new HashMap<>();
for (Flag flag : FlagRegistryModule.getInstance().getAll()) {
globalFlagMap.put(flag.getName(), flag.getDefaultClaimTypeValue(null));
}
this.defaultClaimFlags.put("global", globalFlagMap);
Map<String, Boolean> wildernessFlagMap = new HashMap<>();
for (Flag flag : FlagRegistryModule.getInstance().getAll()) {
wildernessFlagMap.put(flag.getName(), flag.getDefaultClaimTypeValue(ClaimTypes.WILDERNESS));
}
this.defaultClaimFlags.put(ClaimTypes.WILDERNESS.getName().toLowerCase(), wildernessFlagMap);
}
public void refreshFlags() {
for (ClaimType type : ClaimTypeRegistryModule.getInstance().getAll()) {
final Map<String, Boolean> flagTypeMap = this.defaultClaimFlags.get(type.getName().toLowerCase());
if (flagTypeMap != null) {
for (Flag flag : FlagRegistryModule.getInstance().getAll()) {
if (!flagTypeMap.containsKey(flag.getName())) {
flagTypeMap.put(flag.getName(), flag.getDefaultClaimTypeValue(type));
}
}
}
}
final Map<String, Boolean> globalFlagMap = this.defaultClaimFlags.get("global");
for (Flag flag : FlagRegistryModule.getInstance().getAll()) {
if (!globalFlagMap.containsKey(flag.getName())) {
globalFlagMap.put(flag.getName(), flag.getDefaultClaimTypeValue(null));
}
}
}
public Map<String, Boolean> getFlagDefaults(String type) {
return this.defaultClaimFlags.get(type.toLowerCase());
}
}

View File

@ -24,15 +24,9 @@
*/
package com.griefdefender.configuration.category;
import com.google.common.collect.Maps;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.claim.ClaimBlockSystem;
import com.griefdefender.api.claim.ClaimType;
import com.griefdefender.api.claim.ClaimTypes;
import com.griefdefender.api.permission.flag.Flag;
import com.griefdefender.api.permission.option.Options;
import com.griefdefender.registry.ClaimTypeRegistryModule;
import com.griefdefender.registry.FlagRegistryModule;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ -40,15 +34,7 @@
import java.util.Map;
@ConfigSerializable
public class DefaultPermissionCategory extends ConfigCategory {
@Setting(value = "default-claim-flags", comment = "The default flag settings used by claims. The group name represents the claim type."
+ "\nEx: The group admin will ONLY affect admin claims."
+ "\nSupported groups are : global, admin, basic, subdivision, town, and wilderness."
+ "\nNote: Global represents all claim types."
+ "\nNote: Specific types, such as wilderness, have higher priority than global."
+ "\nNote: Defaults do not force flags onto user claims. A newly created claim will have no flags set and use these default settings until a claim owner sets flags.")
private Map<String, Map<String, Boolean>> defaultClaimFlags = Maps.newHashMap();
public class DefaultOptionCategory extends ConfigCategory {
@Setting(value = "default-user-options", comment = "The default user options for all players.\nNote: Setting default claim type options will override this.")
private Map<String, String> defaultUserOptions = new HashMap<>();
@ -62,18 +48,7 @@ public class DefaultPermissionCategory extends ConfigCategory {
@Setting(value = "default-user-town-options", comment = "The default options applied to users for towns.\nNote: These options override default global options.")
private Map<String, String> defaultTownOptions = new HashMap<>();
public DefaultPermissionCategory() {
Map<String, Boolean> globalFlagMap = new HashMap<>();
for (Flag flag : FlagRegistryModule.getInstance().getAll()) {
globalFlagMap.put(flag.getName(), flag.getDefaultClaimTypeValue(null));
}
this.defaultClaimFlags.put("global", globalFlagMap);
Map<String, Boolean> wildernessFlagMap = new HashMap<>();
for (Flag flag : FlagRegistryModule.getInstance().getAll()) {
wildernessFlagMap.put(flag.getName(), flag.getDefaultClaimTypeValue(ClaimTypes.WILDERNESS));
}
this.defaultClaimFlags.put(ClaimTypes.WILDERNESS.getName().toLowerCase(), wildernessFlagMap);
public DefaultOptionCategory() {
final int maxAccruedBlocks = GriefDefenderPlugin.CLAIM_BLOCK_SYSTEM == ClaimBlockSystem.VOLUME ? 20480000 : 80000;
this.defaultUserOptions.put(Options.ABANDON_DELAY.getName(), "0");
this.defaultUserOptions.put(Options.ABANDON_RETURN_RATIO.getName(), "1.0");
@ -170,29 +145,6 @@ public void checkOptions() {
}
}
public void refreshFlags() {
for (ClaimType type : ClaimTypeRegistryModule.getInstance().getAll()) {
final Map<String, Boolean> flagTypeMap = this.defaultClaimFlags.get(type.getName().toLowerCase());
if (flagTypeMap != null) {
for (Flag flag : FlagRegistryModule.getInstance().getAll()) {
if (!flagTypeMap.containsKey(flag.getName())) {
flagTypeMap.put(flag.getName(), flag.getDefaultClaimTypeValue(type));
}
}
}
}
final Map<String, Boolean> globalFlagMap = this.defaultClaimFlags.get("global");
for (Flag flag : FlagRegistryModule.getInstance().getAll()) {
if (!globalFlagMap.containsKey(flag.getName())) {
globalFlagMap.put(flag.getName(), flag.getDefaultClaimTypeValue(null));
}
}
}
public Map<String, Boolean> getFlagDefaults(String type) {
return this.defaultClaimFlags.get(type.toLowerCase());
}
public Map<String, String> getBasicOptionDefaults() {
return this.defaultBasicOptions;
}

View File

@ -1,64 +0,0 @@
/*
* This file is part of GriefDefender, licensed under the MIT License (MIT).
*
* Copyright (c) bloodmc
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.griefdefender.configuration.category;
import com.griefdefender.api.permission.option.Options;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import java.util.ArrayList;
import java.util.List;
@ConfigSerializable
public class OptionCategory extends ConfigCategory {
@Setting(value = "user-town-options", comment = "A list of options standard users can manage in their towns with the /co commands.")
private List<String> userTownOptions = new ArrayList<>();
public OptionCategory() {
this.userTownOptions.add(Options.ABANDON_RETURN_RATIO.toString());
this.userTownOptions.add(Options.BLOCKS_ACCRUED_PER_HOUR.toString());
this.userTownOptions.add(Options.EXPIRATION.toString());
this.userTownOptions.add(Options.CREATE_LIMIT.toString());
this.userTownOptions.add(Options.EXPIRATION.toString());
this.userTownOptions.add(Options.INITIAL_BLOCKS.toString());
this.userTownOptions.add(Options.MAX_ACCRUED_BLOCKS.toString());
this.userTownOptions.add(Options.MAX_LEVEL.toString());
this.userTownOptions.add(Options.MAX_SIZE_X.toString());
this.userTownOptions.add(Options.MAX_SIZE_Y.toString());
this.userTownOptions.add(Options.MAX_SIZE_Z.toString());
this.userTownOptions.add(Options.MIN_LEVEL.toString());
this.userTownOptions.add(Options.MIN_SIZE_X.toString());
this.userTownOptions.add(Options.MIN_SIZE_Y.toString());
this.userTownOptions.add(Options.MIN_SIZE_Z.toString());
this.userTownOptions.add(Options.TAX_EXPIRATION.toString());
this.userTownOptions.add(Options.TAX_EXPIRATION_DAYS_KEEP.toString());
this.userTownOptions.add(Options.TAX_RATE.toString());
}
public List<String> getUserTownOptions() {
return this.userTownOptions;
}
}

View File

@ -31,6 +31,7 @@
import java.util.UUID;
import com.google.common.reflect.TypeToken;
import com.griefdefender.api.Tristate;
import com.griefdefender.api.permission.Context;
import com.griefdefender.api.permission.ContextKeys;
import com.griefdefender.api.permission.flag.Flag;
@ -39,7 +40,6 @@
import com.griefdefender.permission.flag.GDFlagData;
import com.griefdefender.permission.flag.GDFlagDefinition;
import com.griefdefender.registry.FlagRegistryModule;
import com.griefdefender.util.PermissionUtil;
import net.kyori.text.Component;
import net.kyori.text.TextComponent;
import net.kyori.text.serializer.legacy.LegacyComponentSerializer;
@ -53,13 +53,22 @@ public class FlagDefinitionSerializer implements TypeSerializer<FlagDefinition>
public FlagDefinition deserialize(TypeToken<?> type, ConfigurationNode node) throws ObjectMappingException {
final String flagDisplayName = node.getKey().toString();
final boolean enabled = node.getNode("enabled").getBoolean();
final boolean adminGroup = node.getParent().getParent().getNode("admin-group").getBoolean();
final String groupName = (String) node.getParent().getParent().getKey();
final String descr = node.getNode("description").getString();
Component description = TextComponent.empty();
if (descr != null) {
description = LegacyComponentSerializer.legacy().deserialize(descr, '&');
}
if (node.getNode("default-value").isVirtual()) {
throw new ObjectMappingException("No 'default-value' found for flag definition '" + flagDisplayName + "' in group '" + groupName + "'. A default value is required and needs to be set to either 'true' or 'false'.");
}
final boolean defaultValue = node.getNode("default-value").getBoolean();
List<String> contextList = node.getNode("contexts").getList(TypeToken.of(String.class));
if (adminGroup && (contextList == null || contextList.isEmpty())) {
throw new ObjectMappingException("No contexts found for admin flag definition '" + flagDisplayName + "' in group '" + groupName + "'. You must specify one of the following contexts :'gd_claim_default=<type>' , 'gd_claim_override=<type>', or 'gd_claim=claim'.");
}
List<String> permissionList = node.getNode("permissions").getList(TypeToken.of(String.class));
if (permissionList == null) {
throw new ObjectMappingException("No permissions found for flag definition '" + flagDisplayName + "'. You must specify at least 1 or more permissions.");
@ -94,11 +103,15 @@ public FlagDefinition deserialize(TypeToken<?> type, ConfigurationNode node) thr
break;
case "used_item":
case "item_name":
case ContextKeys.CLAIM_DEFAULT:
case ContextKeys.CLAIM_OVERRIDE:
case ContextKeys.STATE:
flagContexts.add(new Context(key, value));
break;
case "server":
case "world":
case ContextKeys.CLAIM_DEFAULT:
case ContextKeys.CLAIM_OVERRIDE:
// gd_claim contexts should always be set at the definition level
throw new ObjectMappingException("Invalid context '" + key + "' with value '" + value + "'.\nContext '" + key + "' can only be used for the definition.");
default:
throw new ObjectMappingException("Invalid context '" + key + "' with value '" + value + "'.");
}
@ -108,10 +121,10 @@ public FlagDefinition deserialize(TypeToken<?> type, ConfigurationNode node) thr
throw new ObjectMappingException("No linked flag specified. You need to specify 'flag=<flagname>'.");
}
flagDataList.add(new GDFlagData(linkedFlag, flagContexts));
final GDFlagData flagData = new GDFlagData(linkedFlag, flagContexts);
flagDataList.add(flagData);
}
final GDFlagDefinition flagDefinition = new GDFlagDefinition(flagDataList, flagDisplayName, description);
flagDefinition.setIsEnabled(enabled);
Set<Context> contexts = new HashSet<>();
if (contextList != null) {
for (String context : contextList) {
@ -146,25 +159,18 @@ public FlagDefinition deserialize(TypeToken<?> type, ConfigurationNode node) thr
contexts.add(new Context(key, value));
}
}
boolean hasServerContext = false;
for (Context context : contexts) {
if (context.getKey().equalsIgnoreCase("server")) {
hasServerContext = true;
break;
}
}
if (!hasServerContext) {
final String serverName = PermissionUtil.getInstance().getServerName() == null ? "global" : PermissionUtil.getInstance().getServerName();
contexts.add(new Context("server", serverName));
}
flagDefinition.setContexts(contexts);
}
final GDFlagDefinition flagDefinition = new GDFlagDefinition(flagDataList, flagDisplayName, description, groupName, adminGroup, contexts);
flagDefinition.setIsEnabled(enabled);
flagDefinition.setDefaultValue(Tristate.fromBoolean(defaultValue));
return flagDefinition;
}
@Override
public void serialize(TypeToken<?> type, FlagDefinition obj, ConfigurationNode node) throws ObjectMappingException {
node.getNode("enabled").setValue(obj.isEnabled());
node.getNode("default-value").setValue(obj.getDefaultValue().asBoolean());
String description = "";
if (obj.getDescription() != TextComponent.empty()) {
description = LegacyComponentSerializer.legacy().serialize((Component) obj.getDescription(), '&');

View File

@ -27,7 +27,6 @@
import com.griefdefender.configuration.category.BanCategory;
import com.griefdefender.configuration.category.BlacklistCategory;
import com.griefdefender.configuration.category.ClaimCategory;
import com.griefdefender.configuration.category.OptionCategory;
import com.griefdefender.configuration.category.TownCategory;
import com.griefdefender.configuration.category.VisualCategory;
@ -52,9 +51,6 @@ public class ConfigBase {
@Setting
public ClaimCategory claim = new ClaimCategory();
@Setting
public OptionCategory options = new OptionCategory();
@Setting
public TownCategory town = new TownCategory();

View File

@ -25,8 +25,6 @@
package com.griefdefender.configuration.type;
import com.griefdefender.configuration.category.GuiCategory;
import com.griefdefender.configuration.category.CustomFlagGroupDefinitionCategory;
import com.griefdefender.configuration.category.DefaultPermissionCategory;
import com.griefdefender.configuration.category.DynmapCategory;
import com.griefdefender.configuration.category.EconomyCategory;
import com.griefdefender.configuration.category.MessageCategory;
@ -39,32 +37,6 @@
public class GlobalConfig extends ConfigBase {
@Setting(value = "custom-flags", comment = "Used to define a group of custom flags for players/admins."
+ "\nEach group defined will be displayed in the flag GUI for users."
+ "\nGroups can have the following settings : "
+ "\n enabled=<true|false>: Whether the group is enabled."
+ "\n admin-group=<true|false>: Whether this group is considered for admin use only."
+ "\n hover=<text>: The hover text to be displayed when hovering over group name in GUI."
+ "\n title=<text>: The title text to be used for TAB display."
+ "\n value=<true|false>: This is used to set a default value for the flag definition. It is only used in conjunction with 'override=<type>, default=<type> settings."
+ "\n contexts=[\"key=value\"]: A list of optional definition contexts that will be applied to all permissions."
+ "\nNote: This is primary used with 'default' and 'override' contexts. Ex. contexts=[\"default=global\"]"
+ "\nEach group will have an associated permission in order to be viewable."
+ "\nThe 'user' group will use the permission : 'griefdefender.custom.flag.group.user'"
+ "\nThe 'admin' group will use the permission : 'griefdefender.custom.flag.group.admin'"
+ "\nWithin each group, you can define flag definitions."
+ "\nEach flag definition must be defined in the following format:"
+ "\nenabled: Controls whether the definition is enabled. Accepts a value of 'true' or 'false'"
+ "\ndescription: The flag description to display on hover. Uses the legacy text format."
+ "\npermissions: The list of permissions to link to definition. Each permission accepts the following contexts :"
+ "\n flag=<linked-flag>: This context is used to link the permission to a GD specific flag. Ex. 'flag=block-break' would link permission to GD's block-break flag"
+ "\n source=<id>: This context is used to specify a source id such as 'minecraft:creeper'."
+ "\n target=<id>: This context is used to specify a target id such as 'minecraft:chest'."
+ "\n state=<properties>: This context is used to specify a blockstate property such as 'state=lit:true'."
+ "\nNote: Required if no source or target context is specified, the permission will default to ALL."
+ "\nNote: Available contexts are : flag, source, target, state, used_item, item_name"
+ "\nThese contexts may change, See https://github.com/bloodmc/GriefDefender/wiki for latest information.")
public CustomFlagGroupDefinitionCategory customFlags = new CustomFlagGroupDefinitionCategory();
@Setting
public DynmapCategory dynmap = new DynmapCategory();
@Setting
@ -81,8 +53,6 @@ public class GlobalConfig extends ConfigBase {
public MigratorCategory migrator = new MigratorCategory();
@Setting(value = "modules")
public ModuleCategory modules = new ModuleCategory();
@Setting(value = "default-permissions")
public DefaultPermissionCategory permissionCategory = new DefaultPermissionCategory();
@Setting
public ThreadCategory thread = new ThreadCategory();

View File

@ -227,20 +227,20 @@ public void onBlockPre(ChangeBlockEvent.Pre event) {
// If a player successfully interacted with a block recently such as a pressure plate, ignore check
// This fixes issues such as pistons not being able to extend
if (user != null && !isForgePlayerBreak && playerData != null && playerData.eventResultCache != null && playerData.eventResultCache.checkEventResultCache(targetClaim, "block-pre") == Tristate.TRUE) {
GDPermissionManager.getInstance().addEventLogEntry(event, location, source, blockState, user, Flags.BLOCK_BREAK, playerData.eventResultCache.lastTrust, Tristate.TRUE);
GDPermissionManager.getInstance().addEventLogEntry(event, targetClaim, location, source, blockState, user, Flags.BLOCK_BREAK, playerData.eventResultCache.lastTrust, Tristate.TRUE);
continue;
}
if (user != null && targetClaim.isUserTrusted(user, TrustTypes.BUILDER)) {
GDPermissionManager.getInstance().addEventLogEntry(event, location, source, blockState, user, Flags.BLOCK_BREAK, TrustTypes.BUILDER.getName().toLowerCase(), Tristate.TRUE);
GDPermissionManager.getInstance().addEventLogEntry(event, targetClaim, location, source, blockState, user, Flags.BLOCK_BREAK, TrustTypes.BUILDER.getName().toLowerCase(), Tristate.TRUE);
continue;
}
if (sourceClaim.getOwnerUniqueId().equals(targetClaim.getOwnerUniqueId()) && user == null && sourceEntity == null && !isFireSource && !isLeafDecay) {
GDPermissionManager.getInstance().addEventLogEntry(event, location, source, blockState, user, Flags.BLOCK_BREAK, "owner", Tristate.TRUE);
GDPermissionManager.getInstance().addEventLogEntry(event, targetClaim, location, source, blockState, user, Flags.BLOCK_BREAK, "owner", Tristate.TRUE);
continue;
}
if (user != null && pistonExtend) {
if (targetClaim.isUserTrusted(user, TrustTypes.ACCESSOR)) {
GDPermissionManager.getInstance().addEventLogEntry(event, location, source, blockState, user, Flags.BLOCK_BREAK, TrustTypes.ACCESSOR.getName().toLowerCase(), Tristate.TRUE);
GDPermissionManager.getInstance().addEventLogEntry(event, targetClaim, location, source, blockState, user, Flags.BLOCK_BREAK, TrustTypes.ACCESSOR.getName().toLowerCase(), Tristate.TRUE);
continue;
}
}
@ -289,11 +289,11 @@ public void onBlockPre(ChangeBlockEvent.Pre event) {
// If a player successfully interacted with a block recently such as a pressure plate, ignore check
// This fixes issues such as pistons not being able to extend
if (!isForgePlayerBreak && playerData != null && playerData.eventResultCache != null && playerData.eventResultCache.checkEventResultCache(targetClaim, "block-pre") == Tristate.TRUE) {
GDPermissionManager.getInstance().addEventLogEntry(event, location, source, blockState, user, Flags.BLOCK_BREAK, playerData.eventResultCache.lastTrust, Tristate.TRUE);
GDPermissionManager.getInstance().addEventLogEntry(event, targetClaim, location, source, blockState, user, Flags.BLOCK_BREAK, playerData.eventResultCache.lastTrust, Tristate.TRUE);
continue;
}
if (targetClaim.isUserTrusted(user, TrustTypes.BUILDER)) {
GDPermissionManager.getInstance().addEventLogEntry(event, location, source, blockState, user, Flags.BLOCK_BREAK, TrustTypes.BUILDER.getName().toLowerCase(), Tristate.TRUE);
GDPermissionManager.getInstance().addEventLogEntry(event, targetClaim, location, source, blockState, user, Flags.BLOCK_BREAK, TrustTypes.BUILDER.getName().toLowerCase(), Tristate.TRUE);
continue;
}

View File

@ -330,7 +330,7 @@ public boolean onEntityMove(MoveEntityEvent event, Location<World> fromLocation,
}
if (player != null) {
if (GDFlags.ENTITY_RIDING && onMount) {
if (GDFlags.ENTITY_RIDING && onMount) {
if (GDPermissionManager.getInstance().getFinalPermission(event, targetEntity.getLocation(), toClaim, Flags.ENTITY_RIDING, player, targetEntity, player, TrustTypes.ACCESSOR, true) == Tristate.FALSE) {
event.setCancelled(true);
Location<World> safeLocation = Sponge.getGame().getTeleportHelper()

View File

@ -470,7 +470,7 @@ public boolean protectEntity(Event event, Entity targetEntity, Cause cause, Dama
return false;
}
// If pet protection is enabled, deny the interaction
if (GriefDefenderPlugin.getActiveConfig(player.getWorld().getProperties()).getConfig().claim.protectedTamedEntities) {
if (GriefDefenderPlugin.getActiveConfig(player.getWorld().getProperties()).getConfig().claim.protectTamedEntities) {
final GDPermissionUser owner = PermissionHolderCache.getInstance().getOrCreateUser(ownerID);
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.CLAIM_PROTECTED_ENTITY,
ImmutableMap.of(
@ -962,21 +962,21 @@ private boolean getPvpProtectResult(Event event, GDClaim claim, GDPermissionUser
if (sourceInCombat && targetInCombat && (source.getInternalPlayerData().lastPvpTimestamp == target.getInternalPlayerData().lastPvpTimestamp)) {
source.getInternalPlayerData().lastPvpTimestamp = Instant.now();
target.getInternalPlayerData().lastPvpTimestamp = Instant.now();
GDPermissionManager.getInstance().addEventLogEntry(event, targetPlayer.getLocation(), source, targetPlayer, source, Flags.ENTITY_DAMAGE, "pvp-combat", Tristate.TRUE);
GDPermissionManager.getInstance().addEventLogEntry(event, claim, targetPlayer.getLocation(), source, targetPlayer, source, Flags.ENTITY_DAMAGE, "pvp-combat", Tristate.TRUE);
return false;
}
// Check target claim
if (!claim.isPvpEnabled()) {
GriefDefenderPlugin.sendMessage(sourcePlayer, MessageCache.getInstance().PVP_CLAIM_NOT_ALLOWED);
GDPermissionManager.getInstance().addEventLogEntry(event, targetPlayer.getLocation(), source, targetPlayer, source, Flags.ENTITY_DAMAGE, "pvp", Tristate.FALSE);
GDPermissionManager.getInstance().addEventLogEntry(event, claim, targetPlayer.getLocation(), source, targetPlayer, source, Flags.ENTITY_DAMAGE, "pvp", Tristate.FALSE);
return true;
}
// Check source claim
final GDClaim sourceClaim = GriefDefenderPlugin.getInstance().dataStore.getClaimAtPlayer(source.getInternalPlayerData(), sourcePlayer.getLocation());
if (!sourceClaim.isPvpEnabled()) {
GriefDefenderPlugin.sendMessage(sourcePlayer, MessageCache.getInstance().PVP_CLAIM_NOT_ALLOWED);
GDPermissionManager.getInstance().addEventLogEntry(event, targetPlayer.getLocation(), source, targetPlayer, source, Flags.ENTITY_DAMAGE, "pvp", Tristate.FALSE);
GDPermissionManager.getInstance().addEventLogEntry(event, sourceClaim, targetPlayer.getLocation(), source, targetPlayer, source, Flags.ENTITY_DAMAGE, "pvp", Tristate.FALSE);
return true;
}
@ -985,12 +985,12 @@ private boolean getPvpProtectResult(Event event, GDClaim claim, GDPermissionUser
Tristate targetResult = GDPermissionManager.getInstance().getFinalPermission(event, sourcePlayer.getLocation(), claim, Flags.ENTITY_DAMAGE, targetPlayer, sourcePlayer, targetPlayer, true);
if (sourceResult == Tristate.FALSE) {
GriefDefenderPlugin.sendMessage(sourcePlayer, MessageCache.getInstance().PVP_SOURCE_NOT_ALLOWED);
GDPermissionManager.getInstance().addEventLogEntry(event, targetPlayer.getLocation(), source, targetPlayer, source, Flags.ENTITY_DAMAGE, "pvp", Tristate.FALSE);
GDPermissionManager.getInstance().addEventLogEntry(event, claim, targetPlayer.getLocation(), source, targetPlayer, source, Flags.ENTITY_DAMAGE, "pvp", Tristate.FALSE);
return true;
}
if (targetResult == Tristate.FALSE) {
GriefDefenderPlugin.sendMessage(sourcePlayer, MessageCache.getInstance().PVP_TARGET_NOT_ALLOWED);
GDPermissionManager.getInstance().addEventLogEntry(event, targetPlayer.getLocation(), source, targetPlayer, source, Flags.ENTITY_DAMAGE, "pvp", Tristate.FALSE);
GDPermissionManager.getInstance().addEventLogEntry(event, claim, targetPlayer.getLocation(), source, targetPlayer, source, Flags.ENTITY_DAMAGE, "pvp", Tristate.FALSE);
return true;
}
@ -1005,19 +1005,19 @@ private boolean getPvpProtectResult(Event event, GDClaim claim, GDPermissionUser
}
if (sourceResult == Tristate.FALSE) {
GriefDefenderPlugin.sendMessage(sourcePlayer, MessageCache.getInstance().PVP_SOURCE_NOT_ALLOWED);
GDPermissionManager.getInstance().addEventLogEntry(event, targetPlayer.getLocation(), source, targetPlayer, source, Options.PVP.getPermission(), "pvp", Tristate.FALSE);
GDPermissionManager.getInstance().addEventLogEntry(event, claim, targetPlayer.getLocation(), source, targetPlayer, source, Options.PVP.getPermission(), "pvp", Tristate.FALSE);
return true;
}
if (targetResult == Tristate.FALSE) {
GriefDefenderPlugin.sendMessage(sourcePlayer, MessageCache.getInstance().PVP_TARGET_NOT_ALLOWED);
GDPermissionManager.getInstance().addEventLogEntry(event, targetPlayer.getLocation(), source, targetPlayer, source, Options.PVP.getPermission(), "pvp", Tristate.FALSE);
GDPermissionManager.getInstance().addEventLogEntry(event, claim, targetPlayer.getLocation(), source, targetPlayer, source, Options.PVP.getPermission(), "pvp", Tristate.FALSE);
return true;
}
final Instant now = Instant.now();
source.getInternalPlayerData().lastPvpTimestamp = now;
target.getInternalPlayerData().lastPvpTimestamp = now;
GDPermissionManager.getInstance().addEventLogEntry(event, targetPlayer.getLocation(), source, targetPlayer, source, Flags.ENTITY_DAMAGE, "pvp", Tristate.TRUE);
GDPermissionManager.getInstance().addEventLogEntry(event, claim, targetPlayer.getLocation(), source, targetPlayer, source, Flags.ENTITY_DAMAGE, "pvp", Tristate.TRUE);
return false;
}
}

View File

@ -213,7 +213,7 @@ public void onPlayerChat(MessageChannelEvent.Chat event, @First Player player) {
// check for command input
if (playerData.isWaitingForInput()) {
playerData.commandInput = event.getRawMessage().toPlain();
playerData.trustAddConsumer.accept(player);
playerData.commandConsumer.accept(player);
event.setCancelled(true);
return;
}
@ -240,7 +240,7 @@ public void onPlayerChat(MessageChannelEvent.Chat event, @First Player player) {
Text footer = event.getFormatter().getFooter().toText();
Text townMessage = Text.of(TextColors.GREEN, body);
if (townTag != null) {
townMessage = Text.of(townTag, townMessage);
townMessage = Text.of(SpongeUtil.getSpongeText(townTag), townMessage);
}
event.setMessage(townMessage);
Set<CommandSource> recipientsToRemove = new HashSet<>();
@ -729,7 +729,7 @@ public void onPlayerInteractEntity(InteractEntityEvent.Primary event, @First Pla
return;
}
// If pet protection is enabled, deny the interaction
if (GriefDefenderPlugin.getActiveConfig(player.getWorld().getProperties()).getConfig().claim.protectedTamedEntities) {
if (GriefDefenderPlugin.getActiveConfig(player.getWorld().getProperties()).getConfig().claim.protectTamedEntities) {
final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(ownerID);
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.CLAIM_PROTECTED_ENTITY,
ImmutableMap.of(
@ -796,7 +796,7 @@ public void onPlayerInteractEntity(InteractEntityEvent.Secondary event, @First P
return;
}
// If pet protection is enabled, deny the interaction
if (GriefDefenderPlugin.getActiveConfig(player.getWorld().getProperties()).getConfig().claim.protectedTamedEntities) {
if (GriefDefenderPlugin.getActiveConfig(player.getWorld().getProperties()).getConfig().claim.protectTamedEntities) {
final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(ownerID);
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.CLAIM_PROTECTED_ENTITY,
ImmutableMap.of(
@ -1149,7 +1149,7 @@ public InteractEvent handleItemInteract(InteractEvent event, Player player, Worl
if (playerData.claimMode || (!itemInHand.isEmpty() && (itemInHand.getType().equals(GriefDefenderPlugin.getInstance().modificationTool.getType()) ||
itemInHand.getType().equals(GriefDefenderPlugin.getInstance().investigationTool.getType())))) {
GDPermissionManager.getInstance().addEventLogEntry(event, location, itemInHand, blockSnapshot == null ? entity : blockSnapshot, player, flag, null, Tristate.TRUE);
GDPermissionManager.getInstance().addEventLogEntry(event, claim, location, itemInHand, blockSnapshot == null ? entity : blockSnapshot, player, flag, null, Tristate.TRUE);
event.setCancelled(true);
if (investigateClaim(event, player, blockSnapshot, itemInHand)) {
return event;
@ -1167,7 +1167,7 @@ public InteractEvent handleItemInteract(InteractEvent event, Player player, Worl
return event;
}
if (GDPermissionManager.getInstance().getFinalPermission(event, location, claim, flag, player, itemType, player, TrustTypes.ACCESSOR, true) == Tristate.FALSE) {
if (GDPermissionManager.getInstance().getFinalPermission(event, location, claim, flag, player, itemInHand, player, TrustTypes.ACCESSOR, true) == Tristate.FALSE) {
Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PERMISSION_INTERACT_ITEM,
ImmutableMap.of(
"player", claim.getOwnerName(),

View File

@ -144,11 +144,6 @@ public class GDPermissionManager implements PermissionManager {
EventContextKeys.FAKE_PLAYER, EventContextKeys.NOTIFIER, EventContextKeys.OWNER, EventContextKeys.PISTON_EXTEND,
EventContextKeys.PISTON_RETRACT, EventContextKeys.SERVICE_MANAGER, EventContextKeys.PLAYER_BREAK, EventContextKeys.SPAWN_TYPE);
private static final Pattern PATTERN_META = Pattern.compile("\\.[\\d+]*$");
private static final List<Context> CONTEXT_LIST = Arrays.asList(
ClaimContexts.ADMIN_DEFAULT_CONTEXT, ClaimContexts.ADMIN_OVERRIDE_CONTEXT,
ClaimContexts.BASIC_DEFAULT_CONTEXT, ClaimContexts.BASIC_OVERRIDE_CONTEXT,
ClaimContexts.TOWN_DEFAULT_CONTEXT, ClaimContexts.TOWN_OVERRIDE_CONTEXT,
ClaimContexts.WILDERNESS_OVERRIDE_CONTEXT, ClaimContexts.WILDERNESS_DEFAULT_CONTEXT);
private enum BanType {
BLOCK,
@ -496,7 +491,7 @@ public Tristate processResult(Claim claim, String permission, String trust, Tris
}
}
GriefDefenderPlugin.addEventLogEntry(this.currentEvent, this.eventLocation, this.eventSourceId, this.eventTargetId, permissionHolder, permission, trust, permissionValue);
GriefDefenderPlugin.addEventLogEntry(this.currentEvent, claim, this.eventLocation, this.eventSourceId, this.eventTargetId, this.eventSubject == null ? permissionHolder : this.eventSubject, permission, trust, permissionValue, this.eventContexts);
}
if (eventPlayerData != null && eventPlayerData.eventResultCache != null) {
@ -508,23 +503,23 @@ public Tristate processResult(Claim claim, String permission, String trust, Tris
return permissionValue;
}
public void addEventLogEntry(Event event, Location<World> location, Object source, Object target, User user, Flag flag, String trust, Tristate result) {
public void addEventLogEntry(Event event, Claim claim, Location<World> location, Object source, Object target, User user, Flag flag, String trust, Tristate result) {
final GDPermissionHolder holder = PermissionHolderCache.getInstance().getOrCreateUser(user);
addEventLogEntry(event, location, source, target, holder, flag, trust, result);
addEventLogEntry(event, claim, location, source, target, holder, flag, trust, result);
}
// Used for situations where events are skipped for perf reasons
public void addEventLogEntry(Event event, Location<World> location, Object source, Object target, GDPermissionHolder permissionSubject, Flag flag, String trust, Tristate result) {
this.addEventLogEntry(event, location, source, target, permissionSubject, flag.getPermission(), trust, result);
public void addEventLogEntry(Event event, Claim claim, Location<World> location, Object source, Object target, GDPermissionHolder permissionSubject, Flag flag, String trust, Tristate result) {
this.addEventLogEntry(event, claim, location, source, target, permissionSubject, flag.getPermission(), trust, result);
}
public void addEventLogEntry(Event event, Location<World> location, Object source, Object target, GDPermissionHolder permissionSubject, String permission, String trust, Tristate result) {
public void addEventLogEntry(Event event, Claim claim, Location<World> location, Object source, Object target, GDPermissionHolder permissionSubject, String permission, String trust, Tristate result) {
if (GriefDefenderPlugin.debugActive) {
String sourceId = getPermissionIdentifier(source, true);
String targetId = getPermissionIdentifier(target);
if (permissionSubject == null) {
permissionSubject = GriefDefenderPlugin.DEFAULT_HOLDER;
}
GriefDefenderPlugin.addEventLogEntry(event, location, sourceId, targetId, permissionSubject, permission, trust, result);
GriefDefenderPlugin.addEventLogEntry(event, claim, location, sourceId, targetId, permissionSubject, permission, trust, result, this.eventContexts);
}
}
@ -674,7 +669,6 @@ public Set<Context> getPermissionContexts(GDClaim claim, Object obj, boolean isS
return null;
}
final String id = blockstate.getType().getId();
contexts.add(new Context("meta", String.valueOf(BlockUtil.getInstance().getBlockStateMeta(blockstate))));
this.addBlockPropertyContexts(contexts, blockstate);
if (this.isObjectIdBanned(claim, id, BanType.BLOCK)) {
return null;

View File

@ -97,7 +97,7 @@ public class GDPermissions {
// flags
public static final String USER_CLAIM_FLAGS = "griefdefender.user.claim.flag";
public static final String COMMAND_FLAGS_CLAIM = "griefdefender.user.claim.command.flag.base";
public static final String COMMAND_FLAGS_CLAIM_ARG = "griefdefender.user.claim.command.flag.arg";
public static final String COMMAND_FLAGS_CLAIM_ARG = "griefdefender.admin.claim.command.flag.arg";
public static final String COMMAND_FLAGS_CLAIM_GUI = "griefdefender.user.claim.command.flag.gui";
public static final String COMMAND_FLAGS_DEBUG = "griefdefender.user.claim.command.flag.debug";
public static final String COMMAND_FLAGS_PLAYER = "griefdefender.user.claim.command.flag.player";

View File

@ -37,13 +37,16 @@ public class FlagContexts {
public static final Context SOURCE_ENDERMAN = new Context(ContextKeys.SOURCE, "minecraft:enderman");
public static final Context SOURCE_SNOWMAN = new Context(ContextKeys.SOURCE, "minecraft:snowman");
public static final Context SOURCE_WITHER = new Context(ContextKeys.SOURCE, "minecraft:wither");
public static final Context SOURCE_LAVA = new Context(ContextKeys.SOURCE, "minecraft:flowing_lava");
public static final Context SOURCE_WATER = new Context(ContextKeys.SOURCE, "minecraft:flowing_water");
public static final Context SOURCE_LAVA_1_12 = new Context(ContextKeys.SOURCE, "minecraft:flowing_lava");
public static final Context SOURCE_WATER_1_12 = new Context(ContextKeys.SOURCE, "minecraft:flowing_water");
public static final Context SOURCE_LAVA = new Context(ContextKeys.SOURCE, "minecraft:lava");
public static final Context SOURCE_WATER = new Context(ContextKeys.SOURCE, "minecraft:water");
public static final Context SOURCE_LIGHTNING_BOLT = new Context(ContextKeys.SOURCE, "minecraft:lightning_bolt");
public static final Context SOURCE_FALL = new Context(ContextKeys.SOURCE, "minecraft:fall");
public static final Context SOURCE_FIRE = new Context(ContextKeys.SOURCE, "minecraft:fire");
public static final Context SOURCE_FIREWORKS = new Context(ContextKeys.SOURCE, "minecraft:fireworks");
public static final Context SOURCE_PISTON = new Context(ContextKeys.TARGET, "minecraft:piston");
public static final Context SOURCE_ICE = new Context(ContextKeys.SOURCE, "minecraft:ice");
public static final Context SOURCE_PISTON = new Context(ContextKeys.SOURCE, "minecraft:piston");
public static final Context SOURCE_VINE = new Context(ContextKeys.SOURCE, "minecraft:vine");
public static final Context SOURCE_TYPE_MONSTER = new Context(ContextKeys.SOURCE, "#monster");
@ -51,6 +54,7 @@ public class FlagContexts {
public static final Context STATE_FARMLAND_DRY = new Context("state", "moisture:0");
// Targets
public static final Context TARGET_AIR = new Context(ContextKeys.TARGET, "minecraft:air");
public static final Context TARGET_BED = new Context(ContextKeys.TARGET, "minecraft:bed");
public static final Context TARGET_BOAT = new Context(ContextKeys.TARGET, "minecraft:boat");
public static final Context TARGET_CHEST = new Context(ContextKeys.TARGET, "minecraft:chest");
@ -60,6 +64,7 @@ public class FlagContexts {
public static final Context TARGET_FLINTANDSTEEL = new Context(ContextKeys.TARGET, "minecraft:flint_and_steel");
public static final Context TARGET_GRASS= new Context(ContextKeys.TARGET, "minecraft:grass");
public static final Context TARGET_ITEM_FRAME = new Context(ContextKeys.TARGET, "minecraft:item_frame");
public static final Context TARGET_LAVA_BUCKET = new Context(ContextKeys.TARGET, "minecraft:lava_bucket");
public static final Context TARGET_MINECART = new Context(ContextKeys.TARGET, "minecraft:minecart");
public static final Context TARGET_MYCELIUM = new Context(ContextKeys.TARGET, "minecraft:mycelium");
public static final Context TARGET_PAINTING = new Context(ContextKeys.TARGET, "minecraft:painting");
@ -67,9 +72,11 @@ public class FlagContexts {
public static final Context TARGET_PLAYER = new Context(ContextKeys.TARGET, "minecraft:player");
public static final Context TARGET_ICE_FORM = new Context(ContextKeys.TARGET, "minecraft:ice");
public static final Context TARGET_ICE_MELT = new Context(ContextKeys.TARGET, "minecraft:water");
public static final Context TARGET_SNOW_LAYER = new Context(ContextKeys.TARGET, "minecraft:snow_layer");
public static final Context TARGET_SNOW_1_12 = new Context(ContextKeys.TARGET, "minecraft:snow_layer");
public static final Context TARGET_SNOW = new Context(ContextKeys.TARGET, "minecraft:snow");
public static final Context TARGET_TURTLE_EGG = new Context(ContextKeys.TARGET, "minecraft:turtle_egg");
public static final Context TARGET_VINE = new Context(ContextKeys.TARGET, "minecraft:vine");
public static final Context TARGET_WATER_BUCKET = new Context(ContextKeys.TARGET, "minecraft:water_bucket");
public static final Context TARGET_XP_ORB = new Context(ContextKeys.TARGET, "minecraft:xp_orb");
public static final Context TARGET_TYPE_ANIMAL = new Context(ContextKeys.TARGET, "#animal");
public static final Context TARGET_TYPE_CROP = new Context(ContextKeys.TARGET, "#crop");
@ -79,4 +86,7 @@ public class FlagContexts {
public static final Context TARGET_TYPE_MUSHROOM = new Context(ContextKeys.TARGET, "#mushroom");
public static final Context TARGET_TYPE_PORTAL = new Context(ContextKeys.TARGET, "#portal");
public static final Context TARGET_TYPE_VEHICLE = new Context(ContextKeys.TARGET, "#vehicle");
public static final Context USED_ITEM_LAVA_BUCKET = new Context(ContextKeys.USED_ITEM, "minecraft:lava_bucket");
public static final Context USED_ITEM_WATER_BUCKET = new Context(ContextKeys.USED_ITEM, "minecraft:water_bucket");
}

View File

@ -27,10 +27,12 @@
import com.griefdefender.api.Tristate;
import com.griefdefender.api.permission.Context;
import com.griefdefender.api.permission.flag.FlagData;
import net.kyori.text.Component;
import net.kyori.text.TextComponent;
import net.kyori.text.format.TextColor;
import net.kyori.text.format.TextDecoration;
import java.util.Set;
public class GDActiveFlagData {
@ -41,14 +43,18 @@ public enum Type {
UNDEFINED
}
private final GDFlagDefinition flagDefinition;
private final FlagData flagData;
private final Tristate value;
private final Type type;
private final Set<Context> contexts;
public GDActiveFlagData(FlagData flagData, Tristate value, Type type) {
public GDActiveFlagData(GDFlagDefinition flagDefinition, FlagData flagData, Tristate value, Set<Context> contexts, Type type) {
this.flagDefinition = flagDefinition;
this.flagData = flagData;
this.value = value;
this.type = type;
this.contexts = contexts;
}
public FlagData getFlagData() {
@ -72,24 +78,44 @@ public TextColor getColor() {
return TextColor.GRAY;
}
public Type getType() {
return this.type;
}
public Component getComponent() {
TextComponent.Builder contextBuilder = TextComponent.builder();
int count = 0;
for (Context context : this.flagData.getContexts()) {
if (count > 0) {
contextBuilder.append(", ");
}
contextBuilder.append(context.getKey().replace("gd_claim_", "").replace("gd_claim", ""), TextColor.GREEN)
.append("=")
.append(context.getValue(), TextColor.GRAY);
String descr = "Active Claim Result: ";
final TextColor valueColor = this.getColor();
TextComponent valueComponent = TextComponent.of(this.value.toString().toLowerCase()).color(valueColor);
if (this.type == Type.OVERRIDE) {
descr = "Active Override Result: ";
valueComponent = TextComponent.of(this.value.toString().toLowerCase()).color(valueColor).decoration(TextDecoration.ITALIC, true).decoration(TextDecoration.UNDERLINED, true);
} else if (this.type == Type.DEFAULT) {
descr = "Active Default Result: ";
} else {
descr = "No Result: ";
}
TextComponent.Builder builder = TextComponent.builder();
builder
.append(this.flagData.getFlag().getName().toLowerCase(), this.getColor())
.append("=", TextColor.WHITE)
.append(this.value.toString().toLowerCase(), TextColor.GOLD)
.append(" ")
.append(contextBuilder.build());
builder.append("\n" + descr, TextColor.AQUA);
builder.append(valueComponent);
builder.append("\nFlag: ")
.append(this.flagData.getFlag().getName(), TextColor.GREEN);
if (!this.flagData.getContexts().isEmpty()) {
builder.append("\nContexts: ");
}
for (Context context : this.contexts) {
if (!this.flagDefinition.isAdmin() && context.getKey().contains("gd_claim")) {
continue;
}
builder.append("\n");
final String key = context.getKey();
final String value = context.getValue();
TextColor keyColor = TextColor.AQUA;
builder.append(key, keyColor)
.append("=", TextColor.WHITE)
.append(value.replace("minecraft:", ""), TextColor.GRAY);
}
return builder.build();
}
}

View File

@ -91,7 +91,6 @@ public boolean getDefaultClaimTypeValue(ClaimType type) {
case "entity-damage" :
case "explosion-block" :
case "explosion-entity" :
case "fire-spread" :
case "interact-block-primary" :
case "interact-block-secondary" :
case "interact-entity-primary" :
@ -104,15 +103,6 @@ public boolean getDefaultClaimTypeValue(ClaimType type) {
return true;
}
}
if (type == ClaimTypes.WILDERNESS) {
switch (this.name) {
case "fire-spread" :
return false;
default :
return true;
}
}
return true;
}

View File

@ -81,6 +81,12 @@ public Builder flag(Flag flag) {
return this;
}
@Override
public Builder context(Context context) {
this.contexts.add(context);
return this;
}
@Override
public Builder contexts(Set<Context> contexts) {
this.contexts = contexts;

View File

@ -37,7 +37,6 @@
import com.griefdefender.api.permission.flag.Flag;
import com.griefdefender.api.permission.flag.FlagData;
import com.griefdefender.api.permission.flag.FlagDefinition;
import com.griefdefender.registry.FlagDefinitionRegistryModule;
import net.kyori.text.Component;
import net.kyori.text.TextComponent;
@ -46,6 +45,7 @@
public class GDFlagDefinition implements FlagDefinition {
private boolean enabled = true;
private boolean adminDefinition = false;
private Set<Context> definitionContexts = new HashSet<>();
private List<FlagData> data = new ArrayList<>();
private String displayName;
@ -53,18 +53,13 @@ public class GDFlagDefinition implements FlagDefinition {
private Tristate defaultValue = Tristate.UNDEFINED;
private Component description;
public GDFlagDefinition(Flag flag, Set<Context> contexts, String displayName, Component description) {
this.data.add(new GDFlagData(flag, contexts));
this.displayName = displayName;
this.description = description;
FlagDefinitionRegistryModule.getInstance().registerCustomType(this);
}
public GDFlagDefinition(List<FlagData> flagData, String displayName, Component description) {
public GDFlagDefinition(List<FlagData> flagData, String displayName, Component description, String groupName, boolean isAdmin, Set<Context> contexts) {
this.data = flagData;
this.displayName = displayName;
this.description = description;
FlagDefinitionRegistryModule.getInstance().registerCustomType(this);
this.groupName = groupName;
this.definitionContexts = contexts;
this.adminDefinition = isAdmin;
}
public void addFlagData(Flag flag, Set<Context> contexts) {
@ -109,11 +104,6 @@ public Set<Context> getContexts() {
return this.definitionContexts;
}
@Override
public void setContexts(Set<Context> contexts) {
this.definitionContexts = contexts;
}
@Override
public boolean isEnabled() {
return this.enabled;
@ -124,6 +114,11 @@ public void setIsEnabled(boolean val) {
this.enabled = val;
}
@Override
public boolean isAdmin() {
return this.adminDefinition;
}
@Override
public String getId() {
return GriefDefenderPlugin.MOD_ID + ":" + this.displayName;
@ -139,11 +134,6 @@ public String getGroupName() {
return this.groupName;
}
@Override
public void setGroupName(String group) {
this.groupName = group;
}
@Override
public Tristate getDefaultValue() {
return this.defaultValue;
@ -157,7 +147,8 @@ public void setDefaultValue(Tristate value) {
public static class FlagDefinitionBuilder implements Builder {
private boolean enabled = true;
private Set<Context> definitionContexts = new HashSet<>();
private boolean isAdmin = false;
private Set<Context> contexts = new HashSet<>();
private List<FlagData> data = new ArrayList<>();
private String displayName;
private String groupName;
@ -170,21 +161,45 @@ public Builder enabled(boolean enabled) {
return this;
}
@Override
public Builder admin(boolean value) {
this.isAdmin = value;
return this;
}
@Override
public Builder group(String group) {
this.groupName = group;
return this;
}
@Override
public Builder defaultValue(Tristate value) {
this.defaultValue = value;
return this;
}
@Override
public Builder flagData(FlagData data) {
this.data.add(data);
return this;
}
@Override
public Builder flagData(List<FlagData> data) {
this.data = data;
return this;
}
@Override
public Builder context(Context context) {
this.contexts.add(context);
return this;
}
@Override
public Builder contexts(Set<Context> contexts) {
this.definitionContexts = contexts;
this.contexts = contexts;
return this;
}
@ -203,7 +218,8 @@ public Builder description(Component description) {
@Override
public Builder reset() {
this.enabled = true;
this.definitionContexts = new HashSet<>();
this.isAdmin = false;
this.contexts = new HashSet<>();
this.data = new ArrayList<>();
this.displayName = "";
this.groupName = "";
@ -218,11 +234,9 @@ public FlagDefinition build() {
checkNotNull(this.displayName);
checkNotNull(this.groupName);
checkNotNull(this.description);
final GDFlagDefinition definition = new GDFlagDefinition(this.data, this.displayName, this.description);
definition.setContexts(this.definitionContexts);
final GDFlagDefinition definition = new GDFlagDefinition(this.data, this.displayName, this.description, this.groupName, this.isAdmin, this.contexts);
definition.setIsEnabled(this.enabled);
definition.setDefaultValue(this.defaultValue);
definition.setGroupName(this.groupName);
return definition;
}

View File

@ -1,412 +0,0 @@
/*
* This file is part of GriefDefender, licensed under the MIT License (MIT).
*
* Copyright (c) bloodmc
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.griefdefender.permission.flag;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.griefdefender.api.claim.ClaimContexts;
import com.griefdefender.api.permission.Context;
import com.griefdefender.api.permission.flag.Flags;
import com.griefdefender.cache.MessageCache;
public class GDFlagDefinitions {
// ADMIN
public static final GDFlagDefinition BLOCK_BREAK;
public static final GDFlagDefinition BLOCK_GROW;
public static final GDFlagDefinition BLOCK_PLACE;
public static final GDFlagDefinition BLOCK_SPREAD;
public static final GDFlagDefinition ENDERPEARL;
public static final GDFlagDefinition EXIT_PLAYER;
public static final GDFlagDefinition EXPLOSION_BLOCK;
public static final GDFlagDefinition EXPLOSION_ENTITY;
public static final GDFlagDefinition EXP_DROP;
public static final GDFlagDefinition FALL_DAMAGE;
public static final GDFlagDefinition INTERACT_BLOCK;
public static final GDFlagDefinition INTERACT_ENTITY;
public static final GDFlagDefinition INTERACT_INVENTORY;
public static final GDFlagDefinition INVINCIBLE;
public static final GDFlagDefinition ITEM_DROP;
public static final GDFlagDefinition ITEM_PICKUP;
public static final GDFlagDefinition MONSTER_DAMAGE;
public static final GDFlagDefinition PISTONS;
public static final GDFlagDefinition PORTAL_USE;
public static final GDFlagDefinition SPAWN_MONSTER;
public static final GDFlagDefinition TELEPORT_FROM;
public static final GDFlagDefinition TELEPORT_TO;
public static final GDFlagDefinition USE;
public static final GDFlagDefinition VEHICLE_DESTROY;
public static final GDFlagDefinition WITHER_DAMAGE;
// USER
public static final GDFlagDefinition BLOCK_TRAMPLING;
public static final GDFlagDefinition CHEST_ACCESS;
public static final GDFlagDefinition CHORUS_FRUIT_TELEPORT;
public static final GDFlagDefinition CROP_GROWTH;
public static final GDFlagDefinition DAMAGE_ANIMALS;
public static final GDFlagDefinition ENDERMAN_GRIEF;
public static final GDFlagDefinition ENTER_PLAYER;
public static final GDFlagDefinition EXPLOSION_CREEPER;
public static final GDFlagDefinition EXPLOSION_TNT;
public static final GDFlagDefinition FIRE_DAMAGE;
public static final GDFlagDefinition FIRE_SPREAD;
public static final GDFlagDefinition GRASS_GROWTH;
public static final GDFlagDefinition ICE_FORM;
public static final GDFlagDefinition ICE_MELT;
public static final GDFlagDefinition LAVA_FLOW;
public static final GDFlagDefinition LEAF_DECAY;
public static final GDFlagDefinition LIGHTNING;
public static final GDFlagDefinition LIGHTER;
public static final GDFlagDefinition MUSHROOM_GROWTH;
public static final GDFlagDefinition MYCELIUM_SPREAD;
public static final GDFlagDefinition PVP;
public static final GDFlagDefinition RIDE;
public static final GDFlagDefinition SLEEP;
public static final GDFlagDefinition SNOW_FALL;
public static final GDFlagDefinition SNOW_MELT;
public static final GDFlagDefinition SNOWMAN_TRAIL;
public static final GDFlagDefinition SOIL_DRY;
public static final GDFlagDefinition SPAWN_AMBIENT;
public static final GDFlagDefinition SPAWN_ANIMAL;
public static final GDFlagDefinition SPAWN_AQUATIC;
public static final GDFlagDefinition VEHICLE_DESTROY_CLAIM;
public static final GDFlagDefinition VEHICLE_PLACE;
public static final GDFlagDefinition VINE_GROWTH;
public static final GDFlagDefinition WATER_FLOW;
public static final List<GDFlagDefinition> ADMIN_FLAGS = new ArrayList<>();
public static final List<GDFlagDefinition> USER_FLAGS = new ArrayList<>();
static {
Set<Context> contexts = new HashSet<>();
contexts = new HashSet<>();
BLOCK_BREAK = new GDFlagDefinition(Flags.BLOCK_BREAK, contexts, "block-break", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_BREAK);
contexts = new HashSet<>();
BLOCK_PLACE = new GDFlagDefinition(Flags.BLOCK_PLACE, contexts, "block-place", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_PLACE);
contexts = new HashSet<>();
BLOCK_GROW = new GDFlagDefinition(Flags.BLOCK_GROW, contexts, "block-grow", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_GROW);
contexts = new HashSet<>();
BLOCK_SPREAD = new GDFlagDefinition(Flags.BLOCK_SPREAD, contexts, "block-spread", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_SPREAD);
// ADMIN
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
ENDERPEARL = new GDFlagDefinition(Flags.INTERACT_ITEM_SECONDARY, contexts, "enderpearl", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ENDERPEARL);
ENDERPEARL.getContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
ENTER_PLAYER = new GDFlagDefinition(Flags.ENTER_CLAIM, contexts, "enter-player", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ENTER_PLAYER);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
EXIT_PLAYER = new GDFlagDefinition(Flags.ENTER_CLAIM, contexts, "exit-player", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXIT_PLAYER);
contexts = new HashSet<>();
EXPLOSION_BLOCK = new GDFlagDefinition(Flags.EXPLOSION_BLOCK, contexts, "explosion-block", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_BLOCK);
EXPLOSION_BLOCK.getContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_CREEPER);
EXPLOSION_CREEPER = new GDFlagDefinition(Flags.EXPLOSION_BLOCK, contexts, "explosion-creeper", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_CREEPER);
EXPLOSION_CREEPER.addFlagData(Flags.EXPLOSION_ENTITY, contexts);
contexts = new HashSet<>();
EXPLOSION_ENTITY = new GDFlagDefinition(Flags.EXPLOSION_ENTITY, contexts, "explosion-entity", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_ENTITY);
EXPLOSION_ENTITY.getContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_TNT);
EXPLOSION_TNT = new GDFlagDefinition(Flags.EXPLOSION_BLOCK, contexts, "explosion-tnt", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_TNT);
EXPLOSION_TNT.addFlagData(Flags.EXPLOSION_ENTITY, contexts);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_XP_ORB);
EXP_DROP = new GDFlagDefinition(Flags.ENTITY_SPAWN, contexts, "exp-drop", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXP_DROP);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_FALL);
contexts.add(FlagContexts.TARGET_PLAYER);
FALL_DAMAGE = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "fall-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FALL_DAMAGE);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
INTERACT_BLOCK = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "interact-block", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INTERACT_BLOCK);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
INTERACT_ENTITY = new GDFlagDefinition(Flags.INTERACT_ENTITY_SECONDARY, contexts, "interact-entity", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INTERACT_ENTITY);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
INTERACT_INVENTORY = new GDFlagDefinition(Flags.INTERACT_INVENTORY, contexts, "interact-inventory", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INTERACT_INVENTORY);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_PLAYER);
INVINCIBLE = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "invincible", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INVINCIBLE);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
ITEM_DROP = new GDFlagDefinition(Flags.ITEM_DROP, contexts, "item-drop", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ITEM_DROP);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
ITEM_PICKUP = new GDFlagDefinition(Flags.ITEM_PICKUP, contexts, "item-pickup", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ITEM_PICKUP);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_TYPE_MONSTER);
MONSTER_DAMAGE = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "monster-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MONSTER_DAMAGE);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_PISTON);
PISTONS = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "pistons", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PISTONS);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
contexts.add(FlagContexts.TARGET_TYPE_PORTAL);
PORTAL_USE = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "portal-use", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PORTAL_USE);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_TYPE_MONSTER);
SPAWN_MONSTER = new GDFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-monster", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_MONSTER);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_PLAYER);
TELEPORT_FROM = new GDFlagDefinition(Flags.ENTITY_TELEPORT_FROM, contexts, "teleport-from", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_TELEPORT_FROM);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_PLAYER);
TELEPORT_TO = new GDFlagDefinition(Flags.ENTITY_TELEPORT_TO, contexts, "teleport-to", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_TELEPORT_TO);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
VEHICLE_DESTROY = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "vehicle-destroy", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VEHICLE_DESTROY);
VEHICLE_DESTROY.getContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_WITHER);
WITHER_DAMAGE = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "wither-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_WITHER_DAMAGE);
WITHER_DAMAGE.getContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
ADMIN_FLAGS.add(BLOCK_BREAK);
ADMIN_FLAGS.add(BLOCK_PLACE);
ADMIN_FLAGS.add(BLOCK_GROW);
ADMIN_FLAGS.add(BLOCK_SPREAD);
ADMIN_FLAGS.add(ENDERPEARL);
ADMIN_FLAGS.add(ENTER_PLAYER);
ADMIN_FLAGS.add(EXIT_PLAYER);
ADMIN_FLAGS.add(EXPLOSION_BLOCK);
ADMIN_FLAGS.add(EXPLOSION_CREEPER);
ADMIN_FLAGS.add(EXPLOSION_ENTITY);
ADMIN_FLAGS.add(EXPLOSION_TNT);
ADMIN_FLAGS.add(EXP_DROP);
ADMIN_FLAGS.add(FALL_DAMAGE);
ADMIN_FLAGS.add(INTERACT_BLOCK);
ADMIN_FLAGS.add(INTERACT_ENTITY);
ADMIN_FLAGS.add(INTERACT_INVENTORY);
ADMIN_FLAGS.add(INVINCIBLE);
ADMIN_FLAGS.add(ITEM_DROP);
ADMIN_FLAGS.add(ITEM_PICKUP);
ADMIN_FLAGS.add(MONSTER_DAMAGE);
ADMIN_FLAGS.add(PISTONS);
ADMIN_FLAGS.add(SPAWN_MONSTER);
ADMIN_FLAGS.add(TELEPORT_FROM);
ADMIN_FLAGS.add(TELEPORT_TO);
ADMIN_FLAGS.add(VEHICLE_DESTROY);
ADMIN_FLAGS.add(WITHER_DAMAGE);
// USER
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_FARMLAND);
contexts.add(FlagContexts.TARGET_TURTLE_EGG);
BLOCK_TRAMPLING = new GDFlagDefinition(Flags.COLLIDE_BLOCK, contexts, "block-trampling", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_TRAMPLING);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
contexts.add(FlagContexts.TARGET_CHEST);
CHEST_ACCESS = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "chest-access", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CHEST_ACCESS);
CHEST_ACCESS.addFlagData(Flags.INTERACT_INVENTORY, contexts);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_CHORUS_FRUIT);
CHORUS_FRUIT_TELEPORT = new GDFlagDefinition(Flags.INTERACT_ITEM_SECONDARY, contexts, "chorus-fruit-teleport", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CHORUS_FRUIT_TELEPORT);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_TYPE_CROP);
CROP_GROWTH = new GDFlagDefinition(Flags.BLOCK_GROW, contexts, "crop-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CROP_GROWTH);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_TYPE_ANIMAL);
DAMAGE_ANIMALS = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "damage-animals", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_DAMAGE_ANIMALS);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_ENDERMAN);
ENDERMAN_GRIEF = new GDFlagDefinition(Flags.BLOCK_BREAK, contexts, "enderman-grief", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ENDERMAN_GRIEF);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_FIRE);
FIRE_DAMAGE = new GDFlagDefinition(Flags.BLOCK_MODIFY, contexts, "fire-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FIRE_DAMAGE);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_FIRE);
FIRE_SPREAD = new GDFlagDefinition(Flags.BLOCK_SPREAD, contexts, "fire-spread", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FIRE_SPREAD);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_GRASS);
GRASS_GROWTH = new GDFlagDefinition(Flags.BLOCK_GROW, contexts, "grass-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_GRASS_GROWTH);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_ICE_FORM);
ICE_FORM = new GDFlagDefinition(Flags.BLOCK_MODIFY, contexts, "ice-form", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ICE_FORM);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_ICE_MELT);
ICE_MELT = new GDFlagDefinition(Flags.BLOCK_MODIFY, contexts, "ice-melt", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ICE_MELT);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_LAVA);
LAVA_FLOW = new GDFlagDefinition(Flags.LIQUID_FLOW, contexts, "lava-flow", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LAVA_FLOW);
contexts = new HashSet<>();
LEAF_DECAY = new GDFlagDefinition(Flags.LEAF_DECAY, contexts, "leaf-decay", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LEAF_DECAY);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_LIGHTNING_BOLT);
LIGHTNING = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "lightning", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LIGHTNING);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_FLINTANDSTEEL);
LIGHTER = new GDFlagDefinition(Flags.INTERACT_ITEM_SECONDARY, contexts, "lighter", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LIGHTER);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_TYPE_MUSHROOM);
MUSHROOM_GROWTH = new GDFlagDefinition(Flags.BLOCK_GROW, contexts, "mushroom-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MUSHROOM_GROWTH);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_MYCELIUM);
MYCELIUM_SPREAD = new GDFlagDefinition(Flags.BLOCK_SPREAD, contexts, "mycelium-spread", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MYCELIUM_SPREAD);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
contexts.add(FlagContexts.TARGET_PLAYER);
PVP = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "pvp", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PVP);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
RIDE = new GDFlagDefinition(Flags.ENTITY_RIDING, contexts, "ride", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_RIDE);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
contexts.add(FlagContexts.TARGET_BED);
SLEEP = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "sleep", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SLEEP);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_SNOW_LAYER);
SNOW_FALL = new GDFlagDefinition(Flags.BLOCK_PLACE, contexts, "snow-fall", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SNOW_FALL);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_SNOW_LAYER);
SNOW_MELT = new GDFlagDefinition(Flags.BLOCK_BREAK, contexts, "snow-melt", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SNOW_MELT);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_SNOWMAN);
SNOWMAN_TRAIL = new GDFlagDefinition(Flags.BLOCK_MODIFY, contexts, "snowman-trail", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SNOWMAN_TRAIL);
contexts = new HashSet<>();
contexts.add(FlagContexts.STATE_FARMLAND_DRY);
SOIL_DRY = new GDFlagDefinition(Flags.BLOCK_MODIFY, contexts, "soil-dry", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SOIL_DRY);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_TYPE_AMBIENT);
SPAWN_AMBIENT = new GDFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-ambient", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_AMBIENT);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_TYPE_ANIMAL);
SPAWN_ANIMAL = new GDFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-animal", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_ANIMAL);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_TYPE_AQUATIC);
SPAWN_AQUATIC = new GDFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-aquatic", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_AQUATIC);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_PLAYER);
USE = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "use", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_USE);
USE.addFlagData(Flags.INTERACT_ENTITY_SECONDARY, new HashSet<>(contexts));
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
VEHICLE_DESTROY_CLAIM = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "vehicle-destroy", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VEHICLE_DESTROY);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
VEHICLE_PLACE = new GDFlagDefinition(Flags.INTERACT_ITEM_SECONDARY, contexts, "vehicle-place", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VEHICLE_PLACE);
contexts = new HashSet<>();
contexts.add(FlagContexts.TARGET_VINE);
VINE_GROWTH = new GDFlagDefinition(Flags.BLOCK_GROW, contexts, "vine-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VINE_GROWTH);
contexts = new HashSet<>();
contexts.add(FlagContexts.SOURCE_WATER);
WATER_FLOW = new GDFlagDefinition(Flags.LIQUID_FLOW, contexts, "water-flow", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_WATER_FLOW);
USER_FLAGS.add(CHEST_ACCESS);
USER_FLAGS.add(CHORUS_FRUIT_TELEPORT);
USER_FLAGS.add(CROP_GROWTH);
USER_FLAGS.add(DAMAGE_ANIMALS);
USER_FLAGS.add(ENDERMAN_GRIEF);
USER_FLAGS.add(FIRE_DAMAGE);
USER_FLAGS.add(FIRE_SPREAD);
USER_FLAGS.add(GRASS_GROWTH);
USER_FLAGS.add(ICE_FORM);
USER_FLAGS.add(ICE_MELT);
USER_FLAGS.add(LAVA_FLOW);
USER_FLAGS.add(LEAF_DECAY);
USER_FLAGS.add(LIGHTER);
USER_FLAGS.add(LIGHTNING);
USER_FLAGS.add(MYCELIUM_SPREAD);
USER_FLAGS.add(PVP);
USER_FLAGS.add(RIDE);
USER_FLAGS.add(SLEEP);
USER_FLAGS.add(SNOW_FALL);
USER_FLAGS.add(SNOW_MELT);
USER_FLAGS.add(SOIL_DRY);
USER_FLAGS.add(SPAWN_AMBIENT);
USER_FLAGS.add(SPAWN_ANIMAL);
USER_FLAGS.add(SPAWN_AQUATIC);
USER_FLAGS.add(USE);
USER_FLAGS.add(VEHICLE_DESTROY_CLAIM);
USER_FLAGS.add(VEHICLE_PLACE);
USER_FLAGS.add(WATER_FLOW);
}
}

View File

@ -49,7 +49,9 @@
public class UIHelper {
public static Comparator<Component> PLAIN_COMPARATOR = (text1, text2) -> PlainComponentSerializer.INSTANCE.serialize(text1).compareTo(PlainComponentSerializer.INSTANCE.serialize(text2));
public static Comparator<Component> PLAIN_COMPARATOR = (text1, text2) ->
PlainComponentSerializer.INSTANCE.serialize(text1).replace("true", "").replace("false", "")
.compareTo(PlainComponentSerializer.INSTANCE.serialize(text2).replace("true", "").replace("false", ""));
public static List<Component> stripeText(List<Component> texts) {
Collections.sort(texts, PLAIN_COMPARATOR);

View File

@ -809,30 +809,52 @@ public PermissionResult setPermissionValue(GDPermissionHolder holder, String per
return new GDPermissionResult(ResultTypes.FAILURE, TextComponent.builder().append(result.name()).build());
}
public void setTransientOption(GDPermissionHolder holder, String permission, String value, Set<Context> contexts) {
public PermissionResult setTransientOption(GDPermissionHolder holder, String permission, String value, Set<Context> contexts) {
// If no server context exists, add global
this.checkServerContext(contexts);
MutableContextSet contextSet = this.getLPContexts(contexts);
final PermissionHolder permissionHolder = this.getLuckPermsHolder(holder);
if (permissionHolder == null) {
return;
return new GDPermissionResult(ResultTypes.FAILURE, TextComponent.builder().append("invalid").build());
}
final Node node = this.luckPermsApi.getNodeBuilderRegistry().forMeta().key(permission).value(value).context(contextSet).build();
permissionHolder.transientData().add(node);
DataMutateResult result = null;
if (value == null) {
final Node node = this.luckPermsApi.getNodeBuilderRegistry().forMeta().key(permission).context(contextSet).build();
result = permissionHolder.transientData().remove(node);
} else {
final Node node = this.luckPermsApi.getNodeBuilderRegistry().forMeta().key(permission).value(value).context(contextSet).build();
result = permissionHolder.transientData().add(node);
}
if (result.wasSuccessful()) {
return new GDPermissionResult(ResultTypes.SUCCESS, TextComponent.builder().append(result.name()).build());
}
return new GDPermissionResult(ResultTypes.FAILURE, TextComponent.builder().append(result.name()).build());
}
public void setTransientPermission(GDPermissionHolder holder, String permission, Boolean value, Set<Context> contexts) {
public PermissionResult setTransientPermission(GDPermissionHolder holder, String permission, Tristate value, Set<Context> contexts) {
// If no server context exists, add global
this.checkServerContext(contexts);
MutableContextSet contextSet = this.getLPContexts(contexts);
final PermissionHolder permissionHolder = this.getLuckPermsHolder(holder);
if (permissionHolder == null) {
return;
return new GDPermissionResult(ResultTypes.FAILURE, TextComponent.builder().append("invalid").build());
}
final PermissionNode node = this.luckPermsApi.getNodeBuilderRegistry().forPermission().permission(permission).value(value).context(contextSet).build();
permissionHolder.transientData().add(node);
DataMutateResult result = null;
if (value == Tristate.UNDEFINED) {
final Node node = this.luckPermsApi.getNodeBuilderRegistry().forPermission().permission(permission).value(value.asBoolean()).context(contextSet).build();
result = permissionHolder.transientData().remove(node);
} else {
final PermissionNode node = this.luckPermsApi.getNodeBuilderRegistry().forPermission().permission(permission).value(value.asBoolean()).context(contextSet).build();
result = permissionHolder.transientData().add(node);
}
if (result.wasSuccessful()) {
return new GDPermissionResult(ResultTypes.SUCCESS, TextComponent.builder().append(result.name()).build());
}
return new GDPermissionResult(ResultTypes.FAILURE, TextComponent.builder().append(result.name()).build());
}
public void savePermissionHolder(PermissionHolder holder) {

View File

@ -382,7 +382,7 @@ default PermissionResult setPermissionValue(GDPermissionHolder holder, String pe
* @param contexts The contexts
* @return Whether the set permission operation was successful
*/
void setTransientOption(GDPermissionHolder holder, String permission, String value, Set<Context> contexts);
PermissionResult setTransientOption(GDPermissionHolder holder, String permission, String value, Set<Context> contexts);
/**
* Sets a transient permission and value with contexts to a holder.
@ -393,7 +393,7 @@ default PermissionResult setPermissionValue(GDPermissionHolder holder, String pe
* @param contexts The contexts
* @return Whether the set permission operation was successful
*/
void setTransientPermission(GDPermissionHolder holder, String permission, Boolean value, Set<Context> contexts);
PermissionResult setTransientPermission(GDPermissionHolder holder, String permission, Tristate value, Set<Context> contexts);
/**
* Refreshes all cached permission data of holder.

View File

@ -82,7 +82,7 @@ public void registerDefaults() {
@Override
public void registerCustomType(Flag type) {
this.registryMap.put(type.getId().toLowerCase(Locale.ENGLISH), type);
GriefDefenderPlugin.getGlobalConfig().getConfig().permissionCategory.refreshFlags();
GriefDefenderPlugin.getInstance().flagConfig.getConfig().defaultFlagCategory.refreshFlags();
GriefDefenderPlugin.getInstance().dataStore.setDefaultGlobalPermissions();
}

View File

@ -31,6 +31,7 @@
import com.griefdefender.GDPlayerData;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.GriefDefender;
import com.griefdefender.api.Tristate;
import com.griefdefender.api.claim.Claim;
import com.griefdefender.api.claim.ClaimContexts;
import com.griefdefender.api.claim.ClaimResult;
@ -45,8 +46,10 @@
import com.griefdefender.claim.GDClaimManager;
import com.griefdefender.claim.GDClaimResult;
import com.griefdefender.configuration.ClaimTemplateStorage;
import com.griefdefender.configuration.FlagConfig;
import com.griefdefender.configuration.GriefDefenderConfig;
import com.griefdefender.configuration.MessageStorage;
import com.griefdefender.configuration.OptionConfig;
import com.griefdefender.configuration.type.ConfigBase;
import com.griefdefender.configuration.type.GlobalConfig;
import com.griefdefender.event.GDCauseStackManager;
@ -318,8 +321,9 @@ public void setDefaultGlobalPermissions() {
// Admin defaults
Set<Context> contexts = new HashSet<>();
contexts.add(ClaimContexts.ADMIN_DEFAULT_CONTEXT);
final GriefDefenderConfig<GlobalConfig> activeConfig = GriefDefenderPlugin.getGlobalConfig();
final Map<String, Boolean> adminDefaultFlags = activeConfig.getConfig().permissionCategory.getFlagDefaults(ClaimTypes.ADMIN.getName().toLowerCase());
final FlagConfig flagConfig = GriefDefenderPlugin.getInstance().flagConfig;
final OptionConfig optionConfig = GriefDefenderPlugin.getInstance().optionConfig;
final Map<String, Boolean> adminDefaultFlags = flagConfig.getConfig().defaultFlagCategory.getFlagDefaults(ClaimTypes.ADMIN.getName().toLowerCase());
if (adminDefaultFlags != null && !adminDefaultFlags.isEmpty()) {
this.setDefaultFlags(contexts, adminDefaultFlags);
}
@ -327,11 +331,11 @@ public void setDefaultGlobalPermissions() {
// Basic defaults
contexts = new HashSet<>();
contexts.add(ClaimContexts.BASIC_DEFAULT_CONTEXT);
final Map<String, Boolean> basicDefaultFlags = activeConfig.getConfig().permissionCategory.getFlagDefaults(ClaimTypes.BASIC.getName().toLowerCase());
final Map<String, Boolean> basicDefaultFlags = flagConfig.getConfig().defaultFlagCategory.getFlagDefaults(ClaimTypes.BASIC.getName().toLowerCase());
if (basicDefaultFlags != null && !basicDefaultFlags.isEmpty()) {
this.setDefaultFlags(contexts, basicDefaultFlags);
}
final Map<String, String> basicDefaultOptions = activeConfig.getConfig().permissionCategory.getBasicOptionDefaults();
final Map<String, String> basicDefaultOptions = optionConfig.getConfig().defaultOptionCategory.getBasicOptionDefaults();
contexts = new HashSet<>();
contexts.add(ClaimTypes.BASIC.getDefaultContext());
this.setDefaultOptions(ClaimTypes.BASIC.toString(), contexts, new HashMap<>(basicDefaultOptions));
@ -339,8 +343,8 @@ public void setDefaultGlobalPermissions() {
// Town defaults
contexts = new HashSet<>();
contexts.add(ClaimContexts.TOWN_DEFAULT_CONTEXT);
final Map<String, Boolean> townDefaultFlags = activeConfig.getConfig().permissionCategory.getFlagDefaults(ClaimTypes.TOWN.getName().toLowerCase());
final Map<String, String> townDefaultOptions = activeConfig.getConfig().permissionCategory.getTownOptionDefaults();
final Map<String, Boolean> townDefaultFlags = flagConfig.getConfig().defaultFlagCategory.getFlagDefaults(ClaimTypes.TOWN.getName().toLowerCase());
final Map<String, String> townDefaultOptions = optionConfig.getConfig().defaultOptionCategory.getTownOptionDefaults();
if (townDefaultFlags != null && !townDefaultFlags.isEmpty()) {
this.setDefaultFlags(contexts, townDefaultFlags);
}
@ -351,24 +355,25 @@ public void setDefaultGlobalPermissions() {
// Subdivision defaults
contexts = new HashSet<>();
contexts.add(ClaimTypes.SUBDIVISION.getDefaultContext());
final Map<String, String> subdivisionDefaultOptions = activeConfig.getConfig().permissionCategory.getSubdivisionOptionDefaults();
final Map<String, String> subdivisionDefaultOptions = optionConfig.getConfig().defaultOptionCategory.getSubdivisionOptionDefaults();
this.setDefaultOptions(ClaimTypes.SUBDIVISION.toString(), contexts, new HashMap<>(subdivisionDefaultOptions));
// Wilderness defaults
contexts = new HashSet<>();
contexts.add(ClaimContexts.WILDERNESS_DEFAULT_CONTEXT);
final Map<String, Boolean> wildernessDefaultFlags = activeConfig.getConfig().permissionCategory.getFlagDefaults(ClaimTypes.WILDERNESS.getName().toLowerCase());
final Map<String, Boolean> wildernessDefaultFlags = flagConfig.getConfig().defaultFlagCategory.getFlagDefaults(ClaimTypes.WILDERNESS.getName().toLowerCase());
this.setDefaultFlags(contexts, wildernessDefaultFlags);
// Global default options
contexts = new HashSet<>();
contexts.add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
final Map<String, Boolean> globalDefaultFlags = activeConfig.getConfig().permissionCategory.getFlagDefaults("global");
final Map<String, Boolean> globalDefaultFlags = flagConfig.getConfig().defaultFlagCategory.getFlagDefaults("global");
this.setDefaultFlags(contexts, globalDefaultFlags);
final Map<String, String> globalDefaultOptions = activeConfig.getConfig().permissionCategory.getUserOptionDefaults();
final Map<String, String> globalDefaultOptions = optionConfig.getConfig().defaultOptionCategory.getUserOptionDefaults();
this.setDefaultOptions(ClaimContexts.GLOBAL_DEFAULT_CONTEXT.getName(), contexts, new HashMap<>(globalDefaultOptions));
//GriefDefenderPlugin.getInstance().getPermissionProvider().setTransientPermission(GriefDefenderPlugin.DEFAULT_HOLDER, "griefdefender", false, new HashSet<>());
activeConfig.save();
flagConfig.save();
optionConfig.save();
}
private void setDefaultFlags(Set<Context> contexts, Map<String, Boolean> defaultFlags) {
@ -382,13 +387,7 @@ private void setDefaultFlags(Set<Context> contexts, Map<String, Boolean> default
if (flag == null) {
continue;
}
PermissionUtil.getInstance().setTransientPermission(GriefDefenderPlugin.DEFAULT_HOLDER, flag.getPermission(), mapEntry.getValue(), contexts);
if (flag == Flags.ENTITY_DAMAGE) {
// allow monsters to be attacked by default
contexts.add(FlagContexts.TARGET_TYPE_MONSTER);
PermissionUtil.getInstance().setTransientPermission(GriefDefenderPlugin.DEFAULT_HOLDER, flag.getPermission(), true, contexts);
contexts.remove(FlagContexts.TARGET_TYPE_MONSTER);
}
PermissionUtil.getInstance().setTransientPermission(GriefDefenderPlugin.DEFAULT_HOLDER, flag.getPermission(), Tristate.fromBoolean(mapEntry.getValue()), contexts);
}
PermissionUtil.getInstance().refreshCachedData(GriefDefenderPlugin.DEFAULT_HOLDER);
});

View File

@ -216,12 +216,12 @@ public PermissionResult setPermissionValue(GDPermissionHolder holder, String per
return PERMISSION_PROVIDER.setPermissionValue(holder, permission, value, contexts, check, save);
}
public void setTransientOption(GDPermissionHolder holder, String permission, String value, Set<Context> contexts) {
PERMISSION_PROVIDER.setTransientOption(holder, permission, value, contexts);
public PermissionResult setTransientOption(GDPermissionHolder holder, String permission, String value, Set<Context> contexts) {
return PERMISSION_PROVIDER.setTransientOption(holder, permission, value, contexts);
}
public void setTransientPermission(GDPermissionHolder holder, String permission, Boolean value, Set<Context> contexts) {
PERMISSION_PROVIDER.setTransientPermission(holder, permission, value, contexts);
public PermissionResult setTransientPermission(GDPermissionHolder holder, String permission, Tristate value, Set<Context> contexts) {
return PERMISSION_PROVIDER.setTransientPermission(holder, permission, value, contexts);
}
public void refreshCachedData(GDPermissionHolder holder) {

View File

@ -3,9 +3,9 @@
"libraries": [
{
"name": "com.griefdefender:api:1.0.0",
"sha1": "08d8fa30e0f8bbb43a2100e712bed2a815a8fd87",
"path": "com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200125.004205-14.jar",
"url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200125.004205-14.jar"
"sha1": "0bb7ec5bb796298ed269e1cd642e6dd29704698d",
"path": "com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200505.043120-15.jar",
"url": "https://repo.glaremasters.me/repository/bloodshot/com/griefdefender/api/1.0.0-SNAPSHOT/api-1.0.0-20200505.043120-15.jar"
},
{
"name": "com.griefdefender:reflect-helper:1.0",