mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 14:05:25 +01:00
Document some of api events
This commit is contained in:
parent
516df9ad01
commit
891262ca00
@ -688,7 +688,8 @@ public class PlayerManager {
|
||||
message = message.replace("%jobname%", job.getNameWithColor());
|
||||
|
||||
if (levelUpEvent.getOldTitle() != null)
|
||||
message = message.replace("%titlename%", levelUpEvent.getOldTitleColor() + levelUpEvent.getOldTitleName());
|
||||
message = message.replace("%titlename%", levelUpEvent.getOldTitle()
|
||||
.getChatColor().toString() + levelUpEvent.getOldTitle().getName());
|
||||
|
||||
message = message.replace("%playername%", player != null ? player.getDisplayName() : jPlayer.getName());
|
||||
message = message.replace("%joblevel%", "" + prog.getLevel());
|
||||
@ -724,7 +725,8 @@ public class PlayerManager {
|
||||
message = Jobs.getLanguage().getMessage("message.skillup.nobroadcast");
|
||||
|
||||
message = message.replace("%playername%", player != null ? player.getDisplayName() : jPlayer.getName());
|
||||
message = message.replace("%titlename%", levelUpEvent.getNewTitleColor() + levelUpEvent.getNewTitleName());
|
||||
message = message.replace("%titlename%", levelUpEvent.getNewTitle()
|
||||
.getChatColor().toString() + levelUpEvent.getNewTitle().getName());
|
||||
message = message.replace("%jobname%", job.getNameWithColor());
|
||||
|
||||
for (String line : message.split("\n")) {
|
||||
|
@ -4,6 +4,9 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gamingmesh.jobs.container.CuboidArea;
|
||||
|
||||
/**
|
||||
* Called when a player attempted to select an area.
|
||||
*/
|
||||
public final class JobsAreaSelectionEvent extends BaseEvent {
|
||||
private CuboidArea area;
|
||||
private Player player;
|
||||
@ -13,10 +16,20 @@ public final class JobsAreaSelectionEvent extends BaseEvent {
|
||||
this.area = area;
|
||||
}
|
||||
|
||||
/**
|
||||
* The player who selected an area.
|
||||
*
|
||||
* @return {@link Player}
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the selected area.
|
||||
*
|
||||
* @return {@link CuboidArea}
|
||||
*/
|
||||
public CuboidArea getArea() {
|
||||
return area;
|
||||
}
|
||||
|
@ -3,7 +3,11 @@ package com.gamingmesh.jobs.api;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
/**
|
||||
* Fired when there is a new chunk explored by player moving.
|
||||
* <p>
|
||||
* <b>This is same behaviour when using {@link org.bukkit.event.player.PlayerMoveEvent}
|
||||
*/
|
||||
public final class JobsChunkChangeEvent extends BaseEvent implements Cancellable {
|
||||
private Player player;
|
||||
private Chunk oldChunk;
|
||||
@ -16,14 +20,29 @@ public final class JobsChunkChangeEvent extends BaseEvent implements Cancellable
|
||||
this.newChunk = newChunk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player who explored a chunk.
|
||||
*
|
||||
* @return {@link Player}
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the old explored chunk.
|
||||
*
|
||||
* @return {@link Chunk}
|
||||
*/
|
||||
public Chunk getOldChunk() {
|
||||
return oldChunk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the new explored chunk.
|
||||
*
|
||||
* @return {@link Chunk}
|
||||
*/
|
||||
public Chunk getNewChunk() {
|
||||
return newChunk;
|
||||
}
|
||||
|
@ -9,6 +9,9 @@ import org.bukkit.event.Cancellable;
|
||||
import com.gamingmesh.jobs.container.ActionInfo;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
|
||||
/**
|
||||
* Called when a player gains exp from jobs.
|
||||
*/
|
||||
public final class JobsExpGainEvent extends BaseEvent implements Cancellable {
|
||||
|
||||
private OfflinePlayer offlinePlayer;
|
||||
@ -37,34 +40,76 @@ public final class JobsExpGainEvent extends BaseEvent implements Cancellable {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the player who got exp.
|
||||
*
|
||||
* @return {@link OfflinePlayer}
|
||||
*/
|
||||
public OfflinePlayer getPlayer() {
|
||||
return offlinePlayer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the job where the player is got the exp from.
|
||||
*
|
||||
* @return {@link Job}
|
||||
*/
|
||||
public Job getJob() {
|
||||
return job;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of gained exp for player.
|
||||
*
|
||||
* @return got exp amount
|
||||
*/
|
||||
public double getExp() {
|
||||
return exp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the exp to a new value.
|
||||
*
|
||||
* @param exp the new value
|
||||
*/
|
||||
public void setExp(double exp) {
|
||||
this.exp = exp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the block which the player broken and got income.
|
||||
*
|
||||
* @return {@link Block}
|
||||
*/
|
||||
public Block getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the entity that the player killed or did something before.
|
||||
* <p>
|
||||
* This method is used for Citizens NPCs and armor stand breaking.
|
||||
*
|
||||
* @return {@link Entity}
|
||||
*/
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the living entity that the player killed.
|
||||
*
|
||||
* @return {@link LivingEntity}
|
||||
*/
|
||||
public LivingEntity getLivingEntity() {
|
||||
return living;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the action info, containing the action which the player performed.
|
||||
*
|
||||
* @return {@link ActionInfo}
|
||||
*/
|
||||
public ActionInfo getActionInfo() {
|
||||
return info;
|
||||
}
|
||||
|
@ -15,10 +15,20 @@ public final class JobsJoinEvent extends BaseEvent implements Cancellable {
|
||||
this.job = job;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the player who joined to a job.
|
||||
*
|
||||
* @return {@link JobsPlayer}
|
||||
*/
|
||||
public JobsPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the job where the player joined.
|
||||
*
|
||||
* @return {@link Job}
|
||||
*/
|
||||
public Job getJob() {
|
||||
return job;
|
||||
}
|
||||
|
@ -15,10 +15,20 @@ public final class JobsLeaveEvent extends BaseEvent implements Cancellable {
|
||||
this.job = job;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the player who left a job.
|
||||
*
|
||||
* @return {@link JobsPlayer}
|
||||
*/
|
||||
public JobsPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the job where the player left.
|
||||
*
|
||||
* @return {@link Job}
|
||||
*/
|
||||
public Job getJob() {
|
||||
return job;
|
||||
}
|
||||
|
@ -7,25 +7,25 @@ import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.container.Title;
|
||||
|
||||
public final class JobsLevelUpEvent extends BaseEvent implements Cancellable {
|
||||
|
||||
private JobsPlayer player;
|
||||
private String JobName;
|
||||
private Title OldTitle;
|
||||
private Title NewTitle;
|
||||
private int level;
|
||||
private Sound soundLevelupSound = Sound.values()[0];
|
||||
private int soundLevelupVolume = 1;
|
||||
private int soundLevelupPitch = 3;
|
||||
private Sound soundTitleChangeSound = Sound.values()[0];
|
||||
private int soundTitleChangeVolume = 1;
|
||||
private int soundTitleChangePitch = 3;
|
||||
private String jobName;
|
||||
private Title oldTitle;
|
||||
private Title newTitle;
|
||||
|
||||
private Sound soundLevelupSound;
|
||||
private Sound soundTitleChangeSound;
|
||||
|
||||
private int level, soundLevelupVolume = 1, soundLevelupPitch = 3,
|
||||
soundTitleChangeVolume = 1, soundTitleChangePitch = 3;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public JobsLevelUpEvent(JobsPlayer jPlayer, String JobName, int level, Title OldTitle, Title NewTitle, String soundLevelupSound, Integer soundLevelupVolume,
|
||||
Integer soundLevelupPitch, String soundTitleChangeSound, Integer soundTitleChangeVolume, Integer soundTitleChangePitch) {
|
||||
this.player = jPlayer;
|
||||
this.JobName = JobName;
|
||||
this.OldTitle = OldTitle;
|
||||
this.NewTitle = NewTitle;
|
||||
this.jobName = JobName;
|
||||
this.oldTitle = OldTitle;
|
||||
this.newTitle = NewTitle;
|
||||
this.level = level;
|
||||
this.soundLevelupSound = getSound(soundLevelupSound);
|
||||
this.soundLevelupVolume = soundLevelupVolume;
|
||||
@ -35,52 +35,99 @@ public final class JobsLevelUpEvent extends BaseEvent implements Cancellable {
|
||||
this.soundTitleChangePitch = soundTitleChangePitch;
|
||||
}
|
||||
|
||||
private static Sound getSound(String soundName) {
|
||||
for (Sound one : Sound.values()) {
|
||||
if (one.name().equalsIgnoreCase(soundName))
|
||||
return one;
|
||||
private Sound getSound(String soundName) {
|
||||
if (soundName != null) {
|
||||
for (Sound one : Sound.values()) {
|
||||
if (one.name().equalsIgnoreCase(soundName))
|
||||
return one;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
return Sound.values()[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the player who got level up in a job.
|
||||
*
|
||||
* @return {@link JobsPlayer}
|
||||
*/
|
||||
public JobsPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the job name where the player level up.
|
||||
*
|
||||
* @return the job name
|
||||
*/
|
||||
public String getJobName() {
|
||||
return JobName;
|
||||
return jobName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the old title of the player.
|
||||
*
|
||||
* @return {@link Title}
|
||||
*/
|
||||
public Title getOldTitle() {
|
||||
return OldTitle;
|
||||
return oldTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #getOldTitle()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public String getOldTitleName() {
|
||||
return OldTitle.getName();
|
||||
return oldTitle.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #getOldTitle()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public String getOldTitleShort() {
|
||||
return OldTitle.getShortName();
|
||||
return oldTitle.getShortName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #getOldTitle()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public String getOldTitleColor() {
|
||||
return OldTitle.getChatColor().toString();
|
||||
return oldTitle.getChatColor().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the new title of the player.
|
||||
*
|
||||
* @return {@link Title}
|
||||
*/
|
||||
public Title getNewTitle() {
|
||||
return NewTitle;
|
||||
return newTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #getNewTitle()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public String getNewTitleName() {
|
||||
return NewTitle.getName();
|
||||
return newTitle.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #getNewTitle()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public String getNewTitleShort() {
|
||||
return NewTitle.getShortName();
|
||||
return newTitle.getShortName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #getNewTitle()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public String getNewTitleColor() {
|
||||
return NewTitle.getChatColor().toString();
|
||||
return newTitle.getChatColor().toString();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ -89,11 +136,11 @@ public final class JobsLevelUpEvent extends BaseEvent implements Cancellable {
|
||||
}
|
||||
|
||||
public Sound getSound() {
|
||||
return this.soundLevelupSound == null ? Sound.values()[0] : this.soundLevelupSound;
|
||||
return soundLevelupSound;
|
||||
}
|
||||
|
||||
public void setSound(Sound soundLevelupSound) {
|
||||
this.soundLevelupSound = soundLevelupSound;
|
||||
this.soundLevelupSound = soundLevelupSound == null ? Sound.values()[0] : soundLevelupSound;
|
||||
}
|
||||
|
||||
public int getSoundVolume() {
|
||||
@ -118,11 +165,11 @@ public final class JobsLevelUpEvent extends BaseEvent implements Cancellable {
|
||||
}
|
||||
|
||||
public Sound getTitleChangeSound() {
|
||||
return this.soundTitleChangeSound == null ? Sound.values()[0] : this.soundTitleChangeSound;
|
||||
return soundTitleChangeSound;
|
||||
}
|
||||
|
||||
public void setTitleChangeSound(Sound soundTitleChangeSound) {
|
||||
this.soundTitleChangeSound = soundTitleChangeSound;
|
||||
this.soundTitleChangeSound = soundTitleChangeSound == null ? Sound.values()[0] : soundTitleChangeSound;
|
||||
}
|
||||
|
||||
public int getTitleChangeVolume() {
|
||||
@ -141,6 +188,11 @@ public final class JobsLevelUpEvent extends BaseEvent implements Cancellable {
|
||||
this.soundTitleChangePitch = soundTitleChangePitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the player job progression level.
|
||||
*
|
||||
* @return player job progression level
|
||||
*/
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
@ -30,6 +30,11 @@ public final class JobsPaymentEvent extends Event implements Cancellable {
|
||||
this.payments = payments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the player who got payment.
|
||||
*
|
||||
* @return {@link OfflinePlayer}
|
||||
*/
|
||||
public OfflinePlayer getPlayer() {
|
||||
return offlinePlayer;
|
||||
}
|
||||
@ -68,15 +73,32 @@ public final class JobsPaymentEvent extends Event implements Cancellable {
|
||||
this.payments.put(CurrencyType.POINTS, points);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the payment amount of currency type.
|
||||
*
|
||||
* @param type {@link CurrencyType}
|
||||
* @return the amount of payment in specific type
|
||||
*/
|
||||
public Double get(CurrencyType type) {
|
||||
Double amount = payments.get(type);
|
||||
return amount == null ? 0 : amount;
|
||||
return payments.getOrDefault(type, 0D);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the payment amount to a new one for the given currency type.
|
||||
*
|
||||
* @param type {@link CurrencyType}
|
||||
* @param amount the new amount
|
||||
* @return the given amount
|
||||
*/
|
||||
public Double set(CurrencyType type, double amount) {
|
||||
return payments.put(type, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all payment types map.
|
||||
*
|
||||
* @return {@link HashMap}
|
||||
*/
|
||||
public HashMap<CurrencyType, Double> getPayment() {
|
||||
return payments;
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
/**
|
||||
* Event fired, before the payment calculation process should beginning.
|
||||
*/
|
||||
public final class JobsPrePaymentEvent extends BaseEvent implements Cancellable {
|
||||
private OfflinePlayer offlinePlayer;
|
||||
private double money;
|
||||
@ -39,42 +42,94 @@ public final class JobsPrePaymentEvent extends BaseEvent implements Cancellable
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the player who performed something in a job.
|
||||
*
|
||||
* @return {@link OfflinePlayer}
|
||||
*/
|
||||
public OfflinePlayer getPlayer() {
|
||||
return offlinePlayer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of expected income.
|
||||
*
|
||||
* @return expected income before calculations
|
||||
*/
|
||||
public double getAmount() {
|
||||
return money;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of expected points.
|
||||
*
|
||||
* @return expected points before calculations
|
||||
*/
|
||||
public double getPoints() {
|
||||
return points;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the job where the payment will calculate.
|
||||
*
|
||||
* @return {@link Job}
|
||||
*/
|
||||
public Job getJob() {
|
||||
return job;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a new money amount before calculations.
|
||||
*
|
||||
* @param money new amount
|
||||
*/
|
||||
public void setAmount(double money) {
|
||||
this.money = money;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a new points amount before calculations.
|
||||
*
|
||||
* @param points
|
||||
*/
|
||||
public void setPoints(double points) {
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the block which the player performed to break.
|
||||
*
|
||||
* @return {@link Block}
|
||||
*/
|
||||
public Block getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the entity that the player killed or did something before.
|
||||
* <p>
|
||||
* This method is used for Citizens NPCs and armor stand breaking.
|
||||
*
|
||||
* @return {@link Entity}
|
||||
*/
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the living entity that the player killed.
|
||||
*
|
||||
* @return {@link LivingEntity}
|
||||
*/
|
||||
public LivingEntity getLivingEntity() {
|
||||
return living;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the action info, containing the action which the player performed.
|
||||
*
|
||||
* @return {@link ActionInfo}
|
||||
*/
|
||||
public ActionInfo getActionInfo() {
|
||||
return info;
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ package com.gamingmesh.jobs.api;
|
||||
import com.gamingmesh.jobs.container.Schedule;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
/**
|
||||
* Called when a schedule has been started.
|
||||
*/
|
||||
public class JobsScheduleStartEvent extends BaseEvent implements Cancellable {
|
||||
private boolean cancelled = false;
|
||||
private Schedule schedule;
|
||||
@ -11,6 +14,11 @@ public class JobsScheduleStartEvent extends BaseEvent implements Cancellable {
|
||||
this.schedule = schedule;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the schedule which started.
|
||||
*
|
||||
* @return {@link Schedule}
|
||||
*/
|
||||
public Schedule getSchedule() {
|
||||
return schedule;
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ package com.gamingmesh.jobs.api;
|
||||
import com.gamingmesh.jobs.container.Schedule;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
/**
|
||||
* Called when a schedule has been stopped.
|
||||
*/
|
||||
public class JobsScheduleStopEvent extends BaseEvent implements Cancellable {
|
||||
private boolean cancelled = false;
|
||||
private Schedule schedule;
|
||||
@ -11,6 +14,11 @@ public class JobsScheduleStopEvent extends BaseEvent implements Cancellable {
|
||||
this.schedule = schedule;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the schedule which stopped.
|
||||
*
|
||||
* @return {@link Schedule}
|
||||
*/
|
||||
public Schedule getSchedule() {
|
||||
return schedule;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import com.gamingmesh.jobs.listeners.JobsPaymentListener;
|
||||
* marked as "removeable". In the future this class will get removed
|
||||
* and not used anymore by anyone. Instead use {@link Jobs#getBlockOwnerShips()}
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(forRemoval = true)
|
||||
public class FurnaceBrewingHandling {
|
||||
|
||||
static HashMap<UUID, List<blockLoc>> furnaceMap = new HashMap<>();
|
||||
|
Loading…
Reference in New Issue
Block a user