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
This commit is contained in:
BONNe1704 2019-02-22 11:31:09 +02:00
parent 7bb2ad09d3
commit 60965eb013
4 changed files with 578 additions and 0 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}