Block mine fieldability check

This commit is contained in:
kuroppoi 2021-06-02 00:00:20 +02:00
parent 3520fe2a44
commit d1e00bded3
3 changed files with 32 additions and 1 deletions

View file

@ -0,0 +1,22 @@
package brainwine.gameserver.item;
import com.fasterxml.jackson.annotation.JsonCreator;
public enum Fieldability {
TRUE,
FALSE,
PLACED;
@JsonCreator
private static Fieldability create(String string) {
switch(string) {
default:
return TRUE;
case "false":
return FALSE;
case "placed":
return PLACED;
}
}
}

View file

@ -41,6 +41,9 @@ public class Item {
@JsonProperty("rotation")
private String rotation;
@JsonProperty("fieldable")
private Fieldability fieldability = Fieldability.TRUE;
@JsonProperty("loot_graphic")
private LootGraphic lootGraphic = LootGraphic.NONE;
@ -146,6 +149,10 @@ public class Item {
return id == 0;
}
public Fieldability getFieldability() {
return fieldability;
}
public LootGraphic getLootGraphic() {
return lootGraphic;
}

View file

@ -6,6 +6,7 @@ import java.util.Map;
import brainwine.gameserver.entity.player.Player;
import brainwine.gameserver.item.Action;
import brainwine.gameserver.item.Fieldability;
import brainwine.gameserver.item.Item;
import brainwine.gameserver.item.ItemUseType;
import brainwine.gameserver.item.Layer;
@ -50,7 +51,8 @@ public class BlockMineRequest extends PlayerRequest {
return;
}
if(!digging && zone.isBlockProtected(x, y, player) && !player.isAdmin()) {
// TODO block ownership & 'placed' fieldability
if(!digging && item.getFieldability() == Fieldability.TRUE && zone.isBlockProtected(x, y, player) && !player.isAdmin()) {
fail(player, "This block is protected.");
return;
}