Add confirmation menu when user is disguised

This commit is contained in:
Spencer 2018-01-03 19:08:09 -05:00 committed by Alexander Meech
parent 468c012639
commit bc608e8670

View File

@ -7,6 +7,7 @@ import java.util.concurrent.atomic.AtomicReference;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@ -23,6 +24,9 @@ import mineplex.core.punish.Punishment;
import mineplex.core.punish.UI.PunishPage;
import mineplex.core.punish.UI.PunishShop;
import mineplex.core.punish.UI.history.PunishHistoryPage;
import mineplex.core.shop.confirmation.ConfirmationCallback;
import mineplex.core.shop.confirmation.ConfirmationPage;
import mineplex.core.shop.confirmation.ConfirmationProcessor;
import mineplex.core.shop.item.ShopItem;
public class PunishStaffPage extends PunishPage
@ -111,7 +115,7 @@ public class PunishStaffPage extends PunishPage
AtomicInteger aSeverity = new AtomicInteger(sev);
AtomicReference<Category> aCategory = new AtomicReference<>(category);
addButton(getSlot(sev + 1, columnOffset), buildSeverityIcon(category, sev), (p, c)-> doPunishment(aCategory.get(), aSeverity.get()));
addButton(getSlot(sev + 1, columnOffset), buildSeverityIcon(category, sev), (p, c)-> doPunishmentCustom(aCategory.get(), aSeverity.get()));
}
}
@ -179,30 +183,30 @@ public class PunishStaffPage extends PunishPage
if (coreClient.hasPermission(Category.Warning.getNeededPermission()))
{
addButton(getSlot(1, _customButtonColumn), buildDummyCategoryIcon(Category.Warning), (p, c) -> doPunishment(Category.Warning, 1));
addButton(getSlot(1, _customButtonColumn), buildDummyCategoryIcon(Category.Warning), (p, c) -> doPunishmentCustom(Category.Warning, 1));
}
if (coreClient.hasPermission(Category.Other.getNeededPermission()))
{
addButton(getSlot(4, _customButtonColumn), buildDummyCategoryIcon(Category.Other), (p, c) -> doPunishment(Category.Other, 1));
addButton(getSlot(4, _customButtonColumn), buildDummyCategoryIcon(Category.Other), (p, c) -> doPunishmentCustom(Category.Other, 1));
}
if (coreClient.hasPermission(Category.PermMute.getNeededPermission()))
{
addButton(getSlot(3, _customButtonColumn), buildDummyCategoryIcon(Category.PermMute), (p, c) -> doPunishment(Category.PermMute, 1));
addButton(getSlot(3, _customButtonColumn), buildDummyCategoryIcon(Category.PermMute), (p, c) -> doPunishmentCustom(Category.PermMute, 1));
}
if (coreClient.hasPermission(Category.ReportAbuse.getNeededPermission()))
{
addButton(getSlot(2, _customButtonColumn), buildDummyCategoryIcon(Category.ReportAbuse), (p, c) -> doPunishment(Category.ReportAbuse, 1));
addButton(getSlot(2, _customButtonColumn), buildDummyCategoryIcon(Category.ReportAbuse), (p, c) -> doPunishmentCustom(Category.ReportAbuse, 1));
}
}
private void buildDisguiseIcon()
private ItemStack buildDisguiseIcon()
{
if (!_wasDisguised || _disguisedName == null || _originalName == null)
{
return;
return null;
}
ItemStack item = new ItemStack(Material.NETHER_STAR);
@ -217,7 +221,7 @@ public class PunishStaffPage extends PunishPage
}, LineFormat.LORE)));
item.setItemMeta(meta);
addItem(getSlot(5, 4), item);
return item;
}
private String getDurationString(Category category, int severity)
@ -232,6 +236,31 @@ public class PunishStaffPage extends PunishPage
return UtilTime.MakeStr((long) hours * 3600000L);
}
private void doPunishmentCustom(Category category, int severity)
{
if (_wasDisguised)
{
new ConfirmationPage<>(getPlayer(), this, new ConfirmationProcessor()
{
@Override
public void init(Inventory inventory)
{
doPunishment(category, severity);
}
@Override
public void process(ConfirmationCallback callback)
{
}
}, buildDisguiseIcon());
}
else
{
doPunishment(category, severity);
}
}
@Override
protected void buildPage()
{
@ -244,6 +273,10 @@ public class PunishStaffPage extends PunishPage
buildHistory();
buildCustomButtons();
buildDisguiseIcon();
if (_wasDisguised)
{
addItem(getSlot(5, 4), buildDisguiseIcon());
}
}
}