changerooonis

This commit is contained in:
Ben 2016-03-11 00:41:28 +00:00
parent 33d978c6d6
commit bcfe4a42c0
19 changed files with 243 additions and 58 deletions

View File

@ -48,9 +48,9 @@ public class PlayerCache
try try
{ {
PlayerInfo playerInfo = _repository.getElement(uuid.toString()); PlayerInfo playerInfo = _repository.getElement(uuid.toString());
System.out.println("Got playerInfo: " + playerInfo);
if (playerInfo != null) if (playerInfo != null)
{ {
System.out.println("Got playerInfo: " + playerInfo);
System.out.println("account id: " + playerInfo.getAccountId()); System.out.println("account id: " + playerInfo.getAccountId());
System.out.println("name: " + playerInfo.getName()); System.out.println("name: " + playerInfo.getName());
} }

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_DISABLED_BUILDER" value="org.eclipse.m2e.core.maven2Builder"/>
<mapAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
</launchConfiguration>

View File

@ -54,7 +54,6 @@ public class Chat extends MiniPlugin
private CoreClientManager _clientManager; private CoreClientManager _clientManager;
private PreferencesManager _preferences; private PreferencesManager _preferences;
private AchievementManager _achievements; private AchievementManager _achievements;
private IncognitoManager _incognitoManager;
private String[] _hackusations = {"hack", "hax", "hacker", "hacking", "cheat", "cheater", "cheating", "forcefield", "flyhack", "flyhacking", "autoclick", "aimbot"}; private String[] _hackusations = {"hack", "hax", "hacker", "hacking", "cheat", "cheater", "cheating", "forcefield", "flyhack", "flyhacking", "autoclick", "aimbot"};
private String _filterUrl = "https://chat.mineplex.com:8003/content/item/moderate"; private String _filterUrl = "https://chat.mineplex.com:8003/content/item/moderate";
@ -303,7 +302,7 @@ public class Chat extends MiniPlugin
Player sender = event.getPlayer(); Player sender = event.getPlayer();
if (_incognitoManager.Get(sender).Status) if (IncognitoManager.Instance.Get(sender).Status)
{ {
UtilPlayer.message(sender, C.cYellow + "You can not chat while incognito."); UtilPlayer.message(sender, C.cYellow + "You can not chat while incognito.");
event.setCancelled(true); event.setCancelled(true);

View File

@ -31,6 +31,7 @@ public class IncognitoRepository extends MinecraftRepository
public void SetStatus(int accountId, boolean status) public void SetStatus(int accountId, boolean status)
{ {
System.out.println("[INCOGNITO] Updated status for " + accountId + " to " + status);
executeUpdate(SET_STATUS, new ColumnInt("accountId", accountId), new ColumnBoolean("status", status)); executeUpdate(SET_STATUS, new ColumnInt("accountId", accountId), new ColumnBoolean("status", status));
} }

View File

@ -1073,6 +1073,11 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onJoin(PlayerLoginEvent event) public void onJoin(PlayerLoginEvent event)
{ {
if (true)
{
return;
}
Rank rank = _clientManager.Get(event.getPlayer()).GetRank(); Rank rank = _clientManager.Get(event.getPlayer()).GetRank();
if (!event.getPlayer().isOp() && !event.getPlayer().isWhitelisted() && !rank.has(Rank.LEGEND)) if (!event.getPlayer().isOp() && !event.getPlayer().isWhitelisted() && !rank.has(Rank.LEGEND))
{ {

View File

@ -102,7 +102,7 @@ public class PvpTimer extends MiniClientPlugin<PvpTimerClient>
if (territory != null && territory.Owner.equals("Borderlands")) if (territory != null && territory.Owner.equals("Borderlands"))
{ {
UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), Spawn.ORIGIN), 2.6, true, 0.5, 1, 1.35, true); UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), Spawn.ORIGIN), 2.6, true, 0.5, .2, 1.35, true);
player.playSound(player.getLocation(), Sound.NOTE_BASS, 1.0f, 1.0f); player.playSound(player.getLocation(), Sound.NOTE_BASS, 1.0f, 1.0f);
UtilPlayer.message(player, " "); UtilPlayer.message(player, " ");

View File

@ -2,16 +2,17 @@ package mineplex.game.clans.clans.siege;
import java.util.Stack; import java.util.Stack;
import mineplex.game.clans.clans.pvptimer.PvpTimer;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Slime;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import com.google.gson.Gson; import com.google.gson.Gson;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
@ -64,6 +65,12 @@ public class SiegeManager extends MiniPlugin
}); });
} }
@EventHandler
public void join(PlayerJoinEvent event)
{
event.getPlayer().getWorld().getEntitiesByClass(Slime.class).forEach(Entity::remove);
}
@EventHandler @EventHandler
public void save(UpdateEvent event) public void save(UpdateEvent event)
{ {

View File

@ -1,6 +1,5 @@
package mineplex.game.clans.clans.siege.outpost; package mineplex.game.clans.clans.siege.outpost;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -21,7 +20,6 @@ import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Door;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -29,7 +27,6 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.ColorFader; import mineplex.core.common.util.ColorFader;
import mineplex.core.common.util.EnclosedObject; import mineplex.core.common.util.EnclosedObject;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.LoopIterator; import mineplex.core.common.util.LoopIterator;
import mineplex.core.common.util.RGBData; import mineplex.core.common.util.RGBData;
import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAction;
@ -104,8 +101,6 @@ public class Outpost implements Listener
public ClanInfo _againstClan; public ClanInfo _againstClan;
private List<Hologram> _nameHolograms;
private Hologram _lifetimeLeft; private Hologram _lifetimeLeft;
public Outpost(OutpostManager outpostManager, OutpostToken token) public Outpost(OutpostManager outpostManager, OutpostToken token)
@ -116,8 +111,6 @@ public class Outpost implements Listener
_ownerClan = token.OwnerClan; _ownerClan = token.OwnerClan;
_nameHolograms = new ArrayList<>();
_startCorner = token.Origin.clone().subtract(token.Type._size, 1.1, token.Type._size); _startCorner = token.Origin.clone().subtract(token.Type._size, 1.1, token.Type._size);
_endCorner = token.Origin.clone().add(token.Type._size + .9, token.Type._ySize - 1, token.Type._size + .9); _endCorner = token.Origin.clone().add(token.Type._size + .9, token.Type._ySize - 1, token.Type._size + .9);
@ -166,30 +159,6 @@ public class Outpost implements Listener
Collections.reverse(reverse); Collections.reverse(reverse);
_reverseCircleStages = new LoopIterator<Vector>(reverse); _reverseCircleStages = new LoopIterator<Vector>(reverse);
if (token.OutpostState == OutpostState.CONSTRUCTING || token.OutpostState == OutpostState.LIVE)
{
_nameHolograms.add(new Hologram(outpostManager.getClansManager().getHologramManager(), _origin.clone().add((_type._size / 2) + 1, 2, 0).add(2, 0, 0).add(.5, 0, .5), C.cGreen + _ownerClan.getName()));
_nameHolograms.add(new Hologram(outpostManager.getClansManager().getHologramManager(), _origin.clone().subtract((_type._size / 2) + 1, -2, 0).subtract(2, 0, 0).add(.5, 0, .5), C.cGreen + _ownerClan.getName()));
_nameHolograms.add(new Hologram(outpostManager.getClansManager().getHologramManager(), _origin.clone().add(0, 2, (_type._size / 2) + 1).add(0, 0, 2).add(.5, 0, .5), C.cGreen + _ownerClan.getName()));
_nameHolograms.add(new Hologram(outpostManager.getClansManager().getHologramManager(), _origin.clone().subtract(0, -2, (_type._size / 2) + 1).subtract(0, 0, 2).add(.5, 0, .5), C.cGreen + _ownerClan.getName()));
_nameHolograms.forEach(Hologram::start);
_nameHolograms.forEach(hologram ->
hologram.setInteraction((player, click) ->
UtilBlock.getInRadius(hologram.getLocation(), 2, 2).forEach((block, dist) -> {
if (block.getType() == Material.IRON_DOOR)
{
Door door = (Door) block.getState();
door.setOpen(!door.isOpen());
}
})
)
);
_lifetimeLeft.start();
}
} }
public Outpost(OutpostManager outpostManager, ClanInfo clan, Location location, OutpostType type) public Outpost(OutpostManager outpostManager, ClanInfo clan, Location location, OutpostType type)
@ -213,7 +182,6 @@ public class Outpost implements Listener
_timeSpawned = System.currentTimeMillis(); _timeSpawned = System.currentTimeMillis();
_core = _type.getCoreLocation(_origin); _core = _type.getCoreLocation(_origin);
_nameHolograms = new ArrayList<>();
_preHologram = new Hologram(_ownerClan.Clans.getHologramManager(), _origin.clone().add(0.5, 2.3, 0.5), F.elem(_ownerClan.getName()) + C.cWhite + "'s Outpost block (Right-Click to activate)"); _preHologram = new Hologram(_ownerClan.Clans.getHologramManager(), _origin.clone().add(0.5, 2.3, 0.5), F.elem(_ownerClan.getName()) + C.cWhite + "'s Outpost block (Right-Click to activate)");
_preHologram2 = new Hologram(_ownerClan.Clans.getHologramManager(), _origin.clone().add(0.5, 3, 0.5), "Despawning: " + UtilText.getProgress(null, 0, null, true)); _preHologram2 = new Hologram(_ownerClan.Clans.getHologramManager(), _origin.clone().add(0.5, 3, 0.5), "Despawning: " + UtilText.getProgress(null, 0, null, true));
@ -245,11 +213,6 @@ public class Outpost implements Listener
kill(); kill();
} }
}); });
_nameHolograms.add(new Hologram(outpostManager.getClansManager().getHologramManager(), _origin.clone().add((_type._size / 2) + 1, 2, 0).add(2, 0, 0).add(.5, 0, .5), C.cGreen + _ownerClan.getName()));
_nameHolograms.add(new Hologram(outpostManager.getClansManager().getHologramManager(), _origin.clone().subtract((_type._size / 2) + 1, -2, 0).subtract(2, 0, 0).add(.5, 0, .5), C.cGreen + _ownerClan.getName()));
_nameHolograms.add(new Hologram(outpostManager.getClansManager().getHologramManager(), _origin.clone().add(0, 2, (_type._size / 2) + 1).add(0, 0, 2).add(.5, 0, .5), C.cGreen + _ownerClan.getName()));
_nameHolograms.add(new Hologram(outpostManager.getClansManager().getHologramManager(), _origin.clone().subtract(0, -2, (_type._size / 2) + 1).subtract(0, 0, 2).add(.5, 0, .5), C.cGreen + _ownerClan.getName()));
} }
private void cleanup() private void cleanup()
@ -264,8 +227,6 @@ public class Outpost implements Listener
_state = OutpostState.DEAD; _state = OutpostState.DEAD;
_nameHolograms.forEach(Hologram::stop);
_outpostManager.queueForRemoval(_ownerClan.getName()); _outpostManager.queueForRemoval(_ownerClan.getName());
} }
@ -309,7 +270,7 @@ public class Outpost implements Listener
if(_outpostManager.getClansManager().getPvpTimer().hasTimer(event.getPlayer())) if(_outpostManager.getClansManager().getPvpTimer().hasTimer(event.getPlayer()))
{ {
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot activate an Outpost whilst on protected from pvp.")); UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot activate an Outpost whilst protected from pvp."));
return; return;
} }
@ -321,7 +282,7 @@ public class Outpost implements Listener
if (event.getClickedBlock() != null && _origin.equals(event.getClickedBlock().getLocation())) if (event.getClickedBlock() != null && _origin.equals(event.getClickedBlock().getLocation()))
{ {
if (event.getClickedBlock().getType().equals(Material.NETHERRACK)) if (event.getClickedBlock().getType().equals(Material.BEACON))
{ {
_origin.getBlock().setType(Material.AIR); _origin.getBlock().setType(Material.AIR);
beginConstruction(); beginConstruction();
@ -551,8 +512,6 @@ public class Outpost implements Listener
UtilTextMiddle.display("Siege", "A Siege has been declared on your Clan!", 20, 100, 20, clan.getOnlinePlayersArray()); UtilTextMiddle.display("Siege", "A Siege has been declared on your Clan!", 20, 100, 20, clan.getOnlinePlayersArray());
} }
} }
_nameHolograms.forEach(Hologram::start);
} }
public void kill() public void kill()

