Make booster gui smaller

This commit is contained in:
Shaun Bennett 2016-06-16 15:29:05 -05:00
parent 2f1954e41c
commit ea551182b6
2 changed files with 60 additions and 40 deletions

View File

@ -24,7 +24,7 @@ public class BoosterPage extends ShopPageBase<BoosterManager, BoosterShop>
{
public BoosterPage(BoosterManager plugin, BoosterShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player)
{
super(plugin, shop, clientManager, donationManager, "Boosters", player, 54);
super(plugin, shop, clientManager, donationManager, "Boosters", player, 45);
buildPage();
}
@ -48,6 +48,11 @@ public class BoosterPage extends ShopPageBase<BoosterManager, BoosterShop>
lore.add(C.cGray + "Booster would activate " + C.cGreen + "now");
lore.add(" ");
lore.add(C.cWhite + "Click to Activate Booster");
lore.add(" ");
lore.add(C.cGray + C.Italics + "Once a booster is activated");
lore.add(C.cGray + C.Italics + "or queued, you are not able to");
lore.add(C.cGray + C.Italics + "cancel it. You will still get");
lore.add(C.cGray + C.Italics + "tips if you are offline.");
}
else
{
@ -65,11 +70,11 @@ public class BoosterPage extends ShopPageBase<BoosterManager, BoosterShop>
ShopItem booster = new ShopItem(Material.SUGAR, "Game Booster", lore.toArray(new String[0]), 0, false, false);
if (getPlugin().canActivateBoosters())
{
addButton(4, booster, new ActivateBoosterButton(getShop(), getPlugin()));
addButton(13, booster, new ActivateBoosterButton(getShop(), getPlugin()));
}
else
{
setItem(4, booster);
setItem(13, booster);
}
addActiveBoosters();
@ -93,38 +98,46 @@ public class BoosterPage extends ShopPageBase<BoosterManager, BoosterShop>
}
int startIndex = Math.max(0, (9 - boosters.size()) / 2);
for (int i = 0; i < 9 && i < boosters.size(); i++)
if (boosters.size() > 0)
{
int queueIndex = boosters.get(i).getLeft();
int deliveryAmount = 1;
Booster booster = boosters.get(i).getRight();
boolean active = booster.isActive();
int index = 18 + startIndex + i;
long timeActivatedDif = System.currentTimeMillis() - booster.getActivationTime().getTime();
String activationTime = UtilTime.convertString(timeActivatedDif, 0, UtilTime.TimeUnit.FIT);
List<String> lore = new ArrayList<String>();
lore.add(" ");
if (active)
for (int i = 0; i < 9 && i < boosters.size(); i++)
{
lore.add(C.cWhite + "Active");
lore.add(C.cWhite + "Expires in " + C.cGreen + UtilTime.convertColonString(booster.getTimeRemaining(), UtilTime.TimeUnit.MINUTES, UtilTime.TimeUnit.SECONDS));
}
else
{
deliveryAmount = Math.max(1, queueIndex);
long timeToActive = booster.getStartTime().getTime() - System.currentTimeMillis();
lore.add(C.cWhite + "Starts in " + C.cGreen + UtilTime.convertColonString(timeToActive, UtilTime.TimeUnit.HOURS, UtilTime.TimeUnit.SECONDS));
lore.add(C.cWhite + "Position " + C.cGreen + deliveryAmount + C.cWhite + " in queue");
}
int queueIndex = boosters.get(i).getLeft();
int deliveryAmount = 1;
Booster booster = boosters.get(i).getRight();
boolean active = booster.isActive();
lore.add(" ");
lore.add(C.cGray + "Added " + activationTime + " ago");
int index = 27 + startIndex + i;
long timeActivatedDif = System.currentTimeMillis() - booster.getActivationTime().getTime();
String activationTime = UtilTime.convertString(timeActivatedDif, 0, UtilTime.TimeUnit.FIT);
ShopItem shopItem = new ShopItem(booster.isActive() ? Material.EMERALD_BLOCK : Material.REDSTONE_BLOCK,
"Game Booster", lore.toArray(new String[0]), deliveryAmount, !active, false);
setItem(index, shopItem);
List<String> lore = new ArrayList<String>();
lore.add(" ");
if (active)
{
lore.add(C.cWhite + "Active");
lore.add(C.cWhite + "Expires in " + C.cGreen + UtilTime.convertColonString(booster.getTimeRemaining(), UtilTime.TimeUnit.MINUTES, UtilTime.TimeUnit.SECONDS));
} else
{
deliveryAmount = Math.max(1, queueIndex);
long timeToActive = booster.getStartTime().getTime() - System.currentTimeMillis();
lore.add(C.cWhite + "Starts in " + C.cGreen + UtilTime.convertColonString(timeToActive, UtilTime.TimeUnit.HOURS, UtilTime.TimeUnit.SECONDS));
lore.add(C.cWhite + "Position " + C.cGreen + deliveryAmount + C.cWhite + " in queue");
}
lore.add(" ");
lore.add(C.cGray + "Added " + activationTime + " ago");
ShopItem shopItem = new ShopItem(booster.isActive() ? Material.EMERALD_BLOCK : Material.REDSTONE_BLOCK,
"Game Booster", lore.toArray(new String[0]), deliveryAmount, !active, false);
setItem(index, shopItem);
}
}
else
{
String[] lore = new String[] { " ", C.cGray + "Your active Boosters will show here", C.cGray + "Use the sugar above to activate boosters" };
ShopItem shopItem = new ShopItem(Material.BEDROCK, "No Active Boosters", lore, 1, false, false);
setItem(27 + 4, shopItem);
}
}
@ -179,7 +192,7 @@ public class BoosterPage extends ShopPageBase<BoosterManager, BoosterShop>
ShopItem shopItem = new ShopItem(Material.GOLD_BLOCK,
"Game Booster", lore.toArray(new String[0]), 1, false, false);
setItem(startIndex + i, shopItem);
setItem(startIndex + i + 27, shopItem);
}

View File

@ -115,6 +115,7 @@ import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Chest;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity;
@ -123,17 +124,11 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.block.*;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.*;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.util.Vector;
@ -619,6 +614,18 @@ public class ArcadeManager extends MiniPlugin implements IRelation
return true;
}
@EventHandler
public void onInteract(PlayerInteractEvent event)
{
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CHEST)
{
Chest chest = ((Chest) event.getClickedBlock().getState());
event.getPlayer().openInventory(chest.getBlockInventory());
Bukkit.broadcastMessage("cancelled and fired!");
event.setCancelled(true);
}
}
@Override
public boolean isSafe(Player player)
{