Preparation for beta

This commit is contained in:
Sam 2017-02-23 14:42:55 +00:00
parent bde899212f
commit 2b64de8ad1
25 changed files with 543 additions and 152 deletions

View File

@ -242,6 +242,11 @@ public class CosmeticManager extends MiniPlugin
{
return _boosterManager;
}
public void displayUI(Player player)
{
_shop.attemptShopOpen(player);
}
public void disableTeamArmor()
{

View File

@ -4,8 +4,6 @@ import static mineplex.core.Managers.require;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.spigotmc.SpigotConfig;
@ -15,11 +13,13 @@ import mineplex.core.TimingsFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.boosters.BoosterManager;
import mineplex.core.chat.Chat;
import mineplex.core.command.CommandCenter;
import mineplex.core.common.Constants;
import mineplex.core.common.events.ServerShutdownEvent;
import mineplex.core.communities.CommunityManager;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.creature.Creature;
import mineplex.core.delayedtask.DelayedTask;
import mineplex.core.disguise.DisguiseManager;
@ -52,9 +52,11 @@ import mineplex.core.serverConfig.ServerConfiguration;
import mineplex.core.stats.StatsManager;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.teleport.Teleport;
import mineplex.core.thank.ThankManager;
import mineplex.core.updater.FileUpdater;
import mineplex.core.updater.Updater;
import mineplex.core.visibility.VisibilityManager;
import mineplex.gemhunters.beta.BetaModule;
import mineplex.gemhunters.bounties.BountyModule;
import mineplex.gemhunters.chat.ChatModule;
import mineplex.gemhunters.death.DeathModule;
@ -129,7 +131,7 @@ public class GemHunters extends JavaPlugin
Give.Initialize(this);
// Server config
new ServerConfiguration(this, clientManager);
ServerConfiguration serverConfig = new ServerConfiguration(this, clientManager);
// Teleport
new Teleport(this, clientManager);
@ -226,12 +228,22 @@ public class GemHunters extends JavaPlugin
// Menus
new MenuManager(this);
// Gadgets, used for mounts, lots of managers for something really small :(
new GadgetManager(this, clientManager, donationManager, inventoryManager, new MountManager(this, clientManager, donationManager, blockRestore, disguiseManager), new PetManager(this, clientManager, donationManager, inventoryManager, disguiseManager, creature, blockRestore), preferenceManager, disguiseManager, blockRestore, new ProjectileManager(this), achievementManager, packetHandler, hologramManager, incognito);
// Gadgets, used for mounts, lots of managers for something really small
// :(
MountManager mountManager = new MountManager(this, clientManager, donationManager, blockRestore, disguiseManager);
PetManager petManager = new PetManager(this, clientManager, donationManager, inventoryManager, disguiseManager, creature, blockRestore);
ProjectileManager projectileManager = new ProjectileManager(this);
GadgetManager gadgetManager = new GadgetManager(this, clientManager, donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler, hologramManager, incognito);
ThankManager thankManager = new ThankManager(this, clientManager, donationManager);
BoosterManager boosterManager = new BoosterManager(this, null, clientManager, donationManager, inventoryManager, thankManager);
CosmeticManager cosmeticManager = new CosmeticManager(this, clientManager, donationManager, inventoryManager, gadgetManager, mountManager, petManager, null, boosterManager);
cosmeticManager.setActive(false);
// Now we finally get to enable the Gem Hunters modules
// Though if any other module needs one of these it will be generated in
// order, however they are all here just for good measure.
// order, however they are all here just for good measure.s
require(BetaModule.class);
require(DebugModule.class);
require(BountyModule.class);
require(CashOutModule.class);
@ -274,20 +286,6 @@ public class GemHunters extends JavaPlugin
public void onDisable()
{
getServer().getPluginManager().callEvent(new ServerShutdownEvent(this));
// Cleanup all rouge entities
for (World world : getServer().getWorlds())
{
for (Entity entity : world.getEntities())
{
if (entity instanceof Player)
{
continue;
}
entity.remove();
}
}
}
}

View File

@ -0,0 +1,49 @@
package mineplex.gemhunters.beta;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ReflectivelyCreateMiniPlugin
public class BetaModule extends MiniPlugin
{
private static final String[] ANNOUCEMENTS = {
"Please remember this game is an early access BETA and all bugs should be reported to a staff member.",
"Thank you for playing Gem Hunters!",
"Many more features are being added over the coming days!",
"Players in your party show up on your map!",
"Safezones are marked as green areas on your map!",
"Players that have super valuable items show up on your map!"
};
private int _lastIndex;
private BetaModule()
{
super("Beta");
}
@EventHandler
public void annouce(UpdateEvent event)
{
if (event.getType() != UpdateType.MIN_01)
{
return;
}
Bukkit.broadcastMessage(F.main(C.cRedB + "BETA", C.cYellow + ANNOUCEMENTS[_lastIndex]));
if (++_lastIndex == ANNOUCEMENTS.length)
{
_lastIndex = 0;
}
}
}

View File

