The SamitoD quest

This commit is contained in:
Sam 2017-02-17 18:55:38 +00:00
parent 2657a98e70
commit 5fbbae1493
5 changed files with 109 additions and 12 deletions

View File

@ -23,10 +23,12 @@ import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.menu.Menu;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.gemhunters.quest.types.ChestOpenerQuest;
import mineplex.gemhunters.quest.types.Quest;
import mineplex.gemhunters.quest.types.SamitoDQuest;
import mineplex.gemhunters.world.WorldDataModule;
@ReflectivelyCreateMiniPlugin
@ -36,7 +38,13 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
private static final int MAX_QUESTS = 5;
private static final long RESET_QUESTS_TIME = TimeUnit.MINUTES.toMillis(15);
private final Quest[] _quests = { new ChestOpenerQuest(0, "Chest Opener", 100, 250, 5), new ChestOpenerQuest(1, "Grand Chest Opener", 200, 500, 20), new ChestOpenerQuest(2, "Superior Chest Opener", 500, 750, 40) };
private final Quest[] _quests = {
new ChestOpenerQuest(0, "Chest Opener", 100, 250, 5),
new ChestOpenerQuest(1, "Grand Chest Opener", 200, 500, 20),
new ChestOpenerQuest(2, "Superior Chest Opener", 500, 750, 40),
new SamitoDQuest(3, "Give to the Homeless", "Donate " + F.count(String.valueOf(10)) + " gems to the Hobo.", 100, 300, 10)
};
private final WorldDataModule _worldData;
@ -211,6 +219,11 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
public void updateQuestItem(Quest quest, Player player)
{
if (!Recharge.Instance.use(player, "Quest Update Item", 1000, false, false))
{
return;
}
ItemStack itemStack = getItemStack(quest, player, false, true);
for (ItemStack items : player.getInventory().getContents())

View File

@ -39,14 +39,11 @@ public class ChestOpenerQuest extends Quest
if (!isActive(player))
{
DebugModule.getInstance().d("Not active.");
return;
}
int amount = getAndIncrement(player, 1);
DebugModule.getInstance().d("amount = " + amount);
if (amount >= _goal)
{
onReward(player);

View File

@ -16,6 +16,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.donation.DonationManager;
import mineplex.gemhunters.economy.EconomyModule;
import mineplex.gemhunters.quest.QuestModule;
import mineplex.gemhunters.world.WorldDataModule;
public abstract class Quest implements Listener
{
@ -30,6 +31,7 @@ public abstract class Quest implements Listener
protected final CoreClientManager _clientManager;
protected final DonationManager _donation;
protected final EconomyModule _economy;
protected final WorldDataModule _worldData;
private final Map<UUID, Integer> _counter;
@ -45,6 +47,7 @@ public abstract class Quest implements Listener
_clientManager = Managers.require(CoreClientManager.class);
_donation = Managers.require(DonationManager.class);
_economy = Managers.require(EconomyModule.class);
_worldData = Managers.require(WorldDataModule.class);
_counter = new HashMap<>();
@ -71,9 +74,9 @@ public abstract class Quest implements Listener
return newAmount;
}
public int remove(Player player)
public void remove(Player player)
{
return _counter.remove(player.getUniqueId());
_counter.remove(player.getUniqueId());
}
public void onStart(Player player)

View File

@ -0,0 +1,80 @@
package mineplex.gemhunters.quest.types;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.gemhunters.debug.DebugModule;
public class SamitoDQuest extends Quest
{
private static final String NPC_NAME = "Hobo";
private static final String[] REACTIONS = {
"Well hello there folks and welcome... to... my... youtube channel",
"WILLIAMMMMMMM",
"ALEXXXXXXXXXX",
};
private final Location _pot;
private final int _gemsToDonate;
public SamitoDQuest(int id, String name, String description, int startCost, int completeReward, int gemsToDonate)
{
super(id, name, description, startCost, completeReward);
_pot = _worldData.getCustomLocation("QUEST_SAM").get(0);
_pot.getBlock().setType(Material.FLOWER_POT);
_gemsToDonate = gemsToDonate;
}
@Override
public float getProgress(Player player)
{
return 0;
}
@EventHandler
public void onInteract(PlayerInteractEvent event)
{
Player player = event.getPlayer();
if (event.isCancelled() || !isActive(player))
{
return;
}
DebugModule.getInstance().d(event.getEventName());
Block block = event.getClickedBlock();
if (block == null)
{
return;
}
if (UtilMath.offsetSquared(block.getLocation(), _pot) < 4)
{
if (_economy.getGems(player) < _gemsToDonate)
{
player.sendMessage(F.main(NPC_NAME, "Awww come on man, even alex has more gems than you."));
return;
}
player.sendMessage(F.main(NPC_NAME, REACTIONS[UtilMath.random.nextInt(REACTIONS.length)]));
_economy.removeFromStore(player, _gemsToDonate);
UtilFirework.playFirework(_pot, Type.BURST, Color.GREEN, true, false);
onReward(player);
}
}
}

View File

@ -1,7 +1,6 @@
package mineplex.gemhunters.world;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import org.bukkit.Bukkit;
@ -16,7 +15,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.updater.UpdateType;
@ -55,8 +53,14 @@ public class SewerMobs implements Listener
}
EntityType type = UtilMath.random.nextBoolean() ? EntityType.ZOMBIE : EntityType.SKELETON;
Location location = getRandomLocation(world);
_entities.add(world.spawnEntity(getRandomLocation(world), type));
if (location == null)
{
continue;
}
_entities.add(world.spawnEntity(location, type));
}
}
@ -66,7 +70,7 @@ public class SewerMobs implements Listener
while (attempts < 40)
{
Location location = new Location(world, UtilMath.r(SpawnModule.WORLD_BORDER_RADIUS * 2) - SpawnModule.WORLD_BORDER_RADIUS, 46, UtilMath.r(SpawnModule.WORLD_BORDER_RADIUS * 2) - SpawnModule.WORLD_BORDER_RADIUS);
Location location = new Location(world, UtilMath.r(SpawnModule.WORLD_BORDER_RADIUS * 2) - SpawnModule.WORLD_BORDER_RADIUS, 51, UtilMath.r(SpawnModule.WORLD_BORDER_RADIUS * 2) - SpawnModule.WORLD_BORDER_RADIUS);
if (!isSuitable(location.getBlock()))
{