View File

@ -126,8 +126,8 @@ public class OutpostManager extends MiniPlugin
} }
} }
for (int x = -4; x < 4; x++) for (int x = -2; x < 2; x++)
for (int z = -4; z < 4; z++) for (int z = -2; z < 2; z++)
{ {
Chunk chunk = location.getWorld().getChunkAt(location.getChunk().getX() + x, location.getChunk().getZ() + z); Chunk chunk = location.getWorld().getChunkAt(location.getChunk().getX() + x, location.getChunk().getZ() + z);

View File

@ -74,7 +74,8 @@ public class Cannon extends SiegeWeapon
return false; return false;
} }
if(_clans.getPvpTimer().hasTimer(player)) { if(_clans.getPvpTimer().hasTimer(player))
{
UtilPlayer.message(player, F.main("Clans", "You cannot fire a cannon whilst on PvPTimer")); UtilPlayer.message(player, F.main("Clans", "You cannot fire a cannon whilst on PvPTimer"));
return false; return false;
} }
@ -371,7 +372,7 @@ public class Cannon extends SiegeWeapon
protected void handleLeftClick(Player player) protected void handleLeftClick(Player player)
{ {
if (_rider == null) if (_rider == null && _ownerClan.isMember(player))
{ {
UtilPlayer.message(player, F.main("Clans", "You picked up your Cannon.")); UtilPlayer.message(player, F.main("Clans", "You picked up your Cannon."));

View File

@ -349,6 +349,8 @@ public abstract class SiegeWeapon implements Listener
_comprisedOf.clear(); _comprisedOf.clear();
_infoHologram.stop(); _infoHologram.stop();
if (_collisionBox != null) _collisionBox.Destruct();
_siegeManager.dead(this); _siegeManager.dead(this);
_alive = false; _alive = false;
@ -654,7 +656,7 @@ public abstract class SiegeWeapon implements Listener
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onDmg(EntityDamageByEntityEvent event) public void onDmg(EntityDamageByEntityEvent event)
{ {
if (!_comprisedOf.contains(event.getEntity()) && event.getDamager() instanceof Player) if (_comprisedOf.contains(event.getEntity()) && event.getDamager() instanceof Player)
handleLeftClick((Player) event.getDamager()); handleLeftClick((Player) event.getDamager());
} }

View File

@ -12,7 +12,7 @@ import mineplex.game.clans.clans.ClansManager;
public class TntGeneratorManager extends MiniPlugin public class TntGeneratorManager extends MiniPlugin
{ {
public static final int SECONDS_PER_TNT = 1000 * 30;//60 * 60 * 10; // 10 Hours public static final int SECONDS_PER_TNT = 30;//60 * 60 * 10; // 10 Hours
public static final int MAX_GENERATOR_STOCK = 3; public static final int MAX_GENERATOR_STOCK = 3;
private ClansManager _clansManager; private ClansManager _clansManager;

View File

@ -236,6 +236,15 @@ public class GoldManager extends MiniPlugin
public void dropGold(Location location, int amount, double velMult) public void dropGold(Location location, int amount, double velMult)
{ {
int count = amount / 1000; int count = amount / 1000;
if (count > 75)
{
double x = Math.random() * 2 * Math.PI;
Vector velocity = new Vector(Math.sin(x), 0, Math.cos(x));
dropGold(location, amount, velocity, velMult, "Gold " + 0);
return;
}
int extraGold = amount % 1000; int extraGold = amount % 1000;
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)

View File

@ -570,6 +570,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
if (ci != null && LegendaryWeights.elements().contains(ci.getClass())) if (ci != null && LegendaryWeights.elements().contains(ci.getClass()))
{ {
lore.add(" ");
lore.add(C.cWhite + "Original Owner: " + C.cYellow + (ci.OriginalOwner == null ? "You" : Bukkit.getOfflinePlayer(UUID.fromString(ci.OriginalOwner)).getName())); lore.add(C.cWhite + "Original Owner: " + C.cYellow + (ci.OriginalOwner == null ? "You" : Bukkit.getOfflinePlayer(UUID.fromString(ci.OriginalOwner)).getName()));
} }

View File

@ -50,6 +50,18 @@ public class MeridianScepter extends LegendaryItem
{ {
if ((System.currentTimeMillis() - _lastBlock) < 98 && (System.currentTimeMillis() - _interactWait) >= 98) if ((System.currentTimeMillis() - _lastBlock) < 98 && (System.currentTimeMillis() - _interactWait) >= 98)
{ {
if (ClansManager.getInstance().getPvpTimer().hasTimer(wielder))
{
UtilPlayer.message(wielder, F.main("Clans", "You are not allowed to fire the Meridian Scepter whilst under pvp protection."));
return;
}
if (ClansManager.getInstance().getClanUtility().getClaim(wielder.getLocation()) != null && ClansManager.getInstance().getClanUtility().getClaim(wielder.getLocation()).isSafe(wielder.getLocation()))
{
UtilPlayer.message(wielder, F.main("Clans", "You are not allowed to fire the " + F.elem("Meridian Scepter") + " whilst in a safe zone."));
return;
}
if (Recharge.Instance.use(wielder, "Meridian Scepter", 4000, true, true)) if (Recharge.Instance.use(wielder, "Meridian Scepter", 4000, true, true))
{ {
fire(wielder); fire(wielder);
@ -153,7 +165,7 @@ public class MeridianScepter extends LegendaryItem
Vector newDirection = closestPlayer.getLocation().add(0, 1, 0).toVector() Vector newDirection = closestPlayer.getLocation().add(0, 1, 0).toVector()
.subtract(projectile.toVector()); .subtract(projectile.toVector());
direction.add(newDirection.normalize().multiply(0.01)).normalize().multiply(0.2); direction.add(newDirection.normalize().multiply(0.01)).normalize().multiply(0.15);
} }
projectile.add(direction); projectile.add(direction);

View File

@ -16,6 +16,7 @@ import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
@ -52,6 +53,11 @@ public class RunedPickaxe extends RareItem
RunedPickaxe pick = (RunedPickaxe) gear.getWeapon(); RunedPickaxe pick = (RunedPickaxe) gear.getWeapon();
if (!pick._enabled && !UtilTime.elapsed(pick._instamineEnabled, 12000))
{
UtilTextBottom.displayProgress("Instant mine", (((double) (((double) System.currentTimeMillis()) - ((double) pick._instamineEnabled))) / 12000D), null, true, player);
}
if (pick._enabled if (pick._enabled
&& (System.currentTimeMillis() - pick._instamineEnabled) >= 12000) && (System.currentTimeMillis() - pick._instamineEnabled) >= 12000)
{ {
@ -110,7 +116,7 @@ public class RunedPickaxe extends RareItem
return; return;
} }
if (Recharge.Instance.usable(event.getPlayer(), "Instant Mine", true)) if (Recharge.Instance.usable(event.getPlayer(), "Instant Mine", true) && UtilTime.elapsed(_instamineEnabled, 15000))
{ {
UtilTextMiddle.display("", "Instant mine enabled for " + F.elem("12 Seconds"), 20, 80, 20, event.getPlayer()); UtilTextMiddle.display("", "Instant mine enabled for " + F.elem("12 Seconds"), 20, 80, 20, event.getPlayer());
_instamineEnabled = System.currentTimeMillis(); _instamineEnabled = System.currentTimeMillis();

View File

@ -0,0 +1,154 @@
package mineplex.game.clans.shop.pvp.tnt;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilUI;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.tntGenerator.TntGenerator;
import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager;
import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.shop.ClansShopItem;
public class TNTGenPage extends ShopPageBase<ClansManager, TNTGenShop>
{
public TNTGenPage(ClansManager plugin, TNTGenShop shop, CoreClientManager clientManager, DonationManager donationManager, org.bukkit.entity.Player player)
{
super(plugin, shop, clientManager, donationManager, "TNT Generator", player);
buildPage();
}
@Override
protected void buildPage()
{
ClanInfo clan = _plugin.getClan(_player);
if (clan == null)
{
_player.closeInventory();
_player.playSound(_player.getLocation(), Sound.NOTE_BASS, 1, 1);
UtilPlayer.message(_player, F.main("Clans", "You must be in a clan to manage a TNT Generator."));
return;
}
if (clan.getGenerator() == null)
{
addButton(13, new ItemBuilder(Material.BREWING_STAND_ITEM).setTitle(C.cRed + "Buy TNT Generator").setLore(" ", C.cYellow + ClansShopItem.TNT_GENERATOR.getBuyPrice() + " Gold").build(), (player, click) -> {
clearPage();
buildPage();
// Check if generator is still null
// Prevents someone from buying a generator at the same time as another clan member does.
if (clan.getGenerator() != null)
{
_player.playSound(_player.getLocation(), Sound.NOTE_BASS, 1, 1);
UtilPlayer.message(_player, F.main("Clans", "Your clan already has a TNT Generator."));
return;
}
if (_donationManager.Get(player).getGold() >= ClansShopItem.TNT_GENERATOR.getBuyPrice())
{
GoldManager.getInstance().deductGold(success -> {
UtilPlayer.message(player, F.main("Clans", "You purchased a " + F.elem("TNT Generator") + " for your Clan. You can now access it from the " + F.elem("PvP Shop") + "."));
clan.inform(F.main("Clans", F.elem(player.getName()) + " purchased a " + F.elem("TNT Generator") + " for the Clan. You can now access it from the " + F.elem("PvP Shop") + "."), player.getName());
TntGenerator generator = new TntGenerator(player.getUniqueId().toString());
clan.setGenerator(generator);
_plugin.getClanDataAccess().updateGenerator(clan, null);
}, player, ClansShopItem.TNT_GENERATOR.getBuyPrice());
}
else
{
UtilPlayer.message(player, F.main("Clans", "You can not afford to purchase a " + F.elem("TNT Generator") + " for your Clan."));
_player.playSound(player.getLocation(), Sound.NOTE_BASS, 1, 1);
}
clearPage();
buildPage();
});
}
else
{
TntGenerator generator = clan.getGenerator();
String nextTnt = "Never";
if (generator.getStock() < 3)
{
nextTnt = UtilTime.MakeStr((TntGeneratorManager.SECONDS_PER_TNT - generator.getTicks()) * 1000);
}
addButton(13, new ItemBuilder(Material.BREWING_STAND_ITEM)
.setTitle(C.cGreen + "TNT Generator")
.setLore(
" ",
C.cWhite + "Purchased by " + F.elem(clan.getMembers().get(generator.getCreator()).getPlayerName()),
" ",
C.cWhite + "TNT Available: " + F.elem(Integer.valueOf(generator.getStock())),
" ",
C.cWhite + "Next TNT: " + F.elem(nextTnt)).build(), (player, click) -> {
clearPage();
buildPage();
});
if (generator.getStock() == 0)
{
return;
}
int[] indices = UtilUI.getIndicesFor(generator.getStock(), 2);
for (int index : indices)
{
addButton(index, new ItemBuilder(Material.TNT).setTitle(C.cGreen + "Retrieve TNT").setLore(" ", "Click to collect this TNT.").build(), (player, click) -> {
clearPage();
buildPage();
if (generator.getStock() <= 0)
{
UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("TNT Generator") + " no longer contains this piece of TNT."));
_player.playSound(player.getLocation(), Sound.NOTE_BASS, 1, 1);
return;
}
if (UtilInv.HasSpace(player, Material.TNT, 1))
{
UtilPlayer.message(player, F.main("Clans", "You have successfully collected TNT from your " + F.elem("TNT Generator") + "."));
clan.inform(F.main("Clans", F.elem(player.getName()) + " has collected TNT from the Clan's " + F.elem("TNT Generator") + "."), player.getName());
player.getInventory().addItem(new ItemStack(Material.TNT, 1));
generator.setStock(generator.getStock() - 1);
_player.playSound(player.getLocation(), Sound.NOTE_PLING, 1, 1);
}
else
{
UtilPlayer.message(player, F.main("Clans", "You do not have enough sufficient space in your inventory to collect TNT."));
_player.playSound(player.getLocation(), Sound.NOTE_BASS, 1, 1);
}
clearPage();
buildPage();
});
}
}
}
}

View File

@ -0,0 +1,22 @@
package mineplex.game.clans.shop.pvp.tnt;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.game.clans.clans.ClansManager;
public class TNTGenShop extends ShopBase<ClansManager>
{
public TNTGenShop(ClansManager plugin, CoreClientManager clientManager, mineplex.core.donation.DonationManager donationManager)
{
super(plugin, clientManager, donationManager, "TNT Generator");
}
@Override
protected ShopPageBase<ClansManager, ? extends ShopBase<ClansManager>> buildPagesFor(Player player)
{
return new TNTGenPage(getPlugin(), this, getClientManager(), getDonationManager(), player);
}
}