-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added `world_loader` WebHook * Added `world_save` WebHook * Added `world_unload` WebHook * meet code standards
- Loading branch information
Showing
6 changed files
with
115 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/com/shweit/serverapi/webhooks/world/WorldLoad.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.shweit.serverapi.webhooks.world; | ||
|
||
import com.shweit.serverapi.MinecraftServerAPI; | ||
import com.shweit.serverapi.webhooks.RegisterWebHooks; | ||
import com.shweit.serverapi.webhooks.WebHook; | ||
import com.shweit.serverapi.webhooks.WebHookEnum; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.world.WorldLoadEvent; | ||
import org.json.JSONObject; | ||
|
||
public final class WorldLoad implements WebHook, Listener { | ||
|
||
private final String eventName = WebHookEnum.WORLD_LOAD.label; | ||
|
||
@Override | ||
public void register() { | ||
if (RegisterWebHooks.doActivateWebhook(eventName)) { | ||
MinecraftServerAPI plugin = MinecraftServerAPI.getInstance(); | ||
plugin.getServer().getPluginManager().registerEvents(this, plugin); | ||
} | ||
} | ||
|
||
@EventHandler | ||
public void onWorldLoad(final WorldLoadEvent event) { | ||
JSONObject jsonObject = new JSONObject(); | ||
jsonObject.put("event", eventName); | ||
jsonObject.put("world", event.getWorld().getName()); | ||
|
||
RegisterWebHooks.sendToAllUrls(jsonObject); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/shweit/serverapi/webhooks/world/WorldSave.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.shweit.serverapi.webhooks.world; | ||
|
||
import com.shweit.serverapi.MinecraftServerAPI; | ||
import com.shweit.serverapi.webhooks.RegisterWebHooks; | ||
import com.shweit.serverapi.webhooks.WebHook; | ||
import com.shweit.serverapi.webhooks.WebHookEnum; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.world.WorldSaveEvent; | ||
import org.json.JSONObject; | ||
|
||
public final class WorldSave implements WebHook, Listener { | ||
|
||
private final String eventName = WebHookEnum.WORLD_SAVE.label; | ||
|
||
@Override | ||
public void register() { | ||
if (RegisterWebHooks.doActivateWebhook(eventName)) { | ||
MinecraftServerAPI plugin = MinecraftServerAPI.getInstance(); | ||
plugin.getServer().getPluginManager().registerEvents(this, plugin); | ||
} | ||
} | ||
|
||
@EventHandler | ||
public void onWorldSave(final WorldSaveEvent event) { | ||
JSONObject jsonObject = new JSONObject(); | ||
jsonObject.put("event", eventName); | ||
jsonObject.put("world", event.getWorld().getName()); | ||
|
||
RegisterWebHooks.sendToAllUrls(jsonObject); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/shweit/serverapi/webhooks/world/WorldUnload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.shweit.serverapi.webhooks.world; | ||
|
||
import com.shweit.serverapi.MinecraftServerAPI; | ||
import com.shweit.serverapi.webhooks.RegisterWebHooks; | ||
import com.shweit.serverapi.webhooks.WebHook; | ||
import com.shweit.serverapi.webhooks.WebHookEnum; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.world.WorldUnloadEvent; | ||
import org.json.JSONObject; | ||
|
||
public final class WorldUnload implements WebHook, Listener { | ||
|
||
private final String eventName = WebHookEnum.WORLD_UNLOAD.label; | ||
|
||
@Override | ||
public void register() { | ||
if (RegisterWebHooks.doActivateWebhook(eventName)) { | ||
MinecraftServerAPI plugin = MinecraftServerAPI.getInstance(); | ||
plugin.getServer().getPluginManager().registerEvents(this, plugin); | ||
} | ||
} | ||
|
||
@EventHandler | ||
public void onWorldUnload(final WorldUnloadEvent event) { | ||
JSONObject jsonObject = new JSONObject(); | ||
jsonObject.put("event", eventName); | ||
jsonObject.put("world", event.getWorld().getName()); | ||
|
||
RegisterWebHooks.sendToAllUrls(jsonObject); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters