Wooo finally!

This commit is contained in:
Sam 2017-03-13 22:01:06 +00:00
parent 7ab201f206
commit a231c0b031
28 changed files with 284 additions and 247 deletions

View File

@ -107,6 +107,7 @@ public class TextTutorialManager extends MiniPlugin
else else
{ {
iterator.remove(); iterator.remove();
tut.stopTutorial(player);
//Inform //Inform
UtilPlayer.message(player, F.main("Tutorial", "You completed " + F.elem(tut.getName()) + ".")); UtilPlayer.message(player, F.main("Tutorial", "You completed " + F.elem(tut.getName()) + "."));

View File

@ -15,7 +15,7 @@ public class BetaModule extends MiniPlugin
{ {
private static final String[] ANNOUCEMENTS = { private static final String[] ANNOUCEMENTS = {
"Please remember this game is an early access BETA and all bugs should be reported at mineplex.com/forums/viewforum/2369449/m/11929946 .", "Please remember this game is an early access BETA and all bugs should be reported at mineplex.com/forums/viewforum/2369449/m/11929946",
"Thank you for playing Gem Hunters!", "Thank you for playing Gem Hunters!",
"Safezones are marked as green areas on your map!", "Safezones are marked as green areas on your map!",
"Players that have super valuable items show up on your map!", "Players that have super valuable items show up on your map!",

View File

@ -38,6 +38,8 @@ import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.gemhunters.death.event.PlayerCustomRespawnEvent; import mineplex.gemhunters.death.event.PlayerCustomRespawnEvent;
import mineplex.gemhunters.playerstatus.PlayerStatusModule;
import mineplex.gemhunters.playerstatus.PlayerStatusType;
import mineplex.gemhunters.spawn.SpawnModule; import mineplex.gemhunters.spawn.SpawnModule;
/** /**
@ -53,6 +55,7 @@ public class DeathModule extends MiniPlugin
private static final int DEATH_ANIMATION_TIME = 7000; private static final int DEATH_ANIMATION_TIME = 7000;
private static final int DEATH_ANIMATION_COUNTDOWN = 2000; private static final int DEATH_ANIMATION_COUNTDOWN = 2000;
private final PlayerStatusModule _playerStatus;
private final SpawnModule _spawn; private final SpawnModule _spawn;
private final Map<UUID, Long> _toRemove; private final Map<UUID, Long> _toRemove;
@ -61,6 +64,7 @@ public class DeathModule extends MiniPlugin
{ {
super("Death"); super("Death");
_playerStatus = require(PlayerStatusModule.class);
_spawn = require(SpawnModule.class); _spawn = require(SpawnModule.class);
_toRemove = new HashMap<>(); _toRemove = new HashMap<>();
@ -146,6 +150,8 @@ public class DeathModule extends MiniPlugin
{ {
other.hidePlayer(player); other.hidePlayer(player);
} }
_playerStatus.setStatus(player, PlayerStatusType.DANGER, true);
} }
public void stopAnimation(Player player) public void stopAnimation(Player player)

View File

@ -18,6 +18,7 @@ import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.texttutorial.TextTutorialManager;
import mineplex.gemhunters.death.event.QuitNPCDespawnEvent; import mineplex.gemhunters.death.event.QuitNPCDespawnEvent;
import mineplex.gemhunters.death.event.QuitNPCSpawnEvent; import mineplex.gemhunters.death.event.QuitNPCSpawnEvent;
import mineplex.gemhunters.economy.event.PlayerCashOutCompleteEvent; import mineplex.gemhunters.economy.event.PlayerCashOutCompleteEvent;
@ -28,6 +29,8 @@ public class QuitNPCModule extends MiniPlugin
private static final long LOG_OUT_TIME = TimeUnit.SECONDS.toMillis(60); private static final long LOG_OUT_TIME = TimeUnit.SECONDS.toMillis(60);
private final TextTutorialManager _tutorial;
private final Map<UUID, QuitNPC> _npcs; private final Map<UUID, QuitNPC> _npcs;
private final Map<UUID, String> _killedBy; private final Map<UUID, String> _killedBy;
private final Set<UUID> _aboutToCashOut; private final Set<UUID> _aboutToCashOut;
@ -36,6 +39,8 @@ public class QuitNPCModule extends MiniPlugin
{ {
super("Quit NPC"); super("Quit NPC");
_tutorial = require(TextTutorialManager.class);
_npcs = new HashMap<>(); _npcs = new HashMap<>();
_killedBy = new HashMap<>(); _killedBy = new HashMap<>();
_aboutToCashOut = new HashSet<>(); _aboutToCashOut = new HashSet<>();
@ -83,7 +88,14 @@ public class QuitNPCModule extends MiniPlugin
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void playerQuit(PlayerQuitEvent event) public void playerQuit(PlayerQuitEvent event)
{ {
spawnNpc(event.getPlayer()); Player player = event.getPlayer();
if (_tutorial.isInTutorial(player))
{
return;
}
spawnNpc(player);
} }
@EventHandler @EventHandler

View File

@ -519,12 +519,6 @@ public class LootModule extends MiniPlugin
public void handleRewardItem(Player player, ItemStack itemStack) public void handleRewardItem(Player player, ItemStack itemStack)
{ {
LootItem lootItem = fromItemStack(itemStack); LootItem lootItem = fromItemStack(itemStack);
if (lootItem == null || lootItem.getMetadata() == null)
{
return;
}
LootItemReward reward = null; LootItemReward reward = null;
for (LootItemReward storedReward : _itemRewards) for (LootItemReward storedReward : _itemRewards)
@ -535,7 +529,7 @@ public class LootModule extends MiniPlugin
} }
} }
if (reward == null) if (reward == null && lootItem != null && lootItem.getMetadata() != null)
{ {
String[] metadataSplit = lootItem.getMetadata().split(" "); String[] metadataSplit = lootItem.getMetadata().split(" ");
String key = metadataSplit[0]; String key = metadataSplit[0];

View File

@ -211,9 +211,9 @@ public class ItemMapRenderer extends MapRenderer
byte cursorType = 5; // http://i.imgur.com/wpH6PT8.png byte cursorType = 5; // http://i.imgur.com/wpH6PT8.png
// Those are byte 5 and 6 // Those are byte 5 and 6
byte rotation = (byte) (int) (((point.getYaw() + 180) * 16D) / 360D); byte rotation = (byte) (int) ((point.getYaw() * 16D) / 360D);
MapCursor cursor = new MapCursor(b0, b1, rotation, cursorType, true); MapCursor cursor = new MapCursor(b0, b1, (byte) (rotation & 0xF), cursorType, true);
cursors.addCursor(cursor); cursors.addCursor(cursor);
} }

View File

@ -5,11 +5,9 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin;
@ -21,20 +19,16 @@ import mineplex.core.incognito.IncognitoManager;
import mineplex.core.incognito.events.IncognitoStatusChangeEvent; import mineplex.core.incognito.events.IncognitoStatusChangeEvent;
import mineplex.core.teleport.event.MineplexTeleportEvent; import mineplex.core.teleport.event.MineplexTeleportEvent;
import mineplex.gemhunters.moderation.command.ModeratorModeCommand; import mineplex.gemhunters.moderation.command.ModeratorModeCommand;
import mineplex.gemhunters.moderation.ui.TeleportUI; import mineplex.gemhunters.spawn.SpawnModule;
import mineplex.gemhunters.spawn.event.PlayerTeleportIntoMapEvent; import mineplex.gemhunters.spawn.event.PlayerTeleportIntoMapEvent;
@ReflectivelyCreateMiniPlugin @ReflectivelyCreateMiniPlugin
public class ModerationModule extends MiniPlugin public class ModerationModule extends MiniPlugin
{ {
//private static final ItemStack[] MOD_ITEMS = { new ItemBuilder(Material.COMPASS).setTitle(C.cGreen + "Teleport Compass").build() };
private final CoreClientManager _client; private final CoreClientManager _client;
private final IncognitoManager _incognito; private final IncognitoManager _incognito;
//private final SpawnModule _spawn; private final SpawnModule _spawn;
private final TeleportUI _teleportUI;
private final Set<UUID> _moderators; private final Set<UUID> _moderators;
@ -44,9 +38,7 @@ public class ModerationModule extends MiniPlugin
_client = require(CoreClientManager.class); _client = require(CoreClientManager.class);
_incognito = require(IncognitoManager.class); _incognito = require(IncognitoManager.class);
//_spawn = require(SpawnModule.class); _spawn = require(SpawnModule.class);
_teleportUI = new TeleportUI(this);
_moderators = new HashSet<>(); _moderators = new HashSet<>();
} }
@ -86,7 +78,6 @@ public class ModerationModule extends MiniPlugin
} }
else if (event.getNewState()) else if (event.getNewState())
{ {
event.setCancelled(true);
enableModeratorMode(player); enableModeratorMode(player);
} }
} }
@ -104,46 +95,13 @@ public class ModerationModule extends MiniPlugin
enableModeratorMode(player); enableModeratorMode(player);
} }
@EventHandler
public void interact(PlayerInteractEvent event)
{
Player player = event.getPlayer();
if (!isModerating(player) || player.getItemInHand() == null)
{
return;
}
Material material = player.getItemInHand().getType();
switch (material)
{
case COMPASS:
_teleportUI.open(player);
break;
default:
break;
}
}
public void enableModeratorMode(Player player) public void enableModeratorMode(Player player)
{ {
player.sendMessage(F.main(_moduleName, "Enabled moderator mode.")); player.sendMessage(F.main(_moduleName, "Enabled moderator mode."));
player.setGameMode(GameMode.SPECTATOR); player.setGameMode(GameMode.SPECTATOR);
player.getInventory().clear();
// player.getInventory().clear();
// player.getInventory().addItem(MOD_ITEMS);
// player.setAllowFlight(true);
// player.setFlying(true);
//
((CraftPlayer) player).getHandle().spectating = true; ((CraftPlayer) player).getHandle().spectating = true;
//
// for (Player other : Bukkit.getOnlinePlayers())
// {
// other.hidePlayer(player);
// }
_moderators.add(player.getUniqueId()); _moderators.add(player.getUniqueId());
} }
@ -151,21 +109,11 @@ public class ModerationModule extends MiniPlugin
public void disableModeratorMode(Player player) public void disableModeratorMode(Player player)
{ {
player.sendMessage(F.main(_moduleName, "Disabled moderator mode.")); player.sendMessage(F.main(_moduleName, "Disabled moderator mode."));
player.setGameMode(GameMode.SURVIVAL); player.setGameMode(GameMode.SURVIVAL);
// player.getInventory().clear();
// player.setFlying(false);
// player.setAllowFlight(false);
//
((CraftPlayer) player).getHandle().spectating = false; ((CraftPlayer) player).getHandle().spectating = false;
//
// _spawn.teleportToSpawn(player); _spawn.teleportToSpawn(player);
//
// for (Player other : Bukkit.getOnlinePlayers())
// {
// other.showPlayer(player);
// }
_moderators.remove(player.getUniqueId()); _moderators.remove(player.getUniqueId());
} }

View File

@ -1,71 +0,0 @@
package mineplex.gemhunters.moderation.ui;
import java.util.Arrays;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilSkull;
import mineplex.core.menu.Button;
import mineplex.core.menu.Menu;
import mineplex.gemhunters.moderation.ModerationModule;
public class TeleportUI extends Menu<ModerationModule>
{
public TeleportUI(ModerationModule plugin)
{
super("Teleporter", plugin);
}
@Override
protected Button[] setUp(Player player)
{
Button[] buttons = new Button[54];
int i = 0;
int max = buttons.length;
for (Player other : Bukkit.getOnlinePlayers())
{
if (UtilPlayer.isSpectator(other))
{
continue;
}
if (max <= i)
{
break;
}
buttons[i++] = new TeleportButton(other, getPlugin());
}
return buttons;
}
private class TeleportButton extends Button<ModerationModule>
{
private Player _player;
public TeleportButton(Player player, ModerationModule plugin)
{
super(UtilSkull.getPlayerHead(player.getName(), C.cYellow + player.getName(), Arrays.asList(C.cGray + "Click to teleport to " + player.getName() + ".")), plugin);
_player = player;
}
@Override
public void onClick(Player player, ClickType clickType)
{
player.sendMessage(F.main(getPlugin().getName(), "Teleported to " + F.elem(_player.getName()) + "."));
player.teleport(_player);
}
}
}

View File

@ -138,9 +138,7 @@ public class MountModule extends MiniClientPlugin<MountData>
data.setMountType(mountType); data.setMountType(mountType);
data.setCooldown(cooldown); data.setCooldown(cooldown);
Entity finalEntity = entity; entity.setPassenger(player);
runSyncLater(() -> finalEntity.setPassenger(player), 5);
} }
public void despawnMount(Player player) public void despawnMount(Player player)
@ -152,7 +150,7 @@ public class MountModule extends MiniClientPlugin<MountData>
{ {
entity.remove(); entity.remove();
Recharge.Instance.useForce(player, _moduleName, data.getCooldown()); Recharge.Instance.use(player, _moduleName, data.getCooldown(), true, false);
} }
} }

View File

@ -63,6 +63,11 @@ public class PlayerStatusModule extends MiniClientPlugin<PlayerStatus>
return; return;
} }
if (event.getDamager() instanceof Player)
{
setStatus((Player) event.getDamager(), PlayerStatusType.COMBAT, COMBAT_TIME);
}
setStatus((Player) event.getEntity(), PlayerStatusType.COMBAT, COMBAT_TIME); setStatus((Player) event.getEntity(), PlayerStatusType.COMBAT, COMBAT_TIME);
} }

View File

@ -101,7 +101,6 @@ public abstract class Quest implements Listener
public void onStart(Player player) public void onStart(Player player)
{ {
_economy.removeFromStore(player, _startCost);
} }
public void onReward(Player player) public void onReward(Player player)

View File

@ -11,6 +11,7 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
@ -25,8 +26,9 @@ import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilItem.ItemAttribute;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
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.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
@ -148,7 +150,10 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
continue; continue;
} }
player.sendMessage(F.main(C.cYellowB + "Quest Master", "I have " + F.count(String.valueOf(MAX_QUESTS)) + " new quests for you! Come and see me to start them!")); if (playerData.getLastClear() != 0)
{
player.sendMessage(F.main(C.cYellowB + "Quest Master", "I have " + F.count(String.valueOf(MAX_QUESTS)) + " new quests for you! Come and see me to start them!"));
}
playerData.clear(); playerData.clear();
updateQuests(player); updateQuests(player);
@ -183,7 +188,7 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
return; return;
} }
boolean able = startQuest(quest, player); boolean able = startQuest(quest, player, false);
if (!able) if (!able)
{ {
@ -191,9 +196,11 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
} }
else else
{ {
UUID owner = UUID.fromString(item.getMetadata(ITEM_METADATA).get(0).asString()); // UUID owner = UUID.fromString(item.getMetadata(ITEM_METADATA).get(0).asString());
Player other = UtilPlayer.searchExact(owner); // Player other = UtilPlayer.searchExact(owner);
event.getItem().remove();
event.setCancelled(true);
/* /*
* Noting here that when a player leaves their quest progress is removed. * Noting here that when a player leaves their quest progress is removed.
* However that means that if a new player picks up their quest item we * However that means that if a new player picks up their quest item we
@ -209,13 +216,6 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
* corners and saying that if a player quits out then don't allow other * corners and saying that if a player quits out then don't allow other
* players to be able to pickup the quest. * players to be able to pickup the quest.
*/ */
if (other == null)
{
event.setCancelled(true);
return;
}
} }
} }
@ -244,6 +244,12 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
item.setMetadata(ITEM_METADATA, new FixedMetadataValue(_plugin, player.getUniqueId().toString())); item.setMetadata(ITEM_METADATA, new FixedMetadataValue(_plugin, player.getUniqueId().toString()));
} }
@EventHandler
public void playerDeath(PlayerDeathEvent event)
{
Get(event.getEntity()).clear(true);
}
public void updateQuests(Player player) public void updateQuests(Player player)
{ {
QuestPlayerData playerData = Get(player); QuestPlayerData playerData = Get(player);
@ -263,7 +269,7 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
} }
} }
public boolean startQuest(Quest quest, Player player) public boolean startQuest(Quest quest, Player player, boolean applyCost)
{ {
if (isActive(quest, player)) if (isActive(quest, player))
{ {
@ -280,7 +286,7 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
player.sendMessage(F.main(_moduleName, "You do not have enough space in your inventory to start this quest.")); player.sendMessage(F.main(_moduleName, "You do not have enough space in your inventory to start this quest."));
return false; return false;
} }
else if (_economy.Get(player) < quest.getStartCost()) else if (applyCost && _economy.Get(player) < quest.getStartCost())
{ {
player.sendMessage(F.main(_moduleName, "You do not have enough gems to start this quest.")); player.sendMessage(F.main(_moduleName, "You do not have enough gems to start this quest."));
return false; return false;
@ -294,6 +300,11 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
updateQuestItem(quest, player); updateQuestItem(quest, player);
quest.onStart(player); quest.onStart(player);
if (applyCost)
{
_economy.removeFromStore(player, quest.getStartCost());
}
return true; return true;
} }
@ -388,7 +399,6 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
{ {
String progress = C.mBody + "[" + C.cGreen + quest.get(player) + C.mBody + "/" + C.cGreen + quest.getGoal() + C.mBody + "]"; String progress = C.mBody + "[" + C.cGreen + quest.get(player) + C.mBody + "/" + C.cGreen + quest.getGoal() + C.mBody + "]";
builder.setTitle(builder.getTitle() + " " + progress);
builder.addLore(UtilTextMiddle.progress(quest.getProgress(player)) + C.mBody + " " + progress); builder.addLore(UtilTextMiddle.progress(quest.getProgress(player)) + C.mBody + " " + progress);
} }
@ -428,12 +438,7 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
for (ItemStack items : player.getInventory().getContents()) for (ItemStack items : player.getInventory().getContents())
{ {
if (items == null || items.getType() == Material.AIR || items.getItemMeta() == null) if (UtilItem.isSimilar(itemStack, items, ItemAttribute.NAME, ItemAttribute.MATERIAL, ItemAttribute.DATA, ItemAttribute.AMOUNT))
{
continue;
}
if (itemStack.getType() == items.getType() && itemStack.getItemMeta().getDisplayName().startsWith(items.getItemMeta().getDisplayName()))
{ {
player.getInventory().remove(items); player.getInventory().remove(items);
} }

View File

@ -22,11 +22,24 @@ public class QuestPlayerData
} }
public void clear() public void clear()
{
clear(false);
}
public void clear(boolean active)
{ {
_possibleQuests.clear(); _possibleQuests.clear();
_completedQuests.clear(); _completedQuests.clear();
_lastClear = System.currentTimeMillis(); if (active)
{
_activeQuests.clear();
_lastClear = 0;
}
else
{
_lastClear = System.currentTimeMillis();
}
} }
public List<Integer> getPossibleQuests() public List<Integer> getPossibleQuests()

View File

@ -57,7 +57,7 @@ public class QuestUI extends Menu<QuestModule>
@Override @Override
public void onClick(Player player, ClickType clickType) public void onClick(Player player, ClickType clickType)
{ {
getPlugin().startQuest(_quest, player); getPlugin().startQuest(_quest, player, true);
resetAndUpdate(); resetAndUpdate();
} }

View File

@ -6,6 +6,10 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.gemhunters.quest.Quest; import mineplex.gemhunters.quest.Quest;
public class KillMostValuableQuest extends Quest public class KillMostValuableQuest extends Quest
@ -16,8 +20,49 @@ public class KillMostValuableQuest extends Quest
super(id, name, description, startCost, completeReward); super(id, name, description, startCost, completeReward);
} }
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
Player player = getMostValuable();
String display = C.cRed + "The most valuable player is " + C.cYellow + (player != null ? player.getName() : "No one");
for (Player other : Bukkit.getOnlinePlayers())
{
if (!isActive(other) || !_quest.getItemStack(this, other, false, true, true).isSimilar(other.getItemInHand()))
{
continue;
}
UtilTextBottom.display(display, other);
}
}
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void playerDeath(PlayerDeathEvent event) public void playerDeath(PlayerDeathEvent event)
{
Player player = getMostValuable();
if (player == null || !event.getEntity().equals(player))
{
return;
}
Player killer = player.getKiller();
if (!isActive(killer))
{
return;
}
onReward(killer);
}
private Player getMostValuable()
{ {
Player mostGemsPlayer = null; Player mostGemsPlayer = null;
int mostGems = 0; int mostGems = 0;
@ -33,19 +78,6 @@ public class KillMostValuableQuest extends Quest
} }
} }
if (mostGemsPlayer == null || !event.getEntity().equals(mostGemsPlayer)) return mostGemsPlayer;
{
return;
}
Player killer = mostGemsPlayer.getKiller();
if (!isActive(killer))
{
return;
}
onReward(killer);
} }
} }

