Merge branch 'clans/beta' of github.com:Mineplex-LLC/Minecraft-PC into clans/beta

This commit is contained in:
phobia 2016-04-04 12:49:00 +10:00
commit 3173adca53
19 changed files with 204 additions and 97 deletions

View File

@ -486,6 +486,7 @@ public class NpcManager extends MiniPlugin
public void removeFakeNpc(Npc npc) public void removeFakeNpc(Npc npc)
{ {
_npcs.remove(npc); _npcs.remove(npc);
npc.getEntity().remove();
} }
public void loadNpcs() throws SQLException public void loadNpcs() throws SQLException

View File

@ -130,7 +130,7 @@ public class Clans extends JavaPlugin
new Explosion(this, blockRestore); new Explosion(this, blockRestore);
new InventoryManager(this, _clientManager); new InventoryManager(this, _clientManager);
ResourcePackManager resourcePackManager = new ResourcePackManager(this, portal); ResourcePackManager resourcePackManager = new ResourcePackManager(this, portal);
resourcePackManager.setResourcePack("http://garblox.com/files/b/ResClans.zip", "http://garblox.com/files/mineplex/ResClans19.zip", true); resourcePackManager.setResourcePack("http://phinary.ca/ResClans.zip", "http://phinary.ca/ResClans19.zip", true);
// Enable custom-gear related managers // Enable custom-gear related managers
new CustomTagFix(this, packetHandler); new CustomTagFix(this, packetHandler);

View File

