made it so that no messages are shown when in tutorial

This commit is contained in:
NewGarbo 2015-11-30 19:08:16 +00:00
parent 0862cfce72
commit 813e7ee789
5 changed files with 62 additions and 39 deletions

View File

@ -227,7 +227,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
TaskManager taskManager = new TaskManager(plugin, _clientManager, webServerAddress);
_tutorialManager = new TutorialManager(plugin, _goldManager, taskManager, donationManager, preferencesManager, this);
_tutorialManager = new TutorialManager(plugin, _goldManager, taskManager, donationManager, preferencesManager, this, packetHandler);
ClanTips = new ClanTips(plugin, this, preferencesManager);

View File

@ -30,6 +30,9 @@ import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.donation.DonationManager;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.scoreboard.ScoreboardManager;
import mineplex.core.scoreboard.elements.ScoreboardElement;
import mineplex.core.task.TaskManager;
@ -38,6 +41,7 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClanTipEvent;
import mineplex.game.clans.economy.GoldManager;
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
/**
*
@ -53,6 +57,8 @@ public abstract class Tutorial implements ScoreboardElement, Listener
public static String TUTORIAL_REWARD_TASK = "tatatatatat%sRewardGiven"; //do not change
public static String SKIPPED_TASK = "tatatatata%sSkip";
public static String ALLOWED_MESSAGE_CODE = C.cPurpleB . C.cGold . C.cYellowB . C.cBlueB . C.cDBlueB . C.cRed . C.cDRedB . C.cWhite . C.Reset;
protected final TutorialManager _manager;
protected final GoldManager _goldManager;
protected final ClansManager _clansManager;
@ -75,7 +81,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
protected int _gemReward = -1;
protected int _coinReward = -1;
public Tutorial(final GoldManager goldManager, final TaskManager taskManager, final ClansManager clansManager, final DonationManager donationManager, final TutorialManager manager)
public Tutorial(final GoldManager goldManager, final TaskManager taskManager, final ClansManager clansManager, final DonationManager donationManager, final TutorialManager manager, final PacketHandler packetHandler)
{
_clansManager = clansManager;
_goldManager = goldManager;
@ -86,6 +92,19 @@ public abstract class Tutorial implements ScoreboardElement, Listener
_inTutorial = new LinkedHashMap<>();
_nameToTask = new LinkedHashMap<>();
packetHandler.addPacketHandler(new IPacketHandler(){
public void handle(PacketInfo packet)
{
if (packet.getPacket() instanceof PacketPlayOutChat)
{
if (!((PacketPlayOutChat) packet.getPacket()).a.c().startsWith(ALLOWED_MESSAGE_CODE))
{
packet.setCancelled(true);
}
}
}
}, PacketPlayOutChat.class);
_manager.getPluginManager().registerEvents(this, _manager.getPlugin());
}
@ -238,7 +257,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
if (_goldReward != -1)
{
_goldManager.addGold(player, _goldReward);
UtilPlayer.message(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gold") + "."));
msg(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gold") + "."));
}
if (_gemReward != -1)
@ -246,7 +265,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
_donationManager.RewardGems(new Callback<Boolean>() {
public void run(Boolean data)
{
UtilPlayer.message(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gems") + "."));
msg(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gems") + "."));
}
}, "Clans", player.getName(), player.getUniqueId(), _gemReward);
}
@ -256,7 +275,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
_donationManager.RewardCoins(new Callback<Boolean>() {
public void run(Boolean data)
{
UtilPlayer.message(player, F.main("Tutorials", "You have been awarded " + F.elem(_coinReward + " Coins") + "."));
msg(player, F.main("Tutorials", "You have been awarded " + F.elem(_coinReward + " Coins") + "."));
}
}, "Clans", player.getName(), _clansManager.getClientManager().getAccountId(player), _coinReward);
}
@ -373,6 +392,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
public void skip(final Player player)
{
new JsonMessage(
ALLOWED_MESSAGE_CODE .
F.main(
"Tutorial",
"Are you sure you want to skip the tutorial? We "
@ -494,4 +514,9 @@ public abstract class Tutorial implements ScoreboardElement, Listener
_inTutorial.remove(player.getName());
}
protected void msg(Player player, String msg)
{
UtilPlayer.message(player, ALLOWED_MESSAGE_CODE . msg);
}
}

View File

@ -12,6 +12,7 @@ import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.task.TaskManager;
import mineplex.game.clans.clans.ClansManager;
@ -30,7 +31,7 @@ public class TutorialManager extends MiniPlugin
private final TaskManager _taskManager;
public TutorialManager(final JavaPlugin plugin, final GoldManager goldManager, final TaskManager taskManager, final DonationManager donationManager, final PreferencesManager preferencesManager, final ClansManager clansManager)
public TutorialManager(final JavaPlugin plugin, final GoldManager goldManager, final TaskManager taskManager, final DonationManager donationManager, final PreferencesManager preferencesManager, final ClansManager clansManager, final PacketHandler packetHandler)
{
super("Tutorials", plugin);
@ -38,7 +39,7 @@ public class TutorialManager extends MiniPlugin
_taskManager = taskManager;
_tutorials.put(TutorialGettingStarted.class, new TutorialGettingStarted(this, clansManager, donationManager, goldManager,taskManager));
_tutorials.put(TutorialGettingStarted.class, new TutorialGettingStarted(this, clansManager, donationManager, goldManager, taskManager, packetHandler));
}
public void addCommands()
@ -78,7 +79,7 @@ public class TutorialManager extends MiniPlugin
getTutorial(player).cancelFor(player);
UtilPlayer.message(player, F.main("Tutorials", "You have cancelled the " + F.elem(getTutorial(player)._displayName + " Tutorial") + "."));
UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + F.main("Tutorials", "You have cancelled the " + F.elem(getTutorial(player)._displayName + " Tutorial") + "."));
_playerTutorials.remove(player.getName());
}
}
@ -95,7 +96,7 @@ public class TutorialManager extends MiniPlugin
{
if (isInTutorial(player))
{
UtilPlayer.message(player, F.main("Tutorials", "You have skipped the " + F.elem(getTutorial(player)._displayName + " Tutorial") + "."));
UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + F.main("Tutorials", "You have skipped the " + F.elem(getTutorial(player)._displayName + " Tutorial") + "."));
getTutorial(player).doSkip(player);
}
}

View File

@ -85,15 +85,15 @@ public class TutorialTask<T extends Tutorial> implements Listener
if (System.currentTimeMillis() - client.LastDescriptionSentTime > client.CurrentTask.getDescriptionWaitTime())
{
UtilPlayer.message(player, " ");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cYellowB + "Part " + _id + ": " + _displayName);
UtilPlayer.message(player, C.cWhite + _description.replace("{", C.cAqua).replace("}", C.cWhite));
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------");
UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + " ");
UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + " ");
UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + " ");
UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + C.cDGreenB + C.Strike + "---------------------------------------------");
UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + " ");
UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + C.cYellowB + "Part " + _id + ": " + _displayName);
UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + C.cWhite + _description.replace("{", C.cAqua).replace("}", C.cWhite));
UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + " ");
UtilPlayer.message(player, Tutorial.ALLOWED_MESSAGE_CODE + C.cDGreenB + C.Strike + "---------------------------------------------");
client.LastDescriptionSentTime = System.currentTimeMillis();
}
}

View File

@ -5,10 +5,9 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.donation.DonationManager;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.task.TaskManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -20,9 +19,9 @@ import mineplex.game.clans.tutorials.TutorialManager;
public class TutorialGettingStarted extends Tutorial
{
public TutorialGettingStarted(final TutorialManager manager, final ClansManager clansManager, final DonationManager donationManager, final GoldManager goldManager, final TaskManager taskManager)
public TutorialGettingStarted(final TutorialManager manager, final ClansManager clansManager, final DonationManager donationManager, final GoldManager goldManager, final TaskManager taskManager, final PacketHandler packetHandler)
{
super(goldManager, taskManager, clansManager, donationManager, manager);
super(goldManager, taskManager, clansManager, donationManager, manager, packetHandler);
// addTask(new TaskWelcome(this, 1));
@ -40,8 +39,6 @@ public class TutorialGettingStarted extends Tutorial
addTask(new TaskMakingMoney(this, ++id));
addTask(new TaskDisbandClan(this, ++id));
_doScoreboard = true;
_ghostMode = true;
_startOnJoin = true;
@ -54,12 +51,12 @@ public class TutorialGettingStarted extends Tutorial
@Override
public void onFinished(final Player player)
{
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------");
UtilPlayer.message(player, C.cYellowB + "CONGRATULATIONS");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cWhite + "You have completed the Clans basic tutorial and have been awarded " + C.cAqua + "30,000 Gold");
UtilPlayer.message(player, C.cWhite + "You can now begin your adventure, but do take a moment to read the signs around spawn for more information!");
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------");
msg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
msg(player, C.cYellowB + "CONGRATULATIONS");
msg(player, " ");
msg(player, C.cWhite + "You have completed the Clans basic tutorial and have been awarded " + C.cAqua + "30,000 Gold");
msg(player, C.cWhite + "You can now begin your adventure, but do take a moment to read the signs around spawn for more information!");
msg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
player.resetPlayerTime();
player.teleport(Spawn.getEastSpawn());
@ -68,17 +65,17 @@ public class TutorialGettingStarted extends Tutorial
@Override
public void onBegin(final Player player)
{
UtilPlayer.message(player, " ");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cYellowB + "Getting Started");
UtilPlayer.message(player, C.cWhite + "Welcome to Clans! "
msg(player, " ");
msg(player, " ");
msg(player, " ");
msg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
msg(player, " ");
msg(player, C.cYellowB + "Getting Started");
msg(player, C.cWhite + "Welcome to Clans! "
+ "In this game mode you are able to create a clan, invite your friends to play with you, build a base, and wage war against others! "
+ "When you finish the tutorial, you will be awarded " + C.cAqua + "30,000 Gold");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------");
msg(player, " ");
msg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
}