Final push
This commit is contained in:
parent
596d3866ba
commit
bbc3e59370
@ -11,20 +11,21 @@ import mineplex.core.common.util.UtilText;
|
||||
public enum MissionLength
|
||||
{
|
||||
|
||||
DAY("Daily", UtilText.splitLineToArray(C.cGray + "Here you will find missions that reset every day. Missions only reset if you've completed them or you've discarded them, click on an active mission to discard it.", LineFormat.LORE), ChatColor.WHITE, 0, 1, Calendar.DAY_OF_WEEK),
|
||||
WEEK("Weekly", UtilText.splitLineToArray(C.cGray + "These missions wil rotate out every Monday. They will be daily missions that have an increased objective and rewards.", LineFormat.LORE), ChatColor.GREEN, 7, 7, Calendar.WEEK_OF_YEAR),
|
||||
EVENT("Event", UtilText.splitLineToArray(C.cGray + "These super special missions will only show up every once in a while and come with a super special reward!", LineFormat.LORE), ChatColor.LIGHT_PURPLE, 10, 1, -1);
|
||||
DAY("Daily", "tomorrow", UtilText.splitLineToArray(C.cGray + "Here you will find missions that reset every day. Missions only reset if you've completed them or you've discarded them, click on an active mission to discard it.", LineFormat.LORE), ChatColor.WHITE, 0, 1, Calendar.DAY_OF_WEEK),
|
||||
WEEK("Weekly", "next week", UtilText.splitLineToArray(C.cGray + "These missions wil rotate out every Monday. They are daily missions that have an increased objective and rewards.", LineFormat.LORE), ChatColor.GREEN, 7, 7, Calendar.WEEK_OF_YEAR),
|
||||
EVENT("Event", null, UtilText.splitLineToArray(C.cGray + "These super special missions will only show up every once in a while and come with a super special reward!", LineFormat.LORE), ChatColor.LIGHT_PURPLE, 10, 1, -1);
|
||||
|
||||
private final String _name;
|
||||
private final String _name, _resetWhen;
|
||||
private final String[] _resetInfo;
|
||||
private final ChatColor _chatColour;
|
||||
private final byte _colourData;
|
||||
private final int _xScale;
|
||||
private final int _calendarField;
|
||||
|
||||
MissionLength(String name, String[] resetInfo, ChatColor chatColour, int colourData, int xScale, int calendarField)
|
||||
MissionLength(String name, String resetWhen, String[] resetInfo, ChatColor chatColour, int colourData, int xScale, int calendarField)
|
||||
{
|
||||
_name = name;
|
||||
_resetWhen = resetWhen;
|
||||
_resetInfo = resetInfo;
|
||||
_chatColour = chatColour;
|
||||
_colourData = (byte) colourData;
|
||||
@ -42,6 +43,11 @@ public enum MissionLength
|
||||
return _name;
|
||||
}
|
||||
|
||||
public String getResetWhen()
|
||||
{
|
||||
return _resetWhen;
|
||||
}
|
||||
|
||||
public String[] getResetInfo()
|
||||
{
|
||||
return _resetInfo;
|
||||
|
@ -16,13 +16,17 @@ import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.MiniDbClientPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
@ -32,6 +36,10 @@ import mineplex.core.achievement.leveling.rewards.LevelReward;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.game.GameDisplay;
|
||||
@ -189,6 +197,7 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
|
||||
int y = resultSet.getInt("y");
|
||||
long startTime = resultSet.getLong("startTime");
|
||||
byte completeStatus = resultSet.getByte("complete");
|
||||
|
||||
PlayerMission mission = new PlayerMission<>(context, MissionLength.values()[length], x, y, progress, false);
|
||||
|
||||
Calendar start = Calendar.getInstance(utc, uk);
|
||||
@ -199,8 +208,12 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
|
||||
{
|
||||
mission.reward();
|
||||
}
|
||||
else if (completeStatus == PlayerMission.DISCARDED)
|
||||
{
|
||||
mission.discard();
|
||||
}
|
||||
|
||||
if (lengthField != -1 && now.get(lengthField) != start.get(lengthField) || completeStatus == PlayerMission.DISCARDED)
|
||||
if (lengthField != -1 && now.get(lengthField) != start.get(lengthField) && completeStatus != PlayerMission.ACTIVE)
|
||||
{
|
||||
runAsync(() -> _repository.clearMission(accountId, missionId));
|
||||
}
|
||||
@ -268,6 +281,7 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
|
||||
player.sendMessage("");
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, (float) Math.random());
|
||||
|
||||
_statsManager.incrementStat(player, mission.getLength().getStatName(), 1);
|
||||
runAsync(() -> _repository.completeMission(ClientManager.getAccountId(player), mission.getId()));
|
||||
}
|
||||
|
||||
@ -298,11 +312,35 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
|
||||
player.sendMessage(F.main(getName(), F.name(mission.getName()) + " incremented " + F.count(amount) + "."));
|
||||
}
|
||||
|
||||
_statsManager.incrementStat(player, mission.getLength().getStatName(), 1);
|
||||
int currentProgress = mission.getCurrentProgress() + mission.getUnsavedProgress();
|
||||
int requiredProgress = mission.getRequiredProgress();
|
||||
|
||||
for (double requirement = 0.75; requirement > 0; requirement -= 0.25)
|
||||
{
|
||||
player.sendMessage("" + requirement);
|
||||
|
||||
if (canInform(currentProgress, amount, requiredProgress, requirement))
|
||||
{
|
||||
inform(player, mission, requirement);
|
||||
}
|
||||
}
|
||||
|
||||
mission.incrementProgress(amount);
|
||||
});
|
||||
}
|
||||
|
||||
private boolean canInform(int currentProgress, int amount, int requiredProgress, double requirement)
|
||||
{
|
||||
int progressToGet = (int) (requiredProgress * requirement);
|
||||
|
||||
return currentProgress + amount >= progressToGet && currentProgress < progressToGet;
|
||||
}
|
||||
|
||||
private void inform(Player player, PlayerMission mission, double percentage)
|
||||
{
|
||||
player.sendMessage(F.main(getName(), F.name(mission.getName()) + " is " + F.count((int) (percentage * 100) + "%") + " complete."));
|
||||
}
|
||||
|
||||
private void processUnsavedProgress()
|
||||
{
|
||||
for (Player player : UtilServer.getPlayersCollection())
|
||||
@ -346,9 +384,25 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
|
||||
}
|
||||
|
||||
mission.discard();
|
||||
player.sendMessage(F.main(getName(), "Discarded " + F.name(mission.getName()) + ". You will receive a new one soon."));
|
||||
player.sendMessage(F.main(getName(), "Discarded " + F.name(mission.getName()) + ". You will receive a new one " + mission.getLength().getResetWhen() + "."));
|
||||
|
||||
runAsync(() -> _repository.discardMission(ClientManager.getAccountId(player), mission.getId()));
|
||||
|
||||
ItemStack itemStack = new ItemStack(Material.SLIME_BALL);
|
||||
|
||||
_npcManager.getNPCs(NPC_METADATA).forEach(npc ->
|
||||
{
|
||||
Location location = npc.getEntity().getLocation().add(0, 1, 0);
|
||||
|
||||
location.getWorld().playSound(location, Sound.SLIME_WALK, 1, (float) (0.5 + Math.random() / 2));
|
||||
UtilParticle.PlayParticleToAll(ParticleType.SLIME, location, 1, 1, 1, 0, 8, ViewDist.NORMAL);
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
Item item = UtilItem.dropItem(itemStack, location, false, false, 40, false);
|
||||
item.setVelocity(new Vector(Math.random() - 0.5, 1, Math.random() - 0.5).multiply(0.2));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void selectNewMissions(Player player)
|
||||
@ -493,7 +547,10 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
|
||||
{
|
||||
if (event.getNpc().getMetadata().equals(NPC_METADATA))
|
||||
{
|
||||
_shop.attemptShopOpen(event.getPlayer());
|
||||
Player player = event.getPlayer();
|
||||
|
||||
player.playSound(player.getLocation(), Sound.SLIME_WALK2, 1, 1);
|
||||
_shop.attemptShopOpen(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import mineplex.core.game.GameDisplay;
|
||||
public class PlayerMission<T> implements Mission<T>
|
||||
{
|
||||
|
||||
public static final byte DISCARDED = -1, COMPLETE = 1;
|
||||
public static final byte ACTIVE = 0, DISCARDED = -1, COMPLETE = 1;
|
||||
|
||||
private final MissionContext<T> _context;
|
||||
|
||||
@ -146,6 +146,11 @@ public class PlayerMission<T> implements Mission<T>
|
||||
return _currentProgress;
|
||||
}
|
||||
|
||||
public int getUnsavedProgress()
|
||||
{
|
||||
return _unsavedProgress;
|
||||
}
|
||||
|
||||
public void incrementProgress(int progress)
|
||||
{
|
||||
_unsavedProgress += progress;
|
||||
|
@ -170,7 +170,7 @@ public class MissionMainPage extends ShopPageBase<MissionManager, MissionShop>
|
||||
{
|
||||
ItemStack displayItem = new ItemBuilder(Material.PAPER)
|
||||
.setTitle(C.cRedB + "Discard " + mission.getName())
|
||||
.addLore("", "This will discard the mission.", "You will " + C.cRedB + "NOT" + C.mBody + " allow you to progress and", "claim the rewards for this mission.", "A new one will replace it soon.")
|
||||
.addLore("", "This will discard the mission.", "You will " + C.cRedB + "NOT" + C.mBody + " be able to progress and", "claim the rewards for this mission.", "A new one will replace it " + mission.getLength().getResetWhen() + ".")
|
||||
.build();
|
||||
|
||||
getShop().openPageForPlayer(player, new ConfirmationPage<>(player, this, new ConfirmationProcessor()
|
||||
|
@ -4,11 +4,13 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.account.permissions.Permission;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
@ -109,9 +111,13 @@ public class TeamRequestsModule extends Module
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
ItemStack itemStack = player.getItemInHand();
|
||||
|
||||
//Observer
|
||||
if (getGame().getArcadeManager().IsObserver(player))
|
||||
if (itemStack != null && itemStack.getType() != Material.AIR)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (getGame().getArcadeManager().IsObserver(player))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Game", "Spectators cannot partake in games."));
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user