@ -821,7 +821,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
List<Player> recipients = new ArrayList<>(); List<Player> recipients = new ArrayList<>();
for (Player other : UtilServer.getPlayers()) for (Player other : event.getRecipients())
{ {
ClanInfo otherClan = _clanUtility.getClanByPlayer(other); ClanInfo otherClan = _clanUtility.getClanByPlayer(other);

View File

@ -159,7 +159,7 @@ public abstract class Tutorial implements Listener, ObjectiveListener
{ {
} }
private void finish(Player player) protected final void finish(Player player)
{ {
_objectives.forEach(objective -> objective.clean(player, getRegion(player))); _objectives.forEach(objective -> objective.clean(player, getRegion(player)));
@ -281,7 +281,7 @@ public abstract class Tutorial implements Listener, ObjectiveListener
for (Map.Entry<Player, TutorialSession> entry : _playerSessionMap.entrySet()) for (Map.Entry<Player, TutorialSession> entry : _playerSessionMap.entrySet())
{ {
String prefix = entry.getValue().incrementAndGetColorTick() % 2 == 0 ? C.cYellow : C.cGold; String prefix = entry.getValue().incrementAndGetColorTick() % 2 == 0 ? C.cWhite : C.cGreen;
Objective objective = _objectives.get(entry.getValue().getObjectiveIndex()); Objective objective = _objectives.get(entry.getValue().getObjectiveIndex());
UtilTextBottom.display(prefix + objective.getDescription(entry.getKey()), entry.getKey()); UtilTextBottom.display(prefix + objective.getDescription(entry.getKey()), entry.getKey());
} }
@ -297,12 +297,8 @@ public abstract class Tutorial implements Listener, ObjectiveListener
for (Map.Entry<Player, TutorialSession> entry : _playerSessionMap.entrySet()) for (Map.Entry<Player, TutorialSession> entry : _playerSessionMap.entrySet())
{ {
String extra = _objectives.get(entry.getValue().getObjectiveIndex()).getExtraDescription(entry.getKey()); Player player = entry.getKey();
if (extra == null) Objective objective = _objectives.get(entry.getValue().getObjectiveIndex());
{
// None defined.
continue;
}
if (entry.getValue().incrementAndGetTextSeconds() < 20) if (entry.getValue().incrementAndGetTextSeconds() < 20)
{ {
@ -310,10 +306,7 @@ public abstract class Tutorial implements Listener, ObjectiveListener
return; return;
} }
UtilPlayer.message(entry.getKey(), C.cGold + C.Strike + "---------------------------------------------"); objective.displayChatMessages(player);
UtilPlayer.message(entry.getKey(), C.cGray + " " + extra);
UtilPlayer.message(entry.getKey(), C.cGold + C.Strike + "---------------------------------------------");
entry.getValue().setTextSeconds(0);
} }
} }
@ -327,6 +320,39 @@ public abstract class Tutorial implements Listener, ObjectiveListener
} }
} }
public void setSpawnHologram(Player player, Location location, String... text)
{
if (_playerSessionMap.containsKey(player))
{
TutorialSession session = _playerSessionMap.get(player);
if (session.getSpawnHologram() == null && !session.isRemovedHologram())
{
Hologram hologram = new Hologram(_hologram, location, text);
session.setSpawnHologram(hologram);
hologram.start();
}
else
{
session.getSpawnHologram().setText(text);
}
}
}
public void removeSpawnHologram(Player player)
{
if (_playerSessionMap.containsKey(player))
{
TutorialSession session = _playerSessionMap.get(player);
if (session.getSpawnHologram() != null)
{
session.getSpawnHologram().stop();
session.setSpawnHologram(null);
}
session.setRemovedHologram(true);
}
}
public TutorialSession getTutorialSession(Player player) public TutorialSession getTutorialSession(Player player)
{ {
return _playerSessionMap.get(player); return _playerSessionMap.get(player);

View File

@ -121,6 +121,15 @@ public class TutorialManager extends MiniPlugin implements ScoreboardElement
return null; return null;
} }
public void finishTutorial(Player player)
{
Tutorial tutorial = getTutorial(player);
if (tutorial != null)
{
tutorial.finish(player);
}
}
public boolean startTutorial(Player player, TutorialType type) public boolean startTutorial(Player player, TutorialType type)
{ {
if (inTutorial(player)) if (inTutorial(player))

View File

@ -9,6 +9,7 @@ import mineplex.core.hologram.Hologram;
public class TutorialSession public class TutorialSession
{ {
private final long _startTime;
private int _objectiveIndex; private int _objectiveIndex;
private TutorialRegion _region; private TutorialRegion _region;
private List<Hologram> _hologramList = new ArrayList<>(); private List<Hologram> _hologramList = new ArrayList<>();
@ -16,9 +17,12 @@ public class TutorialSession
private int _colorTick; private int _colorTick;
private int _textSeconds; private int _textSeconds;
private Location _mapTargetLocation; private Location _mapTargetLocation;
private Hologram _spawnHologram;
private boolean _removedHologram;
public TutorialSession() public TutorialSession()
{ {
_startTime = System.currentTimeMillis();
} }
public List<Hologram> getHolograms() public List<Hologram> getHolograms()
@ -81,4 +85,34 @@ public class TutorialSession
{ {
return _mapTargetLocation; return _mapTargetLocation;
} }
public long getStartTime()
{
return _startTime;
}
public long getElapsedTime()
{
return System.currentTimeMillis() - _startTime;
}
public boolean isRemovedHologram()
{
return _removedHologram;
}
public void setRemovedHologram(boolean removedHologram)
{
_removedHologram = removedHologram;
}
public void setSpawnHologram(Hologram spawnHologram)
{
_spawnHologram = spawnHologram;
}
public Hologram getSpawnHologram()
{
return _spawnHologram;
}
} }

View File

@ -0,0 +1,23 @@
package mineplex.game.clans.tutorial.command;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.game.clans.tutorial.TutorialManager;
public class FinishCommand extends CommandBase<TutorialManager>
{
public FinishCommand(TutorialManager plugin)
{
super(plugin, Rank.MODERATOR, "finish", "end");
}
@Override
public void Execute(Player caller, String[] args)
{
Plugin.finishTutorial(caller);
}
}

View File

@ -16,6 +16,7 @@ public class TutorialCommand extends MultiCommandBase<TutorialManager>
super(plugin, Rank.MODERATOR, "tutorial", "tut"); super(plugin, Rank.MODERATOR, "tutorial", "tut");
AddCommand(new StartCommand(plugin)); AddCommand(new StartCommand(plugin));
AddCommand(new FinishCommand(plugin));
} }
@Override @Override

View File

