mirror of
https://github.com/bloodmc/GriefDefender.git
synced 2025-01-04 19:08:39 +01:00
Fix getOptionValue without server context.
* Disable weather change message.
This commit is contained in:
parent
63005e72f8
commit
1ac3ad932e
@ -505,22 +505,13 @@ public void checkPlayerWeather(GDPermissionUser user, GDClaim fromClaim, GDClaim
|
||||
final org.bukkit.WeatherType currentWeather = player.getPlayerWeather();
|
||||
player.setPlayerWeather(PlayerUtil.WEATHERTYPE_MAP.get(weatherType));
|
||||
final org.bukkit.WeatherType newWeather = player.getPlayerWeather();
|
||||
if (currentWeather != newWeather) {
|
||||
// TODO - improve so it doesn't spam
|
||||
/*if (currentWeather != newWeather) {
|
||||
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.OPTION_APPLY_PLAYER_WEATHER,
|
||||
ImmutableMap.of(
|
||||
"weather", weatherType.getName()));
|
||||
GriefDefenderPlugin.sendMessage(player, message);
|
||||
}
|
||||
} else {
|
||||
final org.bukkit.WeatherType currentWeather = player.getPlayerWeather();
|
||||
player.resetPlayerWeather();
|
||||
final org.bukkit.WeatherType newWeather = player.getPlayerWeather();
|
||||
if (currentWeather != newWeather) {
|
||||
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.OPTION_APPLY_PLAYER_WEATHER,
|
||||
ImmutableMap.of(
|
||||
"weather", weatherType.getName()));
|
||||
GriefDefenderPlugin.sendMessage(player, message);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -705,6 +705,8 @@ public Tristate getPermissionValue(GDPermissionHolder holder, String permission,
|
||||
// To set options, pass "meta.option".
|
||||
@Override
|
||||
public String getOptionValue(GDPermissionHolder holder, Option option, Set<Context> contexts) {
|
||||
// If no server context exists, add global
|
||||
this.checkServerContext(contexts);
|
||||
ImmutableContextSet set = this.getLPContexts(contexts).immutableCopy();
|
||||
final PermissionHolder permissionHolder = this.getLuckPermsHolder(holder);
|
||||
if (permissionHolder == null) {
|
||||
@ -718,6 +720,8 @@ public String getOptionValue(GDPermissionHolder holder, Option option, Set<Conte
|
||||
|
||||
@Override
|
||||
public List<String> getOptionValueList(GDPermissionHolder holder, Option option, Set<Context> contexts) {
|
||||
// If no server context exists, add global
|
||||
this.checkServerContext(contexts);
|
||||
ImmutableContextSet set = this.getLPContexts(contexts).immutableCopy();
|
||||
final PermissionHolder permissionHolder = this.getLuckPermsHolder(holder);
|
||||
if (permissionHolder == null) {
|
||||
@ -737,7 +741,7 @@ public PermissionResult setOptionValue(GDPermissionHolder holder, String key, St
|
||||
DataMutateResult result = null;
|
||||
if (check) {
|
||||
// If no server context exists, add global
|
||||
this.checkServerContext(contexts, value);
|
||||
this.checkServerContext(contexts);
|
||||
}
|
||||
ImmutableContextSet set = this.getLPContexts(contexts).immutableCopy();
|
||||
final PermissionHolder permissionHolder = this.getLuckPermsHolder(holder);
|
||||
@ -776,7 +780,7 @@ public PermissionResult setPermissionValue(GDPermissionHolder holder, String per
|
||||
DataMutateResult result = null;
|
||||
if (check) {
|
||||
// If no server context exists, add global
|
||||
this.checkServerContext(contexts, value.name());
|
||||
this.checkServerContext(contexts);
|
||||
}
|
||||
ImmutableContextSet set = this.getLPContexts(contexts).immutableCopy();
|
||||
final Node node = this.luckPermsApi.getNodeBuilderRegistry().forPermission().permission(permission).value(value.asBoolean()).context(set).build();
|
||||
@ -812,7 +816,7 @@ public PermissionResult setPermissionValue(GDPermissionHolder holder, String per
|
||||
|
||||
public void setTransientOption(GDPermissionHolder holder, String permission, String value, Set<Context> contexts) {
|
||||
// If no server context exists, add global
|
||||
this.checkServerContext(contexts, value);
|
||||
this.checkServerContext(contexts);
|
||||
MutableContextSet contextSet = this.getLPContexts(contexts);
|
||||
final PermissionHolder permissionHolder = this.getLuckPermsHolder(holder);
|
||||
if (permissionHolder == null) {
|
||||
@ -825,7 +829,7 @@ public void setTransientOption(GDPermissionHolder holder, String permission, Str
|
||||
|
||||
public void setTransientPermission(GDPermissionHolder holder, String permission, Boolean value, Set<Context> contexts) {
|
||||
// If no server context exists, add global
|
||||
this.checkServerContext(contexts, value.toString());
|
||||
this.checkServerContext(contexts);
|
||||
MutableContextSet contextSet = this.getLPContexts(contexts);
|
||||
final PermissionHolder permissionHolder = this.getLuckPermsHolder(holder);
|
||||
if (permissionHolder == null) {
|
||||
@ -898,7 +902,7 @@ private void clearMeta(PermissionHolder holder, String metaKey, ContextSet set)
|
||||
holder.data().clear(set, NodeType.META.predicate(node -> node.getMetaKey().equals(metaKey)));
|
||||
}
|
||||
|
||||
private void checkServerContext(Set<Context> contexts, String value) {
|
||||
private void checkServerContext(Set<Context> contexts) {
|
||||
for (Context context : contexts) {
|
||||
if (context.getKey().equalsIgnoreCase("server")) {
|
||||
return;
|
||||
|
@ -549,20 +549,21 @@ public void checkPlayerWeather(GDPermissionUser user, GDClaim fromClaim, GDClaim
|
||||
if (weatherType != null) {
|
||||
final Weather currentWeather = player.getWorld().getWeather();
|
||||
PlayerUtil.getInstance().setPlayerWeather(user, weatherType);
|
||||
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.OPTION_APPLY_PLAYER_WEATHER,
|
||||
// TODO - improve so it doesn't spam
|
||||
/*final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.OPTION_APPLY_PLAYER_WEATHER,
|
||||
ImmutableMap.of(
|
||||
"weather", weatherType == WeatherTypes.UNDEFINED ? currentWeather.getName().toUpperCase() : weatherType.getName().toUpperCase()));
|
||||
GriefDefenderPlugin.sendMessage(player, message);
|
||||
GriefDefenderPlugin.sendMessage(player, message);*/
|
||||
} else {
|
||||
final WeatherType currentWeather = playerData.lastWeatherType;
|
||||
PlayerUtil.getInstance().resetPlayerWeather(user);
|
||||
final WeatherType newWeather = playerData.lastWeatherType;
|
||||
if (currentWeather != newWeather) {
|
||||
/*if (currentWeather != newWeather) {
|
||||
final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.OPTION_APPLY_PLAYER_WEATHER,
|
||||
ImmutableMap.of(
|
||||
"weather", newWeather.getName().toUpperCase()));
|
||||
GriefDefenderPlugin.sendMessage(player, message);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -701,6 +701,8 @@ public Tristate getPermissionValue(GDPermissionHolder holder, String permission,
|
||||
// To set options, pass "meta.option".
|
||||
@Override
|
||||
public String getOptionValue(GDPermissionHolder holder, Option option, Set<Context> contexts) {
|
||||
// If no server context exists, add global
|
||||
this.checkServerContext(contexts);
|
||||
ImmutableContextSet set = this.getLPContexts(contexts).immutableCopy();
|
||||
final PermissionHolder permissionHolder = this.getLuckPermsHolder(holder);
|
||||
if (permissionHolder == null) {
|
||||
@ -714,6 +716,8 @@ public String getOptionValue(GDPermissionHolder holder, Option option, Set<Conte
|
||||
|
||||
@Override
|
||||
public List<String> getOptionValueList(GDPermissionHolder holder, Option option, Set<Context> contexts) {
|
||||
// If no server context exists, add global
|
||||
this.checkServerContext(contexts);
|
||||
ImmutableContextSet set = this.getLPContexts(contexts).immutableCopy();
|
||||
final PermissionHolder permissionHolder = this.getLuckPermsHolder(holder);
|
||||
if (permissionHolder == null) {
|
||||
@ -733,7 +737,7 @@ public PermissionResult setOptionValue(GDPermissionHolder holder, String key, St
|
||||
DataMutateResult result = null;
|
||||
if (check) {
|
||||
// If no server context exists, add global
|
||||
this.checkServerContext(contexts, value);
|
||||
this.checkServerContext(contexts);
|
||||
}
|
||||
ImmutableContextSet set = this.getLPContexts(contexts).immutableCopy();
|
||||
final PermissionHolder permissionHolder = this.getLuckPermsHolder(holder);
|
||||
@ -772,7 +776,7 @@ public PermissionResult setPermissionValue(GDPermissionHolder holder, String per
|
||||
DataMutateResult result = null;
|
||||
if (check) {
|
||||
// If no server context exists, add global
|
||||
this.checkServerContext(contexts, value.name());
|
||||
this.checkServerContext(contexts);
|
||||
}
|
||||
ImmutableContextSet set = this.getLPContexts(contexts).immutableCopy();
|
||||
final Node node = this.luckPermsApi.getNodeBuilderRegistry().forPermission().permission(permission).value(value.asBoolean()).context(set).build();
|
||||
@ -808,7 +812,7 @@ public PermissionResult setPermissionValue(GDPermissionHolder holder, String per
|
||||
|
||||
public void setTransientOption(GDPermissionHolder holder, String permission, String value, Set<Context> contexts) {
|
||||
// If no server context exists, add global
|
||||
this.checkServerContext(contexts, value);
|
||||
this.checkServerContext(contexts);
|
||||
MutableContextSet contextSet = this.getLPContexts(contexts);
|
||||
final PermissionHolder permissionHolder = this.getLuckPermsHolder(holder);
|
||||
if (permissionHolder == null) {
|
||||
@ -821,7 +825,7 @@ public void setTransientOption(GDPermissionHolder holder, String permission, Str
|
||||
|
||||
public void setTransientPermission(GDPermissionHolder holder, String permission, Boolean value, Set<Context> contexts) {
|
||||
// If no server context exists, add global
|
||||
this.checkServerContext(contexts, value.toString());
|
||||
this.checkServerContext(contexts);
|
||||
MutableContextSet contextSet = this.getLPContexts(contexts);
|
||||
final PermissionHolder permissionHolder = this.getLuckPermsHolder(holder);
|
||||
if (permissionHolder == null) {
|
||||
@ -894,7 +898,7 @@ private void clearMeta(PermissionHolder holder, String metaKey, ContextSet set)
|
||||
holder.data().clear(set, NodeType.META.predicate(node -> node.getMetaKey().equals(metaKey)));
|
||||
}
|
||||
|
||||
private void checkServerContext(Set<Context> contexts, String value) {
|
||||
private void checkServerContext(Set<Context> contexts) {
|
||||
for (Context context : contexts) {
|
||||
if (context.getKey().equalsIgnoreCase("server")) {
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user