From d1e00bded34fd68411c33a3ad04eb846d249f847 Mon Sep 17 00:00:00 2001 From: kuroppoi <68156848+kuroppoi@users.noreply.github.com> Date: Wed, 2 Jun 2021 00:00:20 +0200 Subject: [PATCH] Block mine fieldability check --- .../gameserver/item/Fieldability.java | 22 +++++++++++++++++++ .../java/brainwine/gameserver/item/Item.java | 7 ++++++ .../server/requests/BlockMineRequest.java | 4 +++- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 gameserver/src/main/java/brainwine/gameserver/item/Fieldability.java diff --git a/gameserver/src/main/java/brainwine/gameserver/item/Fieldability.java b/gameserver/src/main/java/brainwine/gameserver/item/Fieldability.java new file mode 100644 index 0000000..b131449 --- /dev/null +++ b/gameserver/src/main/java/brainwine/gameserver/item/Fieldability.java @@ -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; + } + } +} diff --git a/gameserver/src/main/java/brainwine/gameserver/item/Item.java b/gameserver/src/main/java/brainwine/gameserver/item/Item.java index ece9c87..3f8f1f2 100644 --- a/gameserver/src/main/java/brainwine/gameserver/item/Item.java +++ b/gameserver/src/main/java/brainwine/gameserver/item/Item.java @@ -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; } diff --git a/gameserver/src/main/java/brainwine/gameserver/server/requests/BlockMineRequest.java b/gameserver/src/main/java/brainwine/gameserver/server/requests/BlockMineRequest.java index 65d6ccb..5fa2547 100644 --- a/gameserver/src/main/java/brainwine/gameserver/server/requests/BlockMineRequest.java +++ b/gameserver/src/main/java/brainwine/gameserver/server/requests/BlockMineRequest.java @@ -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; }