diff --git a/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResourcePackManager.java b/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResourcePackManager.java index 31b41dd06..9dcee5edd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResourcePackManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResourcePackManager.java @@ -32,6 +32,7 @@ import mineplex.serverdata.commands.ServerCommandManager; public class ResourcePackManager extends MiniPlugin implements CommandCallback { private String _resourcePackUrl; + private String _resourcePackUrl19; // Resource pack for 1.9 clients private boolean _resourcePackRequired; private NautHashMap _resourcePackUsers = new NautHashMap(); private NautHashMap _resourcePackNoResponse = new NautHashMap(); @@ -62,7 +63,10 @@ public class ResourcePackManager extends MiniPlugin implements CommandCallback } _resourcePackUsers.put(player.getName(), false); - player.setResourcePack(_resourcePackUrl); + + String url = getUrl(player); + System.out.println("Set resource pack for player: " + player + " to " + url); + player.setResourcePack(url); } @EventHandler @@ -89,7 +93,7 @@ public class ResourcePackManager extends MiniPlugin implements CommandCallback // Send it again, enforce it! _resourcePackNoResponse.put(player.getName(), System.currentTimeMillis()); - player.setResourcePack(_resourcePackUrl); + player.setResourcePack(getUrl(player)); } } @@ -144,6 +148,8 @@ public class ResourcePackManager extends MiniPlugin implements CommandCallback { _resourcePackUsers.remove(player.getName()); } + + System.out.println("status: " + player.getName() + " " + event); } @EventHandler @@ -177,6 +183,11 @@ public class ResourcePackManager extends MiniPlugin implements CommandCallback } public void setResourcePack(String resourcePack, boolean forceResourcePack) + { + setResourcePack(resourcePack, resourcePack, forceResourcePack); + } + + public void setResourcePack(String resourcePack, String resourcePack19, boolean forceResourcePack) { if (Objects.equal(resourcePack, _resourcePackUrl) && forceResourcePack == _resourcePackRequired) { @@ -186,6 +197,7 @@ public class ResourcePackManager extends MiniPlugin implements CommandCallback _resourcePackNoResponse.clear(); _resourcePackUsers.clear(); _resourcePackUrl = resourcePack == null || resourcePack.isEmpty() ? null : resourcePack; + _resourcePackUrl19 = resourcePack19; _resourcePackRequired = forceResourcePack; if (_resourcePackUrl == null || _resourcePackUrl.isEmpty()) @@ -207,7 +219,7 @@ public class ResourcePackManager extends MiniPlugin implements CommandCallback } _resourcePackUsers.put(player.getName(), false); - player.setResourcePack(_resourcePackUrl); + player.setResourcePack(getUrl(player)); } } } @@ -235,4 +247,9 @@ public class ResourcePackManager extends MiniPlugin implements CommandCallback } } + private String getUrl(Player player) + { + return UtilPlayer.is1_9(player) ? _resourcePackUrl19 : _resourcePackUrl; + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/texttutorial/TextTutorialManager.java b/Plugins/Mineplex.Core/src/mineplex/core/texttutorial/TextTutorialManager.java new file mode 100644 index 000000000..57c4d924c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/texttutorial/TextTutorialManager.java @@ -0,0 +1,154 @@ +package mineplex.core.texttutorial; + +import java.util.HashSet; +import java.util.Iterator; + +import org.bukkit.Sound; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.donation.DonationManager; +import mineplex.core.task.TaskManager; +import mineplex.core.texttutorial.tutorial.Tutorial; +import mineplex.core.texttutorial.tutorial.TutorialData; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class TextTutorialManager extends MiniPlugin +{ + private DonationManager _donationManager; + private TaskManager _taskManager; + + private HashSet _tutorials; + + public TextTutorialManager(JavaPlugin plugin, DonationManager donationManager, TaskManager taskManager) + { + super("Text Tutorial", plugin); + + _donationManager = donationManager; + _taskManager = taskManager; + } + + @EventHandler + public void startTutorial(PlayerInteractEntityEvent event) + { + if (isInTutorial(event.getPlayer())) + return; + + if (!(event.getRightClicked() instanceof LivingEntity)) + return; + + LivingEntity ent = (LivingEntity)event.getRightClicked(); + + String name = ent.getCustomName(); + if (name == null) + return; + + for (Tutorial tut : _tutorials) + { + if (name.contains(tut.getName())) + { + UtilPlayer.message(event.getPlayer(), F.main("Tutorial", "You started " + F.elem(tut.getName()) + ".")); + tut.startTutorial(event.getPlayer()); + return; + } + } + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + for (final Tutorial tut : _tutorials) + { + Iterator iterator = tut.getTutorialDatas().iterator(); + while (iterator.hasNext()) + { + TutorialData data = iterator.next(); + final Player player = data.getPlayer(); + + //Check if Phase Completed + if (data.tick()) + { + //Next Phase + if (data.getPhaseStep() < tut.getPhaseSize()) + { + data.setNextPhase(tut.getPhase(data.getPhaseStep())); + } + //End Tutorial + else + { + iterator.remove(); + + //Inform + UtilPlayer.message(player, F.main("Tutorial", "You completed " + F.elem(tut.getName()) + ".")); + + //Gems + if (tut.getGemReward() > 0) + { + if (!_taskManager.hasCompletedTask(player, tut.getTaskId())) + { + _taskManager.completedTask(new Callback() + { + public void run(Boolean completed) + { + _donationManager.RewardGems(new Callback() + { + public void run(Boolean completed) + { + if (completed) + { + UtilPlayer.message(player, F.main("Tutorial", "You received " + F.elem(C.cGreen + tut.getGemReward() + " Gems") + ".")); + + //Sound + player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); + } + } + }, "Tutorial " + tut.getName(), player.getName(), player.getUniqueId(), tut.getGemReward()); + } + }, player, tut.getTaskId()); + } + } + } + } + } + } + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + for (Tutorial tut : _tutorials) + tut.stopTutorial(event.getPlayer()); + } + + @EventHandler + public void cancelInteract(PlayerInteractEvent event) + { + if (isInTutorial(event.getPlayer())) + event.setCancelled(true); + } + + public boolean isInTutorial(Player player) + { + for (Tutorial tutorial : _tutorials) + { + if (tutorial.isInTutorial(player)) + return true; + } + + return false; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/texttutorial/tutorial/Phase.java b/Plugins/Mineplex.Core/src/mineplex/core/texttutorial/tutorial/Phase.java new file mode 100644 index 000000000..7cd9a80a9 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/texttutorial/tutorial/Phase.java @@ -0,0 +1,47 @@ +package mineplex.core.texttutorial.tutorial; + +import org.bukkit.Location; + +public class Phase +{ + private Location _location; + private String _header; + private String[] _text; + + public Phase(Location location, String header, String[] text) + { + _location = location; + _header = header; + _text = text; + } + + public Location getLocation() + { + return _location; + } + + public void setLocation(Location location) + { + _location = location; + } + + public String getHeader() + { + return _header; + } + + public void setHeader(String header) + { + _header = header; + } + + public String[] getText() + { + return _text; + } + + public void setText(String[] text) + { + _text = text; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/texttutorial/tutorial/Tutorial.java b/Plugins/Mineplex.Core/src/mineplex/core/texttutorial/tutorial/Tutorial.java new file mode 100644 index 000000000..362139c9c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/texttutorial/tutorial/Tutorial.java @@ -0,0 +1,74 @@ +package mineplex.core.texttutorial.tutorial; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; + +import org.bukkit.entity.Player; + +public abstract class Tutorial +{ + private String _name; + private String _taskId; + private int _gemReward; + + private ArrayList _phases; + private HashMap _playerMap; + + public Tutorial(String name, String taskId, int gemReward) + { + _name = name; + _taskId = taskId; + _gemReward = gemReward; + } + + public String getName() + { + return _name; + } + + public String getTaskId() + { + return _taskId; + } + + public void startTutorial(Player player) + { + _playerMap.put(player, new TutorialData(player, _phases.get(0))); + } + + public void stopTutorial(Player player) + { + _playerMap.remove(player); + } + + public boolean isInTutorial(Player player) + { + return _playerMap.containsKey(player); + } + + protected void addPhase(Phase phase) + { + _phases.add(phase); + } + + public Collection getTutorialDatas() + { + return _playerMap.values(); + } + + public Phase getPhase(int phaseIndex) + { + return _phases.get(phaseIndex); + } + + public int getPhaseSize() + { + return _phases.size(); + } + + public int getGemReward() + { + return _gemReward; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/texttutorial/tutorial/TutorialData.java b/Plugins/Mineplex.Core/src/mineplex/core/texttutorial/tutorial/TutorialData.java new file mode 100644 index 000000000..fdad7738f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/texttutorial/tutorial/TutorialData.java @@ -0,0 +1,102 @@ +package mineplex.core.texttutorial.tutorial; + +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilPlayer; + +public class TutorialData +{ + private Player _player; + private Phase _phase; + private int _phaseStep; + private int _textStep; + private long _sleep; + + public TutorialData(Player player, Phase startPhase) + { + _player = player; + _phase = startPhase; + _phaseStep = 0; + _textStep = 0; + _sleep = System.currentTimeMillis() + 3000; + } + + public boolean tick() + { + if (!_player.getLocation().equals(_phase.getLocation())) + _player.teleport(_phase.getLocation()); + + if (System.currentTimeMillis() < _sleep) + return false; + + if (_textStep >= _phase.getText().length) + { + // No more text to display, move to next phase + _phaseStep++; + _sleep = System.currentTimeMillis() + 2000; + + return true; + } + + // Display Text + String text = _phase.getText()[_textStep]; + + UtilPlayer.message(_player, " "); + UtilPlayer.message(_player, " "); + UtilPlayer.message(_player, " "); + UtilPlayer.message(_player, C.cGreen + C.Strike + C.Bold + "========================================"); + UtilPlayer.message(_player, C.cGold + C.Bold + _phase.getHeader()); + UtilPlayer.message(_player, " "); + + for (int i=0 ; i<=_textStep ; i++) + UtilPlayer.message(_player, " " + _phase.getText()[i]); + + for (int i=_textStep ; i<=5 ; i++) + UtilPlayer.message(_player, " "); + + UtilPlayer.message(_player, C.cGreen + C.Strike + C.Bold + "========================================"); + + if (text.length() > 0) + { + _player.playSound(_player.getLocation(), Sound.ORB_PICKUP, 2f, 1.5f); + _sleep = System.currentTimeMillis() + 1000 + (50*text.length()); + } + else + { + _sleep = System.currentTimeMillis() + 600; + } + + _textStep++; + + return false; + } + + public void setNextPhase(Phase phase) + { + _phase = phase; + _textStep = 0; + _player.teleport(_phase.getLocation()); + } + + public Phase getPhase() + { + return _phase; + } + + public long getSleep() + { + return _sleep; + } + + public int getPhaseStep() + { + return _phaseStep; + } + + public Player getPlayer() + { + return _player; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 3297974c5..562ce4e94 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -127,7 +127,7 @@ public class Clans extends JavaPlugin new FriendManager(this, _clientManager, preferenceManager, portal); new InventoryManager(this, _clientManager); ResourcePackManager resourcePackManager = new ResourcePackManager(this, portal); - resourcePackManager.setResourcePack("http://b.garblox.com/CLANS_BETA_PACK_V6.zip", true); + resourcePackManager.setResourcePack("http://phinary.ca/ResClans.zip", "http://phinary.ca/ResClans19.zip", true); // Enable custom-gear related managers new CustomTagFix(this, packetHandler); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/texttutorial/ClassTutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/texttutorial/ClassTutorial.java new file mode 100644 index 000000000..d6e3b3e79 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/texttutorial/ClassTutorial.java @@ -0,0 +1,14 @@ +package mineplex.game.clans.texttutorial; + +import mineplex.core.texttutorial.tutorial.Phase; +import mineplex.core.texttutorial.tutorial.Tutorial; + +public class ClassTutorial extends Tutorial +{ + public ClassTutorial() + { + super("Class Guide", "Clans.TextTutorial.Class", 0); + + addPhase(new Phase(null, "Classes", new String[] { "" })); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/TutorialManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/TutorialManager.java index ff13349f0..58332d12c 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/TutorialManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/tutorial/TutorialManager.java @@ -87,7 +87,7 @@ public class TutorialManager extends MiniPlugin if (InTutorial(event.getPlayer())) event.setCancelled(true); } - + @EventHandler public void MoveCancel(PlayerMoveEvent event) {