New Game Rewards message
This commit is contained in:
parent
3758946dbc
commit
78866d341d
@ -33,6 +33,11 @@ public class Currency
|
|||||||
return _color + amount + " " + (amount == 1 ? _singular : _plural);
|
return _color + amount + " " + (amount == 1 ? _singular : _plural);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getColor()
|
||||||
|
{
|
||||||
|
return _color;
|
||||||
|
}
|
||||||
|
|
||||||
public Material getDisplayMaterial()
|
public Material getDisplayMaterial()
|
||||||
{
|
{
|
||||||
return _displayMaterial;
|
return _displayMaterial;
|
||||||
|
@ -13,7 +13,6 @@ import mineplex.core.account.CoreClientManager;
|
|||||||
import mineplex.core.account.permissions.Permission;
|
import mineplex.core.account.permissions.Permission;
|
||||||
import mineplex.core.account.permissions.PermissionGroup;
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
import mineplex.core.achievement.command.StatsCommand;
|
import mineplex.core.achievement.command.StatsCommand;
|
||||||
import mineplex.core.achievement.leveling.LevelingManager;
|
|
||||||
import mineplex.core.achievement.ui.AchievementShop;
|
import mineplex.core.achievement.ui.AchievementShop;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
@ -181,7 +180,7 @@ public class AchievementManager extends MiniPlugin
|
|||||||
|
|
||||||
public NautHashMap<Achievement, AchievementLog> getLog(Player player)
|
public NautHashMap<Achievement, AchievementLog> getLog(Player player)
|
||||||
{
|
{
|
||||||
return _log.remove(player.getName());
|
return _log.get(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasCategory(Player player, Achievement[] required)
|
public boolean hasCategory(Player player, Achievement[] required)
|
||||||
|
@ -1224,13 +1224,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
*/
|
*/
|
||||||
public boolean hasBeenPlaying(Player player)
|
public boolean hasBeenPlaying(Player player)
|
||||||
{
|
{
|
||||||
if (_game == null)
|
return _game != null && _game.GetTeam(player) != null;
|
||||||
return false;
|
|
||||||
|
|
||||||
if (_game.GetTeam(player) == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Clear(Player player)
|
public void Clear(Player player)
|
||||||
|
@ -74,7 +74,6 @@ import mineplex.core.lifetimes.Lifetimed;
|
|||||||
import mineplex.core.lifetimes.ListenerComponent;
|
import mineplex.core.lifetimes.ListenerComponent;
|
||||||
import mineplex.core.lifetimes.PhasedLifetime;
|
import mineplex.core.lifetimes.PhasedLifetime;
|
||||||
import mineplex.core.packethandler.IPacketHandler;
|
import mineplex.core.packethandler.IPacketHandler;
|
||||||
import mineplex.core.packethandler.PacketInfo;
|
|
||||||
import mineplex.core.quests.QuestManager;
|
import mineplex.core.quests.QuestManager;
|
||||||
import mineplex.core.quests.event.QuestInteractEvent;
|
import mineplex.core.quests.event.QuestInteractEvent;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
@ -96,6 +95,7 @@ import nautilus.game.arcade.game.games.draw.Draw;
|
|||||||
import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders;
|
import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders;
|
||||||
import nautilus.game.arcade.game.modules.AntiExpOrbModule;
|
import nautilus.game.arcade.game.modules.AntiExpOrbModule;
|
||||||
import nautilus.game.arcade.game.modules.Module;
|
import nautilus.game.arcade.game.modules.Module;
|
||||||
|
import nautilus.game.arcade.game.modules.gamesummary.GameSummaryModule;
|
||||||
import nautilus.game.arcade.kit.ChampionsKit;
|
import nautilus.game.arcade.kit.ChampionsKit;
|
||||||
import nautilus.game.arcade.kit.Kit;
|
import nautilus.game.arcade.kit.Kit;
|
||||||
import nautilus.game.arcade.kit.KitAvailability;
|
import nautilus.game.arcade.kit.KitAvailability;
|
||||||
@ -431,7 +431,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
|||||||
Scoreboard = new GameScoreboard(this);
|
Scoreboard = new GameScoreboard(this);
|
||||||
|
|
||||||
// Map Select
|
// Map Select
|
||||||
_files = new HashMap<GameType, ArrayList<String>>();
|
_files = new HashMap<>();
|
||||||
for (GameType type : GetWorldHostNames())
|
for (GameType type : GetWorldHostNames())
|
||||||
{
|
{
|
||||||
_files.put(type, Manager.LoadFiles(type.GetName()));
|
_files.put(type, Manager.LoadFiles(type.GetName()));
|
||||||
@ -440,10 +440,10 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
|||||||
{
|
{
|
||||||
System.out.println("Map Preference: " + Manager.GetGameCreationManager().MapPref);
|
System.out.println("Map Preference: " + Manager.GetGameCreationManager().MapPref);
|
||||||
|
|
||||||
HashMap<GameType, ArrayList<String>> matches = new HashMap<GameType, ArrayList<String>>();
|
HashMap<GameType, ArrayList<String>> matches = new HashMap<>();
|
||||||
for (GameType game : _files.keySet())
|
for (GameType game : _files.keySet())
|
||||||
{
|
{
|
||||||
ArrayList<String> list = new ArrayList<String>();
|
ArrayList<String> list = new ArrayList<>();
|
||||||
for (String cur : _files.get(game))
|
for (String cur : _files.get(game))
|
||||||
{
|
{
|
||||||
if (cur.replaceAll(" ", "").toLowerCase().contains(Manager.GetGameCreationManager().MapPref.toLowerCase()))
|
if (cur.replaceAll(" ", "").toLowerCase().contains(Manager.GetGameCreationManager().MapPref.toLowerCase()))
|
||||||
@ -489,20 +489,16 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
|||||||
|
|
||||||
Manager.getResourcePackManager().setResourcePack(gameType.getResourcePackUrls(this), gameType.isEnforceResourcePack(this));
|
Manager.getResourcePackManager().setResourcePack(gameType.getResourcePackUrls(this), gameType.isEnforceResourcePack(this));
|
||||||
|
|
||||||
_useEntityPacketHandler = new IPacketHandler()
|
_useEntityPacketHandler = packetInfo ->
|
||||||
{
|
{
|
||||||
@Override
|
if (packetInfo.getPacket() instanceof PacketPlayInUseEntity)
|
||||||
public void handle(PacketInfo packetInfo)
|
|
||||||
{
|
{
|
||||||
if (packetInfo.getPacket() instanceof PacketPlayInUseEntity)
|
net.minecraft.server.v1_8_R3.Entity entity = ((PacketPlayInUseEntity) packetInfo.getPacket())
|
||||||
{
|
.a(((CraftWorld) packetInfo.getPlayer().getWorld()).getHandle());
|
||||||
net.minecraft.server.v1_8_R3.Entity entity = ((PacketPlayInUseEntity) packetInfo.getPacket())
|
|
||||||
.a(((CraftWorld) packetInfo.getPlayer().getWorld()).getHandle());
|
|
||||||
|
|
||||||
if (entity instanceof EntityItem)
|
if (entity instanceof EntityItem)
|
||||||
{
|
{
|
||||||
packetInfo.setCancelled(true);
|
packetInfo.setCancelled(true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -510,6 +506,8 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
|||||||
System.out.println("Loading " + GetName() + "...");
|
System.out.println("Loading " + GetName() + "...");
|
||||||
|
|
||||||
new AntiExpOrbModule().register(this);
|
new AntiExpOrbModule().register(this);
|
||||||
|
new GameSummaryModule()
|
||||||
|
.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// You should never use this so please don't. Use Module.register instead
|
// You should never use this so please don't. Use Module.register instead
|
||||||
@ -1068,7 +1066,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
|||||||
public HashMap<String, GemData> GetGems(Player player)
|
public HashMap<String, GemData> GetGems(Player player)
|
||||||
{
|
{
|
||||||
if (!_gemCount.containsKey(player))
|
if (!_gemCount.containsKey(player))
|
||||||
_gemCount.put(player, new HashMap<String, GemData>());
|
_gemCount.put(player, new HashMap<>());
|
||||||
|
|
||||||
return _gemCount.get(player);
|
return _gemCount.get(player);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
package nautilus.game.arcade.game.modules.gamesummary;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.common.jsonchat.HoverEvent;
|
||||||
|
import mineplex.core.common.jsonchat.JsonMessage;
|
||||||
|
|
||||||
|
public abstract class GameSummaryComponent<T>
|
||||||
|
{
|
||||||
|
|
||||||
|
protected static final String DOUBLE_ARROW = "»";
|
||||||
|
|
||||||
|
private final GameSummaryComponentType _type;
|
||||||
|
private final Function<Player, T> _getFunction;
|
||||||
|
|
||||||
|
public GameSummaryComponent(GameSummaryComponentType type, Function<Player, T> getFunction)
|
||||||
|
{
|
||||||
|
_type = type;
|
||||||
|
_getFunction = getFunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract String getMainText(T data);
|
||||||
|
|
||||||
|
public abstract List<String> getHoverText(T data);
|
||||||
|
|
||||||
|
public void sendMessage(Player player)
|
||||||
|
{
|
||||||
|
T result = _getFunction.apply(player);
|
||||||
|
String mainText = getMainText(result);
|
||||||
|
List<String> hoverText = getHoverText(result);
|
||||||
|
|
||||||
|
if (mainText == null || hoverText == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder hoverTextBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
hoverText.forEach(text -> hoverTextBuilder.append("\n").append(text));
|
||||||
|
|
||||||
|
new JsonMessage(mainText)
|
||||||
|
.hover(HoverEvent.SHOW_TEXT, hoverTextBuilder.toString().substring(1))
|
||||||
|
.sendToPlayer(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void sendBlank(Player player)
|
||||||
|
{
|
||||||
|
player.sendMessage("");
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameSummaryComponentType getType()
|
||||||
|
{
|
||||||
|
return _type;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package nautilus.game.arcade.game.modules.gamesummary;
|
||||||
|
|
||||||
|
public enum GameSummaryComponentType
|
||||||
|
{
|
||||||
|
|
||||||
|
GEMS,
|
||||||
|
SHARDS,
|
||||||
|
EXPERIENCE,
|
||||||
|
LEVEL_UP,
|
||||||
|
KIT,
|
||||||
|
ACHIEVEMENT,
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,146 @@
|
|||||||
|
package nautilus.game.arcade.game.modules.gamesummary;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.tuple.Triple;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.AtomicDouble;
|
||||||
|
|
||||||
|
import mineplex.core.achievement.Achievement;
|
||||||
|
import mineplex.core.achievement.AchievementData;
|
||||||
|
import mineplex.core.achievement.AchievementLog;
|
||||||
|
import mineplex.core.achievement.AchievementManager;
|
||||||
|
import mineplex.core.common.Pair;
|
||||||
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.ArcadeFormat;
|
||||||
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
|
import nautilus.game.arcade.game.Game.GameState;
|
||||||
|
import nautilus.game.arcade.game.GemData;
|
||||||
|
import nautilus.game.arcade.game.modules.Module;
|
||||||
|
import nautilus.game.arcade.game.modules.gamesummary.components.AchievementSummaryComponent;
|
||||||
|
import nautilus.game.arcade.game.modules.gamesummary.components.ExperienceSummaryComponent;
|
||||||
|
import nautilus.game.arcade.game.modules.gamesummary.components.GemSummaryComponent;
|
||||||
|
import nautilus.game.arcade.game.modules.gamesummary.components.KitSummaryComponent;
|
||||||
|
import nautilus.game.arcade.game.modules.gamesummary.components.LevelUpSummaryComponent;
|
||||||
|
import nautilus.game.arcade.game.modules.gamesummary.components.ShardSummaryComponent;
|
||||||
|
|
||||||
|
public class GameSummaryModule extends Module
|
||||||
|
{
|
||||||
|
|
||||||
|
private final List<GameSummaryComponent<?>> _components;
|
||||||
|
|
||||||
|
public GameSummaryModule()
|
||||||
|
{
|
||||||
|
_components = new ArrayList<>(8);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setup()
|
||||||
|
{
|
||||||
|
setupDefaultComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cleanup()
|
||||||
|
{
|
||||||
|
_components.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameSummaryModule addComponent(GameSummaryComponent<?> component)
|
||||||
|
{
|
||||||
|
_components.add(component);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameSummaryModule replaceComponent(GameSummaryComponentType type, GameSummaryComponent<?> newComponent)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _components.size(); i++)
|
||||||
|
{
|
||||||
|
if (_components.get(i).getType().equals(type))
|
||||||
|
{
|
||||||
|
_components.set(i, newComponent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupDefaultComponents()
|
||||||
|
{
|
||||||
|
Function<Player, Pair<AchievementLog, AchievementData>> experienceFunction = player ->
|
||||||
|
{
|
||||||
|
AchievementManager manager = getGame().getArcadeManager().GetAchievement();
|
||||||
|
AchievementLog log = manager.getLog(player).get(Achievement.GLOBAL_MINEPLEX_LEVEL);
|
||||||
|
AchievementData data = manager.get(player, Achievement.GLOBAL_MINEPLEX_LEVEL);
|
||||||
|
|
||||||
|
return Pair.create(log, data);
|
||||||
|
};
|
||||||
|
|
||||||
|
addComponent(new GemSummaryComponent(player -> getGame().GetGems(player), GlobalCurrency.GEM.getColor(), GlobalCurrency.GEM.getPrefix()));
|
||||||
|
addComponent(new ShardSummaryComponent(GameSummaryComponentType.SHARDS, player ->
|
||||||
|
{
|
||||||
|
AtomicDouble total = new AtomicDouble();
|
||||||
|
Map<String, GemData> gems = getGame().GetGems(player);
|
||||||
|
|
||||||
|
gems.values().forEach(gemData -> total.getAndAdd(gemData.Gems));
|
||||||
|
|
||||||
|
return Triple.of(getGame(), player, (int) total.get());
|
||||||
|
}));
|
||||||
|
addComponent(new ExperienceSummaryComponent(experienceFunction));
|
||||||
|
addComponent(new LevelUpSummaryComponent(experienceFunction));
|
||||||
|
addComponent(new AchievementSummaryComponent(getGame().getArcadeManager()));
|
||||||
|
addComponent(new KitSummaryComponent(getGame().getArcadeManager()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void gameDisable(GameStateChangeEvent event)
|
||||||
|
{
|
||||||
|
if (event.GetState() != GameState.Dead)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArcadeManager manager = getGame().getArcadeManager();
|
||||||
|
|
||||||
|
if (!manager.IsRewardGems() || !manager.IsRewardStats() || !manager.IsRewardAchievements())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UtilServer.getPlayersCollection().forEach(this::informRewards);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void informRewards(Player player)
|
||||||
|
{
|
||||||
|
if (!getGame().getArcadeManager().hasBeenPlaying(player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage(ArcadeFormat.Line);
|
||||||
|
|
||||||
|
player.sendMessage(C.Bold + "Game Rewards");
|
||||||
|
player.sendMessage("");
|
||||||
|
|
||||||
|
_components.forEach(component -> component.sendMessage(player));
|
||||||
|
|
||||||
|
player.sendMessage("");
|
||||||
|
player.sendMessage(C.mBody + "Hover over for details.");
|
||||||
|
player.sendMessage(ArcadeFormat.Line);
|
||||||
|
|
||||||
|
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2, 1);
|
||||||
|
|
||||||
|
getGame().getArcadeManager().GetAchievement().clearLog(player);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,208 @@
|
|||||||
|
package nautilus.game.arcade.game.modules.gamesummary.components;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.achievement.Achievement;
|
||||||
|
import mineplex.core.achievement.AchievementData;
|
||||||
|
import mineplex.core.achievement.AchievementLog;
|
||||||
|
import mineplex.core.achievement.AchievementManager;
|
||||||
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
|
import mineplex.core.common.jsonchat.HoverEvent;
|
||||||
|
import mineplex.core.common.jsonchat.JsonMessage;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.stats.StatsManager;
|
||||||
|
import mineplex.core.task.TaskManager;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
|
import nautilus.game.arcade.game.modules.gamesummary.GameSummaryComponentType;
|
||||||
|
|
||||||
|
public class AchievementSummaryComponent extends ComplexSummaryComponent
|
||||||
|
{
|
||||||
|
|
||||||
|
private final AchievementManager _achievementManager;
|
||||||
|
private final DonationManager _donationManager;
|
||||||
|
private final StatsManager _statsManager;
|
||||||
|
private final TaskManager _taskManager;
|
||||||
|
|
||||||
|
public AchievementSummaryComponent(ArcadeManager manager)
|
||||||
|
{
|
||||||
|
super(GameSummaryComponentType.ACHIEVEMENT);
|
||||||
|
|
||||||
|
_achievementManager = manager.GetAchievement();
|
||||||
|
_donationManager = manager.GetDonation();
|
||||||
|
_statsManager = manager.GetStatsManager();
|
||||||
|
_taskManager = manager.GetTaskManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(Player player)
|
||||||
|
{
|
||||||
|
AtomicInteger progressFor = new AtomicInteger();
|
||||||
|
StringBuilder hoverTextBuilder = new StringBuilder(100);
|
||||||
|
|
||||||
|
_achievementManager.getLog(player).entrySet().forEach(entry ->
|
||||||
|
{
|
||||||
|
Achievement achievement = entry.getKey();
|
||||||
|
AchievementLog log = entry.getValue();
|
||||||
|
|
||||||
|
if (log.LevelUp)
|
||||||
|
{
|
||||||
|
AchievementData data = _achievementManager.get(player, achievement);
|
||||||
|
String nameLevel = getAchievementName(achievement, data);
|
||||||
|
|
||||||
|
StringBuilder description = new StringBuilder();
|
||||||
|
|
||||||
|
for (String line : achievement.getDesc())
|
||||||
|
{
|
||||||
|
description.append("\n").append(C.cDAqua).append(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
int[] rewards = getRewards(achievement, data.getLevel());
|
||||||
|
String title;
|
||||||
|
String reward = getRewardsString(player, rewards);
|
||||||
|
|
||||||
|
if (data.getLevel() >= achievement.getMaxLevel())
|
||||||
|
{
|
||||||
|
title = C.cPurpleB + "Achievement Get! ";
|
||||||
|
|
||||||
|
_taskManager.completedTask(success ->
|
||||||
|
{
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
rewardPlayer(player, achievement, rewards);
|
||||||
|
}
|
||||||
|
}, player, achievement.getName());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
title = C.cPurpleB + "Achievement Level Up! ";
|
||||||
|
|
||||||
|
rewardPlayer(player, achievement, rewards);
|
||||||
|
}
|
||||||
|
|
||||||
|
new JsonMessage(title + C.cGray + nameLevel)
|
||||||
|
.hover(HoverEvent.SHOW_TEXT,
|
||||||
|
C.cAquaB + nameLevel + "\n" +
|
||||||
|
C.cDAqua + description.toString().substring(1) + "\n\n" +
|
||||||
|
reward
|
||||||
|
)
|
||||||
|
.sendToPlayer(player);
|
||||||
|
}
|
||||||
|
else if (!_taskManager.hasCompletedTask(player, achievement.getName()))
|
||||||
|
{
|
||||||
|
AchievementData data = _achievementManager.get(player, achievement);
|
||||||
|
String nameLevel = getAchievementName(achievement, data);
|
||||||
|
|
||||||
|
StringBuilder description = new StringBuilder();
|
||||||
|
|
||||||
|
for (String line : achievement.getDesc())
|
||||||
|
{
|
||||||
|
description.append("\n").append(C.cDAqua).append(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
hoverTextBuilder
|
||||||
|
.append("\n\n")
|
||||||
|
.append(C.cAquaB).append(nameLevel)
|
||||||
|
.append("\n")
|
||||||
|
.append(description.toString().substring(1))
|
||||||
|
.append("\n")
|
||||||
|
.append(C.cPurple).append(data.getExpRemainder()).append("/").append(data.getExpNextLevel()).append(C.cGray).append(" (+").append(log.Amount).append(")");
|
||||||
|
|
||||||
|
progressFor.getAndIncrement();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (progressFor.get() == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
new JsonMessage(C.cGray + "Progress for " + C.cYellow + progressFor.get() + " Achievement" + (progressFor.get() == 1 ? "" : "s"))
|
||||||
|
.hover(HoverEvent.SHOW_TEXT, hoverTextBuilder.toString().substring(2))
|
||||||
|
.sendToPlayer(player);
|
||||||
|
sendBlank(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getAchievementName(Achievement achievement, AchievementData data)
|
||||||
|
{
|
||||||
|
String nameLevel = achievement.getName();
|
||||||
|
|
||||||
|
if (achievement.getMaxLevel() > 1)
|
||||||
|
{
|
||||||
|
if (achievement.hasLevelNames())
|
||||||
|
{
|
||||||
|
String tier = data.getLevel() == 0 ? achievement.getDefaultLevelName() : achievement.getLevelNames()[Math.min(data.getLevel(), achievement.getLevelNames().length) - 1];
|
||||||
|
nameLevel += " " + tier;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nameLevel += " " + (data.getLevel() + (achievement == Achievement.GLOBAL_GEM_HUNTER ? 1 : 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nameLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int[] getRewards(Achievement achievement, int level)
|
||||||
|
{
|
||||||
|
int gems = achievement.getGemReward();
|
||||||
|
int crowns = 0;
|
||||||
|
int xp = 0;
|
||||||
|
|
||||||
|
if (achievement.getLevelUpRewards().length > 0)
|
||||||
|
{
|
||||||
|
int[] rewards = achievement.getLevelUpRewards()[Math.min(level, achievement.getLevelUpRewards().length) - 1];
|
||||||
|
gems += rewards[0];
|
||||||
|
crowns += rewards[1];
|
||||||
|
xp += rewards[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
return new int[] {gems, crowns, xp};
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getRewardsString(Player player, int[] rewards)
|
||||||
|
{
|
||||||
|
String reward = "";
|
||||||
|
int gems = rewards[0];
|
||||||
|
int crowns = rewards[1];
|
||||||
|
int xp = rewards[2];
|
||||||
|
|
||||||
|
if (gems > 0)
|
||||||
|
{
|
||||||
|
reward += C.cGreenB + "+" + gems + " Gems ";
|
||||||
|
}
|
||||||
|
if (crowns > 0)
|
||||||
|
{
|
||||||
|
reward += C.cGoldB + "+" + crowns + " Crowns ";
|
||||||
|
}
|
||||||
|
if (xp > 0 && !_taskManager.hasCompletedTask(player, Achievement.GLOBAL_MINEPLEX_LEVEL.getName()))
|
||||||
|
{
|
||||||
|
reward += C.cYellowB + "+" + xp + " EXP ";
|
||||||
|
}
|
||||||
|
|
||||||
|
return reward;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rewardPlayer(Player player, Achievement achievement, int[] rewards)
|
||||||
|
{
|
||||||
|
int gems = rewards[0];
|
||||||
|
int crowns = rewards[1];
|
||||||
|
int xp = rewards[2];
|
||||||
|
|
||||||
|
if (gems > 0)
|
||||||
|
{
|
||||||
|
_donationManager.rewardCurrency(GlobalCurrency.GEM, player, achievement.getName(), gems);
|
||||||
|
}
|
||||||
|
if (crowns > 0)
|
||||||
|
{
|
||||||
|
_donationManager.rewardCrowns(crowns, player);
|
||||||
|
}
|
||||||
|
if (xp > 0)
|
||||||
|
{
|
||||||
|
_statsManager.incrementStat(player, Achievement.GLOBAL_MINEPLEX_LEVEL.getStats()[0], xp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package nautilus.game.arcade.game.modules.gamesummary.components;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.game.modules.gamesummary.GameSummaryComponent;
|
||||||
|
import nautilus.game.arcade.game.modules.gamesummary.GameSummaryComponentType;
|
||||||
|
|
||||||
|
public class ComplexSummaryComponent extends GameSummaryComponent<Object>
|
||||||
|
{
|
||||||
|
|
||||||
|
public ComplexSummaryComponent(GameSummaryComponentType type)
|
||||||
|
{
|
||||||
|
super(type, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMainText(Object data)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getHoverText(Object data)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
package nautilus.game.arcade.game.modules.gamesummary.components;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.achievement.AchievementData;
|
||||||
|
import mineplex.core.achievement.AchievementLog;
|
||||||
|
import mineplex.core.common.Pair;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.game.modules.gamesummary.GameSummaryComponent;
|
||||||
|
import nautilus.game.arcade.game.modules.gamesummary.GameSummaryComponentType;
|
||||||
|
|
||||||
|
public class ExperienceSummaryComponent extends GameSummaryComponent<Pair<AchievementLog, AchievementData>>
|
||||||
|
{
|
||||||
|
|
||||||
|
public ExperienceSummaryComponent(Function<Player, Pair<AchievementLog, AchievementData>> getFunction)
|
||||||
|
{
|
||||||
|
this(GameSummaryComponentType.EXPERIENCE, getFunction);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExperienceSummaryComponent(GameSummaryComponentType type, Function<Player, Pair<AchievementLog, AchievementData>> getFunction)
|
||||||
|
{
|
||||||
|
super(type, getFunction);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMainText(Pair<AchievementLog, AchievementData> data)
|
||||||
|
{
|
||||||
|
return C.cGray + "+" + C.cYellow + data.getLeft().Amount + C.cGray + " Experience";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getHoverText(Pair<AchievementLog, AchievementData> data)
|
||||||
|
{
|
||||||
|
AchievementData achievementData = data.getRight();
|
||||||
|
List<String> text = new ArrayList<>(2);
|
||||||
|
|
||||||
|
text.add(C.cGray + "You are level " + C.cGreen + achievementData.getLevel());
|
||||||
|
|
||||||
|
if (data.getRight().getExpRemainder() > 0)
|
||||||
|
{
|
||||||
|
text.add(C.cYellow + (achievementData.getExpNextLevel() - achievementData.getExpRemainder()) + " EXP " + C.cGray + "util next level");
|
||||||
|
}
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(Player player)
|
||||||
|
{
|
||||||
|
super.sendMessage(player);
|
||||||
|
|
||||||
|
if (!(this instanceof LevelUpSummaryComponent))
|
||||||
|
{
|
||||||
|
sendBlank(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
package nautilus.game.arcade.game.modules.gamesummary.components;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.game.GemData;
|
||||||
|
import nautilus.game.arcade.game.modules.gamesummary.GameSummaryComponent;
|
||||||
|
import nautilus.game.arcade.game.modules.gamesummary.GameSummaryComponentType;
|
||||||
|
|
||||||
|
public class GemSummaryComponent extends GameSummaryComponent<Map<String, GemData>>
|
||||||
|
{
|
||||||
|
|
||||||
|
private final String _colour;
|
||||||
|
private final String _currency;
|
||||||
|
|
||||||
|
public GemSummaryComponent(Function<Player, Map<String, GemData>> getFunction, String colour, String currency)
|
||||||
|
{
|
||||||
|
super(GameSummaryComponentType.GEMS, getFunction);
|
||||||
|
|
||||||
|
_colour = colour;
|
||||||
|
_currency = currency;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMainText(Map<String, GemData> data)
|
||||||
|
{
|
||||||
|
AtomicInteger totalGems = new AtomicInteger();
|
||||||
|
|
||||||
|
data.values().forEach(gemData -> totalGems.getAndAdd((int) gemData.Gems));
|
||||||
|
|
||||||
|
return C.cGray + "+" + _colour + totalGems.get() + C.cGray + " " + _currency;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getHoverText(Map<String, GemData> data)
|
||||||
|
{
|
||||||
|
List<String> text = new ArrayList<>();
|
||||||
|
|
||||||
|
data.forEach((reason, gemData) -> text.add(C.cGray + "+" + _colour + (int) gemData.Gems + C.cGray + " for " + C.cYellow + reason));
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,119 @@
|
|||||||
|
package nautilus.game.arcade.game.modules.gamesummary.components;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.common.jsonchat.HoverEvent;
|
||||||
|
import mineplex.core.common.jsonchat.JsonMessage;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.progression.data.PlayerKit;
|
||||||
|
import mineplex.core.progression.math.Calculations;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
|
import nautilus.game.arcade.game.modules.gamesummary.GameSummaryComponentType;
|
||||||
|
import nautilus.game.arcade.kit.KitProgressionData;
|
||||||
|
import nautilus.game.arcade.kit.ProgressingKit;
|
||||||
|
import nautilus.game.arcade.managers.ProgressingKitManager;
|
||||||
|
|
||||||
|
public class KitSummaryComponent extends ComplexSummaryComponent
|
||||||
|
{
|
||||||
|
|
||||||
|
private final ArcadeManager _manager;
|
||||||
|
private final ProgressingKitManager _kitManager;
|
||||||
|
|
||||||
|
public KitSummaryComponent(ArcadeManager manager)
|
||||||
|
{
|
||||||
|
super(GameSummaryComponentType.KIT);
|
||||||
|
|
||||||
|
_manager = manager;
|
||||||
|
_kitManager = manager.getProgressionKitManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(Player player)
|
||||||
|
{
|
||||||
|
AtomicInteger progressFor = new AtomicInteger();
|
||||||
|
StringBuilder hoverTextBuilder = new StringBuilder(100);
|
||||||
|
|
||||||
|
UUID key = player.getUniqueId();
|
||||||
|
List<KitProgressionData> dataList = _kitManager.getKitData().remove(key);
|
||||||
|
Integer xpGained = _kitManager.getXpGained().remove(key);
|
||||||
|
|
||||||
|
if (dataList == null || xpGained == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
KitProgressionData latestData = dataList.get(dataList.size() - 1);
|
||||||
|
latestData.setEndTime();
|
||||||
|
long totalTime = latestData.getEndTime() - dataList.get(0).getSelectTime();
|
||||||
|
|
||||||
|
for (KitProgressionData data : dataList)
|
||||||
|
{
|
||||||
|
long elapsed = data.getEndTime() - data.getSelectTime();
|
||||||
|
int kitXP = (int) (((double) elapsed / (double) totalTime) * xpGained);
|
||||||
|
|
||||||
|
if (!data.getKit().usesXp())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProgressingKit kit = data.getKit();
|
||||||
|
PlayerKit playerKit = _manager.getKitProgressionManager().getDataManager().get(player.getUniqueId());
|
||||||
|
|
||||||
|
if (playerKit.getLevel(kit.getInternalName()) >= 100)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//We only want them leveling up once a game, and to make sure XP stays the same
|
||||||
|
//Limit their total gained to the max amount they can gain, if they've reached it or exceeded it
|
||||||
|
if (xpGained >= Calculations.getXpForNextLevel(kit.getLevel(player.getUniqueId())))
|
||||||
|
{
|
||||||
|
xpGained = Calculations.getXpForNextLevel(kit.getLevel(player.getUniqueId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
int currentLevel = kit.getLevel(player.getUniqueId());
|
||||||
|
int difference = kit.getXpDifference(player.getUniqueId());
|
||||||
|
|
||||||
|
kit.setXp(kit.getXp(player.getUniqueId()) + kitXP, player.getUniqueId());
|
||||||
|
|
||||||
|
if (kit.isLevelUpReady(player.getUniqueId()))
|
||||||
|
{
|
||||||
|
kit.levelUp(player.getUniqueId());
|
||||||
|
int newLevel = currentLevel + 1;
|
||||||
|
|
||||||
|
//We shouldn't need to update the database, but there are some cases where we'll need too (found through testing)
|
||||||
|
_manager.getKitProgressionManager().getRepository().insertOrUpdate(playerKit, kit.getInternalName());
|
||||||
|
|
||||||
|
new JsonMessage(C.cPurpleB + "Kit Level Up! " + C.cGray + kit.getDisplayName() + " " + C.cWhite + currentLevel + " " + C.cGray + DOUBLE_ARROW + " " + C.cWhite + newLevel)
|
||||||
|
.hover(HoverEvent.SHOW_TEXT, getHoverText(kit, newLevel, Calculations.getXpForNextLevel(currentLevel)))
|
||||||
|
.sendToPlayer(player);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hoverTextBuilder.append("\n").append(getHoverText(kit, currentLevel, difference));
|
||||||
|
|
||||||
|
progressFor.getAndIncrement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (progressFor.get() == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
new JsonMessage(C.cGray + "Progress for " + C.cYellow + progressFor.get() + " Kit" + (progressFor.get() == 1 ? "" : "s"))
|
||||||
|
.hover(HoverEvent.SHOW_TEXT, hoverTextBuilder.toString().substring(1))
|
||||||
|
.sendToPlayer(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getHoverText(ProgressingKit kit, int level, int difference)
|
||||||
|
{
|
||||||
|
return C.cGray + "Your " + C.cYellow + kit.getDisplayName() + C.cGray + " is level " + C.cGreen + level + "\n" +
|
||||||
|
C.cYellow + difference + " EXP " + C.cGray + "util next level";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package nautilus.game.arcade.game.modules.gamesummary.components;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.achievement.Achievement;
|
||||||
|
import mineplex.core.achievement.AchievementData;
|
||||||
|
import mineplex.core.achievement.AchievementLog;
|
||||||
|
import mineplex.core.common.Pair;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.game.modules.gamesummary.GameSummaryComponentType;
|
||||||
|
|
||||||
|
public class LevelUpSummaryComponent extends ExperienceSummaryComponent
|
||||||
|
{
|
||||||
|
|
||||||
|
public LevelUpSummaryComponent(Function<Player, Pair<AchievementLog, AchievementData>> getFunction)
|
||||||
|
{
|
||||||
|
super(GameSummaryComponentType.LEVEL_UP, getFunction);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMainText(Pair<AchievementLog, AchievementData> data)
|
||||||
|
{
|
||||||
|
if (!data.getLeft().LevelUp)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
int level = data.getRight().getLevel();
|
||||||
|
|
||||||
|
return C.cPurpleB + "Level Up! " + Achievement.getExperienceString(level - 1) + C.cGray + " " + DOUBLE_ARROW + " " + Achievement.getExperienceString(level);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,108 @@
|
|||||||
|
package nautilus.game.arcade.game.modules.gamesummary.components;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.tuple.Triple;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
|
import mineplex.core.boosters.Booster;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
|
import nautilus.game.arcade.game.Game;
|
||||||
|
import nautilus.game.arcade.game.modules.gamesummary.GameSummaryComponent;
|
||||||
|
import nautilus.game.arcade.game.modules.gamesummary.GameSummaryComponentType;
|
||||||
|
import nautilus.game.arcade.managers.GameRewardManager.Perm;
|
||||||
|
|
||||||
|
public class ShardSummaryComponent extends GameSummaryComponent<Triple<Game, Player, Integer>>
|
||||||
|
{
|
||||||
|
|
||||||
|
public ShardSummaryComponent(GameSummaryComponentType type, Function<Player, Triple<Game, Player, Integer>> getFunction)
|
||||||
|
{
|
||||||
|
super(type, getFunction);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMainText(Triple<Game, Player, Integer> data)
|
||||||
|
{
|
||||||
|
Game game = data.getLeft();
|
||||||
|
ArcadeManager manager = data.getLeft().getArcadeManager();
|
||||||
|
Player player = data.getMiddle();
|
||||||
|
final int baseShards = data.getRight();
|
||||||
|
int totalShards = baseShards;
|
||||||
|
double extraMult = 0;
|
||||||
|
|
||||||
|
for (Perm shardMultPerm : Perm.values())
|
||||||
|
{
|
||||||
|
if (manager.GetClients().Get(player).hasPermission(shardMultPerm))
|
||||||
|
{
|
||||||
|
extraMult += 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extraMult > 0)
|
||||||
|
{
|
||||||
|
totalShards += ((int) (extraMult * baseShards));
|
||||||
|
}
|
||||||
|
|
||||||
|
Booster booster = manager.getBoosterManager().getActiveBooster();
|
||||||
|
|
||||||
|
if (game.GemBoosterEnabled && booster != null)
|
||||||
|
{
|
||||||
|
double multiplier = booster.getMultiplier() - 1;
|
||||||
|
totalShards += (int) (multiplier * baseShards);
|
||||||
|
}
|
||||||
|
|
||||||
|
return C.cGray + "+" + C.cAqua + totalShards + C.cGray + " Shards";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getHoverText(Triple<Game, Player, Integer> data)
|
||||||
|
{
|
||||||
|
List<String> text = new ArrayList<>();
|
||||||
|
Game game = data.getLeft();
|
||||||
|
ArcadeManager manager = data.getLeft().getArcadeManager();
|
||||||
|
Player player = data.getMiddle();
|
||||||
|
final int baseShards = data.getRight();
|
||||||
|
double extraMult = 0;
|
||||||
|
|
||||||
|
PermissionGroup group = manager.GetClients().Get(player).getPrimaryGroup();
|
||||||
|
|
||||||
|
for (Perm shardMultPerm : Perm.values())
|
||||||
|
{
|
||||||
|
if (manager.GetClients().Get(player).hasPermission(shardMultPerm))
|
||||||
|
{
|
||||||
|
extraMult += 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
text.add(get(baseShards, "Earning " + baseShards + " Gems"));
|
||||||
|
|
||||||
|
if (extraMult > 0)
|
||||||
|
{
|
||||||
|
int extraShards = ((int) (extraMult * baseShards));
|
||||||
|
|
||||||
|
text.add(get(extraShards, group.getDisplay(true, true, true, true) + C.cYellow + " Rank " + C.cAqua + "+" + Math.round((extraMult * 100)) + "%"));
|
||||||
|
}
|
||||||
|
|
||||||
|
Booster booster = manager.getBoosterManager().getActiveBooster();
|
||||||
|
if (game.GemBoosterEnabled && booster != null)
|
||||||
|
{
|
||||||
|
double multiplier = booster.getMultiplier() - 1;
|
||||||
|
int extraShards = ((int) (multiplier * baseShards));
|
||||||
|
|
||||||
|
text.add(get(extraShards, booster.getPlayerName() + "'s" + F.elem(" Game Amplifier" + C.cAqua + " +" + Math.round((multiplier * 100)) + "%")));
|
||||||
|
}
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String get(int shards, String reason)
|
||||||
|
{
|
||||||
|
return C.cGray + "+" + C.cAqua + shards + C.cGray + " for " + C.cYellow + reason;
|
||||||
|
}
|
||||||
|
}
|
@ -1,27 +1,10 @@
|
|||||||
package nautilus.game.arcade.managers;
|
package nautilus.game.arcade.managers;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
import mineplex.core.achievement.Achievement;
|
|
||||||
import mineplex.core.achievement.AchievementData;
|
|
||||||
import mineplex.core.achievement.AchievementLog;
|
|
||||||
import mineplex.core.common.currency.GlobalCurrency;
|
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.common.util.F;
|
|
||||||
import mineplex.core.common.util.NautHashMap;
|
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
|
||||||
import mineplex.core.common.util.UtilServer;
|
|
||||||
import nautilus.game.arcade.ArcadeFormat;
|
|
||||||
import nautilus.game.arcade.ArcadeManager;
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
|
||||||
import nautilus.game.arcade.game.Game;
|
|
||||||
import nautilus.game.arcade.game.Game.GameState;
|
|
||||||
|
|
||||||
public class GameAchievementManager implements Listener
|
public class GameAchievementManager implements Listener
|
||||||
{
|
{
|
||||||
@ -40,206 +23,4 @@ public class GameAchievementManager implements Listener
|
|||||||
{
|
{
|
||||||
Manager.GetAchievement().clearLog(event.getPlayer());
|
Manager.GetAchievement().clearLog(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void processAchievementLog(final GameStateChangeEvent event)
|
|
||||||
{
|
|
||||||
if (!Manager.IsRewardAchievements())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.GetState() != GameState.Dead)
|
|
||||||
return;
|
|
||||||
|
|
||||||
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
for (Player player : UtilServer.getPlayers())
|
|
||||||
{
|
|
||||||
displayAchievementLog(player, event.GetGame(), Manager.GetAchievement().getLog(player));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 120);
|
|
||||||
//Delay after Gems
|
|
||||||
}
|
|
||||||
|
|
||||||
public void displayAchievementLog(final Player player, Game game, NautHashMap<Achievement, AchievementLog> log)
|
|
||||||
{
|
|
||||||
if (!Manager.IsRewardAchievements())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (log == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1f);
|
|
||||||
|
|
||||||
UtilPlayer.message(player, "");
|
|
||||||
UtilPlayer.message(player, ArcadeFormat.Line);
|
|
||||||
|
|
||||||
UtilPlayer.message(player, "§f§lAchievement Progress");
|
|
||||||
|
|
||||||
int out = 0;
|
|
||||||
|
|
||||||
//Display
|
|
||||||
for (final Achievement type : log.keySet())
|
|
||||||
{
|
|
||||||
AchievementData data = Manager.GetAchievement().get(player, type);
|
|
||||||
|
|
||||||
String nameLevel = F.elem(C.cGold + C.Bold + type.getName());
|
|
||||||
if (type.getMaxLevel() > 1)
|
|
||||||
{
|
|
||||||
if (type.hasLevelNames())
|
|
||||||
{
|
|
||||||
String tier = data.getLevel() == 0 ? type.getDefaultLevelName() : type.getLevelNames()[Math.min(data.getLevel(), type.getLevelNames().length) - 1];
|
|
||||||
nameLevel = F.elem(C.cGold + C.Bold + type.getName() + " " + ChatColor.RESET + C.cYellow + " " + tier);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nameLevel = F.elem(C.cGold + C.Bold + type.getName() + " " + ChatColor.RESET + C.cYellow + data.getLevel() + C.cGold + "/" + C.cYellow + type.getMaxLevel());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String progress = F.elem(C.cGreen + "+" + log.get(type).Amount);
|
|
||||||
|
|
||||||
boolean displayDesc = true;
|
|
||||||
|
|
||||||
//Completed Achievement
|
|
||||||
if (data.getLevel() >= type.getMaxLevel())
|
|
||||||
{
|
|
||||||
//Finishing for the first time
|
|
||||||
if (!Manager.GetTaskManager().hasCompletedTask(player, type.getName()))
|
|
||||||
{
|
|
||||||
int gems = type.getGemReward();
|
|
||||||
int crowns = 0;
|
|
||||||
int xp = 0;
|
|
||||||
if (type.getLevelUpRewards().length > 0)
|
|
||||||
{
|
|
||||||
int[] rewards = type.getLevelUpRewards()[type.getLevelUpRewards().length - 1];
|
|
||||||
gems += rewards[0];
|
|
||||||
crowns += rewards[1];
|
|
||||||
xp += rewards[2];
|
|
||||||
}
|
|
||||||
UtilPlayer.message(player, "");
|
|
||||||
String inform = nameLevel + " " + F.elem(C.cAqua + C.Bold + "Completed!");
|
|
||||||
if (gems > 0)
|
|
||||||
{
|
|
||||||
inform += " " + F.elem(C.cGreen + C.Bold + "+" + gems + " Gems");
|
|
||||||
}
|
|
||||||
if (crowns > 0)
|
|
||||||
{
|
|
||||||
inform += " " + F.elem(C.cGold + C.Bold + "+" + crowns + " Crowns");
|
|
||||||
}
|
|
||||||
if (xp > 0 && !Manager.GetTaskManager().hasCompletedTask(player, Achievement.GLOBAL_MINEPLEX_LEVEL.getName()))
|
|
||||||
{
|
|
||||||
inform += " " + F.elem(C.cYellow + C.Bold + "+" + xp + " XP");
|
|
||||||
}
|
|
||||||
UtilPlayer.message(player, inform);
|
|
||||||
|
|
||||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f);
|
|
||||||
|
|
||||||
final int finalGems = gems;
|
|
||||||
final int finalCrowns = crowns;
|
|
||||||
final int finalXp = xp;
|
|
||||||
|
|
||||||
Manager.GetTaskManager().completedTask(completed ->
|
|
||||||
{
|
|
||||||
if (finalGems > 0)
|
|
||||||
{
|
|
||||||
Manager.GetDonation().rewardCurrency(GlobalCurrency.GEM, player, type.getName(), finalGems);
|
|
||||||
}
|
|
||||||
if (finalCrowns > 0)
|
|
||||||
{
|
|
||||||
Manager.GetDonation().rewardCrowns(finalCrowns, player);
|
|
||||||
}
|
|
||||||
if (finalXp > 0)
|
|
||||||
{
|
|
||||||
Manager.GetStatsManager().incrementStat(player, Achievement.GLOBAL_MINEPLEX_LEVEL.getStats()[0], finalXp);
|
|
||||||
}
|
|
||||||
}, player, type.getName());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//Display nothing because already complete bro :O
|
|
||||||
displayDesc = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Multi-Level Achievements
|
|
||||||
else if (log.get(type).LevelUp)
|
|
||||||
{
|
|
||||||
int gems = 0;
|
|
||||||
int crowns = 0;
|
|
||||||
int xp = 0;
|
|
||||||
if (type.getLevelUpRewards().length > 0)
|
|
||||||
{
|
|
||||||
int[] rewards = type.getLevelUpRewards()[Math.min(data.getLevel(), type.getLevelUpRewards().length) - 1];
|
|
||||||
gems += rewards[0];
|
|
||||||
crowns += rewards[1];
|
|
||||||
xp += rewards[2];
|
|
||||||
}
|
|
||||||
UtilPlayer.message(player, "");
|
|
||||||
String inform = nameLevel + " " + progress + " " + F.elem(C.cAqua + C.Bold + "LEVEL UP!");
|
|
||||||
if (gems > 0)
|
|
||||||
{
|
|
||||||
inform += " " + F.elem(C.cGreen + C.Bold + "+" + gems + " Gems");
|
|
||||||
}
|
|
||||||
if (crowns > 0)
|
|
||||||
{
|
|
||||||
inform += " " + F.elem(C.cGold + C.Bold + "+" + crowns + " Crowns");
|
|
||||||
}
|
|
||||||
if (xp > 0 && !Manager.GetTaskManager().hasCompletedTask(player, Achievement.GLOBAL_MINEPLEX_LEVEL.getName()))
|
|
||||||
{
|
|
||||||
inform += " " + F.elem(C.cYellow + C.Bold + "+" + xp + " XP");
|
|
||||||
}
|
|
||||||
UtilPlayer.message(player, inform);
|
|
||||||
|
|
||||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//Single Level
|
|
||||||
if (type.getMaxLevel() == 1)
|
|
||||||
{
|
|
||||||
UtilPlayer.message(player, "");
|
|
||||||
UtilPlayer.message(player, nameLevel + " " + progress +
|
|
||||||
" " + F.elem(ChatColor.YELLOW + "" + (data.getExpNextLevel() - data.getExpRemainder()) + " to Complete"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//Multi Level - Almost Finished
|
|
||||||
if (data.getLevel() == type.getMaxLevel() - 1)
|
|
||||||
{
|
|
||||||
UtilPlayer.message(player, "");
|
|
||||||
UtilPlayer.message(player, nameLevel + " " + progress +
|
|
||||||
" " + F.elem(ChatColor.YELLOW + "" + (data.getExpNextLevel() - data.getExpRemainder()) + " to Complete"));
|
|
||||||
}
|
|
||||||
//Multi Level - Many levels to go
|
|
||||||
else
|
|
||||||
{
|
|
||||||
UtilPlayer.message(player, "");
|
|
||||||
UtilPlayer.message(player, nameLevel + " " + progress +
|
|
||||||
" " + F.elem(ChatColor.YELLOW + "" + (data.getExpNextLevel() - data.getExpRemainder()) + " to Next Level"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (displayDesc)
|
|
||||||
for (String desc : type.getDesc())
|
|
||||||
{
|
|
||||||
UtilPlayer.message(player, desc);
|
|
||||||
out++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
out++;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (out < 5)
|
|
||||||
{
|
|
||||||
//UtilPlayer.message(player, "");
|
|
||||||
out++;
|
|
||||||
}
|
|
||||||
|
|
||||||
UtilPlayer.message(player, "");
|
|
||||||
UtilPlayer.message(player, ArcadeFormat.Line);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,27 +1,18 @@
|
|||||||
package nautilus.game.arcade.managers;
|
package nautilus.game.arcade.managers;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_8_R3.EntityHuman;
|
|
||||||
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity;
|
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
|
||||||
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;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
|
|
||||||
import mineplex.core.account.permissions.Permission;
|
import mineplex.core.account.permissions.Permission;
|
||||||
import mineplex.core.account.permissions.PermissionGroup;
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
import mineplex.core.achievement.Achievement;
|
import mineplex.core.achievement.Achievement;
|
||||||
import mineplex.core.boosters.Booster;
|
import mineplex.core.boosters.Booster;
|
||||||
import mineplex.core.common.currency.GlobalCurrency;
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
@ -31,15 +22,11 @@ import mineplex.minecraft.game.core.combat.CombatComponent;
|
|||||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||||
import mineplex.serverdata.Utility;
|
import mineplex.serverdata.Utility;
|
||||||
|
|
||||||
import nautilus.game.arcade.ArcadeFormat;
|
|
||||||
import nautilus.game.arcade.ArcadeManager;
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
import nautilus.game.arcade.GameType;
|
|
||||||
import nautilus.game.arcade.events.FirstBloodEvent;
|
import nautilus.game.arcade.events.FirstBloodEvent;
|
||||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
import nautilus.game.arcade.events.PlayerStateChangeEvent;
|
|
||||||
import nautilus.game.arcade.game.Game;
|
import nautilus.game.arcade.game.Game;
|
||||||
import nautilus.game.arcade.game.Game.GameState;
|
import nautilus.game.arcade.game.Game.GameState;
|
||||||
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
|
||||||
import nautilus.game.arcade.game.GemData;
|
import nautilus.game.arcade.game.GemData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -139,54 +126,34 @@ public class GameRewardManager implements Listener
|
|||||||
Game game = Manager.GetGame();
|
Game game = Manager.GetGame();
|
||||||
if (game == null) return;
|
if (game == null) return;
|
||||||
|
|
||||||
RewardGems(game, event.getPlayer(), true);
|
GiveGems(game, event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void PlayerStateChange(PlayerStateChangeEvent event)
|
|
||||||
{
|
|
||||||
if (!Manager.IsRewardGems())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.GetState() != PlayerState.OUT)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.GetGame().GetType() == GameType.WitherAssault || event.GetGame().GetType() == GameType.Paintball || event.GetGame().GetType() == GameType.MineStrike)
|
|
||||||
return;
|
|
||||||
|
|
||||||
RewardGems(event.GetGame(), event.GetPlayer(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void GameStateChange(GameStateChangeEvent event)
|
public void GameStateChange(GameStateChangeEvent event)
|
||||||
{
|
{
|
||||||
if (event.GetState() != GameState.Dead)
|
if (event.GetState() != GameState.Dead)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (Player player : UtilServer.getPlayers())
|
UtilServer.getPlayersCollection().forEach(player -> GiveGems(event.GetGame(), player));
|
||||||
RewardGems(event.GetGame(), player, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RewardGems(Game game, Player player, boolean give)
|
private void GiveGems(Game game, Player player)
|
||||||
{
|
|
||||||
//Inform Gems
|
|
||||||
AnnounceGems(game, player, game.GetPlayerGems().get(player), give);
|
|
||||||
|
|
||||||
if (!Manager.IsRewardGems())
|
|
||||||
return;
|
|
||||||
|
|
||||||
//Give Gems
|
|
||||||
if (give)
|
|
||||||
GiveGems(game, player, game.GetPlayerGems().remove(player), game.GemMultiplier);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void GiveGems(Game game, Player player, HashMap<String, GemData> gems, double gameMult)
|
|
||||||
{
|
{
|
||||||
if (!Manager.IsRewardGems())
|
if (!Manager.IsRewardGems())
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
double gameMult = game.GemMultiplier;
|
||||||
|
Map<String, GemData> gems = game.GetGems(player);
|
||||||
|
|
||||||
if (gems == null)
|
if (gems == null)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final int baseGemsEarned;
|
final int baseGemsEarned;
|
||||||
int gemsToReward;
|
int gemsToReward;
|
||||||
@ -222,7 +189,10 @@ public class GameRewardManager implements Listener
|
|||||||
int gemFinder = Manager.GetAchievement().get(player, Achievement.GLOBAL_GEM_HUNTER).getLevel();
|
int gemFinder = Manager.GetAchievement().get(player, Achievement.GLOBAL_GEM_HUNTER).getLevel();
|
||||||
if (gemFinder > 0)
|
if (gemFinder > 0)
|
||||||
{
|
{
|
||||||
gemsToReward += (int) (baseGemsEarned * (gemFinder * 0.25));
|
double factor = gemFinder * 0.25D;
|
||||||
|
int gemFinderGems = (int) (baseGemsEarned * factor);
|
||||||
|
gemsToReward += gemFinderGems;
|
||||||
|
game.AddGems(player, gemFinderGems, "Gem Hunter " + gemFinder + " +" + (int) (factor * 100) + "%", false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,12 +208,17 @@ public class GameRewardManager implements Listener
|
|||||||
if (hoursOnline > 5)
|
if (hoursOnline > 5)
|
||||||
hoursOnline = 5;
|
hoursOnline = 5;
|
||||||
|
|
||||||
gemsToReward += (int) (baseGemsEarned * (hoursOnline * 0.2));
|
int timeGems = (int) (baseGemsEarned * (hoursOnline * 0.2D));
|
||||||
|
gemsToReward += timeGems;
|
||||||
|
game.AddGems(player, timeGems, "Online for " + UtilTime.MakeStr(timeGems), false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DoubleGem && game.GemDoubleEnabled && !game.CrownsEnabled)
|
if (DoubleGem && game.GemDoubleEnabled && !game.CrownsEnabled)
|
||||||
|
{
|
||||||
gemsToReward += baseGemsEarned;
|
gemsToReward += baseGemsEarned;
|
||||||
|
game.AddGems(player, baseGemsEarned, "Double Gem Weekend", false, false);
|
||||||
|
}
|
||||||
|
|
||||||
int accountId = Manager.GetClients().getAccountId(player);
|
int accountId = Manager.GetClients().getAccountId(player);
|
||||||
|
|
||||||
@ -291,163 +266,4 @@ public class GameRewardManager implements Listener
|
|||||||
Manager.GetStatsManager().incrementStat(player, game.GetName() + ".CrownsEarned", gemsToReward);
|
Manager.GetStatsManager().incrementStat(player, game.GetName() + ".CrownsEarned", gemsToReward);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeName(Player player, String newName)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Field name = GameProfile.class.getDeclaredField("name");
|
|
||||||
Field declaredProfile = EntityHuman.class.getDeclaredField("bH");
|
|
||||||
declaredProfile.setAccessible(true);
|
|
||||||
GameProfile gameProfile = (GameProfile) declaredProfile.get(((CraftHumanEntity) ((CraftPlayer) player)).getHandle());
|
|
||||||
|
|
||||||
name.setAccessible(true);
|
|
||||||
name.set(gameProfile, newName);
|
|
||||||
name.setAccessible(false);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AnnounceGems(Game game, Player player, HashMap<String, GemData> gems, boolean give)
|
|
||||||
{
|
|
||||||
if (gems == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1f);
|
|
||||||
|
|
||||||
UtilPlayer.message(player, "");
|
|
||||||
UtilPlayer.message(player, ArcadeFormat.Line);
|
|
||||||
|
|
||||||
UtilPlayer.message(player, Manager.IsRewardGems() ? (game.CrownsEnabled ? "§f§lCrowns Earned" : "§f§lGems Earned") : "§f§lGame Stats");
|
|
||||||
UtilPlayer.message(player, "");
|
|
||||||
|
|
||||||
int earnedGems = 0;
|
|
||||||
|
|
||||||
for (String type : gems.keySet())
|
|
||||||
{
|
|
||||||
int gemCount = (int) gems.get(type).Gems;
|
|
||||||
if (gemCount <= 0)
|
|
||||||
gemCount = 1;
|
|
||||||
|
|
||||||
earnedGems += gemCount;
|
|
||||||
|
|
||||||
int amount = gems.get(type).Amount;
|
|
||||||
String amountStr = "";
|
|
||||||
if (amount > 0)
|
|
||||||
amountStr = amount + " ";
|
|
||||||
|
|
||||||
String out = "";
|
|
||||||
if (Manager.IsRewardGems())
|
|
||||||
out += F.elem((game.CrownsEnabled ? C.cGold : C.cGreen) + "+" + (int) (gemCount * game.GemMultiplier) + (game.CrownsEnabled ? " Crowns" : " Gems")) + " for ";
|
|
||||||
out += F.elem(amountStr + type);
|
|
||||||
|
|
||||||
UtilPlayer.message(player, out);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Manager.IsRewardGems())
|
|
||||||
{
|
|
||||||
UtilPlayer.message(player, "");
|
|
||||||
UtilPlayer.message(player, ArcadeFormat.Line);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
earnedGems = (int) (earnedGems * game.GemMultiplier);
|
|
||||||
|
|
||||||
int totalGems = earnedGems;
|
|
||||||
|
|
||||||
//Gem Finder
|
|
||||||
if (game.GemHunterEnabled && !game.CrownsEnabled)
|
|
||||||
{
|
|
||||||
int gemFinder = Manager.GetAchievement().get(player, Achievement.GLOBAL_GEM_HUNTER).getLevel();
|
|
||||||
if (gemFinder > 0)
|
|
||||||
{
|
|
||||||
UtilPlayer.message(player, F.elem(C.cGreen + "+" + ((int) (earnedGems * (gemFinder * 0.25)) + " Gems")) + " for " +
|
|
||||||
F.elem("Gem Hunter " + gemFinder + C.cGreen + " +" + (gemFinder * 25) + "%"));
|
|
||||||
|
|
||||||
totalGems += earnedGems * (gemFinder * 0.25);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Time Reward
|
|
||||||
if (TimeReward)
|
|
||||||
{
|
|
||||||
long timeOnline = Utility.currentTimeMillis() - Manager.GetClients().Get(player).getNetworkSessionLoginTime();
|
|
||||||
|
|
||||||
double hoursOnline = timeOnline / 3600000d;
|
|
||||||
|
|
||||||
if (hoursOnline < 24)
|
|
||||||
{
|
|
||||||
if (hoursOnline > 5)
|
|
||||||
hoursOnline = 5;
|
|
||||||
|
|
||||||
int extraGems = (int) (earnedGems * (hoursOnline * 0.2));
|
|
||||||
|
|
||||||
if (extraGems > 0)
|
|
||||||
{
|
|
||||||
UtilPlayer.message(player, F.elem((game.CrownsEnabled ? C.cGold : C.cGreen) + "+" + extraGems + (game.CrownsEnabled ? " Crowns" : " Gems")) + " for " +
|
|
||||||
F.elem("Online for " + UtilTime.MakeStr(timeOnline) + C.cGreen + " +" + (int) (hoursOnline * 20) + "%"));
|
|
||||||
|
|
||||||
totalGems += extraGems;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Double Gem
|
|
||||||
if (DoubleGem && game.GemDoubleEnabled && !game.CrownsEnabled)
|
|
||||||
{
|
|
||||||
UtilPlayer.message(player, F.elem(C.cGreen + "+" + (earnedGems) + " Gems") + " for " + F.elem(C.cDGreen + "Double Gem Weekend"));
|
|
||||||
|
|
||||||
totalGems += earnedGems;
|
|
||||||
}
|
|
||||||
|
|
||||||
final int baseShards = earnedGems;
|
|
||||||
int shards = baseShards;
|
|
||||||
double extraMult = 0;
|
|
||||||
|
|
||||||
PermissionGroup group = Manager.GetClients().Get(player).getPrimaryGroup();
|
|
||||||
|
|
||||||
for (Perm shardMultPerm : Perm.values())
|
|
||||||
{
|
|
||||||
if (Manager.GetClients().Get(player).hasPermission(shardMultPerm))
|
|
||||||
{
|
|
||||||
extraMult += 0.5;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UtilPlayer.message(player, F.elem(C.cAqua + "+" + baseShards + " Treasure Shards") + " for " + F.elem("Earning " + baseShards + " Gems"));
|
|
||||||
if (extraMult > 0)
|
|
||||||
{
|
|
||||||
int extraShards = ((int) (extraMult * baseShards));
|
|
||||||
UtilPlayer.message(player, F.elem(C.cAqua + "+" + extraShards + " Treasure Shards") + " for " +
|
|
||||||
F.elem(group.getDisplay(true, true, true, true)) + F.elem(" Rank" + C.cAqua + " +" + Math.round((extraMult * 100)) + "%"));
|
|
||||||
}
|
|
||||||
Booster booster = Manager.getBoosterManager().getActiveBooster();
|
|
||||||
if (game.GemBoosterEnabled && booster != null)
|
|
||||||
{
|
|
||||||
double multiplier = booster.getMultiplier() - 1;
|
|
||||||
int extraShards = ((int) (multiplier * baseShards));
|
|
||||||
UtilPlayer.message(player, F.elem(C.cAqua + "+" + extraShards + " Treasure Shards") + " for " +
|
|
||||||
F.name(booster.getPlayerName()) + "'s" + F.elem(" Game Amplifier" + C.cAqua + " +" + Math.round((multiplier * 100)) + "%"));
|
|
||||||
}
|
|
||||||
|
|
||||||
//Inform
|
|
||||||
UtilPlayer.message(player, "");
|
|
||||||
if (give)
|
|
||||||
{
|
|
||||||
UtilPlayer.message(player, F.elem(C.cWhite + "§lYou now have " +
|
|
||||||
(game.CrownsEnabled ? (C.cGoldB + (Manager.GetDonation().getCrowns(player) + totalGems) + " Crowns") : (C.cGreenB + (Manager.GetDonation().Get(player.getUniqueId()).getBalance(GlobalCurrency.GEM) + totalGems) + " Gems"))) + C.cWhite + C.Bold + " and " +
|
|
||||||
F.elem(C.cAqua + C.Bold + (Manager.GetDonation().Get(player.getUniqueId()).getBalance(GlobalCurrency.TREASURE_SHARD) + shards) + " Treasure Shards"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
UtilPlayer.message(player, F.elem(C.cWhite + "§lGame is still in progress..."));
|
|
||||||
UtilPlayer.message(player, F.elem(C.cWhite + "§lYou may earn more " + (game.CrownsEnabled ? (C.cGoldB + "Crowns") : (C.cGreenB + "Gems")) + C.cWhite + C.Bold + " when it's completed."));
|
|
||||||
}
|
|
||||||
|
|
||||||
UtilPlayer.message(player, ArcadeFormat.Line);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -7,7 +7,6 @@ import java.util.Map;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -20,15 +19,12 @@ import org.bukkit.scheduler.BukkitTask;
|
|||||||
import mineplex.core.account.permissions.Permission;
|
import mineplex.core.account.permissions.Permission;
|
||||||
import mineplex.core.account.permissions.PermissionGroup;
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.progression.data.PlayerKit;
|
import mineplex.core.progression.data.PlayerKit;
|
||||||
import mineplex.core.progression.gui.guis.KitDisplayMenu;
|
import mineplex.core.progression.gui.guis.KitDisplayMenu;
|
||||||
import mineplex.core.progression.math.Calculations;
|
|
||||||
|
|
||||||
import nautilus.game.arcade.ArcadeFormat;
|
|
||||||
import nautilus.game.arcade.ArcadeManager;
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
import nautilus.game.arcade.events.PlayerKitApplyEvent;
|
import nautilus.game.arcade.events.PlayerKitApplyEvent;
|
||||||
@ -55,11 +51,6 @@ public class ProgressingKitManager implements Listener
|
|||||||
private final Map<UUID, Integer> _xpGained;
|
private final Map<UUID, Integer> _xpGained;
|
||||||
private final Map<UUID, BukkitTask> _tasks;
|
private final Map<UUID, BukkitTask> _tasks;
|
||||||
|
|
||||||
private static final String LINE = ArcadeFormat.Line;
|
|
||||||
private static final String INFO = C.cWhiteB + "Kit Progression Progress";
|
|
||||||
private static final String LEVEL_INFO = "Level up a kit by playing with it.";
|
|
||||||
private static final String SPACE = " ";
|
|
||||||
|
|
||||||
public ProgressingKitManager(ArcadeManager manager)
|
public ProgressingKitManager(ArcadeManager manager)
|
||||||
{
|
{
|
||||||
_manager = manager;
|
_manager = manager;
|
||||||
@ -312,9 +303,6 @@ public class ProgressingKitManager implements Listener
|
|||||||
|
|
||||||
//Upon coming back into the lobby, reset player kits so they don't have to select it again
|
//Upon coming back into the lobby, reset player kits so they don't have to select it again
|
||||||
_manager.getPlugin().getServer().getScheduler().runTaskLater(_manager.getPlugin(), this::resetDefaultKits, 80);
|
_manager.getPlugin().getServer().getScheduler().runTaskLater(_manager.getPlugin(), this::resetDefaultKits, 80);
|
||||||
//Show the data for the previous game
|
|
||||||
_manager.getPlugin().getServer().getScheduler().runTaskLater(_manager.getPlugin(), this::displayKitData, 140);
|
|
||||||
//Wait for achievements
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetDefaultKits()
|
private void resetDefaultKits()
|
||||||
@ -339,139 +327,6 @@ public class ProgressingKitManager implements Listener
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayKitData(Player player)
|
|
||||||
{
|
|
||||||
UUID key = player.getUniqueId();
|
|
||||||
List<KitProgressionData> dataList = _data.remove(key);
|
|
||||||
Integer xpGained = _xpGained.remove(key);
|
|
||||||
|
|
||||||
if (dataList == null || xpGained == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
KitProgressionData latestData = dataList.get(dataList.size() - 1);
|
|
||||||
latestData.setEndTime();
|
|
||||||
long totalTime = latestData.getEndTime() - dataList.get(0).getSelectTime();
|
|
||||||
|
|
||||||
player.sendMessage(SPACE);
|
|
||||||
|
|
||||||
player.sendMessage(LINE);
|
|
||||||
player.sendMessage(INFO);
|
|
||||||
player.sendMessage(SPACE);
|
|
||||||
|
|
||||||
for (KitProgressionData data : dataList)
|
|
||||||
{
|
|
||||||
long elapsed = data.getEndTime() - data.getSelectTime();
|
|
||||||
int kitXP = (int) (((double) elapsed / (double) totalTime) * xpGained);
|
|
||||||
|
|
||||||
displayKitData(player, data, kitXP);
|
|
||||||
}
|
|
||||||
|
|
||||||
player.sendMessage(SPACE);
|
|
||||||
player.sendMessage(LEVEL_INFO);
|
|
||||||
player.sendMessage(LINE);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void displayKitData(Player player, KitProgressionData data, int xpGained)
|
|
||||||
{
|
|
||||||
if (!data.getKit().usesXp())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProgressingKit kit = data.getKit();
|
|
||||||
|
|
||||||
PlayerKit playerKit = _manager.getKitProgressionManager().getDataManager().get(player.getUniqueId());
|
|
||||||
|
|
||||||
if (playerKit.getLevel(kit.getInternalName()) >= 100)
|
|
||||||
{
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
String kitName = C.cGoldB + kit.getDisplayName();
|
|
||||||
|
|
||||||
//Name of the kit
|
|
||||||
builder.append(kitName).append(" ").append(C.Reset).append(C.cGoldB).append("MAX LEVEL");
|
|
||||||
|
|
||||||
player.sendMessage(builder.toString());
|
|
||||||
player.sendMessage(C.cWhite + "You maxed out this kit! Great job, and thanks for playing on Mineplex!");
|
|
||||||
|
|
||||||
player.sendMessage(SPACE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//We only want them leveling up once a game, and to make sure XP stays the same
|
|
||||||
//Limit their total gained to the max amount they can gain, if they've reached it or exceeded it
|
|
||||||
if (xpGained >= Calculations.getXpForNextLevel(kit.getLevel(player.getUniqueId())))
|
|
||||||
{
|
|
||||||
xpGained = Calculations.getXpForNextLevel(kit.getLevel(player.getUniqueId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
kit.setXp(kit.getXp(player.getUniqueId()) + xpGained, player.getUniqueId());
|
|
||||||
boolean leveledUp = false;
|
|
||||||
|
|
||||||
if (kit.isLevelUpReady(player.getUniqueId()))
|
|
||||||
{
|
|
||||||
leveledUp = true;
|
|
||||||
kit.levelUp(player.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
int currentLevel = kit.getLevel(player.getUniqueId());
|
|
||||||
int difference = kit.getXpDifference(player.getUniqueId());
|
|
||||||
|
|
||||||
//We shouldn't need to update the database, but there are some cases where we'll need too (found through testing)
|
|
||||||
_manager.getKitProgressionManager().getRepository().insertOrUpdate(playerKit, kit.getInternalName());
|
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
String kitName = C.cGoldB + kit.getDisplayName();
|
|
||||||
|
|
||||||
//Name of the kit
|
|
||||||
builder.append(kitName)
|
|
||||||
.append(" ")
|
|
||||||
.append(C.Reset);
|
|
||||||
|
|
||||||
//Current level out of 100
|
|
||||||
builder.append(C.cYellow)
|
|
||||||
.append(currentLevel)
|
|
||||||
.append(C.cGold)
|
|
||||||
.append("/")
|
|
||||||
.append(C.cYellow)
|
|
||||||
.append(100)
|
|
||||||
.append(" ")
|
|
||||||
.append(C.Reset);
|
|
||||||
|
|
||||||
//The amount of XP the player gained
|
|
||||||
builder.append(C.cGreen)
|
|
||||||
.append("+")
|
|
||||||
.append(xpGained)
|
|
||||||
.append(" ")
|
|
||||||
.append(C.Reset);
|
|
||||||
|
|
||||||
if (!leveledUp)
|
|
||||||
{
|
|
||||||
//The XP required to level up
|
|
||||||
builder.append(C.cYellow)
|
|
||||||
.append(difference)
|
|
||||||
.append(" to Next Level");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
builder.append(C.cAquaB)
|
|
||||||
.append("LEVEL UP! ")
|
|
||||||
.append(C.cYellow)
|
|
||||||
.append(Calculations.getXpForNextLevel(currentLevel))
|
|
||||||
.append(" to Next Level");
|
|
||||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Send the message finally
|
|
||||||
player.sendMessage(builder.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void displayKitData()
|
|
||||||
{
|
|
||||||
UtilServer.getPlayersCollection().forEach(this::displayKitData);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addData(Player player, Game game, ProgressingKit kit)
|
private void addData(Player player, Game game, ProgressingKit kit)
|
||||||
{
|
{
|
||||||
UUID key = player.getUniqueId();
|
UUID key = player.getUniqueId();
|
||||||
@ -483,4 +338,14 @@ public class ProgressingKitManager implements Listener
|
|||||||
{
|
{
|
||||||
_xpGained.put(player.getUniqueId(), xpGained);
|
_xpGained.put(player.getUniqueId(), xpGained);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<UUID, List<KitProgressionData>> getKitData()
|
||||||
|
{
|
||||||
|
return _data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<UUID, Integer> getXpGained()
|
||||||
|
{
|
||||||
|
return _xpGained;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user