@ -199,8 +199,6 @@ public abstract class Objective<Plugin extends Tutorial, Data extends ObjectiveD
{ {
System.out.println(String.format("Tutorial> [%s] finished objective [%s]", player.getName(), getName(player))); System.out.println(String.format("Tutorial> [%s] finished objective [%s]", player.getName(), getName(player)));
showFinishMessage(player);
_active.remove(player.getUniqueId()); _active.remove(player.getUniqueId());
if (_displayFinishMessage) if (_displayFinishMessage)
@ -277,11 +275,36 @@ public abstract class Objective<Plugin extends Tutorial, Data extends ObjectiveD
UtilTextMiddle.display(C.cGreen + "Tutorial Section Completed", getName(player), 20, 60, 20, player); UtilTextMiddle.display(C.cGreen + "Tutorial Section Completed", getName(player), 20, 60, 20, player);
} }
public void displayChatMessages(Player player)
{
for (int i = 0; i < 8; i++)
{
UtilPlayer.message(player, "");
}
ObjectiveGoal<?> goal = getLatestGoal(player);
String name = goal == null ? getName(player) : goal.getName(player);
String extra = getExtraDescription(player);
// UtilPlayer.message(player, C.cGold + C.Strike + "---------------------------------------------");
UtilPlayer.message(player, C.cPurpleB + name);
if (extra != null)
{
UtilPlayer.message(player, "");
UtilPlayer.message(player, C.cGray + " " + extra);
}
UtilPlayer.message(player, "");
UtilPlayer.message(player, C.cGreen + getDescription(player));
// UtilPlayer.message(player, C.cGold + C.Strike + "---------------------------------------------");
getPlugin().getTutorialSession(player).setTextSeconds(0);
}
public void setDisplayStartMessage(boolean displayStartMessage) public void setDisplayStartMessage(boolean displayStartMessage)
{ {
_displayStartMessage = displayStartMessage; _displayStartMessage = displayStartMessage;
} }
public abstract ObjectiveGoal<?> getLatestGoal(Player player);
public void setDisplayFinishMessage(boolean displayFinishMessage) public void setDisplayFinishMessage(boolean displayFinishMessage)
{ {
_displayFinishMessage = displayFinishMessage; _displayFinishMessage = displayFinishMessage;

View File

@ -152,7 +152,7 @@ public abstract class ObjectiveGoal <T extends Objective<?, ?>> implements Liste
*/ */
protected void clean(Player player, TutorialRegion region) protected void clean(Player player, TutorialRegion region)
{ {
_removeList.add(player.getUniqueId());
} }
public T getObjective() public T getObjective()
@ -174,18 +174,7 @@ public abstract class ObjectiveGoal <T extends Objective<?, ?>> implements Liste
UtilTextMiddle.display(C.cYellow + "New Objective", getName(player), player); UtilTextMiddle.display(C.cYellow + "New Objective", getName(player), player);
if (getExtraDescription(player) != null) _objective.displayChatMessages(player);
{
for (int i = 0; i < 5; i++)
{
UtilPlayer.message(player, "");
}
// Display extra information for the first time.
UtilPlayer.message(player, C.cGold + C.Strike + "---------------------------------------------");
UtilPlayer.message(player, C.cGray + " " + getExtraDescription(player));
UtilPlayer.message(player, C.cGold + C.Strike + "---------------------------------------------");
getObjective().getPlugin().getTutorialSession(player).setTextSeconds(0);
}
} }
public void setDisplayStartMessage(boolean displayStartMessage) public void setDisplayStartMessage(boolean displayStartMessage)

View File