View File

@ -4,7 +4,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;

View File

@ -23,9 +23,9 @@ public class GemHuntersScoreboard extends WritableMineplexScoreboard
{ {
super(player); super(player);
_economy = Managers.require(EconomyModule.class); _economy = Managers.get(EconomyModule.class);
_playerStatus = Managers.require(PlayerStatusModule.class); _playerStatus = Managers.get(PlayerStatusModule.class);
_supplyDrop = Managers.require(SupplyDropModule.class); _supplyDrop = Managers.get(SupplyDropModule.class);
} }
public void writeContent(Player player) public void writeContent(Player player)

View File

@ -87,6 +87,12 @@ public class ShopModule extends MiniPlugin
for (String key : map.keySet()) for (String key : map.keySet())
{ {
//TODO this is super temporary
if (key.equals("PINK"))
{
continue;
}
if (key.equals(VILLAGER_MASTER_SHEET_NAME)) if (key.equals(VILLAGER_MASTER_SHEET_NAME))
{ {
int row = 0; int row = 0;

View File

@ -18,6 +18,27 @@ public class GemHuntersTutorial extends Tutorial
private final SpawnModule _spawn; private final SpawnModule _spawn;
private final WorldDataModule _worldData; private final WorldDataModule _worldData;
private final int[][] _locations = {
{
92, 69, 148, 53, 15
},
{
-125, 76, 94, 90, 0
},
{
-220, 69, -280, -135, 20
},
{
-611, 78, -19, -135, 20
},
{
-454, 68, 231, 0, 0
},
{
300, 88, 45, 125, 0
}
};
public GemHuntersTutorial() public GemHuntersTutorial()
{ {
super("Gem Hunters", "gemhunterstutorial", 0); super("Gem Hunters", "gemhunterstutorial", 0);
@ -25,31 +46,31 @@ public class GemHuntersTutorial extends Tutorial
_spawn = Managers.require(SpawnModule.class); _spawn = Managers.require(SpawnModule.class);
_worldData = Managers.require(WorldDataModule.class); _worldData = Managers.require(WorldDataModule.class);
addPhase(new Phase(getLocation(1), "Welcome", new String[] { addPhase(new Phase(getLocation(0), "Welcome", new String[] {
"Welcome To " + C.cGreen + "Gem Hunters", "Welcome To " + C.cGreen + "Gem Hunters",
})); }));
// addPhase(new Phase(getLocation(2), "PVP", new String[] { addPhase(new Phase(getLocation(1), "PVP", new String[] {
// "Players start with " + C.cGreen + EconomyModule.GEM_START_COST + C.cWhite + " Gems and must survive in the city.", "Players start with " + C.cGreen + EconomyModule.GEM_START_COST + C.cWhite + " Gems and must survive in the city.",
// "Killing another player will gift you " + C.cYellow + "50%" + C.cWhite + "of their total gems", "Killing another player will gift you " + C.cYellow + "50%" + C.cWhite + "of their total gems.",
// })); }));
// addPhase(new Phase(getLocation(3), "Safezones", new String[] { addPhase(new Phase(getLocation(2), "Safezones", new String[] {
// "In Safe Zones you cannot take damage and can purchase items like", "In Safe Zones you cannot take damage and can purchase items like",
// "Food, Weapons, and Gear with the Gems you earn in the world.", "Food, Weapons, and Gear with the Gems you earn in the world.",
// })); }));
// addPhase(new Phase(getLocation(4), "Items", new String[] { addPhase(new Phase(getLocation(3), "Items", new String[] {
// "Collect items from chests and powerup.", "Collect items from chests and powerup.",
// "You can find anything from Weaponrs to Cosmetics.", "You can find anything from Weaponrs to Cosmetics.",
// "If you find somethiing you want to keep you can", "If you find somethiing you want to keep you can",
// C.cGreen + "Cash Out" + C.cWhite + " at any time by right clicking the " + C.cGreen + "Emerald" + C.cWhite + " in your inventory.", C.cGreen + "Cash Out" + C.cWhite + " at any time by right clicking the " + C.cGreen + "Emerald" + C.cWhite + " in your inventory.",
// })); }));
// addPhase(new Phase(getLocation(5), "Cashing Out", new String[] { addPhase(new Phase(getLocation(4), "Cashing Out", new String[] {
// "Cashing out will reset your progress in the world,", "Cashing out will reset your progress in the world,",
// "adds any special items you had like", "adds any special items you had like",
// "Gems, Treasure Shards, Cosmetics or Rank Upgrades to your account!", "Gems, Treasure Shards, Cosmetics or Rank Upgrades to your account!",
// })); }));
// addPhase(new Phase(getLocation(6), "Safezones", new String[] { addPhase(new Phase(getLocation(5), "Good luck", new String[] {
// "Stay safe! Anarchy rules in the world of " + C.cGreen + "Gem Hunters" "Stay safe! Anarchy rules in the world of " + C.cGreen + "Gem Hunters" + C.cWhite + "!"
// })); }));
} }
@Override @Override
@ -74,7 +95,9 @@ public class GemHuntersTutorial extends Tutorial
private Location getLocation(int phase) private Location getLocation(int phase)
{ {
return _worldData.getCustomLocation("TUTORIAL " + phase).get(0); int[] locations = _locations[phase];
return new Location(_worldData.World, locations[0] + 0.5, locations[1] + 0.5, locations[2] + 0.5, locations[3], locations[4]);
} }
} }

View File

@ -144,7 +144,7 @@ public class WorldListeners implements Listener
Material material = block.getType(); Material material = block.getType();
if (material == Material.BEACON || material == Material.DISPENSER || material == Material.HOPPER || material == Material.BREWING_STAND) if (material == Material.BEACON || material == Material.DISPENSER || material == Material.HOPPER || material == Material.BREWING_STAND || material == Material.DROPPER)
{ {
event.setCancelled(true); event.setCancelled(true);
} }

View File

@ -61,6 +61,8 @@ public abstract class WorldEvent implements Listener
public abstract Location[] getEventLocations(); public abstract Location[] getEventLocations();
public abstract double getProgress();
private final void start() private final void start()
{ {
if (isLive()) if (isLive())

View File

@ -23,7 +23,6 @@ import mineplex.gemhunters.worldevent.blizzard.BlizzardWorldEvent;
import mineplex.gemhunters.worldevent.command.WorldEventCommand; import mineplex.gemhunters.worldevent.command.WorldEventCommand;
import mineplex.gemhunters.worldevent.giant.GiantWorldEvent; import mineplex.gemhunters.worldevent.giant.GiantWorldEvent;
import mineplex.gemhunters.worldevent.gwenmart.GwenMartWorldEvent; import mineplex.gemhunters.worldevent.gwenmart.GwenMartWorldEvent;
import mineplex.gemhunters.worldevent.nether.NetherPortalWorldEvent;
import mineplex.gemhunters.worldevent.wither.WitherWorldEvent; import mineplex.gemhunters.worldevent.wither.WitherWorldEvent;
@ReflectivelyCreateMiniPlugin @ReflectivelyCreateMiniPlugin
@ -44,7 +43,7 @@ public class WorldEventModule extends MiniPlugin
new GiantWorldEvent(), new GiantWorldEvent(),
new BlizzardWorldEvent(), new BlizzardWorldEvent(),
new NetherPortalWorldEvent(), //new NetherPortalWorldEvent(),
new WitherWorldEvent(), new WitherWorldEvent(),
new GwenMartWorldEvent() new GwenMartWorldEvent()
@ -122,7 +121,7 @@ public class WorldEventModule extends MiniPlugin
WorldEvent worldEvent = getActiveEvents().get(0); WorldEvent worldEvent = getActiveEvents().get(0);
UtilTextTop.display(C.cRed + worldEvent.getEventType().getName() + C.cYellow + " -> " + C.cRed + worldEvent.getEventState().getName(), UtilServer.getPlayers()); UtilTextTop.displayProgress(C.cRed + worldEvent.getEventType().getName() + C.cYellow + " -> " + C.cRed + worldEvent.getEventState().getName(), worldEvent.getProgress(), UtilServer.getPlayers());
} }
public WorldEvent getEvent(WorldEventType eventType) public WorldEvent getEvent(WorldEventType eventType)

View File

@ -37,6 +37,7 @@ public class BlizzardWorldEvent extends WorldEvent
private static final double START_CHANCE = 0.01; private static final double START_CHANCE = 0.01;
private static final long MAX_TIME = TimeUnit.MINUTES.toMillis(10); private static final long MAX_TIME = TimeUnit.MINUTES.toMillis(10);
private static final long GRACE_TIME = TimeUnit.SECONDS.toMillis(60); private static final long GRACE_TIME = TimeUnit.SECONDS.toMillis(60);
private static final long WARM_TIME = TimeUnit.SECONDS.toMillis(5);
private static final int DAMAGE = 2; private static final int DAMAGE = 2;
private static final String TIP = "EQUIP LEATHER ARMOUR OR GET NEAR A FIRE"; private static final String TIP = "EQUIP LEATHER ARMOUR OR GET NEAR A FIRE";
@ -115,7 +116,9 @@ public class BlizzardWorldEvent extends WorldEvent
private boolean shouldDamage(Player player) private boolean shouldDamage(Player player)
{ {
if (_safezone.getSafezone(player.getLocation()).contains(SafezoneModule.SAFEZONE_DATA_IGNORE)) String safezone = _safezone.getSafezone(player.getLocation());
if (safezone != null && safezone.contains(SafezoneModule.SAFEZONE_DATA_IGNORE))
{ {
return false; return false;
} }
@ -138,6 +141,7 @@ public class BlizzardWorldEvent extends WorldEvent
} }
} }
_playerStatus.setStatus(player, PlayerStatusType.WARM, WARM_TIME);
return false; return false;
} }
@ -193,4 +197,10 @@ public class BlizzardWorldEvent extends WorldEvent
return null; return null;
} }
@Override
public double getProgress()
{
return (double) (_start + MAX_TIME - System.currentTimeMillis()) / (double) MAX_TIME;
}
} }

