Add received info to ClansPackagePage
This commit is contained in:
parent
2e79bb3d7f
commit
41e49e3649
@ -1,21 +1,30 @@
|
|||||||
package mineplex.staffServer.ui.packages;
|
package mineplex.staffServer.ui.packages;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import java.util.ArrayList;
|
||||||
import org.bukkit.Color;
|
import java.util.Arrays;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClient;
|
import mineplex.core.account.CoreClient;
|
||||||
import mineplex.core.common.util.UtilColor;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.banner.UtilBanner;
|
|
||||||
import mineplex.core.itemstack.ItemBuilder;
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
import mineplex.staffServer.customerSupport.CustomerSupport;
|
import mineplex.staffServer.customerSupport.CustomerSupport;
|
||||||
import mineplex.staffServer.ui.SupportPage;
|
import mineplex.staffServer.ui.SupportPage;
|
||||||
import mineplex.staffServer.ui.SupportShop;
|
import mineplex.staffServer.ui.SupportShop;
|
||||||
|
import mineplex.staffServer.ui.packages.SupportPackagePage;
|
||||||
|
|
||||||
public class SupportClansPackagePage extends SupportPackagePage
|
public class SupportClansPackagePage extends SupportPackagePage
|
||||||
{
|
{
|
||||||
|
private Map<String, Integer> _receivedClansPackages;
|
||||||
|
|
||||||
public SupportClansPackagePage(CustomerSupport plugin, SupportShop shop, Player player, CoreClient target, SupportPage previousPage)
|
public SupportClansPackagePage(CustomerSupport plugin, SupportShop shop, Player player, CoreClient target, SupportPage previousPage)
|
||||||
{
|
{
|
||||||
super(plugin, shop, player, target, previousPage, "Clans");
|
super(plugin, shop, player, target, previousPage, "Clans");
|
||||||
@ -38,6 +47,12 @@ public class SupportClansPackagePage extends SupportPackagePage
|
|||||||
addRuneAmplifier(20);
|
addRuneAmplifier(20);
|
||||||
addRuneAmplifier(60);
|
addRuneAmplifier(60);
|
||||||
|
|
||||||
|
List<String> allPackages = new ArrayList<>();
|
||||||
|
_packageList.forEach(pair -> allPackages.addAll(pair.getRight()));
|
||||||
|
_receivedClansPackages = getPackageOwnership(allPackages);
|
||||||
|
|
||||||
|
addToItemLores();
|
||||||
|
|
||||||
buildPage();
|
buildPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,4 +93,43 @@ public class SupportClansPackagePage extends SupportPackagePage
|
|||||||
_packageList.add(getPackagePair(new ItemBuilder(Material.EMERALD).setAmount(Math.min(minutes, 64)), minutes + " Minute Rune Amplifier", packageName));
|
_packageList.add(getPackagePair(new ItemBuilder(Material.EMERALD).setAmount(Math.min(minutes, 64)), minutes + " Minute Rune Amplifier", packageName));
|
||||||
_itemPackages.add(packageName);
|
_itemPackages.add(packageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addToItemLores()
|
||||||
|
{
|
||||||
|
_packageList.forEach(pair ->
|
||||||
|
{
|
||||||
|
// Only process item packages, i.e. ones that
|
||||||
|
// can be received multiple times
|
||||||
|
List<String> packages = pair.getRight().stream().filter(p -> _itemPackages.contains(p)).collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (packages.size() == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack item = pair.getLeft();
|
||||||
|
|
||||||
|
List<String> newLore = new ArrayList<>();
|
||||||
|
|
||||||
|
newLore.addAll(Arrays.asList(
|
||||||
|
C.mBody + "This player has",
|
||||||
|
C.mBody + "received:"
|
||||||
|
));
|
||||||
|
|
||||||
|
for (String packageName : packages)
|
||||||
|
{
|
||||||
|
newLore.add(" " + C.cYellow + _receivedClansPackages.computeIfAbsent(packageName, k -> 0) + " " + C.cWhite + packageName);
|
||||||
|
}
|
||||||
|
|
||||||
|
newLore.add("");
|
||||||
|
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
|
||||||
|
newLore.addAll(meta.getLore());
|
||||||
|
|
||||||
|
meta.setLore(newLore);
|
||||||
|
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package mineplex.staffServer.ui.packages;
|
package mineplex.staffServer.ui.packages;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user