More mission fixse

This commit is contained in:
Sam 2018-07-01 17:20:45 +01:00 committed by Alexander Meech
parent 9a24cbb377
commit de061fe80c
9 changed files with 46 additions and 55 deletions

View File

@ -66,4 +66,9 @@ public enum MissionLength
{
return _calendarField;
}
public String getStatName()
{
return "Global.Missions." + getName();
}
}

View File

@ -41,6 +41,7 @@ import mineplex.core.newnpc.NPC;
import mineplex.core.newnpc.NewNPCManager;
import mineplex.core.newnpc.SimpleNPC;
import mineplex.core.newnpc.event.NPCInteractEvent;
import mineplex.core.stats.StatsManager;
@ReflectivelyCreateMiniPlugin
public class MissionManager extends MiniDbClientPlugin<MissionClient>
@ -62,6 +63,7 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
private final DonationManager _donationManager;
private final NewNPCManager _npcManager;
private final StatsManager _statsManager;
private final List<MissionContext> _missions;
private final Set<MissionTracker> _missionTrackers;
@ -77,6 +79,7 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
_donationManager = require(DonationManager.class);
_npcManager = require(NewNPCManager.class);
_statsManager = require(StatsManager.class);
_missions = new ArrayList<>();
_missionTrackers = new HashSet<>();
@ -88,7 +91,7 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
generatePermissions();
runSyncTimer(this::processUnsavedProgress, 20, 60);
runSyncTimer(this::processUnsavedProgress, 20, 100);
}
private void generatePermissions()
@ -259,7 +262,7 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
@SuppressWarnings("unchecked")
public <T> void incrementProgress(Player player, int amount, MissionTrackerType trackerType, GameDisplay game, T data, int y)
{
if (_canIncrement != null && !_canIncrement.get())
if (_canIncrement != null && !_canIncrement.get() || amount <= 0)
{
return;
}
@ -278,6 +281,7 @@ 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);
mission.incrementProgress(amount);
});
}
@ -455,6 +459,11 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
return _donationManager;
}
public StatsManager getStatsManager()
{
return _statsManager;
}
public MissionShop getShop()
{
return _shop;

View File

@ -367,8 +367,8 @@ public class MissionPopulator
.build();
MissionContext.newBuilder(manager, 409)
.name("Steve Walker")
.description("Walk %s blocks")
.name("It Sparkles Now!")
.description("Enchant %s items")
.games(SurvivalGames, SurvivalGamesTeams)
.xRange(1, 25)
.tracker(GAME_ENCHANT_ITEM)
@ -480,7 +480,7 @@ public class MissionPopulator
MissionContext.<String>newBuilder(manager, 600)
.name("Golden Warrior")
.description("Kill %s players with the Golden Pickaxe")
.description("Kill %s players with The Golden Pickaxe")
.games(CakeWars4, CakeWarsDuos)
.xRange(1, 10)
.tracker(GAME_KILL)

View File

@ -14,6 +14,7 @@ import mineplex.core.mission.MissionLength;
import mineplex.core.mission.MissionManager;
import mineplex.core.mission.PlayerMission;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.core.stats.PlayerStats;
public class MissionMainPage extends ShopPageBase<MissionManager, MissionShop>
{
@ -31,6 +32,7 @@ public class MissionMainPage extends ShopPageBase<MissionManager, MissionShop>
int column = 0;
MissionClient client = _plugin.Get(getPlayer());
Set<PlayerMission> missions = client.getMissions();
PlayerStats stats = _plugin.getStatsManager().Get(getPlayer());
for (MissionLength length : MissionLength.values())
{
@ -43,7 +45,7 @@ public class MissionMainPage extends ShopPageBase<MissionManager, MissionShop>
{
glassBuilder.addLore(
"",
C.cDAqua + "You've completed " + C.cAqua + 0 + C.cDAqua + " " + length.getName().toLowerCase() + " missions."
C.cDAqua + "You've completed " + C.cAqua + stats.getStat(length.getStatName()) + C.cDAqua + " " + length.getName().toLowerCase() + " missions."
);
}
@ -80,12 +82,6 @@ public class MissionMainPage extends ShopPageBase<MissionManager, MissionShop>
{
GameDisplay game = games[i];
// No need to repeat games for something like "Survival Games, Survival Games Teams"
if (gameBuilder.toString().contains(game.getName()))
{
continue;
}
gameBuilder
.append(C.mBody)
.append(", ")

View File

@ -1,6 +1,5 @@
package mineplex.minecraft.game.core.combat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -8,17 +7,13 @@ import mineplex.minecraft.game.core.damage.DamageChange;
public class CombatDamage
{
private String _name;
private double _dmg;
private long _time;
private List<DamageChange> _mod;
private Map<String, Object> _metadata;
private final String _name;
private final double _dmg;
private final long _time;
private final List<DamageChange> _mod;
private final Map<String, Object> _metadata;
public CombatDamage(String name, double dmg, List<DamageChange> mod)
{
this(name, dmg, mod, new HashMap<>());
}
public CombatDamage(String name, double dmg, List<DamageChange> mod, Map<String, Object> metadata)
CombatDamage(String name, double dmg, List<DamageChange> mod, Map<String, Object> metadata)
{
_name = name;
_dmg = dmg;

View File

@ -5,7 +5,6 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -250,18 +249,25 @@ public class CustomDamageEvent extends Event implements Cancellable
public String GetReason()
{
String reason = "";
StringBuilder reason = new StringBuilder();
//Get Reason
for (DamageChange change : _damageMod)
{
if (change.UseReason())
reason += C.mSkill + change.GetReason() + ChatColor.GRAY + ", ";
{
reason
.append(C.mSkill)
.append(change.GetReason())
.append(C.mBody)
.append(", ");
}
}
//Trim Reason
if (reason.length() > 0)
{
reason = reason.substring(0, reason.length() - 2);
return reason;
return reason.substring(0, reason.length() - 2);
}
return null;
@ -306,13 +312,6 @@ public class CustomDamageEvent extends Event implements Cancellable
_damagerPlayer = ent instanceof Player ? (Player) ent : null;
}
public void changeReason(String initial, String reason)
{
for (DamageChange change : _damageMod)
if (change.GetReason().equals(initial))
change.setReason(reason);
}
public void setKnockbackOrigin(Location loc)
{
_knockbackOrigin = loc;

View File

@ -2,12 +2,13 @@ package mineplex.minecraft.game.core.damage;
public class DamageChange
{
private String _source;
private String _reason;
private double _modifier;
private boolean _useReason;
private final String _source;
private final String _reason;
private final double _modifier;
private final boolean _useReason;
public DamageChange(String source, String reason, double modifier, boolean useReason)
DamageChange(String source, String reason, double modifier, boolean useReason)
{
_source = source;
_reason = reason;
@ -34,9 +35,4 @@ public class DamageChange
{
return _useReason;
}
public void setReason(String reason)
{
_reason = reason;
}
}

View File

@ -429,7 +429,7 @@ public class DamageManager extends MiniPlugin
event.AddKnockback("Ench Knockback", 1 + (0.5 * (double)enchants.get(e)));
else if (e.equals(Enchantment.ARROW_DAMAGE) || e.equals(Enchantment.DAMAGE_ALL))
event.AddMod("Enchant", "Ench Damage", 0.5 * (double)enchants.get(e), true);
event.AddMod("Enchant", "Ench Damage", 0.5 * (double)enchants.get(e), false);
else if (e.equals(Enchantment.FIRE_ASPECT))
if (_conditionManager != null)

View File

@ -1,6 +1,5 @@
package nautilus.game.arcade.missions;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -33,29 +32,23 @@ public class KillMissionTracker extends GameMissionTracker<Game>
{
killerPlayer = UtilPlayer.searchExact(killer.getUniqueIdOfEntity());
source = killer.GetLastDamageSource();
Bukkit.broadcastMessage("Set killer " + killer.GetName() + " " + source);
}
else
{
Bukkit.broadcastMessage("Killer was not player");
killerPlayer = player.getKiller();
if (killerPlayer == null)
{
Bukkit.broadcastMessage("Null Killer");
return;
}
else
{
for (CombatComponent attacker : event.GetLog().GetAttackers())
{
Bukkit.broadcastMessage("Attacker " + attacker.GetName());
if (attacker.IsPlayer() && attacker.getUniqueIdOfEntity().equals(killerPlayer.getUniqueId()))
{
killerPlayer = UtilPlayer.searchExact(attacker.getUniqueIdOfEntity());
source = attacker.GetLastDamageSource();
Bukkit.broadcastMessage("Set killer " + killerPlayer.getName() + " " + source);
break;
}
}
@ -64,11 +57,9 @@ public class KillMissionTracker extends GameMissionTracker<Game>
if (killerPlayer == null || source == null || player.equals(killerPlayer))
{
Bukkit.broadcastMessage("Null Killer - END");
return;
}
Bukkit.broadcastMessage("increment " + ChatColor.stripColor(source));
_manager.incrementProgress(killerPlayer, 1, _trackerType, getGameType(), ChatColor.stripColor(source));
}
}