@ -73,6 +73,14 @@ public abstract class OrderedObjective<Plugin extends Tutorial> extends Objectiv
return _goals.get(index).getExtraDescription(player); return _goals.get(index).getExtraDescription(player);
} }
@Override
public ObjectiveGoal<?> getLatestGoal(Player player)
{
OrderedObjectiveData data = getData(player);
int index = data == null ? 0 : data.getIndex();
return _goals.get(index);
}
@Override @Override
protected void customStart(Player player) protected void customStart(Player player)
{ {

View File

@ -36,6 +36,12 @@ public abstract class SingleObjective<Plugin extends Tutorial> extends Objective
// Do Nothing // Do Nothing
} }
@Override
public ObjectiveGoal<?> getLatestGoal(Player player)
{
return null;
}
@Override @Override
protected List<ObjectiveGoal<?>> getGoals() protected List<ObjectiveGoal<?>> getGoals()
{ {

View File

@ -74,6 +74,15 @@ public abstract class UnorderedObjective<Plugin extends Tutorial> extends Object
return index == -1 ? super.getExtraDescription(player) : _goals.get(index).getExtraDescription(player); return index == -1 ? super.getExtraDescription(player) : _goals.get(index).getExtraDescription(player);
} }
@Override
public ObjectiveGoal<?> getLatestGoal(Player player)
{
UnorderedObjectiveData data = getData(player);
if (data == null) return null;
int index = data.getFirstIncompleteIndex();
return index == -1 ? null : _goals.get(index);
}
@Override @Override
protected void customStart(Player player) protected void customStart(Player player)
{ {

View File

@ -6,6 +6,7 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import mineplex.core.hologram.Hologram;
import mineplex.core.common.util.*; import mineplex.core.common.util.*;
import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent; import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent;
@ -41,6 +42,7 @@ import mineplex.game.clans.message.ClansMessageManager;
import mineplex.game.clans.spawn.Spawn; import mineplex.game.clans.spawn.Spawn;
import mineplex.game.clans.tutorial.Tutorial; import mineplex.game.clans.tutorial.Tutorial;
import mineplex.game.clans.tutorial.TutorialRegion; import mineplex.game.clans.tutorial.TutorialRegion;
import mineplex.game.clans.tutorial.TutorialSession;
import mineplex.game.clans.tutorial.TutorialWorldManager; import mineplex.game.clans.tutorial.TutorialWorldManager;
import mineplex.game.clans.tutorial.map.TutorialMapManager; import mineplex.game.clans.tutorial.map.TutorialMapManager;
import mineplex.game.clans.tutorial.tutorials.clans.objective.AttackEnemyObjective; import mineplex.game.clans.tutorial.tutorials.clans.objective.AttackEnemyObjective;
@ -106,7 +108,7 @@ public class ClansMainTutorial extends Tutorial
ClansManager.getInstance().getItemMapManager().setMap(player); ClansManager.getInstance().getItemMapManager().setMap(player);
}, 20 * 10L); }, 20 * 10L);
player.setWalkSpeed(0.2F);
//ClansManager.getInstance().getPvpTimer().unpause(player); //ClansManager.getInstance().getPvpTimer().unpause(player);
@ -149,15 +151,17 @@ public class ClansMainTutorial extends Tutorial
//ClansManager.getInstance().getPvpTimer().pause(player); //ClansManager.getInstance().getPvpTimer().pause(player);
// Spawn Holograms // Spawn Holograms
addHologram(player, setSpawnHologram(player,
getPoint(region, ClansMainTutorial.Point.SPAWN).add(0, 1.5, -6), getPoint(region, ClansMainTutorial.Point.SPAWN).add(0, 1.5, -3),
C.cGoldB + "Welcome to the Clans Tutorial!", C.cGoldB + "Welcome to the Clans Tutorial!",
" ", " ",
"This will teach you the basics of Clans.", "This will teach you the basics of Clans.",
"It will take about 5 minutes to complete.", "It will take about 5 minutes to complete.",
"You must complete it before playing Clans.", "You must complete it before playing Clans.",
" ", " ",
"Walk forward to begin!"); "Starting in " + C.cGreen + "10 Seconds");
player.setWalkSpeed(0);
addHologram(player, addHologram(player,
getPoint(region, ClansMainTutorial.Point.SPAWN).add(0, 1.5, -23), getPoint(region, ClansMainTutorial.Point.SPAWN).add(0, 1.5, -23),
@ -430,6 +434,39 @@ public class ClansMainTutorial extends Tutorial
*/ */
} }
@EventHandler
public void preventMovement(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
for (Player player : getPlayers())
{
TutorialSession session = getTutorialSession(player);
long time = session.getElapsedTime();
if (time <= 10000) // 10 seconds
{
// player.teleport(getSpawn(session.getRegion()));
String secondsLeft = UtilTime.convertString(10000 - time, 0, UtilTime.TimeUnit.SECONDS);
setSpawnHologram(player,
getPoint(session.getRegion(), ClansMainTutorial.Point.SPAWN).add(0, 1.5, -3),
C.cGoldB + "Welcome to the Clans Tutorial!",
" ",
"This will teach you the basics of Clans.",
"It will take about 5 minutes to complete.",
"You must complete it before playing Clans.",
" ",
"Starting in " + C.cGreen + secondsLeft);
}
else if (!session.isRemovedHologram())
{
removeSpawnHologram(player);
player.setWalkSpeed(0.2F);
}
}
}
public void performGateCheck(Player player, DyeColor key) public void performGateCheck(Player player, DyeColor key)
{ {
if(player == null || !player.isOnline()) return; if(player == null || !player.isOnline()) return;
@ -443,7 +480,7 @@ public class ClansMainTutorial extends Tutorial
return; return;
} }
if (player.getLocation().distanceSquared(fence) <= (GATE_OPEN_DISTANCE * 2)) if (player.getLocation().distanceSquared(fence) <= (GATE_OPEN_DISTANCE * GATE_OPEN_DISTANCE))
{ {
// Within the correct blocks of the gates. // Within the correct blocks of the gates.
destroyFences(getRegion(player), key); destroyFences(getRegion(player), key);

View File

@ -8,7 +8,6 @@ import java.util.Map;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftZombie;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Zombie; import org.bukkit.entity.Zombie;
@ -40,7 +39,7 @@ import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.LoadCannonGoal; import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.LoadCannonGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.MountCannonGoal; import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.MountCannonGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.StealEnemyPotatoesGoal; import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.StealEnemyPotatoesGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.ClanInfoGoal; import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.ClanInfoGoal;
public class AttackEnemyObjective extends OrderedObjective<ClansMainTutorial> public class AttackEnemyObjective extends OrderedObjective<ClansMainTutorial>
{ {

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan; package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;

View File

@ -115,7 +115,7 @@ public class StealEnemyPotatoesGoal extends ObjectiveGoal<AttackEnemyObjective>
if (event.getItem().getItemStack().getType() == Material.POTATO_ITEM) if (event.getItem().getItemStack().getType() == Material.POTATO_ITEM)
{ {
int count = _playersMap.get(event.getPlayer().getUniqueId()).getAndIncrement(); int count = _playersMap.get(event.getPlayer().getUniqueId()).incrementAndGet();
if (count == 10) if (count == 10)
finish(event.getPlayer()); finish(event.getPlayer());
} }

View File

@ -33,7 +33,7 @@ public class LeaveSpawnGoal extends ObjectiveGoal<ClanObjective>
); );
// 2 seconds after start message // 2 seconds after start message
// setStartMessageDelay(20 * 3); setStartMessageDelay(20 * 11);
} }
@Override @Override

View File

@ -1,58 +0,0 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.fields;
import java.util.UUID;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDeathEvent;
import mineplex.core.common.DefaultHashMap;
import mineplex.game.clans.tutorial.objective.Objective;
import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
public class KillZombiesGoal extends ObjectiveGoal
{
private DefaultHashMap<UUID, Integer> _kills = new DefaultHashMap<>(uuid -> 0);
public KillZombiesGoal(Objective objective)
{
super(objective, "Kill Zombies", "Kill a few zombies in the Fields.");
}
@Override
protected void customStart(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
@EventHandler
public void entityKilled(EntityDeathEvent event)
{
if (event.getEntityType() != EntityType.ZOMBIE)
{
return;
}
if (event.getEntity().getKiller() == null)
{
return;
}
if (!contains(event.getEntity().getKiller()))
{
return;
}
_kills.put(event.getEntity().getKiller().getUniqueId(), Integer.valueOf(_kills.get(event.getEntity().getKiller().getUniqueId()).intValue() + 1));
if (_kills.get(event.getEntity().getKiller().getUniqueId()).intValue() >= 2)
{
finish(event.getEntity().getKiller());
}
}
}