@ -24,7 +24,7 @@ public class BountyModule extends MiniPlugin
_brandingManager = require(BrandingManager.class);
}
@EventHandler
//@EventHandler
public void test(PlayerCommandPreprocessEvent event)
{
if (!event.getMessage().startsWith("/want"))

View File

@ -44,7 +44,7 @@ public class DeathModule extends MiniPlugin
// Some items like the cash out item (and for some reason players drop
// bones?) don't need to be dropped to avoid duplication.
private static final Set<Material> DISALLOWED_DROPS = Sets.newHashSet(Material.EMERALD, Material.BONE, Material.STAINED_GLASS_PANE);
private static final Set<Material> DISALLOWED_DROPS = Sets.newHashSet(Material.EMERALD, Material.MAP, Material.BONE, Material.STAINED_GLASS_PANE);
private static final int DEATH_ANIMATION_TIME = 7000;
private static final int DEATH_ANIMATION_COUNTDOWN = 2000;

View File

@ -16,7 +16,6 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import mineplex.core.MiniPlugin;

View File

@ -35,7 +35,7 @@ public class InventoryModule extends MiniPlugin
private final LootModule _loot;
private final Map<UUID, Integer> _rowsUnlocked;
private final Map<UUID, Integer> _slotsUnlocked;
private InventoryModule()
{
@ -43,7 +43,7 @@ public class InventoryModule extends MiniPlugin
_loot = require(LootModule.class);
_rowsUnlocked = new HashMap<>();
_slotsUnlocked = new HashMap<>();
}
@EventHandler
@ -52,7 +52,7 @@ public class InventoryModule extends MiniPlugin
Player player = event.getPlayer();
Inventory inv = player.getInventory();
_rowsUnlocked.put(player.getUniqueId(), 0);
_slotsUnlocked.put(player.getUniqueId(), 0);
for (int i = START_INDEX; i < inv.getSize(); i++)
{
@ -63,7 +63,7 @@ public class InventoryModule extends MiniPlugin
@EventHandler
public void quit(PlayerQuitEvent event)
{
_rowsUnlocked.remove(event.getPlayer().getUniqueId());
_slotsUnlocked.remove(event.getPlayer().getUniqueId());
}
@EventHandler
@ -86,11 +86,6 @@ public class InventoryModule extends MiniPlugin
@EventHandler
public void interact(PlayerInteractEvent event)
{
if (event.isCancelled())
{
return;
}
if (!UtilEvent.isAction(event, ActionType.R))
{
return;
@ -111,23 +106,17 @@ public class InventoryModule extends MiniPlugin
return;
}
Material material = itemStack.getType();
if (material == Material.CHEST || material == Material.ENDER_CHEST)
{
UtilInv.remove(player, material, (byte) 0, 1);
unlockRows(player, material == Material.CHEST ? 1 : 2);
}
player.setItemInHand(UtilInv.decrement(itemStack));
unlockSlots(player, itemStack.getType() == Material.CHEST ? 9 : 18);
}
public void unlockRows(Player player, int rows)
public void unlockSlots(Player player, int slots)
{
Inventory inv = player.getInventory();
UUID key = player.getUniqueId();
_rowsUnlocked.put(key, _rowsUnlocked.get(key) + rows);
int start = START_INDEX * _rowsUnlocked.get(key);
int end = Math.min(inv.getSize(), start + rows * 9);
int start = START_INDEX + _slotsUnlocked.get(key);
int end = Math.min(inv.getSize(), start + slots);
int delta = end - start;
DebugModule.getInstance().d("start=" + start);
@ -140,5 +129,6 @@ public class InventoryModule extends MiniPlugin
}
player.sendMessage(F.main(_moduleName, "You unlocked an additional " + F.count(String.valueOf(delta)) + " slots of your inventory!"));
_slotsUnlocked.put(key, _slotsUnlocked.get(key) + slots);
}
}

View File

