9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2026-01-04 15:41:35 +00:00

competition

This commit is contained in:
XiaoMoMi
2023-09-29 17:17:33 +08:00
parent 018592923f
commit 89efe4fa15
4 changed files with 96 additions and 22 deletions

View File

@@ -24,6 +24,7 @@ import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Map;
import java.util.Optional;
@@ -87,6 +88,17 @@ public class FishingResultEvent extends PlayerEvent implements Cancellable {
return args.get(key);
}
/**
* Set the value associated with a specific argument key.
* @param key key
* @param value value
* @return previous value
*/
@Nullable
public String setArg(String key, String value) {
return args.put(key, value);
}
/**
* Gets the result of the fishing action.
*
@@ -123,6 +135,24 @@ public class FishingResultEvent extends PlayerEvent implements Cancellable {
return Integer.parseInt(Optional.ofNullable(getArg("{amount}")).orElse("1"));
}
/**
* Set the loot amount (Only works for items)
*
* @param amount amount
*/
public void setAmount(int amount) {
setArg("{amount}", String.valueOf(amount));
}
/**
* Set the score to get in competition
*
* @param score score
*/
public void setScore(double score) {
setArg("{SCORE}", String.valueOf(score));
}
/**
* An enumeration representing possible fishing results (SUCCESS or FAILURE).
*/