Reverting to non-static AddonEvent. Reminder don't break API

Next time I'll add to the API but not break it. I actually did not
realize this API was being used (I forgot).
This commit is contained in:
tastybento 2020-01-12 16:30:50 -08:00
parent 13d7ce2df8
commit 227ebef824
2 changed files with 8 additions and 14 deletions

View File

@ -20,43 +20,37 @@ public class AddonEvent {
/**
* @return Addon event builder
* @deprecated Use static Builder instead
*/
@Deprecated
public AddonEventBuilder builder() {
return new AddonEventBuilder();
}
public static AddonEventBuilder Builder() {
return new AddonEventBuilder();
}
public static class AddonEnableEvent extends AddonBaseEvent {
public class AddonEnableEvent extends AddonBaseEvent {
private AddonEnableEvent(Addon addon, Map<String, Object> keyValues) {
// Final variables have to be declared in the constructor
super(addon, keyValues);
}
}
public static class AddonDisableEvent extends AddonBaseEvent {
public class AddonDisableEvent extends AddonBaseEvent {
private AddonDisableEvent(Addon addon, Map<String, Object> keyValues) {
// Final variables have to be declared in the constructor
super(addon, keyValues);
}
}
public static class AddonLoadEvent extends AddonBaseEvent {
public class AddonLoadEvent extends AddonBaseEvent {
private AddonLoadEvent(Addon addon, Map<String, Object> keyValues) {
// Final variables have to be declared in the constructor
super(addon, keyValues);
}
}
public static class AddonGeneralEvent extends AddonBaseEvent {
public class AddonGeneralEvent extends AddonBaseEvent {
private AddonGeneralEvent(Addon addon, Map<String, Object> keyValues) {
// Final variables have to be declared in the constructor
super(addon, keyValues);
}
}
public static class AddonEventBuilder {
public class AddonEventBuilder {
// Here field are NOT final. They are just used for the building.
private Addon addon;
private Reason reason = Reason.UNKNOWN;

View File

@ -108,7 +108,7 @@ public class AddonsManager {
plugin.getLocalesManager().loadLocalesFromFile(addon.getDescription().getName());
// Fire the load event
AddonEvent.Builder().addon(addon).reason(AddonEvent.Reason.LOAD).build();
new AddonEvent().builder().addon(addon).reason(AddonEvent.Reason.LOAD).build();
// Add it to the list of addons
addons.remove(addon);
@ -176,7 +176,7 @@ public class AddonsManager {
gameMode.getPlayerCommand().ifPresent(c -> c.setWorld(gameMode.getOverWorld()));
gameMode.getAdminCommand().ifPresent(c -> c.setWorld(gameMode.getOverWorld()));
}
AddonEvent.Builder().addon(addon).reason(AddonEvent.Reason.ENABLE).build();
new AddonEvent().builder().addon(addon).reason(AddonEvent.Reason.ENABLE).build();
addon.setState(Addon.State.ENABLED);
plugin.log("Enabling " + addon.getDescription().getName() + "...");
} catch (NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
@ -429,7 +429,7 @@ public class AddonsManager {
addon.getDescription().getAuthors().forEach(plugin::logError);
plugin.logStacktrace(e);
}
AddonEvent.Builder().addon(addon).reason(AddonEvent.Reason.DISABLE).build();
new AddonEvent().builder().addon(addon).reason(AddonEvent.Reason.DISABLE).build();
}
// Clear loaders
if (loaders.containsKey(addon)) {