@ -6,8 +6,10 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
@ -29,6 +31,8 @@ import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
@ -37,15 +41,20 @@ import mineplex.core.google.GoogleSheetsManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.gemhunters.debug.DebugModule;
import mineplex.gemhunters.economy.EconomyModule;
import mineplex.gemhunters.economy.PlayerCashOutCompleteEvent;
import mineplex.gemhunters.loot.command.SpawnChestCommand;
import mineplex.gemhunters.loot.command.UpdateLootCommand;
import mineplex.gemhunters.loot.deserialisers.ChestPropertiesDeserialiser;
import mineplex.gemhunters.loot.deserialisers.LootItemDeserialiser;
import mineplex.gemhunters.loot.event.PlayerChestOpenEvent;
import mineplex.gemhunters.loot.rewards.LootChestReward;
import mineplex.gemhunters.loot.rewards.LootGadgetReward;
import mineplex.gemhunters.loot.rewards.LootItemReward;
import mineplex.gemhunters.loot.rewards.LootRankReward;
import mineplex.gemhunters.loot.rewards.LootShardReward;
import mineplex.gemhunters.safezone.SafezoneModule;
import mineplex.gemhunters.spawn.event.PlayerTeleportIntoMapEvent;
import mineplex.gemhunters.util.SlackSheetsBot;
import mineplex.gemhunters.world.WorldDataModule;
@ -61,7 +70,13 @@ public class LootModule extends MiniPlugin
private static final int MAX_CHEST_CHECK_DISTANCE_SQUARED = 4;
private static final LootItemDeserialiser DESERIALISER = new LootItemDeserialiser();
private static final ChestPropertiesDeserialiser CHEST_DESERIALISER = new ChestPropertiesDeserialiser();
private static final ItemStack[] SPAWN_ITEMS = {
new ItemStack(Material.WOOD_SWORD),
new ItemStack(Material.APPLE, 3),
};
private static final String GEM_METADATA = "GEM";
private final EconomyModule _economy;
private final GoogleSheetsManager _sheets;
private final SafezoneModule _safezone;
private final WorldDataModule _worldData;
@ -70,19 +85,22 @@ public class LootModule extends MiniPlugin
private final Map<String, ChestProperties> _chestProperties;
private final Set<SpawnedChest> _spawnedChest;
private final Set<LootItemReward> _itemRewards;
private final Set<UUID> _shownPlayers;
private LootModule()
{
super("Loot");
_economy = require(EconomyModule.class);
_sheets = require(GoogleSheetsManager.class);
_safezone = require(SafezoneModule.class);
_worldData = require(WorldDataModule.class);
_chestLoot = new HashMap<>();
_chestProperties = new HashMap<>();
_spawnedChest = new HashSet<>(200);
_spawnedChest = new HashSet<>();
_itemRewards = new HashSet<>();
_shownPlayers = new HashSet<>();
runSyncLater(() -> {
updateChestLoot();
@ -233,7 +251,7 @@ public class LootModule extends MiniPlugin
{
return;
}
properties.setLastSpawn();
// Only spawn more chests if we need to
@ -253,6 +271,11 @@ public class LootModule extends MiniPlugin
{
return;
}
if (locations.isEmpty())
{
return;
}
Map<Integer, Integer> spawnedIndexes = properties.getSpawnIndexes();
Location randomLocation = null;
@ -262,14 +285,13 @@ public class LootModule extends MiniPlugin
while (index == -1 || !found && attempts < MAX_SEARCH_ATTEMPTS)
{
attempts++;
index = UtilMath.r(locations.size());
if (spawnedIndexes.getOrDefault(index, 0) >= properties.getMaxChestPerLocation())
{
continue;
}
attempts++;
}
if (index == -1)
@ -516,12 +538,36 @@ public class LootModule extends MiniPlugin
if (reward == null)
{
switch (lootItem.getMetadata())
String[] metadataSplit = lootItem.getMetadata().split(" ");
String key = metadataSplit[0];
String[] values = new String[metadataSplit.length - 1];
for (int i = 1; i < metadataSplit.length; i++)
{
values[i - 1] = metadataSplit[i];
}
switch (key)
{
case "RANK_UPGRADE":
reward = new LootRankReward(itemStack);
break;
case "SHARD":
reward = new LootShardReward(Integer.parseInt(values[0]) * 1000, itemStack, Integer.parseInt(values[1]));
break;
case "CHEST":
reward = new LootChestReward(Integer.parseInt(values[0]) * 1000, itemStack, values[1], Integer.parseInt(values[2]));
break;
case "GADGET":
String gadget = "";
for (int i = 1; i < values.length; i++)
{
gadget += values[i] + " ";
}
reward = new LootGadgetReward(Integer.parseInt(values[0]) * 1000, itemStack, gadget.trim());
break;
default:
return;
}
@ -531,7 +577,68 @@ public class LootModule extends MiniPlugin
reward.collectItem(player);
}
@EventHandler
public void gemClick(PlayerInteractEvent event)
{
if (!UtilEvent.isAction(event, ActionType.R))
{
return;
}
Player player = event.getPlayer();
ItemStack itemStack = player.getItemInHand();
if (itemStack == null)
{
return;
}
LootItem lootItem = fromItemStack(itemStack);
if (lootItem == null || lootItem.getMetadata() == null || !lootItem.getMetadata().startsWith(GEM_METADATA))
{
return;
}
player.setItemInHand(UtilInv.decrement(itemStack));
int amount = Integer.parseInt(lootItem.getMetadata().split(" ")[1]);
_economy.addToStore(player, "Gem Item", amount);
}
@EventHandler
public void mapUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
_shownPlayers.clear();
for (Player player : Bukkit.getOnlinePlayers())
{
UUID key = player.getUniqueId();
for (LootItemReward itemReward : _itemRewards)
{
if (itemReward.getPlayer().equals(player))
{
_shownPlayers.add(key);
break;
}
}
}
}
@EventHandler
public void mapTeleport(PlayerTeleportIntoMapEvent event)
{
event.getPlayer().getInventory().addItem(SPAWN_ITEMS);
}
@EventHandler
public void cashOutComplete(PlayerCashOutCompleteEvent event)
{
@ -549,4 +656,9 @@ public class LootModule extends MiniPlugin
}
}
}
public final Set<UUID> getShownPlayers()
{
return _shownPlayers;
}
}

View File

