Skip to content

Commit

Permalink
feat: added reload event for better plugin integration (RoinujNosde#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
Peng1104 authored Sep 24, 2024
1 parent 9f4f39a commit f466a86
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanPlayerInput;
import net.sacredlabyrinth.phaed.simpleclans.events.PlayerHomeSetEvent;
import net.sacredlabyrinth.phaed.simpleclans.events.PlayerResetKdrEvent;
import net.sacredlabyrinth.phaed.simpleclans.events.ReloadEvent;
import net.sacredlabyrinth.phaed.simpleclans.events.TagChangeEvent;
import net.sacredlabyrinth.phaed.simpleclans.language.LanguageResource;
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
Expand All @@ -15,7 +16,6 @@
import net.sacredlabyrinth.phaed.simpleclans.managers.StorageManager;
import net.sacredlabyrinth.phaed.simpleclans.ui.InventoryController;
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
import net.sacredlabyrinth.phaed.simpleclans.utils.TagValidator;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
Expand Down Expand Up @@ -123,6 +123,8 @@ public void reload(CommandSender sender) {
for (Clan clan : cm.getClans()) {
permissions.updateClanPermissions(clan);
}
Bukkit.getPluginManager().callEvent(new ReloadEvent(sender));

ChatBlock.sendMessage(sender, AQUA + lang("configuration.reloaded", sender));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package net.sacredlabyrinth.phaed.simpleclans.events;

import org.bukkit.command.CommandSender;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;

public class ReloadEvent extends Event {

private static final HandlerList HANDLER_LIST = new HandlerList();

private final CommandSender sender;

public ReloadEvent(CommandSender sender) {
this.sender = sender;
}

public static @NotNull HandlerList getHandlerList() {
return HANDLER_LIST;
}

@Override
public @NotNull HandlerList getHandlers() {
return HANDLER_LIST;
}

public CommandSender getSender() {
return sender;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void run() {
connection.addRequestProperty("User-Agent", userAgent);
InputStreamReader reader = new InputStreamReader(connection.getInputStream());

JsonElement parse = new JsonParser().parse(reader);
JsonElement parse = JsonParser.parseReader(reader);
if (parse.isJsonObject()) {
String latestVersion = parse.getAsJsonObject().get("name").getAsString();

Expand Down

0 comments on commit f466a86

Please sign in to comment.