mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-27 05:05:18 +01:00
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:
parent
13d7ce2df8
commit
227ebef824
@ -20,43 +20,37 @@ public class AddonEvent {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Addon event builder
|
* @return Addon event builder
|
||||||
* @deprecated Use static Builder instead
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public AddonEventBuilder builder() {
|
public AddonEventBuilder builder() {
|
||||||
return new AddonEventBuilder();
|
return new AddonEventBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AddonEventBuilder Builder() {
|
public class AddonEnableEvent extends AddonBaseEvent {
|
||||||
return new AddonEventBuilder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class AddonEnableEvent extends AddonBaseEvent {
|
|
||||||
private AddonEnableEvent(Addon addon, Map<String, Object> keyValues) {
|
private AddonEnableEvent(Addon addon, Map<String, Object> keyValues) {
|
||||||
// Final variables have to be declared in the constructor
|
// Final variables have to be declared in the constructor
|
||||||
super(addon, keyValues);
|
super(addon, keyValues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static class AddonDisableEvent extends AddonBaseEvent {
|
public class AddonDisableEvent extends AddonBaseEvent {
|
||||||
private AddonDisableEvent(Addon addon, Map<String, Object> keyValues) {
|
private AddonDisableEvent(Addon addon, Map<String, Object> keyValues) {
|
||||||
// Final variables have to be declared in the constructor
|
// Final variables have to be declared in the constructor
|
||||||
super(addon, keyValues);
|
super(addon, keyValues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static class AddonLoadEvent extends AddonBaseEvent {
|
public class AddonLoadEvent extends AddonBaseEvent {
|
||||||
private AddonLoadEvent(Addon addon, Map<String, Object> keyValues) {
|
private AddonLoadEvent(Addon addon, Map<String, Object> keyValues) {
|
||||||
// Final variables have to be declared in the constructor
|
// Final variables have to be declared in the constructor
|
||||||
super(addon, keyValues);
|
super(addon, keyValues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static class AddonGeneralEvent extends AddonBaseEvent {
|
public class AddonGeneralEvent extends AddonBaseEvent {
|
||||||
private AddonGeneralEvent(Addon addon, Map<String, Object> keyValues) {
|
private AddonGeneralEvent(Addon addon, Map<String, Object> keyValues) {
|
||||||
// Final variables have to be declared in the constructor
|
// Final variables have to be declared in the constructor
|
||||||
super(addon, keyValues);
|
super(addon, keyValues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AddonEventBuilder {
|
public class AddonEventBuilder {
|
||||||
// Here field are NOT final. They are just used for the building.
|
// Here field are NOT final. They are just used for the building.
|
||||||
private Addon addon;
|
private Addon addon;
|
||||||
private Reason reason = Reason.UNKNOWN;
|
private Reason reason = Reason.UNKNOWN;
|
||||||
|
@ -108,7 +108,7 @@ public class AddonsManager {
|
|||||||
plugin.getLocalesManager().loadLocalesFromFile(addon.getDescription().getName());
|
plugin.getLocalesManager().loadLocalesFromFile(addon.getDescription().getName());
|
||||||
|
|
||||||
// Fire the load event
|
// 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
|
// Add it to the list of addons
|
||||||
addons.remove(addon);
|
addons.remove(addon);
|
||||||
@ -176,7 +176,7 @@ public class AddonsManager {
|
|||||||
gameMode.getPlayerCommand().ifPresent(c -> c.setWorld(gameMode.getOverWorld()));
|
gameMode.getPlayerCommand().ifPresent(c -> c.setWorld(gameMode.getOverWorld()));
|
||||||
gameMode.getAdminCommand().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);
|
addon.setState(Addon.State.ENABLED);
|
||||||
plugin.log("Enabling " + addon.getDescription().getName() + "...");
|
plugin.log("Enabling " + addon.getDescription().getName() + "...");
|
||||||
} catch (NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
|
} catch (NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
|
||||||
@ -429,7 +429,7 @@ public class AddonsManager {
|
|||||||
addon.getDescription().getAuthors().forEach(plugin::logError);
|
addon.getDescription().getAuthors().forEach(plugin::logError);
|
||||||
plugin.logStacktrace(e);
|
plugin.logStacktrace(e);
|
||||||
}
|
}
|
||||||
AddonEvent.Builder().addon(addon).reason(AddonEvent.Reason.DISABLE).build();
|
new AddonEvent().builder().addon(addon).reason(AddonEvent.Reason.DISABLE).build();
|
||||||
}
|
}
|
||||||
// Clear loaders
|
// Clear loaders
|
||||||
if (loaders.containsKey(addon)) {
|
if (loaders.containsKey(addon)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user