@ -0,0 +1,53 @@
package mineplex.gemhunters.loot.rewards;
import org.bukkit.inventory.ItemStack;
import mineplex.core.Managers;
import mineplex.core.common.util.Callback;
import mineplex.core.inventory.InventoryManager;
import mineplex.gemhunters.debug.DebugModule;
public class LootChestReward extends LootItemReward
{
private final InventoryManager _inventory;
private final String _chestName;
private final int _amount;
public LootChestReward(long cashOutDelay, ItemStack itemStack, String chestName, int amount)
{
super(chestName + " Chest", cashOutDelay, itemStack);
_inventory = Managers.require(InventoryManager.class);
_chestName = chestName;
_amount = amount;
}
@Override
public void onCollectItem()
{
}
@Override
public void onSuccessful()
{
_inventory.addItemToInventory(new Callback<Boolean>()
{
@Override
public void run(Boolean success)
{
DebugModule.getInstance().d("Success= " + success);
}
}, _player, _chestName + " Chest", _amount);
}
@Override
public void onDeath()
{
}
}

View File

@ -0,0 +1,55 @@
package mineplex.gemhunters.loot.rewards;
import org.bukkit.inventory.ItemStack;
import mineplex.core.Managers;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.donation.DonationManager;
import mineplex.core.donation.Donor;
import mineplex.gemhunters.debug.DebugModule;
public class LootGadgetReward extends LootItemReward
{
private final DonationManager _donation;
private final String _gadget;
public LootGadgetReward(long cashOutDelay, ItemStack itemStack, String gadget)
{
super(gadget, cashOutDelay, itemStack);
_donation = Managers.require(DonationManager.class);
_gadget = gadget;
}
@Override
public void onCollectItem()
{
}
@Override
public void onSuccessful()
{
Donor donor = _donation.Get(_player);
if (donor.ownsUnknownSalesPackage(_gadget))
{
DebugModule.getInstance().d("Shard duplicate");
donor.addBalance(GlobalCurrency.TREASURE_SHARD, (int) (500 + Math.random() * 1000));
}
else
{
DebugModule.getInstance().d("Adding gadget");
donor.addOwnedUnknownSalesPackage(_gadget);
}
}
@Override
public void onDeath()
{
}
}

View File

