From 60965eb013fef740e83b7ea11f15d559f09d9b46 Mon Sep 17 00:00:00 2001 From: BONNe1704 Date: Fri, 22 Feb 2019 11:31:09 +0200 Subject: [PATCH] Create some challenges related events: - CompletedEvent: fires when challenge/level is competed - ResetEvent: fires when challenge is reset - ResetAllEvent: fires when all challenges data in world is reset --- .../events/ChallengeCompletedEvent.java | 154 ++++++++++++++++++ .../events/ChallengeResetAllEvent.java | 152 +++++++++++++++++ .../events/ChallengeResetEvent.java | 149 +++++++++++++++++ .../events/LevelCompletedEvent.java | 123 ++++++++++++++ 4 files changed, 578 insertions(+) create mode 100644 src/main/java/world/bentobox/challenges/events/ChallengeCompletedEvent.java create mode 100644 src/main/java/world/bentobox/challenges/events/ChallengeResetAllEvent.java create mode 100644 src/main/java/world/bentobox/challenges/events/ChallengeResetEvent.java create mode 100644 src/main/java/world/bentobox/challenges/events/LevelCompletedEvent.java diff --git a/src/main/java/world/bentobox/challenges/events/ChallengeCompletedEvent.java b/src/main/java/world/bentobox/challenges/events/ChallengeCompletedEvent.java new file mode 100644 index 0000000..75764a0 --- /dev/null +++ b/src/main/java/world/bentobox/challenges/events/ChallengeCompletedEvent.java @@ -0,0 +1,154 @@ +package world.bentobox.challenges.events; + + + +import java.util.UUID; + +import world.bentobox.bentobox.api.events.PremadeEvent; + + +/** + * This Event is fired when challenge is completed. + */ +public class ChallengeCompletedEvent extends PremadeEvent +{ + + /** + * Constructor creates a new ChallengeCompletedEvent instance. + * + * @param challengeID of type String + * @param playerUUID of type UUID + * @param admin of type boolean + * @param completionCount of type int + */ + public ChallengeCompletedEvent( + String challengeID, + UUID playerUUID, + boolean admin, + int completionCount) + { + this.challengeID = challengeID; + this.playerUUID = playerUUID; + this.admin = admin; + this.completionCount = completionCount; + } + + +// --------------------------------------------------------------------- +// Section: Getters and setters +// --------------------------------------------------------------------- + + + /** + * This method returns the challengeID value. + * + * @return the value of challengeID. + */ + public String getChallengeID() + { + return challengeID; + } + + + /** + * This method sets the challengeID value. + * + * @param challengeID the challengeID new value. + */ + public void setChallengeID(String challengeID) + { + this.challengeID = challengeID; + } + + + /** + * This method returns the playerUUID value. + * + * @return the value of playerUUID. + */ + public UUID getPlayerUUID() + { + return playerUUID; + } + + + /** + * This method sets the playerUUID value. + * + * @param playerUUID the playerUUID new value. + */ + public void setPlayerUUID(UUID playerUUID) + { + this.playerUUID = playerUUID; + } + + + /** + * This method returns the admin value. + * + * @return the value of admin. + */ + public boolean isAdmin() + { + return admin; + } + + + /** + * This method sets the admin value. + * + * @param admin the admin new value. + */ + public void setAdmin(boolean admin) + { + this.admin = admin; + } + + + /** + * This method returns the completionCount value. + * + * @return the value of completionCount. + */ + public int getCompletionCount() + { + return completionCount; + } + + + /** + * This method sets the completionCount value. + * + * @param completionCount the completionCount new value. + */ + public void setCompletionCount(int completionCount) + { + this.completionCount = completionCount; + } + + +// --------------------------------------------------------------------- +// Section: Variables +// --------------------------------------------------------------------- + + + /** + * Completed challenge ID + */ + private String challengeID; + + /** + * User who completes challenge + */ + private UUID playerUUID; + + /** + * Indicates if admin completes challenge + */ + private boolean admin; + + /** + * Count of completions + */ + private int completionCount; +} diff --git a/src/main/java/world/bentobox/challenges/events/ChallengeResetAllEvent.java b/src/main/java/world/bentobox/challenges/events/ChallengeResetAllEvent.java new file mode 100644 index 0000000..7d46a2e --- /dev/null +++ b/src/main/java/world/bentobox/challenges/events/ChallengeResetAllEvent.java @@ -0,0 +1,152 @@ +package world.bentobox.challenges.events; + + +import java.util.UUID; + +import world.bentobox.bentobox.api.events.PremadeEvent; + + +/** + * This event is fired when all challenges in given world is reset. + */ +public class ChallengeResetAllEvent extends PremadeEvent +{ + /** + * Constructor creates a new ChallengeResetAllEvent instance. + * + * @param worldName of type String + * @param playerUUID of type UUID + * @param admin of type boolean + * @param reason of type String + */ + public ChallengeResetAllEvent( + String worldName, + UUID playerUUID, + boolean admin, + String reason) + { + this.worldName = worldName; + this.playerUUID = playerUUID; + this.admin = admin; + this.reason = reason; + } + + +// --------------------------------------------------------------------- +// Section: Getters and setters +// --------------------------------------------------------------------- + + + /** + * This method returns the worldName value. + * + * @return the value of worldName. + */ + public String getWorldName() + { + return worldName; + } + + + /** + * This method sets the worldName value. + * + * @param worldName the worldName new value. + */ + public void setWorldName(String worldName) + { + this.worldName = worldName; + } + + + /** + * This method returns the playerUUID value. + * + * @return the value of playerUUID. + */ + public UUID getPlayerUUID() + { + return playerUUID; + } + + + /** + * This method sets the playerUUID value. + * + * @param playerUUID the playerUUID new value. + */ + public void setPlayerUUID(UUID playerUUID) + { + this.playerUUID = playerUUID; + } + + + /** + * This method returns the admin value. + * + * @return the value of admin. + */ + public boolean isAdmin() + { + return admin; + } + + + /** + * This method sets the admin value. + * + * @param admin the admin new value. + */ + public void setAdmin(boolean admin) + { + this.admin = admin; + } + + + /** + * This method returns the reason value. + * + * @return the value of reason. + */ + public String getReason() + { + return reason; + } + + + /** + * This method sets the reason value. + * + * @param reason the reason new value. + */ + public void setReason(String reason) + { + this.reason = reason; + } + + +// --------------------------------------------------------------------- +// Section: Variables +// --------------------------------------------------------------------- + + + /** + * World where challenges are reset + */ + private String worldName; + + /** + * User who resets challenges + */ + private UUID playerUUID; + + /** + * Indicates if admin resets challenges + */ + private boolean admin; + + /** + * Reset Reason + */ + private String reason; +} diff --git a/src/main/java/world/bentobox/challenges/events/ChallengeResetEvent.java b/src/main/java/world/bentobox/challenges/events/ChallengeResetEvent.java new file mode 100644 index 0000000..0b7cf5d --- /dev/null +++ b/src/main/java/world/bentobox/challenges/events/ChallengeResetEvent.java @@ -0,0 +1,149 @@ +package world.bentobox.challenges.events; + + +import java.util.UUID; + +import world.bentobox.bentobox.api.events.PremadeEvent; + + +/** + * This event is fired when single challenge is reset by admin. + */ +public class ChallengeResetEvent extends PremadeEvent +{ + /** + * Constructor creates a new ChallengeResetEvent instance. + * + * @param challengeID of type String + * @param playerUUID of type UUID + * @param admin of type boolean + * @param reason of type String + */ + public ChallengeResetEvent( + String challengeID, + UUID playerUUID, + boolean admin, + String reason) + { + this.challengeID = challengeID; + this.playerUUID = playerUUID; + this.admin = admin; + this.reason = reason; + } + + + +// --------------------------------------------------------------------- +// Section: Getters and setters +// --------------------------------------------------------------------- + + + /** + * This method returns the challengeID value. + * @return the value of challengeID. + */ + public String getChallengeID() + { + return challengeID; + } + + + /** + * This method sets the challengeID value. + * @param challengeID the challengeID new value. + * + */ + public void setChallengeID(String challengeID) + { + this.challengeID = challengeID; + } + + + /** + * This method returns the playerUUID value. + * @return the value of playerUUID. + */ + public UUID getPlayerUUID() + { + return playerUUID; + } + + + /** + * This method sets the playerUUID value. + * @param playerUUID the playerUUID new value. + * + */ + public void setPlayerUUID(UUID playerUUID) + { + this.playerUUID = playerUUID; + } + + + /** + * This method returns the admin value. + * @return the value of admin. + */ + public boolean isAdmin() + { + return admin; + } + + + /** + * This method sets the admin value. + * @param admin the admin new value. + * + */ + public void setAdmin(boolean admin) + { + this.admin = admin; + } + + + /** + * This method returns the reason value. + * @return the value of reason. + */ + public String getReason() + { + return reason; + } + + + /** + * This method sets the reason value. + * @param reason the reason new value. + * + */ + public void setReason(String reason) + { + this.reason = reason; + } + + +// --------------------------------------------------------------------- +// Section: Variables +// --------------------------------------------------------------------- + + + /** + * Completed challenge ID + */ + private String challengeID; + + /** + * User who completes challenge + */ + private UUID playerUUID; + + /** + * Indicates if admin completes challenge + */ + private boolean admin; + + /** + * Reset Reason + */ + private String reason; +} diff --git a/src/main/java/world/bentobox/challenges/events/LevelCompletedEvent.java b/src/main/java/world/bentobox/challenges/events/LevelCompletedEvent.java new file mode 100644 index 0000000..c74dfb5 --- /dev/null +++ b/src/main/java/world/bentobox/challenges/events/LevelCompletedEvent.java @@ -0,0 +1,123 @@ +package world.bentobox.challenges.events; + + +import java.util.UUID; + +import world.bentobox.bentobox.api.events.PremadeEvent; + + +/** + * This event is fired when challenge level is completed. + */ +public class LevelCompletedEvent extends PremadeEvent +{ + + /** + * Constructor creates a new LevelCompletedEvent instance. + * + * @param levelID of type String + * @param playerUUID of type UUID + * @param admin of type boolean + */ + public LevelCompletedEvent( + String levelID, + UUID playerUUID, + boolean admin) + { + this.levelID = levelID; + this.playerUUID = playerUUID; + this.admin = admin; + } + + +// --------------------------------------------------------------------- +// Section: Getters and setters +// --------------------------------------------------------------------- + + + /** + * This method returns the levelID value. + * + * @return the value of levelID. + */ + public String getLevelID() + { + return levelID; + } + + + /** + * This method sets the levelID value. + * + * @param levelID the levelID new value. + */ + public void setLevelID(String levelID) + { + this.levelID = levelID; + } + + + /** + * This method returns the playerUUID value. + * + * @return the value of playerUUID. + */ + public UUID getPlayerUUID() + { + return playerUUID; + } + + + /** + * This method sets the playerUUID value. + * + * @param playerUUID the playerUUID new value. + */ + public void setPlayerUUID(UUID playerUUID) + { + this.playerUUID = playerUUID; + } + + + /** + * This method returns the admin value. + * + * @return the value of admin. + */ + public boolean isAdmin() + { + return admin; + } + + + /** + * This method sets the admin value. + * + * @param admin the admin new value. + */ + public void setAdmin(boolean admin) + { + this.admin = admin; + } + + +// --------------------------------------------------------------------- +// Section: Variables +// --------------------------------------------------------------------- + + + /** + * Completed level ID + */ + private String levelID; + + /** + * User who completes challenge + */ + private UUID playerUUID; + + /** + * Indicates if admin completes challenge + */ + private boolean admin; +}