Implement progression titles
This commit is contained in:
parent
9acfa361ad
commit
81a869c264
@ -1,5 +1,7 @@
|
|||||||
package mineplex.gemhunters.chat;
|
package mineplex.gemhunters.chat;
|
||||||
|
|
||||||
|
import mineplex.gemhunters.economy.EconomyModule;
|
||||||
|
import mineplex.gemhunters.progression.ProgressionModule;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -26,15 +28,19 @@ public class ChatModule extends MiniPlugin
|
|||||||
|
|
||||||
private final CoreClientManager _clientManager;
|
private final CoreClientManager _clientManager;
|
||||||
private final Chat _chat;
|
private final Chat _chat;
|
||||||
|
private final EconomyModule _economy;
|
||||||
private final PartyManager _party;
|
private final PartyManager _party;
|
||||||
|
private final ProgressionModule _progression;
|
||||||
|
|
||||||
private ChatModule()
|
private ChatModule()
|
||||||
{
|
{
|
||||||
super("Chat");
|
super("Chat");
|
||||||
|
|
||||||
_clientManager = require(CoreClientManager.class);
|
_clientManager = require(CoreClientManager.class);
|
||||||
_chat = require(Chat.class);
|
_chat = require(Chat.class);
|
||||||
|
_economy = require(EconomyModule.class);
|
||||||
_party = require(PartyManager.class);
|
_party = require(PartyManager.class);
|
||||||
|
_progression = require(ProgressionModule.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
@ -90,7 +96,7 @@ public class ChatModule extends MiniPlugin
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
message += C.cWhite;
|
message = _progression.getTitle(_economy.getGems(player)).getTitle() + " " + message + C.cWhite;
|
||||||
}
|
}
|
||||||
|
|
||||||
message += _chat.getFilteredMessage(player, event.getMessage());
|
message += _chat.getFilteredMessage(player, event.getMessage());
|
||||||
|
@ -1,17 +1,41 @@
|
|||||||
package mineplex.gemhunters.progression;
|
package mineplex.gemhunters.progression;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@ReflectivelyCreateMiniPlugin
|
@ReflectivelyCreateMiniPlugin
|
||||||
public class ProgressionModule extends MiniPlugin
|
public class ProgressionModule extends MiniPlugin
|
||||||
{
|
{
|
||||||
|
|
||||||
private final Map<Integer, String> TITLES = ImmutableMap<Integer, String>().builder().build();
|
private static final List<ProgressionTitle> TITLE_LIST = Arrays.asList(
|
||||||
|
new ProgressionTitle(C.cGray + "Bankrupt", 0),
|
||||||
|
new ProgressionTitle(C.cAqua + "Beggar", 100),
|
||||||
|
new ProgressionTitle(C.cGreen + "Poor", 250),
|
||||||
|
new ProgressionTitle(C.cGreen + "Middle Class", 500),
|
||||||
|
new ProgressionTitle(C.cGold + "Wealthy", 750),
|
||||||
|
new ProgressionTitle(C.cGold + "Loaded", 1000),
|
||||||
|
new ProgressionTitle(C.cRed + "Millionaire", 5000)
|
||||||
|
);
|
||||||
|
|
||||||
public ProgressionModule()
|
public ProgressionModule()
|
||||||
{
|
{
|
||||||
super("Progression");
|
super("Progression");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProgressionTitle getTitle(int gems)
|
||||||
|
{
|
||||||
|
for (ProgressionTitle title : TITLE_LIST)
|
||||||
|
{
|
||||||
|
if (title.getRequiredGems() >= gems)
|
||||||
|
{
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TITLE_LIST.get(TITLE_LIST.size() - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package mineplex.gemhunters.progression;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
|
||||||
|
public class ProgressionTitle
|
||||||
|
{
|
||||||
|
|
||||||
|
private String _title;
|
||||||
|
private int _requiredGems;
|
||||||
|
|
||||||
|
public ProgressionTitle(String title, int requiredGems)
|
||||||
|
{
|
||||||
|
_title = title + C.Reset;
|
||||||
|
_requiredGems = requiredGems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle()
|
||||||
|
{
|
||||||
|
return _title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRequiredGems()
|
||||||
|
{
|
||||||
|
return _requiredGems;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package mineplex.gemhunters.scoreboard;
|
package mineplex.gemhunters.scoreboard;
|
||||||
|
|
||||||
|
import mineplex.gemhunters.progression.ProgressionModule;
|
||||||
|
import mineplex.gemhunters.progression.ProgressionTitle;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.Managers;
|
import mineplex.core.Managers;
|
||||||
@ -17,6 +19,7 @@ public class GemHuntersScoreboard extends WritableMineplexScoreboard
|
|||||||
|
|
||||||
private final EconomyModule _economy;
|
private final EconomyModule _economy;
|
||||||
private final PlayerStatusModule _playerStatus;
|
private final PlayerStatusModule _playerStatus;
|
||||||
|
private final ProgressionModule _progression;
|
||||||
private final SupplyDropModule _supplyDrop;
|
private final SupplyDropModule _supplyDrop;
|
||||||
|
|
||||||
public GemHuntersScoreboard(Player player)
|
public GemHuntersScoreboard(Player player)
|
||||||
@ -25,6 +28,7 @@ public class GemHuntersScoreboard extends WritableMineplexScoreboard
|
|||||||
|
|
||||||
_economy = Managers.get(EconomyModule.class);
|
_economy = Managers.get(EconomyModule.class);
|
||||||
_playerStatus = Managers.get(PlayerStatusModule.class);
|
_playerStatus = Managers.get(PlayerStatusModule.class);
|
||||||
|
_progression = Managers.get(ProgressionModule.class);
|
||||||
_supplyDrop = Managers.get(SupplyDropModule.class);
|
_supplyDrop = Managers.get(SupplyDropModule.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,4 +64,9 @@ public class GemHuntersScoreboard extends WritableMineplexScoreboard
|
|||||||
{
|
{
|
||||||
return _economy.getGems(player);
|
return _economy.getGems(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPrefix(Player perspective, Player subject)
|
||||||
|
{
|
||||||
|
return _progression.getTitle(_economy.getGems(subject)).getTitle() + " " + C.cYellow;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,17 +70,17 @@ public class ScoreboardModule extends MiniPlugin
|
|||||||
for (Player player : Bukkit.getOnlinePlayers())
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
int gems = _economy.getGems(player);
|
int gems = _economy.getGems(player);
|
||||||
|
|
||||||
for (GemHuntersScoreboard scoreboard : _scoreboards.values())
|
for (GemHuntersScoreboard scoreboard : _scoreboards.values())
|
||||||
{
|
{
|
||||||
Objective objective = scoreboard.getHandle().getObjective(DisplaySlot.BELOW_NAME);
|
Objective objective = scoreboard.getHandle().getObjective(DisplaySlot.BELOW_NAME);
|
||||||
Score score = objective.getScore(player.getName());
|
Score score = objective.getScore(player.getName());
|
||||||
|
|
||||||
if (score.getScore() == gems)
|
if (score.getScore() == gems)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
score.setScore(gems);
|
score.setScore(gems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,45 +106,75 @@ public class ScoreboardModule extends MiniPlugin
|
|||||||
_scoreboards.remove(player.getUniqueId());
|
_scoreboards.remove(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createPlayerScoreboard(Player player)
|
@EventHandler
|
||||||
{
|
public void updateScoreboard(UpdateEvent event)
|
||||||
if (!_scoreboards.containsKey(player.getUniqueId()))
|
{
|
||||||
|
if (event.getType() != UpdateType.MIN_01)
|
||||||
{
|
{
|
||||||
GemHuntersScoreboard scoreboard = new GemHuntersScoreboard(player);
|
return;
|
||||||
Scoreboard handle = scoreboard.getHandle();
|
}
|
||||||
|
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
createPlayerScoreboard(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createPlayerScoreboard(Player player)
|
||||||
|
{
|
||||||
|
GemHuntersScoreboard scoreboard;
|
||||||
|
|
||||||
|
if (_scoreboards.containsKey(player.getUniqueId()))
|
||||||
|
{
|
||||||
|
scoreboard = _scoreboards.get(player.getUniqueId());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
scoreboard = new GemHuntersScoreboard(player);
|
||||||
_scoreboards.put(player.getUniqueId(), scoreboard);
|
_scoreboards.put(player.getUniqueId(), scoreboard);
|
||||||
|
|
||||||
// Gem Counter Undername
|
// Gem Counter Undername
|
||||||
Objective gemCounter = handle.registerNewObjective("Gems", "Gems");
|
Objective gemCounter = scoreboard.getHandle().registerNewObjective("Gems", "Gems");
|
||||||
gemCounter.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
gemCounter.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
for (GemHuntersScoreboard other : _scoreboards.values())
|
Scoreboard handle = scoreboard.getHandle();
|
||||||
|
|
||||||
|
for (GemHuntersScoreboard other : _scoreboards.values())
|
||||||
|
{
|
||||||
|
// Set the other player's name tag for the player joining
|
||||||
|
Player otherPlayer = other.getOwner();
|
||||||
|
Team team = handle.getTeam(otherPlayer.getName());
|
||||||
|
|
||||||
|
if (team == null)
|
||||||
{
|
{
|
||||||
// Set the other player's name tag for the player joining
|
team = handle.registerNewTeam(otherPlayer.getName());
|
||||||
Player otherPlayer = other.getOwner();
|
|
||||||
Team team = handle.registerNewTeam(otherPlayer.getName());
|
|
||||||
|
|
||||||
team.setPrefix(C.cYellow);
|
|
||||||
//team.setSuffix(scoreboard.getSuffix(player, otherPlayer));
|
|
||||||
team.addEntry(otherPlayer.getName());
|
|
||||||
|
|
||||||
if (player.equals(otherPlayer))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the player that is joining
|
|
||||||
Scoreboard otherHandle = other.getHandle();
|
|
||||||
Team otherTeam = otherHandle.registerNewTeam(player.getName());
|
|
||||||
|
|
||||||
otherTeam.setPrefix(C.cYellow);
|
|
||||||
//otherTeam.setSuffix(other.getSuffix(other.getOwner(), player));
|
|
||||||
otherTeam.addEntry(player.getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
player.setScoreboard(scoreboard.getHandle());
|
team.setPrefix(scoreboard.getPrefix(player, otherPlayer));
|
||||||
|
//team.setSuffix(scoreboard.getSuffix(player, otherPlayer));
|
||||||
|
team.addEntry(otherPlayer.getName());
|
||||||
|
|
||||||
|
if (player.equals(otherPlayer))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the player that is joining
|
||||||
|
Scoreboard otherHandle = other.getHandle();
|
||||||
|
Team otherTeam = otherHandle.getTeam(player.getName());
|
||||||
|
|
||||||
|
if (otherTeam == null)
|
||||||
|
{
|
||||||
|
otherTeam = otherHandle.registerNewTeam(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
otherTeam.setPrefix(other.getPrefix(other.getOwner(), player));
|
||||||
|
//otherTeam.setSuffix(other.getSuffix(other.getOwner(), player));
|
||||||
|
otherTeam.addEntry(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player.setScoreboard(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateTitles()
|
public void updateTitles()
|
||||||
|
Loading…
Reference in New Issue
Block a user