Skip to content

Commit c839a7e

Browse files
author
Valandur
committed
Merge branch 'release/v3.3.1'
2 parents b62b62e + 1750c5a commit c839a7e

File tree

7 files changed

+52
-19
lines changed

7 files changed

+52
-19
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
group=valandur.webapi
2-
version=3.3.0
2+
version=3.3.1
33
minecraftVersion=1.11.2
44
spongeVersion=7.0

src/main/java/valandur/webapi/WebAPI.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.spongepowered.api.event.Listener;
2828
import org.spongepowered.api.event.Order;
2929
import org.spongepowered.api.event.achievement.GrantAchievementEvent;
30+
import org.spongepowered.api.event.block.InteractBlockEvent;
3031
import org.spongepowered.api.event.command.SendCommandEvent;
3132
import org.spongepowered.api.event.entity.DestructEntityEvent;
3233
import org.spongepowered.api.event.entity.SpawnEntityEvent;
@@ -426,6 +427,10 @@ public void onPlayerChat(MessageChannelEvent.Chat event, @First Player player) {
426427
WebHooks.notifyHooks(WebHooks.WebHookType.CHAT, msg);
427428
}
428429

430+
@Listener(order = Order.POST)
431+
public void onBlockInteract(InteractBlockEvent event) {
432+
WebHooks.notifyHooks(WebHooks.WebHookType.INTERACT_BLOCK, event);
433+
}
429434
@Listener(order = Order.POST)
430435
public void onInteractInventory(InteractInventoryEvent.Open event) {
431436
WebHooks.notifyHooks(WebHooks.WebHookType.INVENTORY_OPEN, event);

src/main/java/valandur/webapi/cache/entity/CachedEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public CachedEntity(Entity entity) {
6666
try {
6767
Inventory inv = ((Carrier) entity).getInventory();
6868
this.inventory = Inventory.builder().from(inv).build(inv.getPlugin());
69-
} catch (AbstractMethodError ignored) {
69+
} catch (Exception | AbstractMethodError ignored) {
7070
}
7171
}
7272
}

