This repository has been archived by the owner on Jan 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
189 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package me.Flibio.EconomyLite; | ||
|
||
import org.spongepowered.api.event.AbstractEvent; | ||
import org.spongepowered.api.event.Cancellable; | ||
|
||
public class BalanceChangeEvent extends AbstractEvent implements Cancellable { | ||
|
||
private boolean cancelled = false; | ||
private String player; | ||
|
||
public BalanceChangeEvent(String player){ | ||
this.player = player; | ||
} | ||
|
||
@Override | ||
public boolean isCancelled() { | ||
return this.cancelled; | ||
} | ||
|
||
@Override | ||
public void setCancelled(boolean cancelled) { | ||
this.cancelled = cancelled; | ||
} | ||
|
||
public String getPlayerName(){ | ||
return player; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package me.Flibio.EconomyLite; | ||
|
||
import org.slf4j.Logger; | ||
import org.spongepowered.api.Game; | ||
import org.spongepowered.api.entity.player.Player; | ||
import org.spongepowered.api.event.Subscribe; | ||
import org.spongepowered.api.scoreboard.Scoreboard; | ||
import org.spongepowered.api.scoreboard.critieria.Criteria; | ||
import org.spongepowered.api.scoreboard.displayslot.DisplaySlots; | ||
import org.spongepowered.api.scoreboard.objective.Objective; | ||
import org.spongepowered.api.text.Texts; | ||
import org.spongepowered.api.text.format.TextColors; | ||
|
||
public class PlayerBalanceChange { | ||
|
||
private Logger logger; | ||
private Game game; | ||
|
||
public PlayerBalanceChange(Logger logger, Game game){ | ||
this.logger = logger; | ||
this.game = game; | ||
} | ||
|
||
@Subscribe | ||
public void onBalanceChange(BalanceChangeEvent event){ | ||
|
||
//Update the scoreboard | ||
if(Main.scoreboardEnabled()) { | ||
int playerBalance = (new DataEditor(logger,game)).getBalance(event.getPlayerName()); | ||
|
||
Player player = null; | ||
|
||
for(Player p : game.getServer().getOnlinePlayers()){ | ||
if(p.getName().equalsIgnoreCase(event.getPlayerName())){ | ||
player = p; | ||
} | ||
} | ||
|
||
if(player!=null){ | ||
Scoreboard board = game.getRegistry().getScoreboardBuilder().build(); | ||
Objective obj = game.getRegistry().getObjectiveBuilder().name("EconomyLite").criterion(Criteria.DUMMY).displayName(Texts.builder("Economy").color(TextColors.YELLOW).build()).build(); | ||
obj.getScore(Texts.builder("Balance: ").color(TextColors.GREEN).build()).setScore(playerBalance); | ||
board.addObjective(obj); | ||
board.addObjective(obj, DisplaySlots.SIDEBAR); | ||
|
||
player.setScoreboard(board); | ||
} | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.