-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
RemoveGroupReward.java
40 lines (34 loc) · 1.69 KB
/
RemoveGroupReward.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package io.github.thatsmusic99.headsplus.api.rewards;
import io.github.thatsmusic99.configurationmaster.api.ConfigSection;
import io.github.thatsmusic99.headsplus.HeadsPlus;
import io.github.thatsmusic99.headsplus.api.Challenge;
import io.github.thatsmusic99.headsplus.api.Reward;
import io.github.thatsmusic99.headsplus.config.MessagesManager;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class RemoveGroupReward extends Reward<String> {
public RemoveGroupReward(@NotNull String group, long xp) {
super(group, xp);
}
public static RemoveGroupReward fromConfigSection(String id, ConfigSection section) {
if (!section.contains("base-value") && !section.contains("reward-value"))
throw new IllegalStateException("Reward type REMOVE_GROUP for reward " + id + " must have a base-value " +
"option!");
return new RemoveGroupReward(section.getString("base-value", section.getString("reward-value")),
section.getLong("base-xp"));
}
@Override
public void rewardPlayer(Challenge challenge, @NotNull Player player) {
super.rewardPlayer(challenge, player);
Permission permissions = HeadsPlus.get().getPermissions();
if (!permissions.isEnabled()) return;
if (!permissions.playerInGroup(player, this.reward)) return;
permissions.playerRemoveGroup(player, this.reward);
}
@Override
public String getDefaultRewardString(Player player, int difficulty) {
return MessagesManager.get().getString("inventory.icon.reward.group-remove", player)
.replace("{group}", this.reward);
}
}