@ -8,19 +8,25 @@ import mineplex.core.Managers;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.F;
import mineplex.core.donation.DonationManager;
public class LootRankReward extends LootItemReward
{
private static final long CASH_OUT_DELAY = TimeUnit.SECONDS.toMillis(60);
private static final long CASH_OUT_DELAY = TimeUnit.MINUTES.toMillis(15);
private static final int CONSOLATION_PRICE = 10000;
private final CoreClientManager _clientManager;
private final DonationManager _donation;
public LootRankReward(ItemStack itemStack)
{
super("Rank", CASH_OUT_DELAY, itemStack);
_clientManager = Managers.require(CoreClientManager.class);
_donation = Managers.require(DonationManager.class);
}
@Override
@ -63,7 +69,8 @@ public class LootRankReward extends LootItemReward
// A suitable rank could not be found.
if (newRank == null)
{
// TODO implement shard reward.
_player.sendMessage(F.main("Loot", "Since you already have eternal ( You are lucky :) ). So instead you can have " + CONSOLATION_PRICE + " shards."));
_donation.Get(_player).addBalance(GlobalCurrency.TREASURE_SHARD, CONSOLATION_PRICE);
return;
}

View File

@ -0,0 +1,42 @@
package mineplex.gemhunters.loot.rewards;
import org.bukkit.inventory.ItemStack;
import mineplex.core.Managers;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.donation.DonationManager;
public class LootShardReward extends LootItemReward
{
private final DonationManager _donation;
private final int _amount;
public LootShardReward(long cashOutDelay, ItemStack itemStack, int amount)
{
super("Shard", cashOutDelay, itemStack);
_donation = Managers.require(DonationManager.class);
_amount = amount;
}
@Override
public void onCollectItem()
{
}
@Override
public void onSuccessful()
{
_donation.Get(_player).addBalance(GlobalCurrency.TREASURE_SHARD, _amount);
}
@Override
public void onDeath()
{
}
}

View File

@ -58,7 +58,6 @@ import mineplex.core.portal.events.ServerTransferEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.gemhunters.death.event.PlayerCustomRespawnEvent;
import mineplex.gemhunters.spawn.SpawnModule;
import net.minecraft.server.v1_8_R3.Block;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.Blocks;
@ -79,7 +78,7 @@ public class ItemMapModule extends MiniPlugin
// Every BLOCK_SCAN_INTERVAL we add as a new region to scan
private static final int BLOCK_SCAN_INTERVAL = 16 * 3;
// 1536 is the width of the entire world from one borderland to the other
private static final int HALF_WORLD_SIZE = SpawnModule.WORLD_BORDER_RADIUS;
private static final int HALF_WORLD_SIZE = 768;
// This slot is where the Clans Map will go by default
private static final int CLANS_MAP_SLOT = 8;
@ -945,6 +944,7 @@ public class ItemMapModule extends MiniPlugin
ItemStack mapSlot = player.getInventory().getItem(slot);
if (mapSlot != null && mapSlot.getType() != Material.AIR)
{
slot = player.getInventory().firstEmpty();
}

View File

@ -1,6 +1,8 @@
package mineplex.gemhunters.map;
import java.awt.Color;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -14,11 +16,11 @@ import org.bukkit.map.MapView;
import mineplex.core.Managers;
import mineplex.core.common.util.UtilTime;
import mineplex.core.communities.Community;
import mineplex.core.communities.CommunityManager;
import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import mineplex.gemhunters.loot.LootModule;
import mineplex.gemhunters.safezone.SafezoneModule;
import mineplex.gemhunters.supplydrop.SupplyDrop;
import mineplex.gemhunters.supplydrop.SupplyDropModule;
import mineplex.gemhunters.worldevent.WorldEvent;
import mineplex.gemhunters.worldevent.WorldEventModule;
@ -33,22 +35,22 @@ public class ItemMapRenderer extends MapRenderer
private static final int STANDARD_Y = 70;
private final ItemMapModule _itemMap;
private final LootModule _loot;
private final SafezoneModule _safezone;
private final SupplyDropModule _supply;
private final WorldEventModule _worldEvent;
private final CommunityManager _community;
private final PartyManager _party;
public ItemMapRenderer()
{
super(true);
_itemMap = Managers.require(ItemMapModule.class);
_loot = Managers.require(LootModule.class);
_safezone = Managers.require(SafezoneModule.class);
_supply = Managers.require(SupplyDropModule.class);
_worldEvent = Managers.require(WorldEventModule.class);
_community = Managers.require(CommunityManager.class);
_party = Managers.require(PartyManager.class);
}
@ -111,21 +113,11 @@ public class ItemMapRenderer extends MapRenderer
Location location = new Location(mapView.getWorld(), blockX, STANDARD_Y, blockZ);
boolean safezone = _safezone.isInSafeZone(location);
boolean supplyDrop = _supply.isNearSupplyDrop(location);
if (safezone || supplyDrop)
if (safezone)
{
boolean colorAll = scale > 0;
Color areaColor = null;
if (safezone)
{
areaColor = Color.GREEN;
}
else if (supplyDrop)
{
areaColor = Color.YELLOW;
}
Color areaColor = Color.GREEN;
if (areaColor != null)
{
@ -136,26 +128,15 @@ public class ItemMapRenderer extends MapRenderer
}
else
{
int chunkBX = blockX & 0xF;
int chunkBZ = blockZ & 0xF;
// int chunkBX = blockX & 0xF;
// int chunkBZ = blockZ & 0xF;
// Border
if (
((chunkBX == 0 || zoom == 13) &&
_safezone.isInSafeZone(new Location(mapView.getWorld(), blockX - 16, STANDARD_Y, blockZ)))
|| ((chunkBZ == 0 || zoom == 13) &&
_safezone.isInSafeZone(new Location(mapView.getWorld(), blockX, STANDARD_Y, blockZ - 16)))
|| ((chunkBX + zoom > 15 || zoom == 13) &&
_safezone.isInSafeZone(new Location(mapView.getWorld(), blockX + 16, STANDARD_Y, blockZ)))
|| ((chunkBZ + zoom > 15 || zoom == 13) &&
_safezone.isInSafeZone(new Location(mapView.getWorld(), blockX, STANDARD_Y, blockZ + 16))))
_safezone.isInSafeZone(new Location(mapView.getWorld(), blockX - 1, STANDARD_Y, blockZ)) ||
_safezone.isInSafeZone(new Location(mapView.getWorld(), blockX, STANDARD_Y, blockZ - 1)) ||
_safezone.isInSafeZone(new Location(mapView.getWorld(), blockX + 16, STANDARD_Y, blockZ)) ||
_safezone.isInSafeZone(new Location(mapView.getWorld(), blockX, STANDARD_Y, blockZ + 1)))
{
Color cColor = MapPalette.getColor(color);
double clans = colorAll ? 1 : 0.8;
@ -222,6 +203,31 @@ public class ItemMapRenderer extends MapRenderer
double mapX = (point.getX() - info.getX()) / zoom;
double mapZ = (point.getZ() - info.getZ()) / zoom;
// To make these appear at the edges of the map, just change it from
// 64 to something like 128 for double the map size
if (mapX > -64 && mapX < 64 && mapZ > -64 && mapZ < 64)
{
byte b0 = (byte) (int) Math.min(127, (double) (mapX * 2.0F) + 0.5D);
byte b1 = (byte) (int) Math.max(-127, (double) (mapZ * 2.0F) + 0.5D);
byte cursorType = 5; // http://i.imgur.com/wpH6PT8.png
// Those are byte 5 and 6
byte rotation = (byte) ((int) Math.floor(System.currentTimeMillis() / 1000D) % 16);
MapCursor cursor = new MapCursor(b0, b1, rotation, cursorType, true);
cursors.addCursor(cursor);
}
}
SupplyDrop supplyDrop = _supply.getActive();
if (_supply.isActive())
{
Location point = supplyDrop.getCurrentLocation();
double mapX = (point.getX() - info.getX()) / zoom;
double mapZ = (point.getZ() - info.getZ()) / zoom;
// To make these appear at the edges of the map, just change it from
// 64 to something like 128 for double the map size
if (mapX > -64 && mapX < 64 && mapZ > -64 && mapZ < 64)
@ -240,7 +246,7 @@ public class ItemMapRenderer extends MapRenderer
}
Party party = _party.getPartyByPlayer(player);
Community[] communities = _community.Get(player).getCommunities();
Set<UUID> shownPlayers = _loot.getShownPlayers();
for (Player other : Bukkit.getOnlinePlayers())
{
@ -259,21 +265,14 @@ public class ItemMapRenderer extends MapRenderer
{
cursorDisplay = MapCursor.Type.WHITE_POINTER;
}
else if (shownPlayers.contains(other.getUniqueId()))
{
cursorDisplay = MapCursor.Type.BLUE_POINTER;
}
else if (party != null && party.isMember(other))
{
cursorDisplay = MapCursor.Type.GREEN_POINTER;
}
else if (communities.length > 0)
{
for (Community community : communities)
{
if (community.getMembers().containsKey(other.getUniqueId()))
{
cursorDisplay = MapCursor.Type.BLUE_POINTER;
break;
}
}
}
if (cursorDisplay == null)
{

View File

@ -2,9 +2,14 @@ package mineplex.gemhunters.mount;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Horse;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.Horse.Color;
import org.bukkit.entity.Horse.Style;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
@ -25,7 +30,7 @@ import mineplex.gemhunters.loot.LootModule;
public class MountModule extends MiniClientPlugin<MountData>
{
private static final String ITEM_METADATA = "UNLOCKER";
private static final String ITEM_METADATA = "MOUNT";
private final LootModule _loot;
private final GadgetManager _gadget;
@ -47,11 +52,6 @@ public class MountModule extends MiniClientPlugin<MountData>
@EventHandler
public void playerInteract(PlayerInteractEvent event)
{
if (event.isCancelled())
{
return;
}
if (!UtilEvent.isAction(event, ActionType.R))
{
return;
@ -72,7 +72,7 @@ public class MountModule extends MiniClientPlugin<MountData>
return;
}
int cooldown = Integer.parseInt(lootItem.getMetadata().split(" ")[1]);
int cooldown = Integer.parseInt(lootItem.getMetadata().split(" ")[1]) * 1000;
if (!Recharge.Instance.use(player, _moduleName, cooldown, true, true))
{
@ -84,19 +84,55 @@ public class MountModule extends MiniClientPlugin<MountData>
public void spawnMount(Player player)
{
spawnMount(player, ((GameModifierMount) _gadget.getActiveGameModifier(player, GameModifierType.GemHunters, g -> g != null)).getMountType());
GameModifierMount mount = ((GameModifierMount) _gadget.getActiveGameModifier(player, GameModifierType.GemHunters, g -> g != null));
MountType mountType = null;
if (mount != null)
{
mountType = mount.getMountType();
}
spawnMount(player, mountType);
}
public void spawnMount(Player player, MountType mountType)
{
MountData data = Get(player);
LivingEntity entity = data.getEntity();
EntityType entityType = mountType.getEntityType();
EntityType entityType = mountType == null ? EntityType.HORSE : mountType.getEntityType();
despawnMount(player);
entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation().add(0, 1, 0), entityType == null ? EntityType.HORSE : entityType);
entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation().add(0, 1, 0), entityType);
if (entity instanceof Tameable)
{
Tameable tameable = (Tameable) entity;
tameable.setOwner(player);
}
if (entity instanceof Horse)
{
Horse horse = (Horse) entity;
horse.setAdult();
horse.setAgeLock(true);
horse.setColor(Color.BROWN);
horse.setStyle(Style.NONE);
horse.setMaxDomestication(1);
horse.setJumpStrength(1);
horse.getInventory().setSaddle(new ItemStack(Material.SADDLE));
}
entity.setCustomName(player.getName() + "\'s Mount");
entity.setCustomNameVisible(true);
entity.setCanPickupItems(false);
entity.setHealth(1);
entity.setMaxHealth(1);
entity.setPassenger(player);
data.setEntity(entity);
data.setMountType(mountType);
}

View File

@ -7,6 +7,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.menu.Menu;
import mineplex.gemhunters.util.SimpleNPC;
@ -37,7 +38,8 @@ public class QuestNPC extends SimpleNPC
event.setCancelled(true);
_questMenu.open(event.getPlayer());
event.getPlayer().sendMessage(F.main("Quest", "The Quest Master is currently disabled but will be avaiable to all players shortly."));
//_questMenu.open(event.getPlayer());/
}
}

View File

@ -4,17 +4,20 @@ import org.bukkit.entity.Player;
import mineplex.core.Managers;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime;
import mineplex.core.scoreboard.WritableMineplexScoreboard;
import mineplex.gemhunters.economy.EconomyModule;
import mineplex.gemhunters.supplydrop.SupplyDropModule;
import mineplex.gemhunters.worldevent.WorldEvent;
import mineplex.gemhunters.worldevent.WorldEventModule;
public class GemHuntersScoreboard extends WritableMineplexScoreboard
{
private final EconomyModule _economy;
private final WorldEventModule _worldEvent;
private final SupplyDropModule _supplyDrop;
public GemHuntersScoreboard(Player player)
{
@ -22,6 +25,7 @@ public class GemHuntersScoreboard extends WritableMineplexScoreboard
_economy = Managers.require(EconomyModule.class);
_worldEvent = Managers.require(WorldEventModule.class);
_supplyDrop = Managers.require(SupplyDropModule.class);
}
public void writeContent(Player player)
@ -33,13 +37,25 @@ public class GemHuntersScoreboard extends WritableMineplexScoreboard
writeNewLine();
write(C.cGoldB + "Supply Drop");
if (_supplyDrop.isActive())
{
write(_supplyDrop.getActive().getName() + " - " + (int) UtilMath.offset(player.getLocation(), _supplyDrop.getActive().getChestLocation()) + "m");
}
else
{
write(UtilTime.MakeStr(_supplyDrop.getLastSupplyDrop() + _supplyDrop.getSequenceTimer() - System.currentTimeMillis()));
}
writeNewLine();
write(C.cYellowB + "World Event");
if (!_worldEvent.isEventActive())
{
write(UtilTime.MakeStr(_worldEvent.getLastEventComplete() + _worldEvent.getEventTimer() - System.currentTimeMillis()));
}
else
else
{
for (WorldEvent event : _worldEvent.getActiveEvents())
{
@ -54,7 +70,7 @@ public class GemHuntersScoreboard extends WritableMineplexScoreboard
{
return C.cGray + " " + perspective.getName();
}
public int getUndernameScore(Player player)
{
return _economy.getGems(player);

View File

@ -12,10 +12,10 @@ public class VillagerPropertiesDeserialiser implements SheetObjectDeserialiser<V
String name = values[0];
String dataKey = values[1];
int spawnRate = Integer.parseInt(values[2]);
int expireRate = Integer.parseInt(values[3]);
int spawnRate = Integer.parseInt(values[4]);
int expireRate = Integer.parseInt(values[5]);
int max = Integer.parseInt(values[4]);
int max = Integer.parseInt(values[7]);
return new VillagerProperties(name, dataKey, spawnRate, expireRate, max);
}

View File

@ -8,6 +8,7 @@ import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
@ -32,7 +33,7 @@ import mineplex.gemhunters.world.WorldDataModule;
public class SpawnModule extends MiniPlugin
{
public static final int WORLD_BORDER_RADIUS = 768;
public static final int WORLD_BORDER_RADIUS = 1024;
private static final int MAX_SPAWNING_Y = 73;
private final SafezoneModule _safezone;
@ -50,7 +51,7 @@ public class SpawnModule extends MiniPlugin
_worldData = require(WorldDataModule.class);
}
@EventHandler
@EventHandler(priority = EventPriority.LOWEST)
public void playerJoin(PlayerJoinEvent event)
{
if (_spawn == null || _center == null)
@ -64,7 +65,9 @@ public class SpawnModule extends MiniPlugin
player.teleport(_spawn);
player.setFoodLevel(20);
player.setExhaustion(0);
player.getInventory().clear();
player.getInventory().setArmorContents(null);
if (_npcsSpawned)
{
return;
@ -167,7 +170,7 @@ public class SpawnModule extends MiniPlugin
public Location getRandomLocation()
{
int attempts = 0;
double range = WORLD_BORDER_RADIUS * 0.95;
double range = WORLD_BORDER_RADIUS * 0.5;
while (attempts < 100)
{

View File

@ -41,6 +41,7 @@ public class SupplyDrop
private static final String SCHEMATIC_PATH = ".." + File.separator + ".." + File.separator + "update" + File.separator + "files" + File.separator + "Helicopter.schematic";
private static final int BLADE_LENGTH = 7;
private final String _name;
private Location _destination;
private Location _despawn;
private Location _current;
@ -51,8 +52,9 @@ public class SupplyDrop
private Set<Block> _bladeBlocks;
private boolean _diagonal;
public SupplyDrop(Location spawn, Location destination, Location despawn)
public SupplyDrop(String name, Location spawn, Location destination, Location despawn)
{
_name = name;
_destination = destination.clone();
_despawn = despawn.clone();
_current = spawn.clone().add(-2, 0, 0);
@ -206,6 +208,16 @@ public class SupplyDrop
UtilFirework.playFirework(fallingBlock.getLocation().add(0.5, 1, 0.5), UtilFirework.getRandomFireworkEffect(false, 2, 1));
}
public final String getName()
{
return _name;
}
public final Location getCurrentLocation()
{
return _current;
}
public final Location getChestLocation()
{
return _destination;

View File

@ -40,8 +40,6 @@ public class SupplyDropModule extends MiniPlugin
private static final String CHEST_COLOUR = "RED";
private static final String LOCATION_DATA = "SUPPLY_DROP";
private static final int SUPPLY_DROP_DISTANCE_SQUARED = 625;
private final BlockRestore _blockRestore;
private final LootModule _loot;
@ -108,7 +106,7 @@ public class SupplyDropModule extends MiniPlugin
@EventHandler
public void fallingBlockChange(EntityChangeBlockEvent event)
{
if (event.getEntity() instanceof FallingBlock && event.getTo() == Material.WOOD && isActive())
if (event.getEntity() instanceof FallingBlock && event.getTo() == Material.WOOD && isActive() && UtilMath.offsetSquared(_current.getChestLocation(), event.getBlock().getLocation()) < 4)
{
Block block = event.getBlock();
@ -149,7 +147,7 @@ public class SupplyDropModule extends MiniPlugin
UtilServer.broadcast(F.main(_moduleName, "A Supply Drop is spawning at " + F.elem(locationKey) + " - " + C.cYellow + UtilWorld.locToStrClean(destination)));
_lastSupplyDrop = System.currentTimeMillis();
_current = new SupplyDrop(spawn, destination, despawn);
_current = new SupplyDrop(locationKey, spawn, destination, despawn);
}
public void startSequence()
@ -175,9 +173,19 @@ public class SupplyDropModule extends MiniPlugin
return _current != null;
}
public boolean isNearSupplyDrop(Location location)
public SupplyDrop getActive()
{
return isActive() ? UtilMath.offsetSquared(location, _current.getChestLocation()) <= SUPPLY_DROP_DISTANCE_SQUARED : false;
return _current;
}
public long getLastSupplyDrop()
{
return _lastSupplyDrop;
}
public long getSequenceTimer()
{
return SEQUENCE_TIMER;
}
public String[] getLocationKeys()

View File

@ -20,11 +20,12 @@ import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.gemhunters.debug.DebugModule;
public class UndergroundMobs implements Listener
{
private static final int MAX_MOBS = 100;
private static final int MAX_MOBS = 300;
private static final String SEWER_KEY = "SEWER_MOB";
private static final String SUBWAY_KEY = "SUBWAY_MOBS";
@ -64,6 +65,8 @@ public class UndergroundMobs implements Listener
}
}
DebugModule.getInstance().d("Spawning mobs " + _entities.size());
for (int i = 0; i < 10; i++)
{
if (_entities.size() >= MAX_MOBS)
@ -72,13 +75,13 @@ public class UndergroundMobs implements Listener
}
{
Location location = UtilAlg.Random(_worldData.getCustomLocation(SEWER_KEY));
Location location = UtilAlg.Random(_worldData.getCustomLocation(SEWER_KEY)).clone().add(0, 1, 0);
Class<? extends Entity> clazz = UtilMath.random.nextBoolean() ? Zombie.class : Skeleton.class;
Entity entity = _world.spawn(location, clazz);
_entities.add(entity);
}
{
Location location = UtilAlg.Random(_worldData.getCustomLocation(SUBWAY_KEY));
Location location = UtilAlg.Random(_worldData.getCustomLocation(SUBWAY_KEY)).clone().add(0, 1, 0);
Class<? extends Entity> clazz = Spider.class;
Entity entity = _world.spawn(location, clazz);
_entities.add(entity);

View File

@ -2,7 +2,6 @@ package mineplex.gemhunters.world;
import java.io.File;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.bukkit.GameMode;
import org.bukkit.Location;
@ -28,20 +27,18 @@ import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.inventory.BeaconInventory;
import org.bukkit.inventory.BrewerInventory;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.recharge.Recharge;
import mineplex.gemhunters.debug.DebugModule;
public class WorldListeners implements Listener
{
private static final long HUNGER_RECHARGE = TimeUnit.SECONDS.toMillis(15);
private final JavaPlugin _plugin;
public WorldListeners(JavaPlugin plugin)
@ -139,9 +136,11 @@ public class WorldListeners implements Listener
return;
}
// Sam don't you dare look here, I understand the implications of this
// but entities, can I just save by UUID? or does not doing this have
// bigger complications?.
if (event.getChunk().getEntities().length == 0)
{
return;
}
event.setCancelled(true);
}
@ -169,21 +168,24 @@ public class WorldListeners implements Listener
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.HIGHEST)
@EventHandler
public void hungerChange(FoodLevelChangeEvent event)
{
if (event.isCancelled())
{
return;
}
Player player = (Player) event.getEntity();
DebugModule.getInstance().d(player.getName() + " hunger " + player.getFoodLevel() + " -> " + event.getFoodLevel());
if (event.getFoodLevel() < player.getFoodLevel() && Recharge.Instance.use((Player) event.getEntity(), "Hunger", HUNGER_RECHARGE, false, false))
// Some witchcraft from the arcade, seems to make hunger not ridiculous.
player.setSaturation(3.8F);
}
@EventHandler
public void weather(WeatherChangeEvent event)
{
if (event.toWeatherState())
{
DebugModule.getInstance().d("Cancelling a weather change");
event.setCancelled(true);
event.getWorld().setStorm(false);
}
}

View File

@ -22,7 +22,7 @@ public class WorldEventModule extends MiniPlugin
{
private static final long EVENT_TIMER = TimeUnit.MINUTES.toMillis(30);
private static final long EVENT_COOLDOWN_TIMER = TimeUnit.MINUTES.toMillis(40);
private static final long EVENT_COOLDOWN_TIMER = TimeUnit.MINUTES.toMillis(20);
private static final long COMPLETE_TIMER = TimeUnit.SECONDS.toMillis(30);
private final List<WorldEvent> _events;

View File

@ -3,6 +3,6 @@ package mineplex.gemhunters.worldevent;
public enum WorldEventPriority
{
GLOBAL, ISOLATED
GLOBAL, TRIGGERED
}