View File

@ -100,6 +100,12 @@ public class CustomGiant implements Listener
Vector direction = UtilAlg.getTrajectory2d(_giant.getLocation(), _target).multiply(MOVE_FACTOR); Vector direction = UtilAlg.getTrajectory2d(_giant.getLocation(), _target).multiply(MOVE_FACTOR);
Location toTeleport = _giant.getLocation().add(direction); Location toTeleport = _giant.getLocation().add(direction);
Location heightCheck = _giant.getLocation().add(direction.clone().multiply(2));
if (Math.abs(UtilBlock.getHighest(_giant.getWorld(), heightCheck).getLocation().getY() - _giant.getLocation().getY()) <= 1)
{
toTeleport.add(0, 1, 0);
}
toTeleport.setYaw(UtilAlg.GetYaw(direction)); toTeleport.setYaw(UtilAlg.GetYaw(direction));
toTeleport.setPitch(UtilAlg.GetPitch(direction)); toTeleport.setPitch(UtilAlg.GetPitch(direction));
@ -115,7 +121,7 @@ public class CustomGiant implements Listener
return; return;
} }
for (Block block : UtilBlock.getInBoundingBox(_giant.getLocation().subtract(GIANT_WIDTH, 0, GIANT_WIDTH), _giant.getLocation().add(GIANT_WIDTH, GIANT_HEIGHT, GIANT_WIDTH))) for (Block block : UtilBlock.getInBoundingBox(_giant.getLocation().add(-GIANT_WIDTH, 1, -GIANT_WIDTH), _giant.getLocation().add(GIANT_WIDTH, GIANT_HEIGHT, GIANT_WIDTH)))
{ {
if (_safezone.isInSafeZone(block.getLocation())) if (_safezone.isInSafeZone(block.getLocation()))
{ {

View File

@ -1,10 +1,11 @@
package mineplex.gemhunters.worldevent.giant; package mineplex.gemhunters.worldevent.giant;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Zombie; import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityCombustEvent;
@ -13,12 +14,12 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.gemhunters.loot.rewards.LootChestReward; import mineplex.gemhunters.loot.rewards.LootChestReward;
@ -71,8 +72,8 @@ public class GiantWorldEvent extends WorldEvent
@Override @Override
public void onEnd() public void onEnd()
{ {
ItemStack itemStack = new ItemBuilder(Material.SEA_LANTERN).setTitle(C.cAqua + "Omega Chest").build(); ItemStack itemStack = SkinData.OMEGA_CHEST.getSkull(C.cAqua + "Omega Chest", new ArrayList<>());
LootChestReward reward = new LootChestReward(CASH_OUT_DELAY, itemStack, "Omega", 1); LootChestReward reward = new LootChestReward(CASH_OUT_DELAY, SkinData.OMEGA_CHEST.getSkull(C.cAqua + "Omega Chest", null), "Omega", 1);
_worldData.World.dropItemNaturally(getEventLocations()[0], itemStack); _worldData.World.dropItemNaturally(getEventLocations()[0], itemStack);
@ -89,6 +90,14 @@ public class GiantWorldEvent extends WorldEvent
return new Location[] { _giant.getGiant().getLocation() }; return new Location[] { _giant.getGiant().getLocation() };
} }
@Override
public double getProgress()
{
LivingEntity giant = _giant.getGiant();
return giant.getHealth() / giant.getMaxHealth();
}
@EventHandler @EventHandler
public void zombieCombust(EntityCombustEvent event) public void zombieCombust(EntityCombustEvent event)
{ {

View File

@ -88,7 +88,7 @@ public class GwenMartWorldEvent extends WorldEvent
for (Location location : _worldData.getCustomLocation("GWEN_MART_CHEST")) for (Location location : _worldData.getCustomLocation("GWEN_MART_CHEST"))
{ {
location.getBlock().setType(Material.CHEST); location.getBlock().setType(Material.CHEST);
_loot.addSpawnedChest(location, UtilMath.random.nextBoolean() ? "ORANGE" : "PINK"); _loot.addSpawnedChest(location, getRandomChestKey());
} }
setEventState(WorldEventState.LIVE); setEventState(WorldEventState.LIVE);
@ -123,6 +123,7 @@ public class GwenMartWorldEvent extends WorldEvent
{ {
if (isInGwenMart(player.getLocation())) if (isInGwenMart(player.getLocation()))
{ {
player.leaveVehicle();
player.teleport(teleportTo); player.teleport(teleportTo);
} }
} }
@ -139,6 +140,12 @@ public class GwenMartWorldEvent extends WorldEvent
return new Location[] { _average }; return new Location[] { _average };
} }
@Override
public double getProgress()
{
return (double) (_start + MAX_TIME - System.currentTimeMillis()) / (double) MAX_TIME;
}
private boolean isInGwenMart(Location location) private boolean isInGwenMart(Location location)
{ {
List<Location> locations = _worldData.getCustomLocation("GWEN_MART"); List<Location> locations = _worldData.getCustomLocation("GWEN_MART");
@ -146,4 +153,20 @@ public class GwenMartWorldEvent extends WorldEvent
return UtilAlg.inBoundingBox(location, locations.get(0), locations.get(1)); return UtilAlg.inBoundingBox(location, locations.get(0), locations.get(1));
} }
private String getRandomChestKey()
{
double random = Math.random();
if (random > 0.6)
{
return "ORANGE";
}
else if (random > 0.1)
{
return "PINK";
}
return "GREEN";
}
} }

View File

@ -69,12 +69,7 @@ public class NetherPortalWorldEvent extends WorldEvent
Player player = event.getPlayer(); Player player = event.getPlayer();
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
if (player.getItemInHand() == null) if (player.getItemInHand() == null || player.getItemInHand().getType() != Material.FLINT_AND_STEEL)
{
return;
}
if (player.getItemInHand().getType() != Material.FLINT_AND_STEEL)
{ {
return; return;
} }
@ -191,8 +186,16 @@ public class NetherPortalWorldEvent extends WorldEvent
return _portalLocations.toArray(new Location[0]); return _portalLocations.toArray(new Location[0]);
} }
@Override
public double getProgress()
{
return (double) (_start + MAX_TIME - System.currentTimeMillis()) / (double) MAX_TIME;
}
private void buildPortal(Location location) private void buildPortal(Location location)
{ {
location.getBlock().setType(Material.SPONGE);
for (Block block : UtilBlock.getInBoundingBox(location.clone().add(2, 4, 0), location.clone().add(-2, 0, 0), false, true, false, false)) for (Block block : UtilBlock.getInBoundingBox(location.clone().add(2, 4, 0), location.clone().add(-2, 0, 0), false, true, false, false))
{ {
_restore.add(block, Material.OBSIDIAN.getId(), (byte) 0, Integer.MAX_VALUE); _restore.add(block, Material.OBSIDIAN.getId(), (byte) 0, Integer.MAX_VALUE);

View File

@ -89,8 +89,10 @@ public class WitherWorldEvent extends WorldEvent
skull.getBlock().setType(Material.AIR); skull.getBlock().setType(Material.AIR);
} }
location.getBlock().getRelative(BlockFace.UP).setType(Material.ENDER_CHEST); Block chest = location.getBlock().getRelative(BlockFace.UP);
_loot.addSpawnedChest(location, "PURPLE");
chest.setType(Material.ENDER_CHEST);
_loot.addSpawnedChest(chest.getLocation(), "PURPLE");
for (int i = 0; i < SKELETONS; i++) for (int i = 0; i < SKELETONS; i++)
{ {
@ -99,6 +101,8 @@ public class WitherWorldEvent extends WorldEvent
skeleton.getEquipment().setItemInHand(IN_HAND); skeleton.getEquipment().setItemInHand(IN_HAND);
skeleton.setMaxHealth(HEALTH); skeleton.setMaxHealth(HEALTH);
skeleton.setHealth(HEALTH); skeleton.setHealth(HEALTH);
addEntity(skeleton);
} }
setEventState(WorldEventState.LIVE); setEventState(WorldEventState.LIVE);
@ -125,6 +129,12 @@ public class WitherWorldEvent extends WorldEvent
return new Location[] { _skulls[1] }; return new Location[] { _skulls[1] };
} }
@Override
public double getProgress()
{
return (double) (_start + MAX_TIME - System.currentTimeMillis()) / (double) MAX_TIME;
}
private void buildAlter() private void buildAlter()
{ {
Location point = _worldData.getCustomLocation("WITHER_ALTER").get(0).clone(); Location point = _worldData.getCustomLocation("WITHER_ALTER").get(0).clone();
@ -139,6 +149,11 @@ public class WitherWorldEvent extends WorldEvent
point.add(0, 0, -1), point.add(0, 0, -1),
point.add(0, 0, -1) point.add(0, 0, -1)
}; };
for (Location location : _skulls)
{
location.getBlock().setType(Material.SPONGE);
}
} }
} }