src/main/java/valandur/webapi/hooks/WebHooks.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public class WebHooks {
2323

2424
public enum WebHookType {
2525
ALL, CUSTOM_COMMAND, CUSTOM_EVENT, ACHIEVEMENT, BLOCK_UPDATE_STATUS, CHAT, COMMAND, GENERATE_CHUNK, EXPLOSION,
26-
INVENTORY_OPEN, INVENTORY_CLOSE, PLAYER_JOIN, PLAYER_LEAVE, PLAYER_DEATH, PLAYER_KICK, PLAYER_BAN, SERVER_START, SERVER_STOP,
27-
WORLD_SAVE, WORLD_LOAD, WORLD_UNLOAD
26+
INTERACT_BLOCK, INVENTORY_OPEN, INVENTORY_CLOSE, PLAYER_JOIN, PLAYER_LEAVE, PLAYER_DEATH, PLAYER_KICK,
27+
PLAYER_BAN, SERVER_START, SERVER_STOP, WORLD_SAVE, WORLD_LOAD, WORLD_UNLOAD
2828
}
2929

3030
private static Map<String, CommandWebHook> commandHooks = new HashMap<>();

src/main/java/valandur/webapi/json/JsonConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ public static void loadExtraSerializers() {
298298
}
299299

300300
// Write back to file
301-
Files.write(file.toPath(), fileContent.getBytes(), StandardOpenOption.CREATE);
301+
Files.write(file.toPath(), fileContent.getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
302302

303303
// Compile the file
304304
Iterable<? extends JavaFileObject> compilationUnits = fm.getJavaFileObjectsFromFiles(Collections.singletonList(file));

src/main/java/valandur/webapi/json/serializers/event/EventSerializer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.spongepowered.api.entity.Entity;
66
import org.spongepowered.api.event.Event;
77
import org.spongepowered.api.event.achievement.GrantAchievementEvent;
8+
import org.spongepowered.api.event.block.TargetBlockEvent;
89
import org.spongepowered.api.event.entity.TargetEntityEvent;
910
import org.spongepowered.api.event.entity.living.humanoid.player.KickPlayerEvent;
1011
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent;
@@ -65,6 +66,10 @@ public void serialize(Event value, JsonGenerator gen, SerializerProvider provide
6566
writeField(provider, "world", ((TargetWorldEvent)value).getTargetWorld());
6667
}
6768

69+
if (value instanceof TargetBlockEvent) {
70+
writeField(provider, "block", ((TargetBlockEvent)value).getTargetBlock());
71+
}
72+
6873
try {
6974
writeField(provider, "cause", value.getCause());
7075
} catch (AbstractMethodError ignored) {}

src/main/resources/assets/webapi/defaults/hooks.conf

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Config file version, used to update correctly
2-
version = 3
2+
version = 4
33

44
# Web hooks are used to send certain events on minecraft to other endpoints.
55
# This can be used for example to log chat or react to certain commands.
@@ -10,7 +10,6 @@ version = 3
1010
# Please note that the hooks don't get called in any particular order, and might even be called concurrently.
1111
events {
1212
# This event is fired for all other events. The "X-WebAPI-Event" header specifies the exact event.
13-
# Data: See below, depends on hook
1413
all=[{
1514
# This is the address of the endpoint. It may contain parameters that are replaced when being called.
1615
# Parameters have to be placed in curly braces, { and }, and will be a simple string (uuid of object
@@ -42,76 +41,100 @@ events {
4241
}]
4342

4443
# This event is fired when a player earns an achievement
45-
# Data: { target: <player>, achievement: <achievement> }
4644
achievement=[
4745
# HOOKS
4846
]
4947

48+
# This event is fired when a block update changes status
49+
# NOTE: These are not actual minecraft blocks updating, these are the WebAPI block updates
50+
block_update_status=[
51+
# HOOKS
52+
]
53+
5054
# This event is fired when a chat message is sent on the server
51-
# Data: <message>
5255
chat=[
5356
# HOOKS
5457
]
5558

5659
# This event is fired when a command is executed
57-
# Data: <command>
5860
command=[
5961
# HOOKS
6062
]
6163

64+
# This event is fired when a chunk is generated
65+
generate_chunk=[
66+
# HOOKS
67+
]
68+
69+
# This event is fired when an explosion occurs
70+
explosion=[
71+
# HOOKS
72+
]
73+
74+
# This event is fired when a player interacts with a block
75+
interact_block=[
76+
# HOOKS
77+
]
78+
6279
# This event is fired when an inventory is opened
63-
# Data: { inventory: <inventory>, cause: { source: <player> } }
6480
inventory_open=[
6581
# HOOKS
6682
]
6783

6884
# This event is fired when an inventory is closed
69-
# Data: { inventory: <inventory>, cause: { source: <player } }
7085
inventory_close=[
7186
# HOOKS
7287
]
7388

7489
# This event is fired when a player joins the server
75-
# Data: { target: <player> }
7690
player_join=[
7791
# HOOKS
7892
]
7993

8094
# This event is fired when a player leaves the server
81-
# Data: { target: <player> }
8295
player_leave=[
8396
# HOOKS
8497
]
8598

8699
# This event is fired when a player dies
87-
# Data: { killer: <player|entity>, target: <player> }
88100
player_death=[
89101
# HOOKS
90102
]
91103

92104
# This event is fired when a player gets kicked
93-
# Data: { target: <player>, message: <string> }
94105
player_kick=[
95106
# HOOKS
96107
]
97108

98109
# This event is fired when a player gets banned
99-
# Data: { target: <player>, ban: { createdOn: <epoch seconds>, expires: <epoch seconds>, source: <string> } }
100110
player_ban=[
101111
# HOOKS
102112
]
103113

104114
# This event is fired when the server starts
105-
# Data: { }
106115
server_start=[
107116
# HOOKS
108117
]
109118

110119
# This event is fired when the server stops
111-
# Data: { }
112120
server_stop=[
113121
# HOOKS
114122
]
123+
124+
# This event is fired when the world is saved
125+
world_save=[
126+
# HOOKS
127+
]
128+
129+
# This event is fired when a world is loaded
130+
world_load=[
131+
# HOOKS
132+
]
133+
134+
# This event is fired when a world is unloaded
135+
world_unload=[
136+
# HOOKS
137+
]
115138
}
116139

117140
# These hooks can be used to bind to custom events. You have to use the fully qualified class name as the key, and then

0 commit comments

Comments
 (0)