Award score on event finish
This commit is contained in:
parent
dfb5999d02
commit
fedb9a56a3
4 changed files with 25 additions and 2 deletions
|
@ -41,6 +41,11 @@ public class TeamScoreBoard {
|
|||
return objective.getScore(team.getName()).getScore();
|
||||
}
|
||||
|
||||
public void addScore(Team team, int score) {
|
||||
int current_score = getScore(team);
|
||||
setScore(team, current_score + score);
|
||||
}
|
||||
|
||||
public Team getTeam(Integer team_index) {
|
||||
Team team = scoreboard.getTeam(team_index.toString());
|
||||
|
||||
|
@ -50,6 +55,7 @@ public class TeamScoreBoard {
|
|||
team.color(colors.get(team_index % colors.size()));
|
||||
team.prefix(Component.text("Team " + team_index.toString() + " "));
|
||||
team.setAllowFriendlyFire(false);
|
||||
setScore(team, 0);
|
||||
}
|
||||
|
||||
return team;
|
||||
|
@ -67,7 +73,6 @@ public class TeamScoreBoard {
|
|||
team.addPlayer(player);
|
||||
team.addEntry(player.getUniqueId().toString());
|
||||
player.sendRichMessage("<rainbow>You have been added to team " + team.getName());
|
||||
this.setScore(team, 0);
|
||||
player.setGlowing(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ public abstract class Event implements Listener {
|
|||
|
||||
protected void eventSuccess() {
|
||||
MC13DTL.board.sendMessageToTeam(team, Component.text("Congratulations! You survived this event").color(NamedTextColor.GREEN));
|
||||
MC13DTL.board.addScore(team, scoreAwarded());
|
||||
eventFinished();
|
||||
}
|
||||
|
||||
|
@ -53,4 +54,6 @@ public abstract class Event implements Listener {
|
|||
}
|
||||
|
||||
protected abstract String getMessage();
|
||||
|
||||
protected abstract int scoreAwarded();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package gent.zeus.mc13dtl.events.catalog;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import gent.zeus.mc13dtl.events.Event;
|
||||
|
@ -13,4 +15,17 @@ public class TestEvent extends Event {
|
|||
protected String getMessage() {
|
||||
return "test";
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (event.getPlayer() == null) {
|
||||
return;
|
||||
}
|
||||
eventSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int scoreAwarded() {
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public class GroupRemoveCommand implements BasicCommand {
|
|||
team.removeEntry(player.getName());
|
||||
player.sendMessage("You have been removed from your team");
|
||||
} else {
|
||||
commandSourceStack.getSender().sendMessage("Player not a team!");
|
||||
commandSourceStack.getSender().sendMessage("Player not in a team!");
|
||||
}
|
||||
} else {
|
||||
commandSourceStack.getSender().sendMessage("Player " + args[0] + " does not exist.");
|
||||
|
|
Loading…
Reference in a new issue