Add block-trampling flag.

Applies to turtle eggs and farmland.

Closes WORLDGUARD-4067, WORLDGUARD-3666.

Also do some misc cleanup.
This commit is contained in:
wizjany 2019-04-19 23:14:14 -04:00
parent c3675a10a2
commit 1dbd25d15e
4 changed files with 33 additions and 18 deletions

View File

@ -60,6 +60,7 @@ public final class Flags {
public static final StateFlag RIDE = register(new StateFlag("ride", false));
public static final StateFlag POTION_SPLASH = register(new StateFlag("potion-splash", false));
public static final StateFlag ITEM_FRAME_ROTATE = register(new StateFlag("item-frame-rotation", false));
public static final StateFlag TRAMPLE_BLOCKS = register(new StateFlag("block-trampling", false));
// These flags are similar to the ones above (used in tandem with BUILD),
// but their defaults are set to TRUE because it is more user friendly.
@ -118,27 +119,35 @@ public final class Flags {
public static final LocationFlag TELE_LOC = register(new LocationFlag("teleport", RegionGroup.MEMBERS));
public static final LocationFlag SPAWN_LOC = register(new LocationFlag("spawn", RegionGroup.MEMBERS));
// session and movement based flags
// idk?
public static final StateFlag INVINCIBILITY = register(new StateFlag("invincible", false));
public static final StateFlag ENTRY = register(new StateFlag("entry", true, RegionGroup.NON_MEMBERS));
public static final StateFlag EXIT = register(new StateFlag("exit", true, RegionGroup.NON_MEMBERS));
public static final StateFlag ENDERPEARL = register(new StateFlag("enderpearl", true));
public static final StateFlag CHORUS_TELEPORT = register(new StateFlag("chorus-fruit-teleport", true));
public static final StateFlag FALL_DAMAGE = register(new StateFlag("fall-damage", true));
// session and movement based flags
public static final StateFlag ENTRY = register(new StateFlag("entry", true, RegionGroup.NON_MEMBERS));
public static final StateFlag EXIT = register(new StateFlag("exit", true, RegionGroup.NON_MEMBERS));
public static final BooleanFlag EXIT_OVERRIDE = register(new BooleanFlag("exit-override"));
public static final StateFlag ENTRY_VIA_TELEPORT = register(new StateFlag("entry-via-teleport", true));
public static final StateFlag EXIT_VIA_TELEPORT = register(new StateFlag("exit-via-teleport", true));
public static final StateFlag ENDERPEARL = register(new StateFlag("enderpearl", true));
public static final StateFlag CHORUS_TELEPORT = register(new StateFlag("chorus-fruit-teleport", true));
public static final StringFlag GREET_MESSAGE = register(new StringFlag("greeting"));
public static final StringFlag FAREWELL_MESSAGE = register(new StringFlag("farewell"));
public static final BooleanFlag NOTIFY_ENTER = register(new BooleanFlag("notify-enter"));
public static final BooleanFlag NOTIFY_LEAVE = register(new BooleanFlag("notify-leave"));
public static final Flag<GameMode> GAME_MODE = register(new GameModeTypeFlag("game-mode"));
public static final StringFlag TIME_LOCK = register(new StringFlag("time-lock"));
public static final Flag<WeatherType> WEATHER_LOCK = register(new WeatherTypeFlag("weather-lock"));
public static final IntegerFlag HEAL_DELAY = register(new IntegerFlag("heal-delay"));
public static final IntegerFlag HEAL_AMOUNT = register(new IntegerFlag("heal-amount"));
public static final DoubleFlag MIN_HEAL = register(new DoubleFlag("heal-min-health"));
public static final DoubleFlag MAX_HEAL = register(new DoubleFlag("heal-max-health"));
public static final IntegerFlag FEED_DELAY = register(new IntegerFlag("feed-delay"));
public static final IntegerFlag FEED_AMOUNT = register(new IntegerFlag("feed-amount"));
public static final IntegerFlag MIN_FOOD = register(new IntegerFlag("feed-min-hunger"));

View File

@ -22,6 +22,7 @@
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.formatting.Style;
import java.util.logging.Formatter;
import java.util.logging.Handler;
import java.util.logging.LogRecord;
@ -29,6 +30,13 @@
* Sends all logger messages to a player.
*/
public class LoggerToChatHandler extends Handler {
private final Formatter formatter = new Formatter() {
@Override
public String format(LogRecord record) {
return formatMessage(record);
}
};
/**
* Player.
*/
@ -62,6 +70,6 @@ public void flush() {
*/
@Override
public void publish(LogRecord record) {
player.printDebug(record.getLevel().getName() + ": " + Style.WHITE + record.getMessage());
player.printDebug(record.getLevel().getName() + ": " + Style.WHITE + formatter.format(record));
}
}

View File

@ -327,7 +327,8 @@ public void loadConfiguration() {
} else {
this.blacklist = blist;
if (summaryOnStart) {
log.log(Level.INFO, "Blacklist loaded.");
log.log(Level.INFO, "({0}) Blacklist loaded with {1} entries.",
new Object[]{worldName, blacklist.getItemCount()});
}
BlacklistLoggerHandler blacklistLogger = blist.getLogger();

View File

@ -396,19 +396,16 @@ public void onPlayerInteract(PlayerInteractEvent event) {
switch (event.getAction()) {
case PHYSICAL:
// turtle eggs are broken when this happens
if (clicked.getType() == Material.TURTLE_EGG) { // normally we'd be safe but WG7 is 1.13+ only
entityBreakBlockDebounce.debounce(clicked, player, event, new BreakBlockEvent(event, cause, clicked));
break;
}
// Forget about Redstone ore
if (clicked.getType() == Material.REDSTONE_ORE || clicked.getType() == Material.FARMLAND) {
DelegateEvent firedEvent = new UseBlockEvent(event, cause, clicked).setAllowed(hasInteractBypass(clicked));
if (clicked.getType() == Material.REDSTONE_ORE) {
silent = true;
}
interactDebounce.debounce(clicked, event.getPlayer(), event,
new UseBlockEvent(event, cause, clicked).setSilent(silent).setAllowed(hasInteractBypass(clicked)));
if (clicked.getType() == Material.FARMLAND || clicked.getType() == Material.TURTLE_EGG) {
silent = true;
firedEvent.getRelevantFlags().add(Flags.TRAMPLE_BLOCKS);
}
firedEvent.setSilent(silent);
interactDebounce.debounce(clicked, event.getPlayer(), event, firedEvent);
break;
case RIGHT_CLICK_BLOCK: