Merge pull request #89 in MIN/mineplex from clans-beta to master
* commit 'eed6966a5b39d1fc9544055a5b5801758a62a56a': Winter MOTD, Stat fixes (maybe?!) made use ability teleport player back to where they should be Forgot to push these changes last update! fixed tnt blowing up in claims when offline fixed task not getting cleanup up after /skiptutorial fixed /skiptutorial not working, and fixed tutorial thinking you're still in tutorial after finishing/cancelling/skipping Fix heavy attribute, disable claim visualizer Disable subtasks for now Clans alpha 0.17 clan claim visualizer fixed infinite claims
This commit is contained in:
commit
8ff034fb5d
@ -56,11 +56,11 @@ public class MotdManager implements Listener, Runnable
|
||||
//String motdLine = "§f§l◄ §c§lMaintenance§f§l ►";
|
||||
//String motdLine = "§f§l◄ §a§lCarl the Creeper§f§l ►";
|
||||
// String motdLine = " §2§l§n M O N S T E R M A Z E B E T A §f";
|
||||
String motdLine = " §f§l◄ §b§lNew Game§f§l ▬ §3§lChampions CTF§f§l ►";
|
||||
String motdLine = " §f❄ §2§lWinter Update §f❄ §2§lSnow Fight §f❄";
|
||||
//String motdLine = " §d§lRank Sale §a§l40% Off");
|
||||
//String motdLine = " §f§l◄§c§lMAINTENANCE§f§l►");
|
||||
|
||||
updateMainMotd(" §f§l§m §8§l§m[ §r §6§lMineplex§r §f§lGames§r §8§l§m ]§f§l§m §r", motdLine);
|
||||
updateMainMotd(" §c§m §f§m §c§m §f§m §2§l§m[ §r §c§lMineplex§r §f§lGames§r §2§l§m ]§f§m §c§m §f§m §c§m §r", motdLine);
|
||||
System.out.println("Updated Bungee MOTD");
|
||||
}
|
||||
}
|
||||
|
@ -110,4 +110,29 @@ public class UtilText {
|
||||
return s.length() <= maxLength ? s : s.substring(0, maxLength);
|
||||
}
|
||||
|
||||
public static <X> String arrayToString(X[] array, String delimiter)
|
||||
{
|
||||
StringBuilder string = new StringBuilder();
|
||||
|
||||
int index = 0;
|
||||
for (X x : array)
|
||||
{
|
||||
string.append(x.toString());
|
||||
|
||||
if (index != array.length - 1)
|
||||
{
|
||||
string.append(delimiter);
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
return string.toString();
|
||||
}
|
||||
|
||||
public static <X> String arrayToString(X[] array)
|
||||
{
|
||||
return arrayToString(array, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -84,19 +84,6 @@ public class ServerCommand extends CommandBase<Portal>
|
||||
else
|
||||
deniedAccess = true;
|
||||
}
|
||||
else if (servUp.contains("CLANS-"))
|
||||
{
|
||||
if (playerRank.has(Rank.MODERATOR))
|
||||
{
|
||||
Plugin.sendPlayerToServer(player, args[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(player,
|
||||
F.main(Plugin.getName(), C.cRed + "You must join clans through the hub! Join " + C.cGold + "ClansHub-1"
|
||||
+ C.cRed + "!"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin.sendPlayerToServer(player, args[0]);
|
||||
|
@ -106,6 +106,10 @@ public class PlayerScoreboard
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ignore extra lines
|
||||
if (i >= _teamNames.length)
|
||||
continue;
|
||||
|
||||
//Update
|
||||
Team team = _scoreboard.getTeam(_teamNames[i]);
|
||||
if (team == null)
|
||||
|
@ -91,41 +91,14 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
UtilServer.getServer().getPluginManager().callEvent(new StatChangeEvent(player.getName(), statName, newValue - value, newValue));
|
||||
|
||||
// Verify stat is in our local cache, if not add it remotely.
|
||||
if (!_stats.containsKey(statName))
|
||||
registerNewStat(statName, new Runnable()
|
||||
{
|
||||
runAsync(new Runnable()
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
synchronized (_statSync)
|
||||
{
|
||||
// If many players come in for a new stat, when the first add finishes the others are queued to add again
|
||||
// This makes a second check for the stat name (already added before lock was released)
|
||||
// Then it pops into queue and forgets adding the new stat to db.
|
||||
if (_stats.containsKey(statName))
|
||||
{
|
||||
addToQueue(statName, player, value);
|
||||
return;
|
||||
}
|
||||
|
||||
_repository.addStat(statName);
|
||||
|
||||
_stats.clear();
|
||||
|
||||
for (Stat stat : _repository.retrieveStats())
|
||||
{
|
||||
_stats.put(stat.Name, stat.Id);
|
||||
}
|
||||
|
||||
addToQueue(statName, player, value);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
addToQueue(statName, player, value);
|
||||
}
|
||||
addToQueue(statName, player, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addToQueue(String statName, Player player, long value)
|
||||
@ -192,23 +165,51 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
|
||||
public boolean incrementStat(final int accountId, final String statName, final long value)
|
||||
{
|
||||
if (_stats.containsKey(statName))
|
||||
return false;
|
||||
|
||||
final NautHashMap<Integer, NautHashMap<Integer, Long>> uploadQueue = new NautHashMap<Integer, NautHashMap<Integer, Long>>();
|
||||
uploadQueue.put(accountId, new NautHashMap<Integer, Long>());
|
||||
uploadQueue.get(accountId).put(_stats.get(statName), value);
|
||||
|
||||
runAsync(new Runnable()
|
||||
// This will register a new stat if we don't have one, otherwise it will just run the callback
|
||||
registerNewStat(statName, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final NautHashMap<Integer, NautHashMap<Integer, Long>> uploadQueue = new NautHashMap<Integer, NautHashMap<Integer, Long>>();
|
||||
uploadQueue.put(accountId, new NautHashMap<Integer, Long>());
|
||||
uploadQueue.get(accountId).put(_stats.get(statName), value);
|
||||
|
||||
_repository.saveStats(uploadQueue);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void registerNewStat(final String statName, final Runnable callback)
|
||||
{
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
synchronized (_statSync)
|
||||
{
|
||||
if (_stats.containsKey(statName))
|
||||
{
|
||||
if (callback != null) callback.run();
|
||||
return;
|
||||
}
|
||||
|
||||
_repository.addStat(statName);
|
||||
|
||||
_stats.clear();
|
||||
|
||||
for (Stat stat : _repository.retrieveStats())
|
||||
{
|
||||
_stats.put(stat.Name, stat.Id);
|
||||
}
|
||||
|
||||
if (callback != null) callback.run();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public int getStatId(String statName)
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||
|
||||
public class Clans extends JavaPlugin
|
||||
{
|
||||
public static final String VERSION = "0.16";
|
||||
public static final String VERSION = "0.17b";
|
||||
private String WEB_CONFIG = "webServer";
|
||||
|
||||
// Modules
|
||||
|
@ -462,7 +462,7 @@ public class ClanInfo
|
||||
|
||||
public boolean isOnline()
|
||||
{
|
||||
return isOnlineNow() || System.currentTimeMillis() - _lastOnline.getTime() < Clans.getOnlineTime();
|
||||
return isOnlineNow();// || System.currentTimeMillis() - _lastOnline.getTime() < Clans.getOnlineTime();
|
||||
}
|
||||
|
||||
public String getProtected()
|
||||
|
@ -17,13 +17,15 @@ import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.game.clans.clans.event.ClanCreatedEvent;
|
||||
import mineplex.game.clans.clans.event.ClanDeleteEvent;
|
||||
import mineplex.game.clans.clans.event.ClanJoinEvent;
|
||||
import mineplex.game.clans.clans.event.ClanLeaveEvent;
|
||||
import mineplex.game.clans.clans.event.ClanSetHomeEvent;
|
||||
import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
|
||||
import mineplex.game.clans.clans.tntGenerator.TntGenerator;
|
||||
import mineplex.game.clans.core.war.ClanWarData;
|
||||
import mineplex.game.clans.core.repository.ClanRepository;
|
||||
import mineplex.game.clans.core.repository.ClanTerritory;
|
||||
import mineplex.game.clans.core.repository.tokens.ClanToken;
|
||||
import mineplex.game.clans.core.war.ClanWarData;
|
||||
|
||||
public class ClansDataAccessLayer
|
||||
{
|
||||
@ -201,6 +203,15 @@ public class ClansDataAccessLayer
|
||||
|
||||
public void join(final ClanInfo clan, final Player player, final ClanRole role, final Callback<Boolean> callback)
|
||||
{
|
||||
ClanJoinEvent event = new ClanJoinEvent(clan, player);
|
||||
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
@ -259,6 +270,15 @@ public class ClansDataAccessLayer
|
||||
{
|
||||
if (clan == null) return;
|
||||
|
||||
ClanLeaveEvent event = new ClanLeaveEvent(clan, clansPlayer);
|
||||
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
@ -636,6 +656,10 @@ public class ClansDataAccessLayer
|
||||
{
|
||||
final Timestamp currentTime = new Timestamp(System.currentTimeMillis());
|
||||
final ClanWarData war = new ClanWarData(clanA.getName(), clanB.getName(), score, currentTime, currentTime, 0);
|
||||
|
||||
// Memory
|
||||
clanA.addWar(war);
|
||||
clanB.addWar(war);
|
||||
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
@ -649,10 +673,6 @@ public class ClansDataAccessLayer
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
// Memory
|
||||
clanA.addWar(war);
|
||||
clanB.addWar(war);
|
||||
|
||||
_manager.log("Initiator war for [" + clanA.getName() + "] against [" + clanB.getName() + "].");
|
||||
|
||||
if (warCallback != null) warCallback.run(war);
|
||||
|
@ -66,6 +66,7 @@ import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClanTips.TipType;
|
||||
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||
import mineplex.game.clans.clans.claimview.ClaimVisualizer;
|
||||
import mineplex.game.clans.clans.commands.ClanManagementCommand;
|
||||
import mineplex.game.clans.clans.commands.ClansAllyChatCommand;
|
||||
import mineplex.game.clans.clans.commands.ClansChatCommand;
|
||||
@ -304,6 +305,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
loadClan(token);
|
||||
}
|
||||
|
||||
// new ClaimVisualizer(plugin, this);
|
||||
|
||||
// RedisDataRepository(ConnectionData writeConn, ConnectionData
|
||||
// readConn, Region region, Class<T> elementType, String elementLabel)
|
||||
// Initialize default region factions and territory
|
||||
@ -672,7 +675,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
if (clan == null)
|
||||
{
|
||||
event.setFormat(rank + C.cYellow + "%1$s " + C.cWhite + "%2$s");
|
||||
System.out.println(_clientManager.Get(event.getPlayer()).GetRank().name() + " " + event.getPlayer().getName() + " " + (event.getPlayer().getGameMode().equals(GameMode.CREATIVE) ? C.cRed + "Creative " : " ") + event.getMessage());
|
||||
System.out.println(_clientManager.Get(event.getPlayer()).GetRank().name() + " " + event.getPlayer().getName() + " " + event.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -692,7 +695,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
String message = event.getMessage();
|
||||
message = _chat.getFilteredMessage(event.getPlayer(), message);
|
||||
ClanRelation rel = _clanUtility.rel(clan, otherClan);
|
||||
String formatted = rank + rel.getColor(true) + clan.getName() + " " + rel.getColor(false) + event.getPlayer().getName() + " " + (event.getPlayer().getGameMode().equals(GameMode.CREATIVE) ? C.cRed + "Creative " : " ") + C.cWhite + message;
|
||||
String formatted = rank + rel.getColor(true) + clan.getName() + " " + rel.getColor(false) + event.getPlayer().getName() + " " + C.cWhite + message;
|
||||
other.sendMessage(formatted);
|
||||
}
|
||||
}
|
||||
|
@ -717,11 +717,11 @@ public class ClansUtility
|
||||
return false;
|
||||
}
|
||||
|
||||
// if (clan.getEnergy() == 0)
|
||||
// {
|
||||
// Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must purchase energy at a shop before you can claim land."));
|
||||
// return false;
|
||||
// }
|
||||
if (clan.getEnergy() == 0)
|
||||
{
|
||||
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must purchase energy at a shop before you can claim land."));
|
||||
return false;
|
||||
}
|
||||
|
||||
String chunk = UtilWorld.chunkToStr(caller.getLocation().getChunk());
|
||||
ClanInfo ownerClan = getOwner(caller.getLocation());
|
||||
@ -740,11 +740,11 @@ public class ClansUtility
|
||||
}
|
||||
}
|
||||
|
||||
// if (clan.getClaims() >= clan.getClaimsMax())
|
||||
// {
|
||||
// Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan cannot claim more Territory."));
|
||||
// return false;
|
||||
// }
|
||||
if (clan.getClaims() >= clan.getClaimsMax())
|
||||
{
|
||||
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan cannot claim more Territory."));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Adjacent
|
||||
boolean selfAdj = false;
|
||||
@ -1084,7 +1084,7 @@ public class ClansUtility
|
||||
}
|
||||
|
||||
// Event
|
||||
PlayerUnClaimTerritoryEvent event = new PlayerUnClaimTerritoryEvent(caller, caller.getLocation().getChunk());
|
||||
PlayerUnClaimTerritoryEvent event = new PlayerUnClaimTerritoryEvent(caller, caller.getLocation().getChunk(), ownerClan);
|
||||
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
|
@ -0,0 +1,351 @@
|
||||
package mineplex.game.clans.clans.claimview;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.claimview.commands.ClaimVisualizeCommand;
|
||||
import mineplex.game.clans.clans.event.ClanDisbandedEvent;
|
||||
import mineplex.game.clans.clans.event.ClanLeaveEvent;
|
||||
import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent;
|
||||
import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent;
|
||||
import net.minecraft.server.v1_8_R3.EnumDirection;
|
||||
|
||||
public class ClaimVisualizer extends MiniPlugin
|
||||
{
|
||||
private ClansManager _clansManager;
|
||||
|
||||
private List<String> _visualizing;
|
||||
|
||||
private NautHashMap<ClanInfo, NautHashMap<String, VisualizedChunkData>> _calculated;
|
||||
|
||||
public ClaimVisualizer(JavaPlugin plugin, ClansManager clansManager)
|
||||
{
|
||||
super("Claim Visualizer", plugin);
|
||||
|
||||
_clansManager = clansManager;
|
||||
_visualizing = new ArrayList<>();
|
||||
_calculated = new NautHashMap<>();
|
||||
|
||||
for (ClanInfo clan : _clansManager.getClanMap().values())
|
||||
{
|
||||
_calculated.put(clan, new NautHashMap<String, VisualizedChunkData>());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new ClaimVisualizeCommand(this));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SLOWER)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_calculated.clear();
|
||||
for (ClanInfo clan : _clansManager.getClanMap().values())
|
||||
{
|
||||
_calculated.put(clan, new NautHashMap<String, VisualizedChunkData>());
|
||||
|
||||
for (String serialized : clan.getClaimSet())
|
||||
{
|
||||
calculate(clan, serialized);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void runVisualization(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (String name : _visualizing)
|
||||
{
|
||||
Player player = Bukkit.getPlayer(name);
|
||||
|
||||
if (player != null && _clansManager.isInClan(player))
|
||||
{
|
||||
visualize(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void visualize(Player player)
|
||||
{
|
||||
for (String serialized : _clansManager.getClan(player).getClaimSet())
|
||||
{
|
||||
if (!_calculated.get(_clansManager.getClan(player)).containsKey(serialized))
|
||||
{
|
||||
calculate(_clansManager.getClan(player), serialized);
|
||||
}
|
||||
}
|
||||
|
||||
draw(player, _calculated.get(_clansManager.getClan(player)).values());
|
||||
}
|
||||
|
||||
private void draw(Player player, Collection<VisualizedChunkData> chunks)
|
||||
{
|
||||
for (VisualizedChunkData chunk : chunks)
|
||||
{
|
||||
if (!chunk.getChunk().getWorld().equals(player.getWorld()))
|
||||
{
|
||||
// return not break because a clan can't have claims in different worlds.
|
||||
return;
|
||||
}
|
||||
|
||||
if (UtilMath.offset2d(chunk.getChunk().getBlock(0, 0, 0).getLocation(), player.getLocation()) > 36)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
for (int x = 0; x < 16; x++)
|
||||
{
|
||||
for (int z = 0; z < 16; z++)
|
||||
{
|
||||
if (chunk.shouldDisplayEdge(x, z) && (z == 0 || z == 15 || x == 0 || x == 15))
|
||||
{
|
||||
Block block = chunk.getChunk().getBlock(x, 0, z);
|
||||
|
||||
UtilParticle.PlayParticle(ParticleType.RED_DUST,
|
||||
new Location(
|
||||
chunk.getChunk().getWorld(),
|
||||
block.getX() + .5,
|
||||
UtilBlock.getHighest(player.getWorld(), block.getX(), block.getZ()).getY() + .5,
|
||||
block.getZ() + .5),
|
||||
new Vector(0f, 0f, 0f), 0f, 1, ViewDist.NORMAL, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void calculate(ClanInfo clan, String serialized)
|
||||
{
|
||||
Chunk chunk = UtilWorld.strToChunk(serialized);
|
||||
|
||||
List<EnumDirection> dirs = new ArrayList<>();
|
||||
|
||||
if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() - 1))))
|
||||
{
|
||||
dirs.add(EnumDirection.NORTH);
|
||||
}
|
||||
|
||||
if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() + 1, chunk.getZ()))))
|
||||
{
|
||||
dirs.add(EnumDirection.EAST);
|
||||
}
|
||||
|
||||
if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() + 1))))
|
||||
{
|
||||
dirs.add(EnumDirection.SOUTH);
|
||||
}
|
||||
|
||||
if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() - 1, chunk.getZ()))))
|
||||
{
|
||||
dirs.add(EnumDirection.WEST);
|
||||
}
|
||||
|
||||
VisualizedChunkData cached = new VisualizedChunkData(chunk, dirs);
|
||||
|
||||
_calculated.get(clan).put(serialized, cached);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event)
|
||||
{
|
||||
if (isVisualizing(event.getPlayer()))
|
||||
{
|
||||
disableVisualizer(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onKick(PlayerKickEvent event)
|
||||
{
|
||||
if (isVisualizing(event.getPlayer()))
|
||||
{
|
||||
disableVisualizer(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLeave(ClanLeaveEvent event)
|
||||
{
|
||||
if (isVisualizing(event.getPlayer().getPlayerName()))
|
||||
{
|
||||
disableVisualizer(event.getPlayer().getPlayerName());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClanDisband(ClanDisbandedEvent event)
|
||||
{
|
||||
for (Player player : event.getClan().getOnlinePlayers())
|
||||
{
|
||||
if (isVisualizing(player))
|
||||
{
|
||||
disableVisualizer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(ClanInfo clan)
|
||||
{
|
||||
_calculated.clear();
|
||||
|
||||
for (String serialized : clan.getClaimSet())
|
||||
{
|
||||
calculate(clan, serialized);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUnclaim(PlayerUnClaimTerritoryEvent event)
|
||||
{
|
||||
if (event.getClan().getClaimCount() == 1)
|
||||
{
|
||||
for (Player player : event.getClan().getOnlinePlayers())
|
||||
{
|
||||
if (isVisualizing(player))
|
||||
{
|
||||
disableVisualizer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isVisualizing(Player player)
|
||||
{
|
||||
return _visualizing.contains(player.getName());
|
||||
}
|
||||
|
||||
public boolean isVisualizing(String name)
|
||||
{
|
||||
return _visualizing.contains(name);
|
||||
}
|
||||
|
||||
public void enableVisualizer(String name)
|
||||
{
|
||||
enableVisualizer(UtilServer.getServer().getPlayer(name));
|
||||
}
|
||||
|
||||
public void disableVisualizer(String name)
|
||||
{
|
||||
disableVisualizer(UtilServer.getServer().getPlayer(name));
|
||||
}
|
||||
|
||||
public void toggleVisualizer(Player player)
|
||||
{
|
||||
if (_visualizing.contains(player.getName()))
|
||||
{
|
||||
disableVisualizer(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
enableVisualizer(player);
|
||||
}
|
||||
}
|
||||
|
||||
public void enableVisualizer(Player player)
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_clansManager.isInClan(player))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Clans", "You must be in a clan to visualize claims."));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanInfo clan = _clansManager.getClan(player);
|
||||
|
||||
if (clan.getClaimCount() == 0)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Clans", "Your Clan does not have any claims!"));
|
||||
return;
|
||||
}
|
||||
|
||||
_visualizing.add(player.getName());
|
||||
UtilPlayer.message(player, F.main("Clans", "You are now visualizing your claims."));
|
||||
|
||||
for (VisualizedChunkData chunk : _calculated.get(clan).values())
|
||||
{
|
||||
if (!chunk.getChunk().getWorld().equals(player.getWorld()))
|
||||
{
|
||||
// return not break because a clan can't have claims in different worlds.
|
||||
return;
|
||||
}
|
||||
|
||||
if (UtilMath.offset2d(chunk.getChunk().getBlock(0, 0, 0).getLocation(), player.getLocation()) > 36)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
for (int x = 0; x < 16; x++)
|
||||
{
|
||||
for (int z = 0; z < 16; z++)
|
||||
{
|
||||
if (chunk.shouldDisplayEdge(x, z) && (z == 0 || z == 15 || x == 0 || x == 15))
|
||||
{
|
||||
Block block = chunk.getChunk().getBlock(x, 0, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void disableVisualizer(Player player)
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_visualizing.contains(player.getName()))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Clans", "You are anot visualizing your claims."));
|
||||
return;
|
||||
}
|
||||
|
||||
_visualizing.remove(player.getName());
|
||||
UtilPlayer.message(player, F.main("Clans", "You are no longer visualizing your claims."));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package mineplex.game.clans.clans.claimview;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EnumDirection;
|
||||
|
||||
public class VisualizedChunkData
|
||||
{
|
||||
private List<EnumDirection> _displayableEdges;
|
||||
private Chunk _chunk;
|
||||
|
||||
public long _start;
|
||||
|
||||
public VisualizedChunkData(Chunk chunk, List<EnumDirection> dir)
|
||||
{
|
||||
_chunk = chunk;
|
||||
_displayableEdges = dir;
|
||||
_start = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public double getLife()
|
||||
{
|
||||
return (double) (System.currentTimeMillis() - _start);
|
||||
}
|
||||
|
||||
public boolean shouldDisplayEdge(int x, int z)
|
||||
{
|
||||
if (z == 15 && !_displayableEdges.contains(EnumDirection.SOUTH))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (x == 15 && !_displayableEdges.contains(EnumDirection.EAST))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (x == 0 && !_displayableEdges.contains(EnumDirection.WEST))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (z == 0 && !_displayableEdges.contains(EnumDirection.NORTH))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Chunk getChunk()
|
||||
{
|
||||
return _chunk;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package mineplex.game.clans.clans.claimview.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.game.clans.clans.claimview.ClaimVisualizer;
|
||||
|
||||
public class ClaimVisualizeCommand extends CommandBase<ClaimVisualizer>
|
||||
{
|
||||
public ClaimVisualizeCommand(ClaimVisualizer plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "showclaims");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
Plugin.toggleVisualizer(caller);
|
||||
}
|
||||
|
||||
}
|
@ -38,7 +38,6 @@ import mineplex.game.clans.items.legendaries.WindBlade;
|
||||
|
||||
public class ClanManagementCommand extends CommandBase<ClansManager>
|
||||
{
|
||||
|
||||
private ClansManager _clansManager;
|
||||
|
||||
public ClanManagementCommand(ClansManager plugin)
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.game.clans.clans.commands;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@ -24,6 +25,7 @@ import mineplex.game.clans.clans.ClanTips.TipType;
|
||||
import mineplex.game.clans.clans.ClansBlacklist;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.ClientClan;
|
||||
import mineplex.game.clans.clans.event.ClanJoinEvent;
|
||||
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
|
||||
import mineplex.game.clans.tutorials.Tutorial;
|
||||
import mineplex.game.clans.tutorials.TutorialManager;
|
||||
@ -382,6 +384,10 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "The clan " + F.elem("Clan " + clan.getName()) + " is full and cannot be joined!"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanJoinEvent event = new ClanJoinEvent(clan, caller);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
// Task
|
||||
Plugin.getClanDataAccess().join(clan, caller, ClanRole.RECRUIT, new Callback<Boolean>()
|
||||
|
@ -6,6 +6,8 @@ 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;
|
||||
import mineplex.core.task.TaskManager;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.tutorials.Tutorial;
|
||||
@ -22,6 +24,12 @@ public class RestartTutCommand extends CommandBase<TutorialManager>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (ClansManager.getInstance().getClan(caller) != null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Tutorial", "You cannot restart the tutorial while in a clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()) != null
|
||||
&& ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()).isSafe(caller.getLocation()))
|
||||
{
|
||||
@ -43,7 +51,7 @@ public class RestartTutCommand extends CommandBase<TutorialManager>
|
||||
}
|
||||
else
|
||||
{
|
||||
TutorialManager.Instance.sendTutorialMsg(caller, "You must be in a safezone to restart the tutorial.");
|
||||
TutorialManager.Instance.sendTutorialMsg(caller, F.main("Clans", "You must be in a Safe Zone to restart the tutorial."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,56 @@
|
||||
package mineplex.game.clans.clans.event;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClansPlayer;
|
||||
|
||||
public class ClanLeaveEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private ClansPlayer _player;
|
||||
|
||||
private ClanInfo _clan;
|
||||
|
||||
private boolean _cancelled;
|
||||
|
||||
public ClanLeaveEvent(ClanInfo clan, ClansPlayer clansPlayer)
|
||||
{
|
||||
_player = clansPlayer;
|
||||
|
||||
_clan = clan;
|
||||
}
|
||||
|
||||
public ClansPlayer getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public ClanInfo getClan()
|
||||
{
|
||||
return _clan;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled)
|
||||
{
|
||||
_cancelled = cancelled;
|
||||
}
|
||||
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return _cancelled;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
@ -5,19 +5,23 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
|
||||
public class PlayerUnClaimTerritoryEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Player _unClaimer;
|
||||
private Chunk _unClaimedChunk;
|
||||
private ClanInfo _clan;
|
||||
|
||||
private boolean _cancelled;
|
||||
|
||||
public PlayerUnClaimTerritoryEvent(Player unClaimer, Chunk unClaimedChunk)
|
||||
public PlayerUnClaimTerritoryEvent(Player unClaimer, Chunk unClaimedChunk, ClanInfo clan)
|
||||
{
|
||||
_unClaimer = unClaimer;
|
||||
_unClaimedChunk = unClaimedChunk;
|
||||
_clan = clan;
|
||||
}
|
||||
|
||||
public Player getUnClaimer()
|
||||
@ -35,6 +39,11 @@ public class PlayerUnClaimTerritoryEvent extends Event
|
||||
_cancelled = cancelled;
|
||||
}
|
||||
|
||||
public ClanInfo getClan()
|
||||
{
|
||||
return _clan;
|
||||
}
|
||||
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return _cancelled;
|
||||
|
@ -42,19 +42,17 @@ public class ClansScoreboardManager extends ScoreboardManager
|
||||
|
||||
private void init(TutorialManager tutorialManager)
|
||||
{
|
||||
setTitle(" MINEPLEX CLANS ");
|
||||
setTitle("Clans Alpha " + Clans.VERSION);
|
||||
|
||||
ScoreboardData data = getData("default", true);
|
||||
|
||||
data.write(C.cGreen + "Clans Alpha " + Clans.VERSION);
|
||||
data.writeEmpty();
|
||||
data.writeElement(new ScoreboardElementClan(_clansManager));
|
||||
data.writeElement(new ScoreboardElementPlayer(_clansManager));
|
||||
data.writeElement(new ScoreboardElementPlayerCount(_clansManager));
|
||||
|
||||
data.writeElement(_worldEvent);
|
||||
// data.writeElement(new ScoreboardElementPlayerCount(_clansManager));
|
||||
|
||||
data.writeElement(_warManager);
|
||||
|
||||
data.writeElement(_worldEvent);
|
||||
|
||||
for (Tutorial tutorial : tutorialManager.getTutorials().values())
|
||||
{
|
||||
data.writeElement(tutorial);
|
||||
|
@ -35,8 +35,7 @@ public class ScoreboardElementClan implements ScoreboardElement
|
||||
|
||||
// Energy
|
||||
if (clanInfo.getEnergyCostPerMinute() > 0)
|
||||
output.add(C.cYellow + "Energy " + C.cWhite + UtilTime.convertString((clanInfo.getEnergy() / clanInfo.getEnergyCostPerMinute()) * 60000L, 1, UtilTime.TimeUnit.FIT));
|
||||
output.add(C.cYellow + "Home " + C.cWhite + clanInfo.getBedStatusStr());
|
||||
output.add(C.cYellow + "Energy " + C.cWhite + UtilTime.convertString((clanInfo.getEnergy() / clanInfo.getEnergyCostPerMinute()) * 60000L, 1, UtilTime.TimeUnit.FIT));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -27,10 +27,9 @@ public class ScoreboardElementPlayer implements ScoreboardElement
|
||||
{
|
||||
List<String> output = new ArrayList<String>();
|
||||
output.add(C.cYellow + "Gold " + C.cWhite + manager.getDonation().Get(player).GetBalance(CurrencyType.Gold) + "");
|
||||
output.add("");
|
||||
|
||||
String regionString = C.xWilderness + "Wilderness";
|
||||
|
||||
output.add(" ");
|
||||
ClanTerritory claim = _clansManager.getClanUtility().getClaim(player.getLocation());
|
||||
if (claim != null)
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ public class ScoreboardElementPlayerCount implements ScoreboardElement
|
||||
List<String> output = new ArrayList<String>();
|
||||
|
||||
output.add("");
|
||||
output.add(C.cYellow + "Players Online " + UtilServer.getPlayers().length + "/100");
|
||||
output.add(C.cYellow + "Players " + C.cWhite + UtilServer.getPlayers().length + "/100");
|
||||
|
||||
return output;
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
|
||||
{
|
||||
for (WarInvasion invasion : invasions)
|
||||
{
|
||||
if (invasion.getInvaderClan().equals(playerClan))
|
||||
if (invasion.getInvaderClan().equals(playerClan.getName()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -125,15 +125,24 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
|
||||
final ClanInfo killerClan = event.getKiller().getClan();
|
||||
|
||||
ClanWarData war = clan.getWarData(killerClan);
|
||||
if (war != null && !war.isOnCooldown())
|
||||
if (war != null)
|
||||
{
|
||||
if (war.isOnCooldown())
|
||||
{
|
||||
// Ignore!
|
||||
return;
|
||||
}
|
||||
|
||||
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_RIP, event.getPlayer().getPlayer());
|
||||
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_NOOICE, event.getKiller().getPlayer());
|
||||
|
||||
// War already exists
|
||||
war.increment(killerClan.getName());
|
||||
ClansUtility.ClanRelation rel = _clansManager.getClanUtility().rel(clan, killerClan);
|
||||
_clansManager.messageClan(killerClan, F.main("Clans", "Your clan gained 1 War Point against " + rel.getColor(false) +
|
||||
clan.getName() + " " + C.Reset + "(" + killerClan.getFormattedWarPoints(clan) + C.Reset + ")"));
|
||||
_clansManager.messageClan(clan, F.main("Clans", "Your clan lost 1 War Point against " + rel.getColor(false) +
|
||||
killerClan.getName() + " " + C.Reset + "(" + clan.getFormattedWarPoints(killerClan) + C.Reset + ")"));
|
||||
war.increment(killerClan.getName());
|
||||
checkWarComplete(war);
|
||||
|
||||
ClanInfo clanA = clan.getName().equals(war.getClanA()) ? clan : killerClan;
|
||||
@ -142,9 +151,6 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
|
||||
|
||||
_clansManager.getScoreboard().refresh(killerClan);
|
||||
_clansManager.getScoreboard().refresh(clan);
|
||||
|
||||
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_RIP, event.getPlayer().getPlayer());
|
||||
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_NOOICE, event.getKiller().getPlayer());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -155,14 +161,13 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
|
||||
public void run(ClanWarData data)
|
||||
{
|
||||
ClansUtility.ClanRelation rel = _clansManager.getClanUtility().rel(clan, killerClan);
|
||||
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_RIP, event.getPlayer().getPlayer());
|
||||
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_NOOICE, event.getKiller().getPlayer());
|
||||
_clansManager.messageClan(killerClan, F.main("Clans", "Your clan gained 1 War Point against " + rel.getColor(false) + clan.getName()));
|
||||
_clansManager.messageClan(clan, F.main("Clans", "Your clan lost 1 War Point against " + rel.getColor(false) + killerClan.getName()));
|
||||
|
||||
_clansManager.getScoreboard().refresh(killerClan);
|
||||
_clansManager.getScoreboard().refresh(clan);
|
||||
|
||||
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_RIP, event.getPlayer().getPlayer());
|
||||
_clansManager.ClanTips.displayTip(TipType.DOMINANCE_NOOICE, event.getKiller().getPlayer());
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -271,7 +276,7 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
|
||||
@EventHandler
|
||||
public void onInvasionEnd(WarInvasionEndEvent event)
|
||||
{
|
||||
Bukkit.broadcastMessage(F.main("War", F.elem(event.getWarInvasion().getInvaderClan()) + "'s invasion against " + F.elem(event.getWarInvasion().getInvaderClan() + " has ended.")));
|
||||
Bukkit.broadcastMessage(F.main("War", F.elem(event.getWarInvasion().getInvaderClan()) + "'s invasion against " + F.elem(event.getWarInvasion().getInvadedClan()) + " has ended."));
|
||||
|
||||
}
|
||||
|
||||
@ -301,13 +306,14 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
|
||||
|
||||
if (clan != null)
|
||||
{
|
||||
List<WarInvasion> invadedList = _invadedMap.get(clan);
|
||||
List<WarInvasion> invaderList = _invaderMap.get(clan);
|
||||
List<WarInvasion> invadedList = _invadedMap.get(clan.getName());
|
||||
List<WarInvasion> invaderList = _invaderMap.get(clan.getName());
|
||||
|
||||
if (invaderList != null && !invaderList.isEmpty())
|
||||
{
|
||||
for (WarInvasion invasion : invaderList)
|
||||
{
|
||||
element.add(" ");
|
||||
element.add(C.cPurpleB + "Invading");
|
||||
element.add(" " + invasion.getInvadedClan());
|
||||
element.add(" " + UtilTime.convertString(invasion.getTimeLeft(), 1, UtilTime.TimeUnit.FIT));
|
||||
@ -318,6 +324,7 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
|
||||
{
|
||||
for (WarInvasion invasion : invadedList)
|
||||
{
|
||||
element.add(" ");
|
||||
element.add(C.cRedB + "Invaded");
|
||||
element.add(" " + invasion.getInvaderClan());
|
||||
element.add(" " + UtilTime.convertString(invasion.getTimeLeft(), 1, UtilTime.TimeUnit.FIT));
|
||||
|
@ -35,6 +35,7 @@ public class HeavyArrowsAttribute extends ItemAttribute
|
||||
@Override
|
||||
public void onAttack(CustomDamageEvent event)
|
||||
{
|
||||
event.AddKnockback("HeavyAttribute", _knockbackPercent);
|
||||
double knockback = (_knockbackPercent / 100d) * 6;
|
||||
event.AddKnockback("Heavy Attribute", knockback);
|
||||
}
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ public class Spawn extends MiniPlugin
|
||||
|
||||
if (isInSpawn(player))
|
||||
{
|
||||
UtilPlayer.message(event.GetPlayer(), F.main("Safe Zone", "You cannot use " + F.skill(event.GetSkillName() + " in " + F.elem("Safe Zone") + ".")));
|
||||
UtilPlayer.message(event.GetPlayer(), F.main("Safe Zone", "You cannot use " + F.skill(event.GetSkillName()) + " in " + F.elem("Safe Zone") + "."));
|
||||
event.SetCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import java.util.Map;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -19,6 +20,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.jsonchat.ClickEvent;
|
||||
@ -27,6 +29,8 @@ import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
@ -40,6 +44,7 @@ import mineplex.core.task.TaskManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.event.ClanJoinEvent;
|
||||
import mineplex.game.clans.clans.event.ClanTipEvent;
|
||||
import mineplex.game.clans.economy.GoldManager;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
|
||||
@ -59,6 +64,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
public static String SKIPPED_TASK = "tatatatata%sSkip";
|
||||
|
||||
public static String AllowedMessage = C.cGold + "TutorialAllowedMessage" + C.Reset;
|
||||
public static String AllowedBypass = C.cBlue + "Tutorial>";
|
||||
|
||||
protected final TutorialManager _manager;
|
||||
protected final GoldManager _goldManager;
|
||||
@ -66,7 +72,8 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
protected final TaskManager _taskManager;
|
||||
protected final DonationManager _donationManager;
|
||||
|
||||
protected final LinkedHashMap<Integer, TutorialTask<?>> _tasks;
|
||||
// protected final LinkedHashMap<Integer, TutorialTask<?>> _tasks;
|
||||
private final ArrayList<TutorialTask<?>> _tasks;
|
||||
protected final LinkedHashMap<String, TutorialTask<?>> _nameToTask;
|
||||
protected final LinkedHashMap<String, TutorialClient> _inTutorial;
|
||||
|
||||
@ -89,7 +96,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
_donationManager = donationManager;
|
||||
_taskManager = taskManager;
|
||||
_manager = manager;
|
||||
_tasks = new LinkedHashMap<>();
|
||||
_tasks = new ArrayList<TutorialTask<?>>();
|
||||
_inTutorial = new LinkedHashMap<>();
|
||||
_nameToTask = new LinkedHashMap<>();
|
||||
|
||||
@ -122,7 +129,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
|
||||
lines.add(C.cAqua + "Tutorial");
|
||||
|
||||
for (final TutorialTask<?> task : _tasks.values())
|
||||
for (final TutorialTask<?> task : _tasks)
|
||||
{
|
||||
if (get(player).CurrentTask.equals(task))
|
||||
{
|
||||
@ -142,10 +149,15 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
public TutorialTask<?> getTask(int index)
|
||||
{
|
||||
return _tasks.get(index);
|
||||
}
|
||||
|
||||
protected void addTask(TutorialTask<?> task)
|
||||
{
|
||||
_tasks.put(_tasks.size() + 1, task);
|
||||
_tasks.add(task);
|
||||
_nameToTask.put(task.getTechnicalName(), task);
|
||||
}
|
||||
|
||||
@ -158,6 +170,11 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
|
||||
return get(player).CurrentTask.getID() < task.getID();
|
||||
}
|
||||
|
||||
private TutorialTask<?> getLastTask()
|
||||
{
|
||||
return _tasks.get(_tasks.size() - 1);
|
||||
}
|
||||
|
||||
protected void finishTask(final Player player, final TutorialTask<?> task)
|
||||
{
|
||||
@ -175,8 +192,10 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
final TutorialTask<?> lastTask = getLastTask();
|
||||
// Cycle to next task, or null if last task.
|
||||
get(player).CurrentTask = task.equals(_tasks.get(_tasks.size())) ? null : _tasks.get(task.getID() + 1);
|
||||
get(player).CurrentTask = task.equals(lastTask) ? null : _tasks.get(task.getDataId() + 1);
|
||||
System.out.println("Next Task: " + get(player).CurrentTask);
|
||||
|
||||
if (!_taskManager.hasCompletedTask(player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName())))
|
||||
{
|
||||
@ -185,7 +204,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
public void run(final Boolean completed)
|
||||
{
|
||||
// If last task, end tutorial.
|
||||
if (task.equals(_tasks.get(_tasks.size())))
|
||||
if (task.equals(lastTask))
|
||||
{
|
||||
finishFor(player);
|
||||
}
|
||||
@ -196,7 +215,9 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
System.out.println("STARTING NEXT TASK!");
|
||||
get(player).CurrentTask.startFor(player);
|
||||
get(player).CurrentTaskStartTime = System.currentTimeMillis();
|
||||
}
|
||||
}, 30L);
|
||||
}
|
||||
@ -252,23 +273,22 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
|
||||
private void finishFor(final Player player)
|
||||
{
|
||||
if (player.getOpenInventory() != null)
|
||||
{
|
||||
_inTutorial.get(player.getName()).QueuedFinish = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// if (player.getOpenInventory() != null)
|
||||
// {
|
||||
// _inTutorial.get(player.getName()).QueuedFinish = true;
|
||||
// return;
|
||||
// }
|
||||
_manager.finishTutorial(player);
|
||||
_inTutorial.remove(player.getName());
|
||||
|
||||
UtilTextMiddle.display(C.cWhite + "Clans Tutorial", C.cGreen + "You have completed the Clans Tutorial!", 20, 20 * 3, 20);
|
||||
onFinished(player);
|
||||
|
||||
_manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
// Custom Finish Method (usually messages)
|
||||
onFinished(player);
|
||||
|
||||
UtilTextMiddle.display(C.cWhite + "Clans Tutorial", C.cGreen + "You have completed the Clans Tutorial!", 20, 20 * 3, 20, player);
|
||||
onFinishedDelay(player);
|
||||
|
||||
// Do Reward
|
||||
if (!_taskManager.hasCompletedTask(player, String.format(TUTORIAL_REWARD_TASK, _technicalName)))
|
||||
{
|
||||
@ -305,6 +325,25 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
}
|
||||
}, player, String.format(TUTORIAL_REWARD_TASK, _technicalName));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilInv.remove(player, Material.IRON_AXE, (byte) 0, 1);
|
||||
|
||||
UtilInv.remove(player, Material.IRON_HELMET, (byte) 0, 1);
|
||||
UtilInv.remove(player, Material.IRON_CHESTPLATE, (byte) 0, 1);
|
||||
UtilInv.remove(player, Material.IRON_LEGGINGS, (byte) 0, 1);
|
||||
UtilInv.remove(player, Material.IRON_BOOTS, (byte) 0, 1);
|
||||
|
||||
ItemStack[] armor = player.getInventory().getArmorContents();
|
||||
for (int i = 0 ; i < armor.length; i++)
|
||||
{
|
||||
if (UtilItem.isIronProduct(armor[i]))
|
||||
{
|
||||
armor[i] = null;
|
||||
}
|
||||
}
|
||||
player.getInventory().setArmorContents(armor);
|
||||
}
|
||||
|
||||
_manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable()
|
||||
{
|
||||
@ -340,13 +379,17 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
}
|
||||
}, 20 * 2);
|
||||
}
|
||||
}, 20 * 4);
|
||||
}, 20 * 2);
|
||||
}
|
||||
|
||||
// Implementation left to sub classes.
|
||||
protected void onFinished(final Player player)
|
||||
{
|
||||
}
|
||||
|
||||
protected void onFinishedDelay(final Player player)
|
||||
{
|
||||
}
|
||||
|
||||
// Implementation left to sub classes.
|
||||
protected void onBegin(final Player player)
|
||||
@ -357,7 +400,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
{
|
||||
if (!_manager.isInTutorial(player))
|
||||
{
|
||||
_manager._playerTutorials.put(player.getName(), this);
|
||||
_manager.setTutorial(player, this);
|
||||
}
|
||||
|
||||
_inTutorial.put(player.getName(), new TutorialClient(player, this));
|
||||
@ -380,8 +423,12 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
|
||||
public void cancelFor(final Player player)
|
||||
{
|
||||
get(player).CurrentTask.cleanup(player);
|
||||
get(player).CurrentTaskStartTime = -1;
|
||||
_inTutorial.remove(player.getName());
|
||||
|
||||
_manager.finishTutorial(player);
|
||||
|
||||
if (_ghostMode)
|
||||
{
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
@ -402,11 +449,6 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
return _inTutorial.containsKey(player);
|
||||
}
|
||||
|
||||
public Map<Integer, TutorialTask<?>> getTasks()
|
||||
{
|
||||
return _tasks;
|
||||
}
|
||||
|
||||
public boolean hasCompleted(final Player player)
|
||||
{
|
||||
return _taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName));
|
||||
@ -419,9 +461,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
|
||||
public void skip(final Player player)
|
||||
{
|
||||
new JsonMessage(
|
||||
AllowedMessage
|
||||
)
|
||||
new JsonMessage("")
|
||||
.extra(
|
||||
F.main(
|
||||
"Tutorial",
|
||||
@ -435,9 +475,11 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
.color("yellow")
|
||||
.extra("!")
|
||||
.color("gray")
|
||||
|
||||
.sendToPlayer(player);
|
||||
|
||||
new JsonMessage(
|
||||
new JsonMessage("")
|
||||
.extra(
|
||||
F.main(
|
||||
"Tutorial",
|
||||
"Click "
|
||||
@ -506,7 +548,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
}
|
||||
}
|
||||
|
||||
get(player).CurrentTask.trySendDescription(player);
|
||||
get(player).CurrentTask.trySendDescription(player, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -532,6 +574,15 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
evt.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoinClan(ClanJoinEvent event)
|
||||
{
|
||||
if (isInTutorial(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(final PlayerJoinEvent evt)
|
||||
{
|
||||
@ -552,9 +603,15 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
|
||||
public void cleanup(Player player)
|
||||
{
|
||||
if (get(player) != null && get(player).CurrentTask != null)
|
||||
System.out.println("Cleaning up Player in " + getClass().getName());
|
||||
|
||||
if (get(player) != null && get(player).CurrentTask != null)
|
||||
{
|
||||
System.out.println("Cleaning up current task: " + get(player).CurrentTask.getClass().getName());
|
||||
get(player).CurrentTask.cleanup(player);
|
||||
|
||||
}
|
||||
|
||||
System.out.println("removing from in tutorial");
|
||||
_inTutorial.remove(player.getName());
|
||||
}
|
||||
}
|
||||
|
@ -11,15 +11,18 @@ public class TutorialClient
|
||||
public long LastDescriptionSentTime = System.currentTimeMillis() - 3000;
|
||||
public boolean InClanOnStart;
|
||||
public boolean QueuedFinish;
|
||||
public long CurrentTaskStartTime;
|
||||
|
||||
public TutorialClient(Player player, Tutorial tutorial)
|
||||
{
|
||||
Player = player;
|
||||
|
||||
CurrentTask = tutorial._tasks.get(1);
|
||||
CurrentTask = tutorial.getTask(0);
|
||||
CurrentTaskStartTime = System.currentTimeMillis();
|
||||
|
||||
InClanOnStart = tutorial._clansManager.isInClan(player);
|
||||
|
||||
|
||||
/*
|
||||
for (TutorialTask<?> task : tutorial._tasks.values())
|
||||
{
|
||||
if (TaskManager.Instance.hasCompletedTask(player, String.format(
|
||||
@ -34,5 +37,6 @@ public class TutorialClient
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import mineplex.game.clans.tutorials.commands.DoSkipTutorialCommand;
|
||||
import mineplex.game.clans.tutorials.commands.SkipTutorialCommand;
|
||||
import mineplex.game.clans.tutorials.gettingstarted.TutorialGettingStarted;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.minecraft.server.v1_8_R3.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
|
||||
|
||||
public class TutorialManager extends MiniPlugin
|
||||
@ -32,7 +33,7 @@ public class TutorialManager extends MiniPlugin
|
||||
public static TutorialManager Instance;
|
||||
|
||||
private final Map<Class<? extends Tutorial>, Tutorial> _tutorials = new HashMap<>();
|
||||
protected final Map<String, Tutorial> _playerTutorials = new HashMap<>();
|
||||
private final Map<String, Tutorial> _playerTutorials = new HashMap<>();
|
||||
|
||||
private final TaskManager _taskManager;
|
||||
|
||||
@ -64,7 +65,7 @@ public class TutorialManager extends MiniPlugin
|
||||
{
|
||||
chat.a.a().remove(0);
|
||||
}
|
||||
else
|
||||
else if (!chat.a.a().get(0).c().contains(Tutorial.AllowedBypass))
|
||||
{
|
||||
if (isInTutorial(packet.getPlayer()))
|
||||
{
|
||||
@ -138,10 +139,13 @@ public class TutorialManager extends MiniPlugin
|
||||
@EventHandler
|
||||
public void quit(PlayerQuitEvent event)
|
||||
{
|
||||
System.out.println("Player Quit. In Tutorial: " + isInTutorial(event.getPlayer()));
|
||||
|
||||
if (!isInTutorial(event.getPlayer()))
|
||||
return;
|
||||
|
||||
getTutorial(event.getPlayer()).cleanup(event.getPlayer());
|
||||
_playerTutorials.remove(event.getPlayer().getName());
|
||||
}
|
||||
|
||||
public void sendTutorialMsg(Player player, String message)
|
||||
@ -156,6 +160,16 @@ public class TutorialManager extends MiniPlugin
|
||||
sendTutorialMsg(player, message);
|
||||
}
|
||||
}
|
||||
|
||||
public void finishTutorial(Player player)
|
||||
{
|
||||
_playerTutorials.remove(player.getName());
|
||||
}
|
||||
|
||||
public void setTutorial(Player player, Tutorial tutorial)
|
||||
{
|
||||
_playerTutorials.put(player.getName(), tutorial);
|
||||
}
|
||||
|
||||
public Tutorial getTutorial(final Player player)
|
||||
{
|
||||
@ -171,4 +185,72 @@ public class TutorialManager extends MiniPlugin
|
||||
{
|
||||
return _taskManager;
|
||||
}
|
||||
|
||||
// Stolen from UtilTabTitle
|
||||
private static class TextConverter
|
||||
{
|
||||
public static String convert(String text)
|
||||
{
|
||||
if (text == null || text.length() == 0)
|
||||
{
|
||||
return "\"\"";
|
||||
}
|
||||
|
||||
char c;
|
||||
int i;
|
||||
int len = text.length();
|
||||
StringBuilder sb = new StringBuilder(len + 4);
|
||||
String t;
|
||||
sb.append('"');
|
||||
|
||||
for (i = 0; i < len; i += 1)
|
||||
{
|
||||
c = text.charAt(i);
|
||||
switch (c)
|
||||
{
|
||||
case '\\':
|
||||
case '"':
|
||||
sb.append('\\');
|
||||
sb.append(c);
|
||||
break;
|
||||
case '/':
|
||||
sb.append('\\');
|
||||
sb.append(c);
|
||||
break;
|
||||
case '\b':
|
||||
sb.append("\\b");
|
||||
break;
|
||||
case '\t':
|
||||
sb.append("\\t");
|
||||
break;
|
||||
case '\n':
|
||||
sb.append("\\n");
|
||||
break;
|
||||
case '\f':
|
||||
sb.append("\\f");
|
||||
break;
|
||||
case '\r':
|
||||
sb.append("\\r");
|
||||
break;
|
||||
default:
|
||||
if (c < ' ')
|
||||
{
|
||||
t = "000" + Integer.toHexString(c);
|
||||
sb.append("\\u").append(t.substring(t.length() - 4));
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
sb.append('"');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String setPlayerName(Player player, String text)
|
||||
{
|
||||
return text.replaceAll("(?i)\\{PLAYER\\}", player.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,21 @@
|
||||
package mineplex.game.clans.tutorials;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.NautArrayList;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
|
||||
public class TutorialTask<T extends Tutorial> implements Listener
|
||||
@ -22,6 +30,8 @@ public class TutorialTask<T extends Tutorial> implements Listener
|
||||
protected String _description;
|
||||
protected String _finishMessage;
|
||||
|
||||
protected String[] _subtasks;
|
||||
|
||||
protected Location _taskPos;
|
||||
|
||||
// How much time after the beginning the task/last teleport it should take to teleport back to _taskPos.
|
||||
@ -29,7 +39,6 @@ public class TutorialTask<T extends Tutorial> implements Listener
|
||||
|
||||
protected long _descriptionWaitTime = 30000;
|
||||
|
||||
protected NautArrayList<String> _playersFinished = new NautArrayList<>();
|
||||
protected NautArrayList<String> _inTask = new NautArrayList<>();
|
||||
|
||||
private long _lastTaskTp;
|
||||
@ -55,7 +64,7 @@ public class TutorialTask<T extends Tutorial> implements Listener
|
||||
{
|
||||
_inTask.add(player.getName());
|
||||
|
||||
trySendDescription(player);
|
||||
trySendDescription(player, true);
|
||||
|
||||
customStartFor(player);
|
||||
|
||||
@ -92,12 +101,41 @@ public class TutorialTask<T extends Tutorial> implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
//@EventHandler
|
||||
//todo: fix the multiline subtitles
|
||||
public void displaySubtasks(UpdateEvent event)
|
||||
{
|
||||
if (!event.getType().equals(UpdateType.SEC))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_subtasks == null || _subtasks.length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator<String> iterator = _inTask.iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Player player = Bukkit.getPlayer(iterator.next());
|
||||
|
||||
if ((System.currentTimeMillis() - _tutorial.get(player).CurrentTaskStartTime) >= 15000)
|
||||
{
|
||||
if (isDoing(player))
|
||||
{
|
||||
UtilTextMiddle.display("", UtilText.arrayToString(_subtasks, "\n"), 1, 25, 25, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDoing(Player player)
|
||||
{
|
||||
return _inTask != null && player != null && _inTask.contains(player.getName());
|
||||
}
|
||||
|
||||
public void trySendDescription(Player player)
|
||||
public void trySendDescription(Player player, boolean force)
|
||||
{
|
||||
if (!_tutorial.isInTutorial(player))
|
||||
{
|
||||
@ -111,19 +149,24 @@ public class TutorialTask<T extends Tutorial> implements Listener
|
||||
return;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() - client.LastDescriptionSentTime > client.CurrentTask.getDescriptionWaitTime())
|
||||
if (force || System.currentTimeMillis() - client.LastDescriptionSentTime > client.CurrentTask.getDescriptionWaitTime())
|
||||
{
|
||||
String description = _description;
|
||||
ClanInfo clan = getClans().getClan(player);
|
||||
if (clan != null) description = description.replace("(clan)", clan.getName());
|
||||
description = description.replace("{", C.cAqua).replace("}", C.cWhite);
|
||||
|
||||
_tutorial._manager.sendTutorialMsg(player, " ");
|
||||
_tutorial._manager.sendTutorialMsg(player, " ");
|
||||
_tutorial._manager.sendTutorialMsg(player, " ");
|
||||
_tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
|
||||
_tutorial._manager.sendTutorialMsg(player, " ");
|
||||
_tutorial._manager.sendTutorialMsg(player, C.cYellowB + "Part " + _id + ": " + _displayName);
|
||||
_tutorial._manager.sendTutorialMsg(player, C.cWhite + " " + _description.replace("{", C.cAqua).replace("}", C.cWhite));
|
||||
_tutorial._manager.sendTutorialMsg(player, C.cYellowB + "Part " + (_id + 1) + ": " + _displayName);
|
||||
_tutorial._manager.sendTutorialMsg(player, C.cWhite + " " + description);
|
||||
_tutorial._manager.sendTutorialMsg(player, " ");
|
||||
_tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
|
||||
|
||||
UtilTextMiddle.display("", getDisplayName());
|
||||
UtilTextMiddle.display("", getDisplayName(), player);
|
||||
|
||||
client.LastDescriptionSentTime = System.currentTimeMillis();
|
||||
}
|
||||
@ -169,30 +212,39 @@ public class TutorialTask<T extends Tutorial> implements Listener
|
||||
{
|
||||
return _tutorial._clansManager;
|
||||
}
|
||||
|
||||
public int getID()
|
||||
|
||||
public int getDataId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public int getID()
|
||||
{
|
||||
return _id + 1;
|
||||
}
|
||||
|
||||
public void finishFor(Player player)
|
||||
{
|
||||
customEndFor(player);
|
||||
cleanup(player);
|
||||
_tutorial.finishTask(player, this);
|
||||
}
|
||||
|
||||
public void visibleFinish(Player player)
|
||||
{
|
||||
_inTask.remove(player.getName());
|
||||
|
||||
if (_finishMessage != null)
|
||||
{
|
||||
String finishMessage = _finishMessage;
|
||||
ClanInfo clan = getClans().getClan(player);
|
||||
if (clan != null) finishMessage = finishMessage.replace("(clan)", clan.getName());
|
||||
finishMessage = finishMessage.replace("{", C.cAqua).replace("}", C.cWhite);
|
||||
|
||||
_tutorial._manager.sendTutorialMsg(player, " ");
|
||||
_tutorial._manager.sendTutorialMsg(player, " ");
|
||||
_tutorial._manager.sendTutorialMsg(player, " ");
|
||||
_tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
|
||||
_tutorial._manager.sendTutorialMsg(player, " ");
|
||||
_tutorial._manager.sendTutorialMsg(player, C.cWhite + _finishMessage.replace("{", C.cAqua).replace("}", C.cWhite));
|
||||
_tutorial._manager.sendTutorialMsg(player, C.cWhite + finishMessage);
|
||||
_tutorial._manager.sendTutorialMsg(player, " ");
|
||||
_tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
|
||||
}
|
||||
@ -201,7 +253,6 @@ public class TutorialTask<T extends Tutorial> implements Listener
|
||||
public void cleanup(Player player)
|
||||
{
|
||||
_inTask.remove(player.getName());
|
||||
_playersFinished.remove(player.getName());
|
||||
}
|
||||
|
||||
public long getDescriptionWaitTime()
|
||||
|
@ -21,7 +21,7 @@ public class TaskClaim extends TutorialTask<TutorialGettingStarted>
|
||||
+ "Once claimed, only your Clan can break/place blocks here. "
|
||||
+ "This is the perfect place to build a base and stash your items! "
|
||||
+ "You can only claim in the Wilderness, and not next to other Clan's Territory. "
|
||||
+ "To claim some territory, go into the Clans GUI by typing {/c} and {Left-Clicking}";
|
||||
+ "To claim some territory, go into the Clans GUI by typing {/c} and {Left-Clicking} the Territory button. (Looks like a flag)";
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
|
@ -48,7 +48,14 @@ public class TaskCustomizeClass extends TutorialTask<TutorialGettingStarted>
|
||||
if (clientclass != null && clientclass.GetSavingCustomBuild() != null && clientclass.GetSavingCustomBuild().AxeSkill != null)
|
||||
{
|
||||
finishFor(player);
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup(Player player)
|
||||
{
|
||||
// handled in onUpdate
|
||||
}
|
||||
}
|
||||
|
@ -25,18 +25,6 @@ public class TaskDisbandClan extends TutorialTask<TutorialGettingStarted>
|
||||
@Override
|
||||
public void customStartFor(final Player player)
|
||||
{
|
||||
if (_tutorial.get(player).InClanOnStart)
|
||||
{
|
||||
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getManager().getPlugin(), new Runnable(){
|
||||
public void run()
|
||||
{
|
||||
if (isDoing(player))
|
||||
{
|
||||
finishFor(player);
|
||||
}
|
||||
}
|
||||
}, 6 * 20);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -46,6 +34,8 @@ public class TaskDisbandClan extends TutorialTask<TutorialGettingStarted>
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println("COMPLETE DISBAND CLAN!");
|
||||
|
||||
finishFor(event.getDisbander());
|
||||
}
|
||||
|
@ -29,6 +29,12 @@ public class TaskEquipClass extends TutorialTask<TutorialGettingStarted>
|
||||
+ "Purchase Iron Armor from the PvP Shop. "
|
||||
+ "Then put on your armor to equip the Knight Class.";
|
||||
|
||||
// _subtasks = new String[] {
|
||||
// "Open the PvP Shop",
|
||||
// "Buy Iron Armor Set",
|
||||
// "Equip Iron Armor"
|
||||
// };
|
||||
|
||||
_taskPos = new Location(Spawn.getSpawnWorld(), 19, 66, -305.844, -100f, 0f);
|
||||
}
|
||||
|
||||
@ -56,6 +62,11 @@ public class TaskEquipClass extends TutorialTask<TutorialGettingStarted>
|
||||
public void customStartFor(Player player)
|
||||
{
|
||||
_bought.put(player.getName(), new NautArrayList<Material>());
|
||||
|
||||
if (getClans().getClassManager().Get(player).GetGameClass() != null)
|
||||
{
|
||||
finishFor(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -57,12 +57,19 @@ public class TaskExploreShops extends TutorialTask<TutorialGettingStarted>
|
||||
if (ClansManager.getInstance().getClan(event.getPlayer()).getEnergyPurchasable() == 0)
|
||||
{
|
||||
finishFor(event.getPlayer());
|
||||
_inTask.remove(event.getPlayer().getName());
|
||||
return;
|
||||
}
|
||||
|
||||
event.setFree(true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void cleanup(Player player)
|
||||
{
|
||||
// handled in on update
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
@ -78,6 +85,7 @@ public class TaskExploreShops extends TutorialTask<TutorialGettingStarted>
|
||||
if (ClansManager.getInstance().getClan(player).getEnergy() == ClansManager.getInstance().getClan(player).getEnergyMax())
|
||||
{
|
||||
finishFor(player);
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.tutorials.TutorialTask;
|
||||
@ -31,6 +33,7 @@ public class TaskLeaveSpawn extends TutorialTask<TutorialGettingStarted>
|
||||
if (player.getLocation().getY() < 100)
|
||||
{
|
||||
finishFor(player);
|
||||
_inTask.remove(player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,12 +48,20 @@ public class TaskLeaveSpawn extends TutorialTask<TutorialGettingStarted>
|
||||
Iterator<String> iterator = _inTask.iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Player player = Bukkit.getPlayer(iterator.next());
|
||||
String playerName = iterator.next();
|
||||
Player player = UtilPlayer.searchExact(playerName);
|
||||
|
||||
if (player.getLocation().getY() < 100 && getClans().getClanUtility().getClaim(player.getLocation()) == null)
|
||||
if (player != null && player.getLocation().getY() < 100 && getClans().getClanUtility().getClaim(player.getLocation()) == null)
|
||||
{
|
||||
finishFor(player);
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup(Player player)
|
||||
{
|
||||
// We handle this in update() to avoid ConcurrentModificationException
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class TaskMakingMoney extends TutorialTask<TutorialGettingStarted>
|
||||
@Override
|
||||
public void customStartFor(Player player)
|
||||
{
|
||||
player.getInventory().addItem(new ItemStack(Material.CARROT, 1));
|
||||
player.getInventory().addItem(new ItemStack(Material.CARROT_ITEM, 1));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -45,7 +45,7 @@ public class TaskMakingMoney extends TutorialTask<TutorialGettingStarted>
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.getItem().getType().equals(Material.CARROT))
|
||||
if (!event.getItem().getType().equals(Material.CARROT_ITEM))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -61,15 +61,12 @@ public class TaskMakingMoney extends TutorialTask<TutorialGettingStarted>
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ClansManager.getInstance().isInClan(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.getItem().getType().equals(Material.CARROT_ITEM))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println("FINISH CARROT");
|
||||
|
||||
finishFor(event.getPlayer());
|
||||
}
|
||||
|
@ -9,14 +9,18 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.CraftingInventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.NautArrayList;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.task.TaskManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
@ -49,7 +53,6 @@ public class TaskUseAbility extends TutorialTask<TutorialGettingStarted>
|
||||
public void customStartFor(Player player)
|
||||
{
|
||||
_bought.put(player.getName(), new NautArrayList<Material>());
|
||||
_teleported.put(player.getName(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -70,7 +73,7 @@ public class TaskUseAbility extends TutorialTask<TutorialGettingStarted>
|
||||
{
|
||||
Player _player = Bukkit.getPlayer(iterator.next());
|
||||
|
||||
if (!_teleported.get(_player.getName()) && _player != null && _player.isOnline() && _player.getOpenInventory().getType() == InventoryType.CRAFTING)
|
||||
if (!_teleported.containsKey(_player.getName()) && _player != null && _player.isOnline() && _player.getOpenInventory().getType() == InventoryType.CRAFTING)
|
||||
{
|
||||
_player.teleport(new Location(Spawn.getSpawnWorld(), 19, 66, -305.844, -100f, 0f));
|
||||
_teleported.put(_player.getName(), true);
|
||||
@ -78,6 +81,7 @@ public class TaskUseAbility extends TutorialTask<TutorialGettingStarted>
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@EventHandler
|
||||
public void onAbilityUesd(SkillTriggerEvent event)
|
||||
{
|
||||
@ -88,6 +92,25 @@ public class TaskUseAbility extends TutorialTask<TutorialGettingStarted>
|
||||
|
||||
finishFor(event.GetPlayer());
|
||||
}
|
||||
*/
|
||||
|
||||
@EventHandler
|
||||
public void onRightClick(PlayerInteractEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!isDoing(player))
|
||||
return;
|
||||
|
||||
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
ItemStack item = player.getItemInHand();
|
||||
if (item != null && item.getType() == Material.IRON_AXE)
|
||||
{
|
||||
finishFor(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void button(ClansShopAddButtonEvent event)
|
||||
|
@ -16,7 +16,7 @@ public class TaskViewClanDetails extends TutorialTask<TutorialGettingStarted>
|
||||
_technicalName = "CommandClanX";
|
||||
|
||||
_description = "Now you can view information about your clan. "
|
||||
+ "To do this type {/c [clan name]}! "
|
||||
+ "To do this type {/c (clan)}! "
|
||||
+ "You can also use any clan's name to get some information about them as well.";
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ public class TutorialGettingStarted extends Tutorial
|
||||
|
||||
// addTask(new TaskWelcome(this, 1));
|
||||
|
||||
int id = 0;
|
||||
int id = -1;
|
||||
addTask(new TaskCreateClan(this, ++id));
|
||||
addTask(new TaskViewClanDetails(this, ++id));
|
||||
addTask(new TaskLeaveSpawn(this, ++id));
|
||||
@ -49,6 +49,13 @@ public class TutorialGettingStarted extends Tutorial
|
||||
|
||||
@Override
|
||||
public void onFinished(final Player player)
|
||||
{
|
||||
player.resetPlayerTime();
|
||||
player.teleport(Spawn.getEastSpawn());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishedDelay(Player player)
|
||||
{
|
||||
_manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
|
||||
_manager.sendTutorialMsg(player, C.cYellowB + "CONGRATULATIONS");
|
||||
@ -56,11 +63,8 @@ public class TutorialGettingStarted extends Tutorial
|
||||
_manager.sendTutorialMsg(player, C.cWhite + "You have completed the Clans basic tutorial and have been awarded " + C.cAqua + "30,000 Gold");
|
||||
_manager.sendTutorialMsg(player, C.cWhite + "You can now begin your adventure, but do take a moment to read the signs around spawn for more information!");
|
||||
_manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
|
||||
|
||||
player.resetPlayerTime();
|
||||
player.teleport(Spawn.getEastSpawn());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBegin(final Player player)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user