Wooo finally!
This commit is contained in:
parent
7ab201f206
commit
a231c0b031
@ -107,7 +107,8 @@ public class TextTutorialManager extends MiniPlugin
|
||||
else
|
||||
{
|
||||
iterator.remove();
|
||||
|
||||
tut.stopTutorial(player);
|
||||
|
||||
//Inform
|
||||
UtilPlayer.message(player, F.main("Tutorial", "You completed " + F.elem(tut.getName()) + "."));
|
||||
|
||||
|
@ -15,7 +15,7 @@ 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 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!",
|
||||
"Safezones are marked as green areas on your map!",
|
||||
"Players that have super valuable items show up on your map!",
|
||||
|
@ -38,6 +38,8 @@ import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.gemhunters.death.event.PlayerCustomRespawnEvent;
|
||||
import mineplex.gemhunters.playerstatus.PlayerStatusModule;
|
||||
import mineplex.gemhunters.playerstatus.PlayerStatusType;
|
||||
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_COUNTDOWN = 2000;
|
||||
|
||||
private final PlayerStatusModule _playerStatus;
|
||||
private final SpawnModule _spawn;
|
||||
|
||||
private final Map<UUID, Long> _toRemove;
|
||||
@ -61,6 +64,7 @@ public class DeathModule extends MiniPlugin
|
||||
{
|
||||
super("Death");
|
||||
|
||||
_playerStatus = require(PlayerStatusModule.class);
|
||||
_spawn = require(SpawnModule.class);
|
||||
|
||||
_toRemove = new HashMap<>();
|
||||
@ -146,6 +150,8 @@ public class DeathModule extends MiniPlugin
|
||||
{
|
||||
other.hidePlayer(player);
|
||||
}
|
||||
|
||||
_playerStatus.setStatus(player, PlayerStatusType.DANGER, true);
|
||||
}
|
||||
|
||||
public void stopAnimation(Player player)
|
||||
|
@ -18,6 +18,7 @@ import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.texttutorial.TextTutorialManager;
|
||||
import mineplex.gemhunters.death.event.QuitNPCDespawnEvent;
|
||||
import mineplex.gemhunters.death.event.QuitNPCSpawnEvent;
|
||||
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 final TextTutorialManager _tutorial;
|
||||
|
||||
private final Map<UUID, QuitNPC> _npcs;
|
||||
private final Map<UUID, String> _killedBy;
|
||||
private final Set<UUID> _aboutToCashOut;
|
||||
@ -36,6 +39,8 @@ public class QuitNPCModule extends MiniPlugin
|
||||
{
|
||||
super("Quit NPC");
|
||||
|
||||
_tutorial = require(TextTutorialManager.class);
|
||||
|
||||
_npcs = new HashMap<>();
|
||||
_killedBy = new HashMap<>();
|
||||
_aboutToCashOut = new HashSet<>();
|
||||
@ -83,7 +88,14 @@ public class QuitNPCModule extends MiniPlugin
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
spawnNpc(event.getPlayer());
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (_tutorial.isInTutorial(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
spawnNpc(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -519,12 +519,6 @@ public class LootModule extends MiniPlugin
|
||||
public void handleRewardItem(Player player, ItemStack itemStack)
|
||||
{
|
||||
LootItem lootItem = fromItemStack(itemStack);
|
||||
|
||||
if (lootItem == null || lootItem.getMetadata() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LootItemReward reward = null;
|
||||
|
||||
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 key = metadataSplit[0];
|
||||
|
@ -211,9 +211,9 @@ public class ItemMapRenderer extends MapRenderer
|
||||
|
||||
byte cursorType = 5; // http://i.imgur.com/wpH6PT8.png
|
||||
// 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);
|
||||
}
|
||||
|
@ -5,11 +5,9 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
@ -21,20 +19,16 @@ import mineplex.core.incognito.IncognitoManager;
|
||||
import mineplex.core.incognito.events.IncognitoStatusChangeEvent;
|
||||
import mineplex.core.teleport.event.MineplexTeleportEvent;
|
||||
import mineplex.gemhunters.moderation.command.ModeratorModeCommand;
|
||||
import mineplex.gemhunters.moderation.ui.TeleportUI;
|
||||
import mineplex.gemhunters.spawn.SpawnModule;
|
||||
import mineplex.gemhunters.spawn.event.PlayerTeleportIntoMapEvent;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
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 IncognitoManager _incognito;
|
||||
//private final SpawnModule _spawn;
|
||||
|
||||
private final TeleportUI _teleportUI;
|
||||
private final SpawnModule _spawn;
|
||||
|
||||
private final Set<UUID> _moderators;
|
||||
|
||||
@ -44,9 +38,7 @@ public class ModerationModule extends MiniPlugin
|
||||
|
||||
_client = require(CoreClientManager.class);
|
||||
_incognito = require(IncognitoManager.class);
|
||||
//_spawn = require(SpawnModule.class);
|
||||
|
||||
_teleportUI = new TeleportUI(this);
|
||||
_spawn = require(SpawnModule.class);
|
||||
|
||||
_moderators = new HashSet<>();
|
||||
}
|
||||
@ -86,7 +78,6 @@ public class ModerationModule extends MiniPlugin
|
||||
}
|
||||
else if (event.getNewState())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
enableModeratorMode(player);
|
||||
}
|
||||
}
|
||||
@ -104,46 +95,13 @@ public class ModerationModule extends MiniPlugin
|
||||
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)
|
||||
{
|
||||
player.sendMessage(F.main(_moduleName, "Enabled moderator mode."));
|
||||
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
|
||||
// player.getInventory().clear();
|
||||
// player.getInventory().addItem(MOD_ITEMS);
|
||||
// player.setAllowFlight(true);
|
||||
// player.setFlying(true);
|
||||
//
|
||||
player.getInventory().clear();
|
||||
|
||||
((CraftPlayer) player).getHandle().spectating = true;
|
||||
//
|
||||
// for (Player other : Bukkit.getOnlinePlayers())
|
||||
// {
|
||||
// other.hidePlayer(player);
|
||||
// }
|
||||
|
||||
_moderators.add(player.getUniqueId());
|
||||
}
|
||||
@ -151,21 +109,11 @@ public class ModerationModule extends MiniPlugin
|
||||
public void disableModeratorMode(Player player)
|
||||
{
|
||||
player.sendMessage(F.main(_moduleName, "Disabled moderator mode."));
|
||||
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
|
||||
// player.getInventory().clear();
|
||||
// player.setFlying(false);
|
||||
// player.setAllowFlight(false);
|
||||
//
|
||||
((CraftPlayer) player).getHandle().spectating = false;
|
||||
//
|
||||
// _spawn.teleportToSpawn(player);
|
||||
//
|
||||
// for (Player other : Bukkit.getOnlinePlayers())
|
||||
// {
|
||||
// other.showPlayer(player);
|
||||
// }
|
||||
|
||||
_spawn.teleportToSpawn(player);
|
||||
|
||||
_moderators.remove(player.getUniqueId());
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -137,10 +137,8 @@ public class MountModule extends MiniClientPlugin<MountData>
|
||||
data.setEntity(entity);
|
||||
data.setMountType(mountType);
|
||||
data.setCooldown(cooldown);
|
||||
|
||||
Entity finalEntity = entity;
|
||||
|
||||
runSyncLater(() -> finalEntity.setPassenger(player), 5);
|
||||
|
||||
entity.setPassenger(player);
|
||||
}
|
||||
|
||||
public void despawnMount(Player player)
|
||||
@ -151,8 +149,8 @@ public class MountModule extends MiniClientPlugin<MountData>
|
||||
if (entity != null)
|
||||
{
|
||||
entity.remove();
|
||||
|
||||
Recharge.Instance.useForce(player, _moduleName, data.getCooldown());
|
||||
|
||||
Recharge.Instance.use(player, _moduleName, data.getCooldown(), true, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,6 +63,11 @@ public class PlayerStatusModule extends MiniClientPlugin<PlayerStatus>
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getDamager() instanceof Player)
|
||||
{
|
||||
setStatus((Player) event.getDamager(), PlayerStatusType.COMBAT, COMBAT_TIME);
|
||||
}
|
||||
|
||||
setStatus((Player) event.getEntity(), PlayerStatusType.COMBAT, COMBAT_TIME);
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,6 @@ public abstract class Quest implements Listener
|
||||
|
||||
public void onStart(Player player)
|
||||
{
|
||||
_economy.removeFromStore(player, _startCost);
|
||||
}
|
||||
|
||||
public void onReward(Player player)
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
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.F;
|
||||
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.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
@ -148,8 +150,11 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
|
||||
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();
|
||||
updateQuests(player);
|
||||
}
|
||||
@ -183,7 +188,7 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
|
||||
return;
|
||||
}
|
||||
|
||||
boolean able = startQuest(quest, player);
|
||||
boolean able = startQuest(quest, player, false);
|
||||
|
||||
if (!able)
|
||||
{
|
||||
@ -191,9 +196,11 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
|
||||
}
|
||||
else
|
||||
{
|
||||
UUID owner = UUID.fromString(item.getMetadata(ITEM_METADATA).get(0).asString());
|
||||
Player other = UtilPlayer.searchExact(owner);
|
||||
// UUID owner = UUID.fromString(item.getMetadata(ITEM_METADATA).get(0).asString());
|
||||
// Player other = UtilPlayer.searchExact(owner);
|
||||
|
||||
event.getItem().remove();
|
||||
event.setCancelled(true);
|
||||
/*
|
||||
* 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
|
||||
@ -209,13 +216,6 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
|
||||
* corners and saying that if a player quits out then don't allow other
|
||||
* 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()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerDeath(PlayerDeathEvent event)
|
||||
{
|
||||
Get(event.getEntity()).clear(true);
|
||||
}
|
||||
|
||||
public void updateQuests(Player 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))
|
||||
{
|
||||
@ -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."));
|
||||
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."));
|
||||
return false;
|
||||
@ -294,6 +300,11 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
|
||||
updateQuestItem(quest, player);
|
||||
|
||||
quest.onStart(player);
|
||||
|
||||
if (applyCost)
|
||||
{
|
||||
_economy.removeFromStore(player, quest.getStartCost());
|
||||
}
|
||||
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 + "]";
|
||||
|
||||
builder.setTitle(builder.getTitle() + " " + 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())
|
||||
{
|
||||
if (items == null || items.getType() == Material.AIR || items.getItemMeta() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (itemStack.getType() == items.getType() && itemStack.getItemMeta().getDisplayName().startsWith(items.getItemMeta().getDisplayName()))
|
||||
if (UtilItem.isSimilar(itemStack, items, ItemAttribute.NAME, ItemAttribute.MATERIAL, ItemAttribute.DATA, ItemAttribute.AMOUNT))
|
||||
{
|
||||
player.getInventory().remove(items);
|
||||
}
|
||||
|
@ -5,48 +5,61 @@ import java.util.List;
|
||||
|
||||
public class QuestPlayerData
|
||||
{
|
||||
|
||||
|
||||
private final List<Integer> _possibleQuests;
|
||||
private final List<Integer> _activeQuests;
|
||||
private final List<Integer> _completedQuests;
|
||||
|
||||
|
||||
private long _lastClear;
|
||||
|
||||
|
||||
public QuestPlayerData()
|
||||
{
|
||||
_possibleQuests = new ArrayList<>();
|
||||
_activeQuests = new ArrayList<>();
|
||||
_completedQuests = new ArrayList<>();
|
||||
|
||||
|
||||
_lastClear = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
|
||||
public void clear()
|
||||
{
|
||||
clear(false);
|
||||
}
|
||||
|
||||
public void clear(boolean active)
|
||||
{
|
||||
_possibleQuests.clear();
|
||||
_completedQuests.clear();
|
||||
|
||||
_lastClear = System.currentTimeMillis();
|
||||
|
||||
if (active)
|
||||
{
|
||||
_activeQuests.clear();
|
||||
_lastClear = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_lastClear = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<Integer> getPossibleQuests()
|
||||
{
|
||||
return _possibleQuests;
|
||||
}
|
||||
|
||||
|
||||
public List<Integer> getActiveQuests()
|
||||
{
|
||||
return _activeQuests;
|
||||
}
|
||||
|
||||
|
||||
public List<Integer> getCompletedQuests()
|
||||
{
|
||||
return _completedQuests;
|
||||
}
|
||||
|
||||
|
||||
public long getLastClear()
|
||||
{
|
||||
return _lastClear;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class QuestUI extends Menu<QuestModule>
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
getPlugin().startQuest(_quest, player);
|
||||
getPlugin().startQuest(_quest, player, true);
|
||||
resetAndUpdate();
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,10 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
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;
|
||||
|
||||
public class KillMostValuableQuest extends Quest
|
||||
@ -16,8 +20,49 @@ public class KillMostValuableQuest extends Quest
|
||||
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)
|
||||
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;
|
||||
int mostGems = 0;
|
||||
@ -33,19 +78,6 @@ public class KillMostValuableQuest extends Quest
|
||||
}
|
||||
}
|
||||
|
||||
if (mostGemsPlayer == null || !event.getEntity().equals(mostGemsPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player killer = mostGemsPlayer.getKiller();
|
||||
|
||||
if (!isActive(killer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
onReward(killer);
|
||||
return mostGemsPlayer;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
@ -23,9 +23,9 @@ public class GemHuntersScoreboard extends WritableMineplexScoreboard
|
||||
{
|
||||
super(player);
|
||||
|
||||
_economy = Managers.require(EconomyModule.class);
|
||||
_playerStatus = Managers.require(PlayerStatusModule.class);
|
||||
_supplyDrop = Managers.require(SupplyDropModule.class);
|
||||
_economy = Managers.get(EconomyModule.class);
|
||||
_playerStatus = Managers.get(PlayerStatusModule.class);
|
||||
_supplyDrop = Managers.get(SupplyDropModule.class);
|
||||
}
|
||||
|
||||
public void writeContent(Player player)
|
||||
@ -34,7 +34,7 @@ public class GemHuntersScoreboard extends WritableMineplexScoreboard
|
||||
|
||||
write(C.cGreenB + "Gems Earned");
|
||||
write(String.valueOf(_economy.getGems(player)));
|
||||
|
||||
|
||||
writeNewLine();
|
||||
|
||||
write(C.cGoldB + "Supply Drop");
|
||||
|
@ -87,6 +87,12 @@ public class ShopModule extends MiniPlugin
|
||||
|
||||
for (String key : map.keySet())
|
||||
{
|
||||
//TODO this is super temporary
|
||||
if (key.equals("PINK"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (key.equals(VILLAGER_MASTER_SHEET_NAME))
|
||||
{
|
||||
int row = 0;
|
||||
|
@ -18,6 +18,27 @@ public class GemHuntersTutorial extends Tutorial
|
||||
private final SpawnModule _spawn;
|
||||
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()
|
||||
{
|
||||
super("Gem Hunters", "gemhunterstutorial", 0);
|
||||
@ -25,31 +46,31 @@ public class GemHuntersTutorial extends Tutorial
|
||||
_spawn = Managers.require(SpawnModule.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",
|
||||
}));
|
||||
// addPhase(new Phase(getLocation(2), "PVP", new String[] {
|
||||
// "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",
|
||||
// }));
|
||||
// addPhase(new Phase(getLocation(3), "Safezones", new String[] {
|
||||
// "In Safe Zones you cannot take damage and can purchase items like",
|
||||
// "Food, Weapons, and Gear with the Gems you earn in the world.",
|
||||
// }));
|
||||
// addPhase(new Phase(getLocation(4), "Items", new String[] {
|
||||
// "Collect items from chests and powerup.",
|
||||
// "You can find anything from Weaponrs to Cosmetics.",
|
||||
// "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.",
|
||||
// }));
|
||||
// addPhase(new Phase(getLocation(5), "Cashing Out", new String[] {
|
||||
// "Cashing out will reset your progress in the world,",
|
||||
// "adds any special items you had like",
|
||||
// "Gems, Treasure Shards, Cosmetics or Rank Upgrades to your account!",
|
||||
// }));
|
||||
// addPhase(new Phase(getLocation(6), "Safezones", new String[] {
|
||||
// "Stay safe! Anarchy rules in the world of " + C.cGreen + "Gem Hunters"
|
||||
// }));
|
||||
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.",
|
||||
"Killing another player will gift you " + C.cYellow + "50%" + C.cWhite + "of their total gems.",
|
||||
}));
|
||||
addPhase(new Phase(getLocation(2), "Safezones", new String[] {
|
||||
"In Safe Zones you cannot take damage and can purchase items like",
|
||||
"Food, Weapons, and Gear with the Gems you earn in the world.",
|
||||
}));
|
||||
addPhase(new Phase(getLocation(3), "Items", new String[] {
|
||||
"Collect items from chests and powerup.",
|
||||
"You can find anything from Weaponrs to Cosmetics.",
|
||||
"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.",
|
||||
}));
|
||||
addPhase(new Phase(getLocation(4), "Cashing Out", new String[] {
|
||||
"Cashing out will reset your progress in the world,",
|
||||
"adds any special items you had like",
|
||||
"Gems, Treasure Shards, Cosmetics or Rank Upgrades to your account!",
|
||||
}));
|
||||
addPhase(new Phase(getLocation(5), "Good luck", new String[] {
|
||||
"Stay safe! Anarchy rules in the world of " + C.cGreen + "Gem Hunters" + C.cWhite + "!"
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -74,7 +95,9 @@ public class GemHuntersTutorial extends Tutorial
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ public class WorldListeners implements Listener
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -61,6 +61,8 @@ public abstract class WorldEvent implements Listener
|
||||
|
||||
public abstract Location[] getEventLocations();
|
||||
|
||||
public abstract double getProgress();
|
||||
|
||||
private final void start()
|
||||
{
|
||||
if (isLive())
|
||||
|
@ -23,7 +23,6 @@ import mineplex.gemhunters.worldevent.blizzard.BlizzardWorldEvent;
|
||||
import mineplex.gemhunters.worldevent.command.WorldEventCommand;
|
||||
import mineplex.gemhunters.worldevent.giant.GiantWorldEvent;
|
||||
import mineplex.gemhunters.worldevent.gwenmart.GwenMartWorldEvent;
|
||||
import mineplex.gemhunters.worldevent.nether.NetherPortalWorldEvent;
|
||||
import mineplex.gemhunters.worldevent.wither.WitherWorldEvent;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
@ -44,7 +43,7 @@ public class WorldEventModule extends MiniPlugin
|
||||
|
||||
new GiantWorldEvent(),
|
||||
new BlizzardWorldEvent(),
|
||||
new NetherPortalWorldEvent(),
|
||||
//new NetherPortalWorldEvent(),
|
||||
new WitherWorldEvent(),
|
||||
new GwenMartWorldEvent()
|
||||
|
||||
@ -122,7 +121,7 @@ public class WorldEventModule extends MiniPlugin
|
||||
|
||||
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)
|
||||
|
@ -37,6 +37,7 @@ public class BlizzardWorldEvent extends WorldEvent
|
||||
private static final double START_CHANCE = 0.01;
|
||||
private static final long MAX_TIME = TimeUnit.MINUTES.toMillis(10);
|
||||
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 String TIP = "EQUIP LEATHER ARMOUR OR GET NEAR A FIRE";
|
||||
|
||||
@ -115,7 +116,9 @@ public class BlizzardWorldEvent extends WorldEvent
|
||||
|
||||
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;
|
||||
}
|
||||
@ -138,6 +141,7 @@ public class BlizzardWorldEvent extends WorldEvent
|
||||
}
|
||||
}
|
||||
|
||||
_playerStatus.setStatus(player, PlayerStatusType.WARM, WARM_TIME);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -192,5 +196,11 @@ public class BlizzardWorldEvent extends WorldEvent
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getProgress()
|
||||
{
|
||||
return (double) (_start + MAX_TIME - System.currentTimeMillis()) / (double) MAX_TIME;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -100,7 +100,13 @@ public class CustomGiant implements Listener
|
||||
|
||||
Vector direction = UtilAlg.getTrajectory2d(_giant.getLocation(), _target).multiply(MOVE_FACTOR);
|
||||
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.setPitch(UtilAlg.GetPitch(direction));
|
||||
|
||||
@ -115,7 +121,7 @@ public class CustomGiant implements Listener
|
||||
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()))
|
||||
{
|
||||
|
@ -1,10 +1,11 @@
|
||||
package mineplex.gemhunters.worldevent.giant;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
@ -13,12 +14,12 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import mineplex.core.common.skin.SkinData;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.gemhunters.loot.rewards.LootChestReward;
|
||||
@ -71,8 +72,8 @@ public class GiantWorldEvent extends WorldEvent
|
||||
@Override
|
||||
public void onEnd()
|
||||
{
|
||||
ItemStack itemStack = new ItemBuilder(Material.SEA_LANTERN).setTitle(C.cAqua + "Omega Chest").build();
|
||||
LootChestReward reward = new LootChestReward(CASH_OUT_DELAY, itemStack, "Omega", 1);
|
||||
ItemStack itemStack = SkinData.OMEGA_CHEST.getSkull(C.cAqua + "Omega Chest", new ArrayList<>());
|
||||
LootChestReward reward = new LootChestReward(CASH_OUT_DELAY, SkinData.OMEGA_CHEST.getSkull(C.cAqua + "Omega Chest", null), "Omega", 1);
|
||||
|
||||
_worldData.World.dropItemNaturally(getEventLocations()[0], itemStack);
|
||||
|
||||
@ -89,6 +90,14 @@ public class GiantWorldEvent extends WorldEvent
|
||||
return new Location[] { _giant.getGiant().getLocation() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getProgress()
|
||||
{
|
||||
LivingEntity giant = _giant.getGiant();
|
||||
|
||||
return giant.getHealth() / giant.getMaxHealth();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void zombieCombust(EntityCombustEvent event)
|
||||
{
|
||||
|
@ -88,7 +88,7 @@ public class GwenMartWorldEvent extends WorldEvent
|
||||
for (Location location : _worldData.getCustomLocation("GWEN_MART_CHEST"))
|
||||
{
|
||||
location.getBlock().setType(Material.CHEST);
|
||||
_loot.addSpawnedChest(location, UtilMath.random.nextBoolean() ? "ORANGE" : "PINK");
|
||||
_loot.addSpawnedChest(location, getRandomChestKey());
|
||||
}
|
||||
|
||||
setEventState(WorldEventState.LIVE);
|
||||
@ -123,6 +123,7 @@ public class GwenMartWorldEvent extends WorldEvent
|
||||
{
|
||||
if (isInGwenMart(player.getLocation()))
|
||||
{
|
||||
player.leaveVehicle();
|
||||
player.teleport(teleportTo);
|
||||
}
|
||||
}
|
||||
@ -139,11 +140,33 @@ public class GwenMartWorldEvent extends WorldEvent
|
||||
return new Location[] { _average };
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getProgress()
|
||||
{
|
||||
return (double) (_start + MAX_TIME - System.currentTimeMillis()) / (double) MAX_TIME;
|
||||
}
|
||||
|
||||
private boolean isInGwenMart(Location location)
|
||||
{
|
||||
List<Location> locations = _worldData.getCustomLocation("GWEN_MART");
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -69,12 +69,7 @@ public class NetherPortalWorldEvent extends WorldEvent
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getClickedBlock();
|
||||
|
||||
if (player.getItemInHand() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getItemInHand().getType() != Material.FLINT_AND_STEEL)
|
||||
if (player.getItemInHand() == null || player.getItemInHand().getType() != Material.FLINT_AND_STEEL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -191,8 +186,16 @@ public class NetherPortalWorldEvent extends WorldEvent
|
||||
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)
|
||||
{
|
||||
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))
|
||||
{
|
||||
_restore.add(block, Material.OBSIDIAN.getId(), (byte) 0, Integer.MAX_VALUE);
|
||||
|
@ -89,8 +89,10 @@ public class WitherWorldEvent extends WorldEvent
|
||||
skull.getBlock().setType(Material.AIR);
|
||||
}
|
||||
|
||||
location.getBlock().getRelative(BlockFace.UP).setType(Material.ENDER_CHEST);
|
||||
_loot.addSpawnedChest(location, "PURPLE");
|
||||
Block chest = location.getBlock().getRelative(BlockFace.UP);
|
||||
|
||||
chest.setType(Material.ENDER_CHEST);
|
||||
_loot.addSpawnedChest(chest.getLocation(), "PURPLE");
|
||||
|
||||
for (int i = 0; i < SKELETONS; i++)
|
||||
{
|
||||
@ -99,6 +101,8 @@ public class WitherWorldEvent extends WorldEvent
|
||||
skeleton.getEquipment().setItemInHand(IN_HAND);
|
||||
skeleton.setMaxHealth(HEALTH);
|
||||
skeleton.setHealth(HEALTH);
|
||||
|
||||
addEntity(skeleton);
|
||||
}
|
||||
|
||||
setEventState(WorldEventState.LIVE);
|
||||
@ -125,6 +129,12 @@ public class WitherWorldEvent extends WorldEvent
|
||||
return new Location[] { _skulls[1] };
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getProgress()
|
||||
{
|
||||
return (double) (_start + MAX_TIME - System.currentTimeMillis()) / (double) MAX_TIME;
|
||||
}
|
||||
|
||||
private void buildAlter()
|
||||
{
|
||||
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)
|
||||
};
|
||||
|
||||
for (Location location : _skulls)
|
||||
{
|
||||
location.getBlock().setType(Material.SPONGE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user