Skip to content

Commit

Permalink
Add frosted-ice-melt flag, and frosted-ice-form flag.
Browse files Browse the repository at this point in the history
Frosted-ice-form is checked with build, meaning it can be set to allow
for non-members to use frost walker, deny for members to not be able to
use frost walker, or none to respect membership.

Reverts behavior of ice-melt flag to pre-7.x behavior.
Apparently this wasn't covered before.

Fixes WORLDGUARD-4077.
Closes #364.
  • Loading branch information
wizjany committed May 5, 2019
1 parent 7199b8e commit c516eb2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
Expand Up @@ -209,7 +209,7 @@ protected static ProtectedRegion checkRegionStandingIn(RegionManager regionManag
builder.append(regionComp);
}
player.print(builder.build());
throw new CommandException("You're standing in several regions (please pick one).");
throw new CommandException("Several regions affect your current location (please pick one).");
}

return set.iterator().next();
Expand Down
Expand Up @@ -108,6 +108,8 @@ public final class Flags {
public static final StateFlag SNOW_MELT = register(new StateFlag("snow-melt", true));
public static final StateFlag ICE_FORM = register(new StateFlag("ice-form", true));
public static final StateFlag ICE_MELT = register(new StateFlag("ice-melt", true));
public static final StateFlag FROSTED_ICE_MELT = register(new StateFlag("frosted-ice-melt", true));
public static final StateFlag FROSTED_ICE_FORM = register(new StateFlag("frosted-ice-form", false)); // this belongs in the first category of "checked with build"
public static final StateFlag MUSHROOMS = register(new StateFlag("mushroom-growth", true));
public static final StateFlag LEAF_DECAY = register(new StateFlag("leaf-decay", true));
public static final StateFlag GRASS_SPREAD = register(new StateFlag("grass-growth", true));
Expand Down Expand Up @@ -145,6 +147,8 @@ public final class Flags {

public static final StringFlag GREET_MESSAGE = register(new StringFlag("greeting"));
public static final StringFlag FAREWELL_MESSAGE = register(new StringFlag("farewell"));
public static final StringFlag GREET_TITLE = register(new StringFlag("greeting-title"));
public static final StringFlag FAREWELL_TITLE = register(new StringFlag("farewell-title"));

public static final BooleanFlag NOTIFY_ENTER = register(new BooleanFlag("notify-enter"));
public static final BooleanFlag NOTIFY_LEAVE = register(new BooleanFlag("notify-leave"));
Expand Down
Expand Up @@ -20,7 +20,6 @@
package com.sk89q.worldguard.bukkit;

import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.weather.WeatherType;
import com.sk89q.worldedit.world.weather.WeatherTypes;
Expand Down
Expand Up @@ -205,12 +205,13 @@ public void onPlaceBlock(final PlaceBlockEvent event) {
canPlace = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, flags.toArray(new StateFlag[flags.size()])));
what = "place fire";

} else if (type == Material.FROSTED_ICE) {
event.setSilent(true); // gets spammy
canPlace = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.BLOCK_PLACE, Flags.FROSTED_ICE_FORM));
what = "use frostwalker"; // hidden anyway
/* Everything else */
} else {
canPlace = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.BLOCK_PLACE));
try {
event.setSilent(type == Material.FROSTED_ICE);
} catch (NoSuchFieldError ignored) {} // back compat
what = "place that block";
}

Expand Down
Expand Up @@ -513,7 +513,7 @@ public void onBlockForm(BlockFormEvent event) {
return;
}

if (Tag.ICE.isTagged(type)) {
if (type == Material.ICE) {
if (wcfg.disableIceFormation) {
event.setCancelled(true);
return;
Expand All @@ -530,7 +530,7 @@ public void onBlockForm(BlockFormEvent event) {
event.setCancelled(true);
return;
}
if (wcfg.allowedSnowFallOver.size() > 0) {
if (!wcfg.allowedSnowFallOver.isEmpty()) {
Material targetId = event.getBlock().getRelative(0, -1, 0).getType();

if (!wcfg.allowedSnowFallOver.contains(BukkitAdapter.asBlockType(targetId).getId())) {
Expand Down Expand Up @@ -620,7 +620,7 @@ public void onBlockFade(BlockFadeEvent event) {

WorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());

if (Tag.ICE.isTagged(event.getBlock().getType())) {
if (event.getBlock().getType() == Material.ICE) {
if (wcfg.disableIceMelting) {
event.setCancelled(true);
return;
Expand All @@ -631,6 +631,12 @@ public void onBlockFade(BlockFadeEvent event) {
event.setCancelled(true);
return;
}
} else if (event.getBlock().getType() == Material.FROSTED_ICE) {
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.FROSTED_ICE_MELT))) {
event.setCancelled(true);
return;
}
} else if (event.getBlock().getType() == Material.SNOW) {
if (wcfg.disableSnowMelting) {
event.setCancelled(true);
Expand Down

0 comments on commit c516eb2

Please sign in to comment.