fixed /skiptutorial bugs, removed safe log out command, fixed tutorial bugs, and much more i can't remember ;-;
This commit is contained in:
parent
da2c7d84a4
commit
ce2e616c74
@ -18,7 +18,7 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class ClansAlphaManager extends MiniPlugin
|
||||
{
|
||||
private static final LinkedList<LinkedList<String>> ANNOUNCEMENTS = new LinkedList<>(Arrays.asList(new LinkedList<>(Arrays.asList(C.cDAquaB + "Welcome to Clans Alpha.", C.cAqua + "Clans is currently still in it's early Alpha stages, and you should expect there to be many bugs that will be fixed as time goes on.", C.cAqua + "Please do report any bugs that you find to Staff members, as that will help us get Clans out of Alpha much sooner!"))));
|
||||
private static final LinkedList<LinkedList<String>> ANNOUNCEMENTS = new LinkedList<>(Arrays.asList(new LinkedList<>(Arrays.asList(C.cDAquaB + "Welcome to Clans Alpha", C.cAqua + "Clans is in early Alpha stages so expect there to be bugs/issues. Please report any bugs to staff, we hope you enjoy this early test!"))));
|
||||
|
||||
private static final boolean RANDOM_ANNOUNCEMENT = true;
|
||||
|
||||
@ -29,8 +29,8 @@ public class ClansAlphaManager extends MiniPlugin
|
||||
*/
|
||||
private static final int SET_ANNOUNCEMENT = 0;
|
||||
|
||||
private static final LinkedList<String> FIRST_JOIN_MESSAGES = new LinkedList<>(Arrays.asList(C.cDAquaB + "Welcome to Clans Alpha.", C.cAqua + "Clans is currently still in its early Alpha stages, and you should expect there to be many bugs that will be fixed as time goes on.", C.cAqua + "Please do report any bugs that you find to Staff members, as that will help us get Clans out of Alpha much sooner!"));
|
||||
private static final UpdateType ANNOUNCEMENT_DELAY = UpdateType.MIN_32;
|
||||
private static final LinkedList<String> FIRST_JOIN_MESSAGES = new LinkedList<>(ANNOUNCEMENTS.getFirst());
|
||||
private static final UpdateType ANNOUNCEMENT_DELAY = UpdateType.MIN_30;
|
||||
|
||||
private TaskManager _taskManager;
|
||||
|
||||
|
@ -1,60 +0,0 @@
|
||||
package mineplex.game.clans.gameplay.safelog;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LogoutData
|
||||
{
|
||||
private String _playerName;
|
||||
private long _endTime;
|
||||
private long _startTime;
|
||||
|
||||
private Location _location;
|
||||
|
||||
public LogoutData(Player player, long duration)
|
||||
{
|
||||
_startTime = System.currentTimeMillis();
|
||||
_endTime = _startTime + duration;
|
||||
_location = player.getLocation();
|
||||
_playerName = player.getName();
|
||||
}
|
||||
|
||||
public Location getLocation()
|
||||
{
|
||||
return _location;
|
||||
}
|
||||
|
||||
public boolean isOnline()
|
||||
{
|
||||
Player player = getPlayer();
|
||||
return player != null && player.isOnline();
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return Bukkit.getPlayer(_playerName);
|
||||
}
|
||||
|
||||
public boolean hasSafeLogout()
|
||||
{
|
||||
return System.currentTimeMillis() >= _endTime;
|
||||
}
|
||||
|
||||
public double getDistanceTravelled()
|
||||
{
|
||||
if (isOnline())
|
||||
{
|
||||
Player player = getPlayer();
|
||||
|
||||
return player.getLocation().distance(_location);
|
||||
}
|
||||
|
||||
return -1d;
|
||||
}
|
||||
|
||||
public long getEnd()
|
||||
{
|
||||
return _endTime;
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package mineplex.game.clans.gameplay.safelog;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
public class QuitCommand extends CommandBase<SafeLog>
|
||||
{
|
||||
private SafeLog _loggingManager;
|
||||
|
||||
public QuitCommand(SafeLog plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "quit", "log", "logout");
|
||||
|
||||
_loggingManager = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (_loggingManager.hasLogoutData(caller))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("SafeLog", "You are already safe-logging!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
_loggingManager.insertLogoutData(caller);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,27 +1,15 @@
|
||||
package mineplex.game.clans.gameplay.safelog;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
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.F;
|
||||
import mineplex.core.common.util.UtilFile;
|
||||
import mineplex.core.common.util.UtilFile.ChunkType;
|
||||
@ -30,33 +18,20 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.gameplay.safelog.npc.NPCManager;
|
||||
|
||||
public class SafeLog extends MiniPlugin
|
||||
{
|
||||
public static final String SAFE_LOG_MESSAGE = "You have safely logged out!";
|
||||
public static final double SAFE_LOG_RANGE = 1.5d; // Distance a player can
|
||||
// move while
|
||||
// safe-logging
|
||||
public static final int LOGOUT_DURATION = 10000; // Duration of safe-log (in
|
||||
// milliseconds)
|
||||
public static final long REJOIN_TIME = 60000;
|
||||
|
||||
// Track Offline Players
|
||||
private Map<String, LogoutData> _logouts;
|
||||
private ClansManager _clansManager;
|
||||
private Map<String, String> _hint;
|
||||
|
||||
public SafeLog(JavaPlugin plugin, ClansManager clansManager)
|
||||
{
|
||||
super("SafeLog", plugin);
|
||||
|
||||
_logouts = new HashMap<>();
|
||||
_hint = new HashMap<>();
|
||||
_clansManager = clansManager;
|
||||
|
||||
new File(clansManager.UserDataDir).mkdir();
|
||||
@ -64,16 +39,16 @@ public class SafeLog extends MiniPlugin
|
||||
|
||||
public void onPlayerQuit(Player player)
|
||||
{
|
||||
Location location = player.getLocation();
|
||||
LogoutData logoutData = _logouts.remove(player.getName());
|
||||
boolean isSafeLog = logoutData != null && logoutData.hasSafeLogout();
|
||||
boolean isSafeLog = false;
|
||||
|
||||
// Players logging in safe zones are safe
|
||||
if (_clansManager.getClanUtility().isSafe(location)) isSafeLog = true;
|
||||
if (_clansManager.getClanUtility().isSafe(player.getLocation()))
|
||||
{
|
||||
isSafeLog = true;
|
||||
}
|
||||
|
||||
if (!isSafeLog)
|
||||
{
|
||||
onCombatLog(player);
|
||||
NPCManager.getInstance().spawnLogoutNpc(player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,8 +75,8 @@ public class SafeLog extends MiniPlugin
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
UtilPlayer.message(player, F.main("SafeLog", "You were killed by " + F.elem(killerName) + " when you logged out unsafely! This happened about " + F.time(UtilTime.MakeStr(System.currentTimeMillis() - time))) + " ago.");
|
||||
UtilTextMiddle.display("You were killed!", "Whilst combat logged, " + F.elem(killerName) + " killed you", 15, 80, 40, player);
|
||||
UtilPlayer.message(player, F.main("SafeLog", "You were killed by " + F.elem(killerName) + " when you logged out! This happened about " + F.time(UtilTime.MakeStr(System.currentTimeMillis() - time))) + " ago.");
|
||||
UtilTextMiddle.display("You were killed!", "Whilst logged out, " + F.elem(killerName) + " killed you", 15, 80, 40, player);
|
||||
}
|
||||
}, 15);
|
||||
reader.close();
|
||||
@ -118,14 +93,8 @@ public class SafeLog extends MiniPlugin
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
Location location = event.getPlayer().getLocation();
|
||||
LogoutData logoutData = _logouts.get(event.getPlayer().getName());
|
||||
boolean isSafeLog = logoutData != null && logoutData.hasSafeLogout();
|
||||
|
||||
if (_clansManager.getClanUtility().isSafe(location)) isSafeLog = true;
|
||||
|
||||
event.setQuitMessage(null);
|
||||
UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName() + " (" + (isSafeLog ? "Safe" : "Unsafe") + ")"));
|
||||
UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName()));
|
||||
|
||||
onPlayerQuit(event.getPlayer());
|
||||
}
|
||||
@ -133,16 +102,8 @@ public class SafeLog extends MiniPlugin
|
||||
@EventHandler
|
||||
public void onPlayerKicked(PlayerKickEvent event)
|
||||
{
|
||||
if (isSafeLogKick(event)) return;
|
||||
|
||||
Location location = event.getPlayer().getLocation();
|
||||
LogoutData logoutData = _logouts.get(event.getPlayer().getName());
|
||||
boolean isSafeLog = logoutData != null && logoutData.hasSafeLogout();
|
||||
|
||||
if (_clansManager.getClanUtility().isSafe(location)) isSafeLog = true;
|
||||
|
||||
event.setLeaveMessage(null);
|
||||
UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName() + " (" + (isSafeLog ? "Safe" : "Unsafe") + ")"));
|
||||
UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName()));
|
||||
|
||||
onPlayerQuit(event.getPlayer());
|
||||
}
|
||||
@ -156,174 +117,4 @@ public class SafeLog extends MiniPlugin
|
||||
onPlayerJoin(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() == UpdateType.TICK) tick();
|
||||
if (event.getType() == UpdateType.SLOW)
|
||||
{
|
||||
List<String> offline = new ArrayList<>();
|
||||
|
||||
for (String name : _hint.keySet())
|
||||
{
|
||||
Player player = Bukkit.getPlayer(name);
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
updateHint(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
offline.add(name);
|
||||
}
|
||||
}
|
||||
|
||||
for (String name : offline)
|
||||
{
|
||||
_hint.remove(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateHint(Player player)
|
||||
{
|
||||
if (_clansManager.getClan(player) != null && _clansManager.getClan(player).getEnergy() <= 50)
|
||||
{
|
||||
_hint.put(player.getName(), "Your Clan is very low on Energy");
|
||||
}
|
||||
else
|
||||
{
|
||||
_hint.put(player.getName(), "Do not move");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new QuitCommand(this));
|
||||
}
|
||||
|
||||
private LogoutData getLogoutData(Player player)
|
||||
{
|
||||
return _logouts.get(player.getName());
|
||||
}
|
||||
|
||||
public LogoutData insertLogoutData(Player player, long duration)
|
||||
{
|
||||
LogoutData data = new LogoutData(player, duration);
|
||||
_logouts.put(player.getName(), data);
|
||||
long logoutDuration = UtilTime.convert(duration, TimeUnit.MILLISECONDS, TimeUnit.SECONDS);
|
||||
notify(player, String.format("Successfully initiated safe-log! Do not move for %d seconds...", logoutDuration));
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public LogoutData insertLogoutData(Player player)
|
||||
{
|
||||
return insertLogoutData(player, LOGOUT_DURATION);
|
||||
}
|
||||
|
||||
public boolean hasLogoutData(Player player)
|
||||
{
|
||||
return getLogoutData(player) != null;
|
||||
}
|
||||
|
||||
private boolean isSafeLogKick(PlayerKickEvent event)
|
||||
{
|
||||
return event.getReason().equals(SAFE_LOG_MESSAGE);
|
||||
}
|
||||
|
||||
private void onCombatLog(Player player)
|
||||
{
|
||||
NPCManager.getInstance().spawnLogoutNpc(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tick the internal logic of this manager and update it's state. Intended
|
||||
* to be ticked/updated every in-game tick.
|
||||
*/
|
||||
private void tick()
|
||||
{
|
||||
for (String playerName : _logouts.keySet())
|
||||
{
|
||||
LogoutData data = _logouts.get(playerName);
|
||||
|
||||
if (data.isOnline())
|
||||
{
|
||||
double distance = data.getDistanceTravelled();
|
||||
|
||||
if (distance >= SAFE_LOG_RANGE)
|
||||
{
|
||||
cancelSafeLog(data.getPlayer());
|
||||
}
|
||||
else if (data.hasSafeLogout())
|
||||
{
|
||||
safeLogPlayer(data.getPlayer());
|
||||
}
|
||||
|
||||
UtilTextMiddle.display("Logging out in " + C.cYellow + UtilTime.MakeStr(data.getEnd() - System.currentTimeMillis()), _hint.get(playerName), data.getPlayer());
|
||||
_hint.put(playerName, "");
|
||||
updateHint(data.getPlayer());
|
||||
}
|
||||
else
|
||||
{
|
||||
_logouts.remove(playerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void cancelSafeLog(Player player)
|
||||
{
|
||||
_logouts.remove(player.getName());
|
||||
notify(player, "Your safe logout has been cancelled!");
|
||||
}
|
||||
|
||||
private void notify(Player player, String message)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("SafeLog", message));
|
||||
}
|
||||
|
||||
private void safeLogPlayer(Player player)
|
||||
{
|
||||
player.kickPlayer(SAFE_LOG_MESSAGE);
|
||||
_logouts.remove(player.getName());
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (hasLogoutData(player))
|
||||
{
|
||||
cancelSafeLog(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onEntityDamaged(EntityDamageByEntityEvent event)
|
||||
{
|
||||
Entity victim = event.getEntity();
|
||||
|
||||
if (victim instanceof Player)
|
||||
{
|
||||
Player player = (Player) victim;
|
||||
|
||||
if (hasLogoutData(player))
|
||||
{
|
||||
cancelSafeLog(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onItemPickup(PlayerPickupItemEvent event)
|
||||
{
|
||||
if (hasLogoutData(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true); // Prevent players that are safe-logging
|
||||
// from picking up items.
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -44,6 +45,7 @@ public class CombatLogNPC
|
||||
private boolean _creative;
|
||||
|
||||
private LivingEntity _npc;
|
||||
private ArmorStand _stand;
|
||||
|
||||
private CraftLivingEntity _lastDamager;
|
||||
|
||||
@ -147,6 +149,11 @@ public class CombatLogNPC
|
||||
System.out.println("Despawning");
|
||||
if (_npc != null)
|
||||
{
|
||||
if (_stand != null){
|
||||
_stand.setPassenger(null);
|
||||
_stand.remove();
|
||||
_stand = null;
|
||||
}
|
||||
_npc.remove();
|
||||
_npc = null;
|
||||
_hologram.stop();
|
||||
@ -197,6 +204,16 @@ public class CombatLogNPC
|
||||
DisguisePlayer disguise = new DisguisePlayer(skel, ((CraftPlayer) player).getHandle().getProfile());
|
||||
_disguiseManager.disguise(disguise, inRange.toArray(new Player[inRange.size()]));
|
||||
|
||||
if (!player.isOnGround())
|
||||
{
|
||||
ArmorStand stand = player.getWorld().spawn(spawnLoc.clone().subtract(0,1,0), ArmorStand.class);
|
||||
|
||||
stand.setVisible(false);
|
||||
stand.setPassenger(skel);
|
||||
|
||||
_stand = stand;
|
||||
}
|
||||
|
||||
return skel;
|
||||
}
|
||||
|
||||
|
@ -6,17 +6,15 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
@ -26,11 +24,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
public class NPCManager extends MiniPlugin
|
||||
{
|
||||
public static final long COMBAT_LOG_DURATION = 15000; // Time (in
|
||||
// milliseconds)
|
||||
// before a combat
|
||||
// log NPC
|
||||
// disappears.
|
||||
public static final long COMBAT_LOG_DURATION = 30000;
|
||||
|
||||
private static NPCManager _instance;
|
||||
|
||||
@ -111,6 +105,23 @@ public class NPCManager extends MiniPlugin
|
||||
return null;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChunkUnload(ChunkUnloadEvent event)
|
||||
{
|
||||
for (Entity entity : event.getChunk().getEntities())
|
||||
{
|
||||
for (CombatLogNPC npc : _logoutNpcs)
|
||||
{
|
||||
if (entity.getEntityId() == npc.getEntityId())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onEntityDeath(EntityDeathEvent event)
|
||||
{
|
||||
@ -197,24 +208,6 @@ public class NPCManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getType() == UpdateType.SLOW) // Test for skeletons
|
||||
// occasionally still sticking
|
||||
// around when players join back
|
||||
// in after combat logging, and
|
||||
// attacking them.
|
||||
{
|
||||
for (World world : UtilServer.getServer().getWorlds())
|
||||
{
|
||||
for (Skeleton skeleton : world.getEntitiesByClass(Skeleton.class))
|
||||
{
|
||||
if (_toKillIds.contains(skeleton.getEntityId()))
|
||||
{
|
||||
skeleton.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isLogoutNpc(Entity entity)
|
||||
|
@ -12,17 +12,11 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
public class PlayerInfo
|
||||
public class PlayerInfo
|
||||
{
|
||||
private String _playerName;
|
||||
public String getPlayerName() { return _playerName; }
|
||||
|
||||
private UUID _playerUuid;
|
||||
public String getPlayerUuid() { return _playerUuid.toString(); }
|
||||
public UUID getUniqueId() { return _playerUuid; }
|
||||
|
||||
private Set<ItemStack> _items;
|
||||
public Set<ItemStack> getItems() { return _items; }
|
||||
|
||||
public PlayerInfo(Player player)
|
||||
{
|
||||
@ -40,6 +34,26 @@ public class PlayerInfo
|
||||
}
|
||||
}
|
||||
|
||||
public String getPlayerName()
|
||||
{
|
||||
return _playerName;
|
||||
}
|
||||
|
||||
public Set<ItemStack> getItems()
|
||||
{
|
||||
return _items;
|
||||
}
|
||||
|
||||
public UUID getUniqueId()
|
||||
{
|
||||
return _playerUuid;
|
||||
}
|
||||
|
||||
public String getPlayerUuid()
|
||||
{
|
||||
return _playerUuid.toString();
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return Bukkit.getPlayerExact(_playerName);
|
||||
@ -61,7 +75,7 @@ public class PlayerInfo
|
||||
{
|
||||
if (item != null && item.getType() != Material.AIR)
|
||||
{
|
||||
items.add(item);
|
||||
items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -272,6 +272,11 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
|
||||
public void startFor(final Player player)
|
||||
{
|
||||
if (!_manager.isInTutorial(player))
|
||||
{
|
||||
_manager._playerTutorials.put(player.getName(), this);
|
||||
}
|
||||
|
||||
_inTutorial.put(player.getName(), TutorialClient.create(player, _taskManager, this));
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
|
||||
|
||||
@ -350,7 +355,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
@EventHandler
|
||||
public void onPlayerJoin(final PlayerJoinEvent evt)
|
||||
{
|
||||
// if (!hasSkipped(evt.getPlayer()))
|
||||
if (!hasSkipped(evt.getPlayer()))
|
||||
{
|
||||
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable()
|
||||
{
|
||||
|
@ -1,8 +1,5 @@
|
||||
package mineplex.game.clans.tutorials;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
@ -14,7 +11,6 @@ public class TutorialClient
|
||||
private final Tutorial _tutorial;
|
||||
private final Player _player;
|
||||
|
||||
private final Map<String, Object> _data = new HashMap<>();
|
||||
private int _currentTask = 1;
|
||||
|
||||
public TutorialClient(final Player player, final TaskManager taskManager, final Tutorial tutorial)
|
||||
@ -79,26 +75,4 @@ public class TutorialClient
|
||||
return task.getID() < _currentTask;
|
||||
}
|
||||
|
||||
public Object getData(final String name, final Object defValue)
|
||||
{
|
||||
if (!_data.containsKey(name)) _data.put(name, defValue);
|
||||
|
||||
return getData(name);
|
||||
}
|
||||
|
||||
public Object getData(final String name)
|
||||
{
|
||||
return _data.get(name);
|
||||
}
|
||||
|
||||
public void setData(final String name, final Object value)
|
||||
{
|
||||
_data.put(name, value);
|
||||
}
|
||||
|
||||
public Map<String, Object> getData()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class TutorialManager extends MiniPlugin
|
||||
public static TutorialManager Instance;
|
||||
|
||||
private final Map<Class<? extends Tutorial>, Tutorial> _tutorials = new HashMap<>();
|
||||
private final Map<String, Tutorial> _playerTutorials = new HashMap<>();
|
||||
protected final Map<String, Tutorial> _playerTutorials = new HashMap<>();
|
||||
|
||||
private final TaskManager _taskManager;
|
||||
|
||||
@ -72,7 +72,7 @@ public class TutorialManager extends MiniPlugin
|
||||
|
||||
public boolean isInTutorial(final Player player)
|
||||
{
|
||||
return _playerTutorials.containsKey(player.getName()) && isInTutorial(player);
|
||||
return _playerTutorials.containsKey(player.getName());
|
||||
}
|
||||
|
||||
public void cancelTutorial(final Player player)
|
||||
@ -93,9 +93,9 @@ public class TutorialManager extends MiniPlugin
|
||||
{
|
||||
getTutorial(player).skip(player);
|
||||
|
||||
_playerTutorials.remove(player.getName());
|
||||
|
||||
UtilPlayer.message(player, F.main("Tutorials", "You have skipped the " + F.elem(getTutorial(player)._friendlyName + " Tutorial") + "."));
|
||||
|
||||
_playerTutorials.remove(player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,11 +48,11 @@ public class TutorialGettingStarted extends Tutorial
|
||||
addTask(4, "Go To The Wilderness", "Access your map with {/map} and head out into the wilderness! You’ll see various other locations marked on your map later.");
|
||||
addTask(5, "Claiming Territory", "In order to claim a chunk of land for your clan you type {/c claim}! Keep in mind that you can only claim in the Wilderness, and not too close to other clan's claims and safe areas. Notice though, your clan runs on energy! You can buy energy from the shops!", "Good job! We won't claim this area just yet, you can do it again later when you find a nice location after the tutorial.");
|
||||
addTask(6, "Visit The Shops", "At the shops you can buy most things you need! Once a day you can transfer 1000 gems to 5000 clans gold here as well!");
|
||||
addTask(7, "Buy Armor", "Head to the PvP Gear villager and purchase a set of armor! Make sure to buy a matching set to access your class skills!");
|
||||
addTask(8, "Equip Armor", "In order to equip a kit, you must put on the full armor set of that kit! Put on the armor set you just bought and you will have selected your kit!");
|
||||
addTask(9, "Use An Ability", "In order to use abilities you need a sword or axe. To use your sword ability, right click with your sword! To use your axe ability, right click with your axe!");
|
||||
addTask(10, "Class Customization", "To customize your class, right click an enchantment table! There you will find the GUI for all the skills in that class! Customize it to your liking!");
|
||||
addTask(11, "Disband Clan", "To disband your own clan, you can do {/c disband}, this will delete your clan, and you will be able to start a new one!");
|
||||
// addTask(7, "Buy Armor", "Head to the PvP Gear villager and purchase a set of armor! Make sure to buy a matching set to access your class skills!");
|
||||
// addTask(8, "Equip Armor", "In order to equip a kit, you must put on the full armor set of that kit! Put on the armor set you just bought and you will have selected your kit!");
|
||||
addTask(7, "Use An Ability", "In order to use abilities you need a sword or axe. To use your sword ability, right click with your sword! To use your axe ability, right click with your axe!");
|
||||
addTask(8, "Class Customization", "To customize your class, right click an enchantment table! There you will find the GUI for all the skills in that class! Customize it to your liking!");
|
||||
addTask(9, "Disband Clan", "To disband your own clan, you can do {/c disband}, this will delete your clan, and you will be able to start a new one!");
|
||||
|
||||
_doScoreboard = true;
|
||||
_ghostMode = true;
|
||||
@ -68,103 +68,6 @@ public class TutorialGettingStarted extends Tutorial
|
||||
UtilPlayer.message(player, F.main("Tutorials", "You are now ready to play, welcome to the game."));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onClansShopButtonAdded(ClansShopAddButtonEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
final Material type = event.getMaterial();
|
||||
|
||||
if (!isInTutorial(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TutorialClient client = get(player);
|
||||
|
||||
if (UtilItem.isWeapon(type) && hasFinishedTask(player, "Buy Armor") && !hasFinishedTask(player, "Use An Ability"))
|
||||
{
|
||||
boolean hasBoughtWeapon = false;
|
||||
|
||||
for (Material material : UtilItem.listIn(ItemCategory.WEAPON))
|
||||
{
|
||||
if (client.getData().containsKey(material.name() + "_bought"))
|
||||
{
|
||||
hasBoughtWeapon = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasBoughtWeapon)
|
||||
{
|
||||
event.setBuyPrice(0);
|
||||
event.setSellPrice(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (UtilItem.isArmor(type) && hasFinishedTask(player, "Visit The Shops") && !hasFinishedTask(player, "Buy Armor"))
|
||||
{
|
||||
boolean hasBoughtFullSet = false;
|
||||
Map<ArmorMaterial, Integer> armorBought = new HashMap<>();
|
||||
ArmorMaterial partialSetType = null;
|
||||
|
||||
for (Material armor : UtilItem.listIn(ItemCategory.ARMOR))
|
||||
{
|
||||
if (client.getData().containsKey(armor.name() + "_bought"))
|
||||
{
|
||||
ArmorMaterial armorType = ArmorMaterial.of(armor);
|
||||
|
||||
armorBought.put(armorType, armorBought.containsKey(armorType) ? armorBought.get(armorType) + 1 : 0);
|
||||
|
||||
if (armorBought.get(armorType) >= 3)
|
||||
{
|
||||
hasBoughtFullSet = true;
|
||||
}
|
||||
|
||||
partialSetType = armorType;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasBoughtFullSet && (partialSetType != null ? ArmorMaterial.of(type).equals(partialSetType) : true) && !client.getData().containsKey(type.name() + "_bought"))
|
||||
{
|
||||
event.setBuyPrice(0);
|
||||
event.setSellPrice(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerBuyItem(ClansPlayerBuyItemEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
final ItemStack item = event.getItem();
|
||||
final TutorialClient client = get(player);
|
||||
|
||||
if (isInTutorial(player) && get(player).hasFinishedTask(getTask("Visit The Shops")) && !get(player).hasFinishedTask(getTask("Buy Armor")))
|
||||
{
|
||||
if (UtilItem.isArmor(item) || UtilItem.isWeapon(item))
|
||||
{
|
||||
Map<ArmorMaterial, Integer> armorBought = new HashMap<>();
|
||||
|
||||
for (Material armor : UtilItem.listIn(ItemCategory.ARMOR))
|
||||
{
|
||||
if (client.getData().containsKey(armor.name() + "_bought"))
|
||||
{
|
||||
ArmorMaterial armorType = ArmorMaterial.of(armor);
|
||||
|
||||
armorBought.put(armorType, armorBought.containsKey(armorType) ? armorBought.get(armorType) + 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (armorBought.containsKey(ArmorMaterial.of(item.getType())) && armorBought.get(ArmorMaterial.of(item.getType())) >= 3)
|
||||
{
|
||||
finishTask(player, "Buy Armor");
|
||||
}
|
||||
|
||||
client.setData(item.getType().name() + "_bought", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onClanCreated(ClanCreatedEvent event)
|
||||
{
|
||||
@ -224,7 +127,7 @@ public class TutorialGettingStarted extends Tutorial
|
||||
{
|
||||
final Player player = event.GetPlayer();
|
||||
|
||||
if (isInTutorial(player) && get(player).hasFinishedTask(getTask("Equip Armor")) && !get(player).hasFinishedTask(getTask("Use An Ability")))
|
||||
if (isInTutorial(player) && get(player).hasFinishedTask(getTask("Visit The Shops")) && !get(player).hasFinishedTask(getTask("Use An Ability")))
|
||||
{
|
||||
finishTask(player, "Use An Ability");
|
||||
}
|
||||
@ -251,16 +154,6 @@ public class TutorialGettingStarted extends Tutorial
|
||||
finishTask(client.getPlayer(), "Class Customization");
|
||||
}
|
||||
}
|
||||
|
||||
if (client.hasFinishedTask(getTask("Buy Armor")) && !client.hasFinishedTask(getTask("Equip Armor")))
|
||||
{
|
||||
final ClientClass clientclass = _clansManager.getClassManager().Get(client.getPlayer());
|
||||
|
||||
if (clientclass != null && clientclass.GetGameClass() != null)
|
||||
{
|
||||
finishTask(client.getPlayer(), "Equip Armor");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user