-
-
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 `lightning_strike` WebHook * Added `weather_change`, `thunder_change` WebHook * meet Code standards * made json parameter in WeatherChange more clear
- Loading branch information
Showing
6 changed files
with
118 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
33 changes: 33 additions & 0 deletions
33
src/main/java/com/shweit/serverapi/webhooks/weather/LightningStrike.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,33 @@ | ||
package com.shweit.serverapi.webhooks.weather; | ||
|
||
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.weather.LightningStrikeEvent; | ||
import org.json.JSONObject; | ||
|
||
public final class LightningStrike implements WebHook, Listener { | ||
|
||
private final String eventName = WebHookEnum.LIGHTNING_STRIKE.label; | ||
|
||
@Override | ||
public void register() { | ||
if (RegisterWebHooks.doActivateWebhook(eventName)) { | ||
MinecraftServerAPI plugin = MinecraftServerAPI.getInstance(); | ||
plugin.getServer().getPluginManager().registerEvents(this, plugin); | ||
} | ||
} | ||
|
||
@EventHandler | ||
public void onLightningStrike(final LightningStrikeEvent event) { | ||
JSONObject jsonObject = new JSONObject(); | ||
jsonObject.put("event", eventName); | ||
jsonObject.put("location", event.getLightning().getLocation().toString()); | ||
jsonObject.put("cause", event.getCause().name()); | ||
|
||
RegisterWebHooks.sendToAllUrls(jsonObject); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/shweit/serverapi/webhooks/weather/ThunderChange.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,33 @@ | ||
package com.shweit.serverapi.webhooks.weather; | ||
|
||
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.weather.ThunderChangeEvent; | ||
import org.json.JSONObject; | ||
|
||
public final class ThunderChange implements WebHook, Listener { | ||
|
||
private final String eventName = WebHookEnum.THUNDER_CHANGE.label; | ||
|
||
@Override | ||
public void register() { | ||
if (RegisterWebHooks.doActivateWebhook(eventName)) { | ||
MinecraftServerAPI plugin = MinecraftServerAPI.getInstance(); | ||
plugin.getServer().getPluginManager().registerEvents(this, plugin); | ||
} | ||
} | ||
|
||
@EventHandler | ||
public void onThunderChange(final ThunderChangeEvent event) { | ||
JSONObject jsonObject = new JSONObject(); | ||
jsonObject.put("event", eventName); | ||
jsonObject.put("world", event.getWorld().getName()); | ||
jsonObject.put("thunder", event.toThunderState()); | ||
|
||
RegisterWebHooks.sendToAllUrls(jsonObject); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/shweit/serverapi/webhooks/weather/WeatherChange.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,33 @@ | ||
package com.shweit.serverapi.webhooks.weather; | ||
|
||
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.weather.WeatherChangeEvent; | ||
import org.json.JSONObject; | ||
|
||
public final class WeatherChange implements WebHook, Listener { | ||
|
||
private final String eventName = WebHookEnum.WEATHER_CHANGE.label; | ||
|
||
@Override | ||
public void register() { | ||
if (RegisterWebHooks.doActivateWebhook(eventName)) { | ||
MinecraftServerAPI plugin = MinecraftServerAPI.getInstance(); | ||
plugin.getServer().getPluginManager().registerEvents(this, plugin); | ||
} | ||
} | ||
|
||
@EventHandler | ||
public void onWeatherChange(final WeatherChangeEvent event) { | ||
JSONObject jsonObject = new JSONObject(); | ||
jsonObject.put("event", eventName); | ||
jsonObject.put("world", event.getWorld().getName()); | ||
jsonObject.put("rain", event.toWeatherState()); | ||
|
||
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