Merge branch 'clans/beta' of https://github.com/Mineplex-LLC/Minecraft-PC into clans/beta
Conflicts: Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/AttackEnemyObjective.java
This commit is contained in:
commit
66a18dcc87
@ -12,11 +12,13 @@ public class DataLocationMap
|
||||
{
|
||||
private EnumMap<DyeColor, List<Location>> _goldDataMap;
|
||||
private EnumMap<DyeColor, List<Location>> _ironDataMap;
|
||||
private EnumMap<DyeColor, List<Location>> _spongeDataMap;
|
||||
|
||||
public DataLocationMap()
|
||||
{
|
||||
_goldDataMap = new EnumMap<>(DyeColor.class);
|
||||
_ironDataMap = new EnumMap<>(DyeColor.class);
|
||||
_spongeDataMap = new EnumMap<>(DyeColor.class);
|
||||
}
|
||||
|
||||
public List<Location> getGoldLocations(DyeColor color)
|
||||
@ -59,5 +61,23 @@ public class DataLocationMap
|
||||
}
|
||||
}
|
||||
|
||||
public void addSpongeLocation(DyeColor color, Location location) {
|
||||
if (_spongeDataMap.containsKey(color))
|
||||
{
|
||||
_spongeDataMap.get(color).add(location);
|
||||
}
|
||||
else
|
||||
{
|
||||
List<Location> list = new ArrayList<>();
|
||||
list.add(location);
|
||||
_spongeDataMap.put(color, list);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Location> getSpongeLocations(DyeColor color)
|
||||
{
|
||||
List<Location> list = _spongeDataMap.get(color);
|
||||
return list == null ? Collections.emptyList() : list;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -59,6 +59,11 @@ public class Schematic
|
||||
if (addDataWool(locationMap, false, originLocation, x, y - 1, z))
|
||||
continue;
|
||||
}
|
||||
else if (materialId == Material.SPONGE.getId())
|
||||
{
|
||||
if (addSpongeLocation(locationMap, originLocation, x, y + 1, z))
|
||||
continue;
|
||||
}
|
||||
else if (materialId == 35)
|
||||
{
|
||||
// Check if this is a dataloc so we can skip setting the block
|
||||
@ -68,7 +73,14 @@ public class Schematic
|
||||
if (Math.abs(_blocks[aboveIndex]) == Material.GOLD_PLATE.getId() || Math.abs(_blocks[aboveIndex]) == Material.IRON_PLATE.getId())
|
||||
continue;
|
||||
}
|
||||
int belowIndex = getIndex(x, y - 1, z);
|
||||
if (hasIndex(belowIndex))
|
||||
{
|
||||
if(Math.abs(_blocks[belowIndex]) == Material.SPONGE.getId())
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UtilBlock.setQuick(originLocation.getWorld(), startX + x, startY + y, startZ + z, materialId, _blockData[index]);
|
||||
}
|
||||
@ -110,6 +122,26 @@ public class Schematic
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean addSpongeLocation(DataLocationMap map, Location origin, int x, int y, int z)
|
||||
{
|
||||
int index = getIndex(x, y, z);
|
||||
if (hasIndex(index))
|
||||
{
|
||||
int materialId = Math.abs(_blocks[index]);
|
||||
if (materialId == 35) // WOOL
|
||||
{
|
||||
byte data = _blockData[index];
|
||||
DyeColor color = DyeColor.getByWoolData(data);
|
||||
if (color != null)
|
||||
{
|
||||
map.addSpongeLocation(color, origin.clone().add(x, y - 1, z));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getSize()
|
||||
{
|
||||
return _blocks.length;
|
||||
|
@ -74,10 +74,10 @@ public class UtilFirework
|
||||
|
||||
public static void packetPlayFirework(Player player, Location loc, Type type, Color color, boolean flicker, boolean trail)
|
||||
{
|
||||
Firework firework = (Firework) loc.getWorld().spawn(loc, Firework.class);
|
||||
Firework firework = loc.getWorld().spawn(loc, Firework.class);
|
||||
FireworkEffect effect = FireworkEffect.builder().flicker(flicker).withColor(color).with(type).trail(trail).build();
|
||||
|
||||
FireworkMeta data = (FireworkMeta) firework.getFireworkMeta();
|
||||
FireworkMeta data = firework.getFireworkMeta();
|
||||
data.clearEffects();
|
||||
data.setPower(1);
|
||||
data.addEffect(effect);
|
||||
@ -98,4 +98,14 @@ public class UtilFirework
|
||||
UtilPlayer.sendPacket(viewing, packet);
|
||||
}
|
||||
}
|
||||
|
||||
public static void spawnRandomFirework(Location location)
|
||||
{
|
||||
playFirework(location,
|
||||
Type.values()[UtilMath.r(Type.values().length)],
|
||||
Color.fromRGB(UtilMath.r(256), UtilMath.r(256), UtilMath.r(256)),
|
||||
UtilMath.random.nextBoolean(),
|
||||
UtilMath.random.nextBoolean()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -375,6 +375,7 @@ public class CoreClientManager extends MiniPlugin
|
||||
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName()));
|
||||
|
@ -33,6 +33,7 @@ import mineplex.core.donation.GiveDonorData;
|
||||
import mineplex.core.facebook.FacebookManager;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.inventory.ClientItem;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.npc.Npc;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
@ -474,6 +475,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
{
|
||||
if (timeTillRankBonus(player) > 0)
|
||||
result.run(false);
|
||||
|
||||
getRepository().attemptRankBonus(player, new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
@ -734,31 +736,35 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
|
||||
if (oldChests > 0)
|
||||
{
|
||||
_inventoryManager.addItemToInventory(player, TreasureType.OLD.getItemName(), oldChests);
|
||||
//_inventoryManager.addItemToInventory(player, TreasureType.OLD.getItemName(), oldChests);
|
||||
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(oldChests + " Old Chests")));
|
||||
_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.OLD.getItemName()), mythicalChests));
|
||||
}
|
||||
|
||||
if (ancientChests > 0)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(ancientChests + " Ancient Chests")));
|
||||
_inventoryManager.addItemToInventory(player, TreasureType.ANCIENT.getItemName(), ancientChests);
|
||||
//_inventoryManager.addItemToInventory(player, TreasureType.ANCIENT.getItemName(), ancientChests);
|
||||
_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.ANCIENT.getItemName()), mythicalChests));
|
||||
}
|
||||
|
||||
if (mythicalChests > 0)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(mythicalChests + " Mythical Chests")));
|
||||
_inventoryManager.addItemToInventory(player, TreasureType.MYTHICAL.getItemName(), mythicalChests);
|
||||
//_inventoryManager.addItemToInventory(player, TreasureType.MYTHICAL.getItemName(), mythicalChests);
|
||||
_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.MYTHICAL.getItemName()), mythicalChests));
|
||||
}
|
||||
|
||||
if (gems > 0)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(gems + " Gems")));
|
||||
_gemQueue.add(new GiveDonorData(null, player.getName(), "Treasure", player.getUniqueId(), coreClient.getAccountId(), gems));
|
||||
//_gemQueue.add(new GiveDonorData(null, player.getName(), "Treasure", player.getUniqueId(), coreClient.getAccountId(), gems));
|
||||
}
|
||||
|
||||
if (gold > 0)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(gold + " Gold")));
|
||||
/*
|
||||
_donationManager.rewardGold(new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
@ -773,12 +779,13 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
}
|
||||
}
|
||||
}, "Earned", player.getName(), coreClient.getAccountId(), gold, true);
|
||||
*/
|
||||
}
|
||||
|
||||
if (coins > 0)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(coins + " Treasure Shards")));
|
||||
_coinQueue.add(new GiveDonorData(null, player.getName(), "Treasure", player.getUniqueId(), coreClient.getAccountId(), coins));
|
||||
//_coinQueue.add(new GiveDonorData(null, player.getName(), "Treasure", player.getUniqueId(), coreClient.getAccountId(), coins));
|
||||
}
|
||||
|
||||
if (tickets > 0)
|
||||
|
@ -259,42 +259,48 @@ public class BonusRepository extends MinecraftRepository
|
||||
|
||||
public void attemptRankBonus(final Player player, final Callback<Boolean> result)
|
||||
{
|
||||
if (!Recharge.Instance.usable(player, "AttemptRankBonus")) {
|
||||
if (!Recharge.Instance.usable(player, "AttemptRankBonus"))
|
||||
{
|
||||
result.run(false);
|
||||
return;
|
||||
}
|
||||
|
||||
final int accountId = _manager.getClientManager().Get(player).getAccountId();
|
||||
final int coins = _manager.getRankBonusAmount(player).getCoins();
|
||||
final int gems = _manager.getRankBonusAmount(player).getGems();
|
||||
final int mythicalChestChange = _manager.getRankBonusAmount(player).getMythicalChests();
|
||||
|
||||
if (!_manager.getRankBonusAmount(player).isGreaterThanZero()) {
|
||||
if (!_manager.getRankBonusAmount(player).isGreaterThanZero())
|
||||
{
|
||||
result.run(false);
|
||||
return;
|
||||
}
|
||||
|
||||
final JavaPlugin plug = _manager.getPlugin();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plug, new Runnable() {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plug, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
|
||||
try (Connection connection = getConnection();
|
||||
CallableStatement callableStatement = connection.prepareCall("{call check_rank(?, ?, ?, ?, ?)}")) {
|
||||
CallableStatement callableStatement = connection.prepareCall("{call rankBonus(?, ?, ?, ?, ?, ?)}"))
|
||||
{
|
||||
callableStatement.setInt(1, accountId);
|
||||
callableStatement.setInt(2, coins);
|
||||
callableStatement.setInt(3, 0);
|
||||
callableStatement.registerOutParameter(4, java.sql.Types.BOOLEAN);
|
||||
callableStatement.registerOutParameter(5, java.sql.Types.DATE);
|
||||
callableStatement.setInt(3, gems);
|
||||
callableStatement.setInt(4, mythicalChestChange);
|
||||
callableStatement.registerOutParameter(5, java.sql.Types.BOOLEAN);
|
||||
callableStatement.registerOutParameter(6, java.sql.Types.DATE);
|
||||
|
||||
callableStatement.executeUpdate();
|
||||
|
||||
final boolean pass = callableStatement.getBoolean(4);
|
||||
final boolean pass = callableStatement.getBoolean(5);
|
||||
|
||||
final Date date = callableStatement.getDate(5);
|
||||
|
||||
Bukkit.getScheduler().runTask(plug, new Runnable() {
|
||||
final Date date = callableStatement.getDate(6);
|
||||
|
||||
Bukkit.getScheduler().runTask(plug, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
@ -311,9 +317,12 @@ public class BonusRepository extends MinecraftRepository
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Recharge.Instance.use(player, "AttemptRankBonus", 1000 * 30, false, false);
|
||||
e.printStackTrace();
|
||||
System.out.println("Error : " + e.getMessage());
|
||||
result.run(false);
|
||||
}
|
||||
}
|
||||
|
@ -466,7 +466,6 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
|
||||
if (!adminMessage)
|
||||
{
|
||||
|
||||
for (FriendStatus friendInfo : friends.getFriends())
|
||||
{
|
||||
|
||||
@ -549,51 +548,60 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
// If this is a admin message, or the sender isn't muted/ignoring the target
|
||||
if (adminMessage || canSenderMessageThem(sender, playerTarget))
|
||||
{
|
||||
if (IncognitoManager.Instance.getRepository().GetStatus(playerTarget))
|
||||
{
|
||||
UtilPlayer.message(sender, F.main("Online Player Search", F.elem("0") + " matches for [" + F.elem(target) + "]."));
|
||||
return;
|
||||
}
|
||||
|
||||
// Construct the command to send to redis
|
||||
RedisMessage globalMessage = new RedisMessage(_serverName,
|
||||
|
||||
sender.getName(),
|
||||
|
||||
adminMessage ? null : friend.ServerName,
|
||||
|
||||
playerTarget,
|
||||
|
||||
message,
|
||||
|
||||
// Include the sender's rank if this is a admin message. So we can format the receivers chat.
|
||||
adminMessage ? F.rank(_clientManager.Get(sender).GetRank()) : null);
|
||||
|
||||
final UUID uuid = globalMessage.getUUID();
|
||||
|
||||
// A backup for the rare case where the message fails to deliver. Server doesn't respond
|
||||
BukkitRunnable runnable = new BukkitRunnable()
|
||||
{
|
||||
public void run()
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
_messageTimeouts.remove(uuid);
|
||||
|
||||
// Inform the player that the message failed to deliver
|
||||
UtilPlayer.message(
|
||||
sender,
|
||||
F.main((adminMessage ? "Admin " : "") + "Message", C.mBody + " Failed to send message to ["
|
||||
+ C.mElem + playerTarget + C.mBody + "]."));
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (IncognitoManager.Instance.getRepository().GetStatus(playerTarget))
|
||||
{
|
||||
UtilPlayer.message(sender, F.main("Online Player Search", F.elem("0") + " matches for [" + F.elem(target) + "]."));
|
||||
return;
|
||||
}
|
||||
|
||||
runSync(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
// Construct the command to send to redis
|
||||
RedisMessage globalMessage = new RedisMessage(_serverName,
|
||||
sender.getName(),
|
||||
adminMessage ? null : friend.ServerName,
|
||||
playerTarget,
|
||||
message,
|
||||
// Include the sender's rank if this is a admin message. So we can format the receivers chat.
|
||||
adminMessage ? F.rank(_clientManager.Get(sender).GetRank()) : null);
|
||||
|
||||
final UUID uuid = globalMessage.getUUID();
|
||||
|
||||
// A backup for the rare case where the message fails to deliver. Server doesn't respond
|
||||
BukkitRunnable runnable = new BukkitRunnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_messageTimeouts.remove(uuid);
|
||||
|
||||
// Inform the player that the message failed to deliver
|
||||
UtilPlayer.message(
|
||||
sender,
|
||||
F.main((adminMessage ? "Admin " : "") + "Message", C.mBody + " Failed to send message to ["
|
||||
+ C.mElem + playerTarget + C.mBody + "]."));
|
||||
}
|
||||
};
|
||||
|
||||
// This will activate in 2 seconds
|
||||
runnable.runTaskLater(getPlugin(), 40);
|
||||
|
||||
// The key is the UUID its trading between servers
|
||||
_messageTimeouts.put(uuid, runnable);
|
||||
|
||||
// Time to send the message!
|
||||
globalMessage.publish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// This will activate in 2 seconds
|
||||
runnable.runTaskLater(getPlugin(), 40);
|
||||
|
||||
// The key is the UUID its trading between servers
|
||||
_messageTimeouts.put(uuid, runnable);
|
||||
|
||||
// Time to send the message!
|
||||
globalMessage.publish();
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ public class Clans extends JavaPlugin
|
||||
Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName());
|
||||
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());
|
||||
|
||||
new ClansBanManager(this, _clientManager, _donationManager);
|
||||
// new ClansBanManager(this, _clientManager, _donationManager);
|
||||
|
||||
PacketHandler packetHandler = new PacketHandler(this);
|
||||
Punish punish = new Punish(this, webServerAddress, _clientManager);
|
||||
@ -117,7 +117,7 @@ public class Clans extends JavaPlugin
|
||||
|
||||
IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal);
|
||||
|
||||
IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler);
|
||||
new IncognitoManager(this, _clientManager, packetHandler);
|
||||
|
||||
StatsManager statsManager = new StatsManager(this, _clientManager);
|
||||
AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager);
|
||||
@ -127,7 +127,6 @@ public class Clans extends JavaPlugin
|
||||
new MemoryFix(this);
|
||||
new FoodDupeFix(this);
|
||||
new Explosion(this, blockRestore);
|
||||
new FriendManager(this, _clientManager, preferenceManager, portal);
|
||||
new InventoryManager(this, _clientManager);
|
||||
ResourcePackManager resourcePackManager = new ResourcePackManager(this, portal);
|
||||
resourcePackManager.setResourcePack("http://garblox.com/files/b/ResClans.zip", "http://garblox.com/files/mineplex/ResClans19.zip", true);
|
||||
@ -137,7 +136,7 @@ public class Clans extends JavaPlugin
|
||||
GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager);
|
||||
|
||||
HologramManager hologram = new HologramManager(this, packetHandler);
|
||||
_clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, teleport, chat, customGear, hologram, webServerAddress);
|
||||
_clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, webServerAddress);
|
||||
new Recipes(this);
|
||||
new Farming(this);
|
||||
new BuildingShop(_clansManager, _clientManager, _donationManager);
|
||||
|
@ -785,8 +785,14 @@ public class ClansDataAccessLayer
|
||||
// Memory
|
||||
claim.Safe = !claim.Safe;
|
||||
|
||||
// Save
|
||||
_repository.updateTerritoryClaim(claim.Chunk, claim.Safe);
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
_repository.updateTerritoryClaim(claim.Chunk, claim.Safe);
|
||||
}
|
||||
});
|
||||
|
||||
// Log
|
||||
_manager.log("Safe Zone at [" + claim.Chunk + "] set to [" + claim.Safe + "] by [" + player + "].");
|
||||
@ -807,7 +813,28 @@ public class ClansDataAccessLayer
|
||||
|
||||
public void clanExists(String clanName, Callback<Boolean> callback)
|
||||
{
|
||||
_repository.clanExists(clanName, callback);
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
_repository.clanExists(clanName, new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void run(Boolean data)
|
||||
{
|
||||
runSync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (callback != null) callback.run(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public ClanRepository getRepository()
|
||||
|
@ -93,7 +93,6 @@ import mineplex.game.clans.clans.nether.NetherManager;
|
||||
import mineplex.game.clans.clans.observer.ObserverManager;
|
||||
import mineplex.game.clans.clans.playtime.Playtime;
|
||||
import mineplex.game.clans.clans.potato.PotatoManager;
|
||||
import mineplex.game.clans.clans.pvptimer.PvpTimer;
|
||||
import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler;
|
||||
import mineplex.game.clans.clans.redis.ClanLoadCommandHandler;
|
||||
import mineplex.game.clans.clans.regions.ClansRegions;
|
||||
@ -198,7 +197,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
private WarPointEvasion _warPointEvasion;
|
||||
private ObserverManager _observerManager;
|
||||
private Punish _punish;
|
||||
private PvpTimer _pvpTimer;
|
||||
|
||||
private int _inviteExpire = 2;
|
||||
private int _nameMin = 3;
|
||||
@ -224,7 +222,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
|
||||
// Spawn area
|
||||
|
||||
public ClansManager(JavaPlugin plugin, String serverName, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress)
|
||||
public ClansManager(JavaPlugin plugin, String serverName, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress)
|
||||
{
|
||||
super("Clans Manager", plugin);
|
||||
|
||||
@ -327,8 +325,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
// Register redis based server commands
|
||||
ServerCommandManager.getInstance().registerCommandType(ClanDeleteCommand.class, new ClanDeleteCommandHandler());
|
||||
ServerCommandManager.getInstance().registerCommandType(ClanLoadCommand.class, new ClanLoadCommandHandler());
|
||||
|
||||
StatsManager statsManager = new StatsManager(plugin, _clientManager);
|
||||
|
||||
AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, donationManager);
|
||||
ClassShopManager shopManager = new ClassShopManager(plugin, _classManager, skillManager, itemFactory, achievementManager, _clientManager);
|
||||
_classShop = new ClassCombatShop(shopManager, _clientManager, donationManager, true, "Class Shop");
|
||||
@ -336,7 +333,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
new ClanEnergyManager(plugin, this, clientManager, donationManager);
|
||||
|
||||
_playTracker = new Playtime(this, statsManager);
|
||||
_pvpTimer = new PvpTimer(this, statsManager);
|
||||
|
||||
_tutorialManager = new mineplex.game.clans.legacytutorial.TutorialManager(plugin, _playTracker, _goldManager, taskManager, donationManager, preferencesManager, this, packetHandler);
|
||||
|
||||
@ -597,21 +593,18 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
event.setJoinMessage(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getJoinMessage() != null)
|
||||
|
||||
event.setJoinMessage(null);
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
event.setJoinMessage(null);
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
if (_tutorialManager.isInTutorial(other))
|
||||
{
|
||||
if (_tutorialManager.isInTutorial(other))
|
||||
{
|
||||
// Don't display join message if player in tutorial.
|
||||
continue;
|
||||
}
|
||||
|
||||
other.sendMessage(F.sys("Join", event.getPlayer().getName()));
|
||||
// Don't display join message if player in tutorial.
|
||||
continue;
|
||||
}
|
||||
|
||||
other.sendMessage(F.sys("Join", event.getPlayer().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -623,21 +616,18 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
event.setQuitMessage(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getQuitMessage() != null)
|
||||
|
||||
event.setQuitMessage(null);
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
event.setQuitMessage(null);
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
if (_tutorialManager.isInTutorial(other))
|
||||
{
|
||||
if (_tutorialManager.isInTutorial(other))
|
||||
{
|
||||
// Don't display quit message if player in tutorial.
|
||||
continue;
|
||||
}
|
||||
|
||||
other.sendMessage(F.sys("Quit", event.getPlayer().getName()));
|
||||
// Don't display quit message if player in tutorial.
|
||||
continue;
|
||||
}
|
||||
|
||||
other.sendMessage(F.sys("Quit", event.getPlayer().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1326,7 +1316,10 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
return _damageManager;
|
||||
}
|
||||
|
||||
public PvpTimer getPvpTimer() { return _pvpTimer; }
|
||||
public boolean hasTimer(Player player)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public ClansBlacklist getBlacklist()
|
||||
{
|
||||
|
@ -109,10 +109,6 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
|
||||
else if (args[0].equalsIgnoreCase("unclaim") || args[0].equalsIgnoreCase("uc"))
|
||||
unclaim(caller, args);
|
||||
|
||||
else if (args[0].equalsIgnoreCase("map") || args[0].equalsIgnoreCase("m"))
|
||||
map(caller, args);
|
||||
|
||||
else if (args[0].equalsIgnoreCase("home") || args[0].equalsIgnoreCase("h"))
|
||||
home(caller, args);
|
||||
|
||||
@ -223,7 +219,6 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
UtilPlayer.message(caller, F.help("/c create <clan>", "Create new Clan", Rank.ALL));
|
||||
UtilPlayer.message(caller, F.help("/c join <clan>", "Join a Clan", Rank.ALL));
|
||||
UtilPlayer.message(caller, F.help("/c leave <clan>", "Leave your Clan", Rank.ALL));
|
||||
UtilPlayer.message(caller, F.help("/c map <toggle>", "View Clan Map", Rank.ALL));
|
||||
UtilPlayer.message(caller, F.help("/cc (Message)", "Clan Chat (Toggle)", Rank.ALL));
|
||||
|
||||
UtilPlayer.message(caller, F.help("/c stuck", "Teleports you to the nearest Wilderness location", Rank.ALL));
|
||||
|
@ -34,6 +34,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.map.MapRenderer;
|
||||
@ -624,6 +625,22 @@ public class ItemMapManager extends MiniPlugin
|
||||
// }
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldChange(PlayerTeleportEvent event)
|
||||
{
|
||||
if (event.getFrom().getWorld() != event.getTo().getWorld() && event.getTo().getWorld().equals("world"))
|
||||
{
|
||||
runSyncLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
setMap(event.getPlayer());
|
||||
}
|
||||
}, 20);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event)
|
||||
{
|
||||
@ -871,7 +888,9 @@ public class ItemMapManager extends MiniPlugin
|
||||
|
||||
public void setMap(Player player)
|
||||
{
|
||||
UtilServer.CallEvent(new PlayerGetMapEvent(player));
|
||||
PlayerGetMapEvent event = UtilServer.CallEvent(new PlayerGetMapEvent(player));
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
for (ItemStack item : UtilInv.getItems(player))
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mineplex.game.clans.clans.map;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
@ -8,6 +9,7 @@ import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClansUtility;
|
||||
import mineplex.game.clans.clans.worldevent.WorldEventManager;
|
||||
import mineplex.game.clans.tutorial.TutorialManager;
|
||||
import mineplex.game.clans.tutorial.TutorialRegion;
|
||||
import mineplex.game.clans.tutorial.TutorialType;
|
||||
import mineplex.game.clans.tutorial.map.TutorialMapManager;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
|
||||
@ -42,92 +44,19 @@ public class ItemMapRenderer extends MapRenderer
|
||||
@Override
|
||||
public void render(MapView mapView, MapCanvas canvas, Player player)
|
||||
{
|
||||
if (_tutorial.inTutorial(player))
|
||||
{
|
||||
renderTutorialMap(mapView, canvas, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
// if (_tutorial.inTutorial(player))
|
||||
// {
|
||||
// renderTutorialMap(mapView, canvas, player);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
renderNormalMap(mapView, canvas, player);
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
private void renderTutorialMap(MapView mapView, MapCanvas canvas, Player player)
|
||||
{
|
||||
TutorialMapManager tutorialMap = ((ClansMainTutorial) _tutorial.getTutorial(TutorialType.MAIN)).getMapManager();
|
||||
int zoom = tutorialMap.getScale();
|
||||
|
||||
Byte[][] map = tutorialMap.getMap(zoom);
|
||||
|
||||
int centerX = 0;
|
||||
int centerZ = 0;
|
||||
|
||||
// We have this cooldown to squeeze out every single bit of performance from the server.
|
||||
if (Recharge.Instance.use(player, "Draw Map", 4000, false, false))
|
||||
{
|
||||
for (int mapX = 0; mapX < 128; mapX++)
|
||||
{
|
||||
for (int mapZ = 0; mapZ < 128; mapZ++)
|
||||
{
|
||||
int blockX = centerX + (mapX - 64);
|
||||
int blockZ = centerZ + (mapZ - 64);
|
||||
|
||||
int pixelX = blockX + (map.length / 2);
|
||||
int pixelZ = blockZ + (map.length / 2);
|
||||
|
||||
Byte color;
|
||||
|
||||
if (!(pixelX < 0 || pixelZ < 0 || pixelX >= map.length || pixelZ >= map.length)
|
||||
&& map[pixelX][pixelZ] != null)
|
||||
{
|
||||
color = map[pixelX][pixelZ];
|
||||
|
||||
blockX *= zoom;
|
||||
blockZ *= zoom;
|
||||
}
|
||||
else
|
||||
{
|
||||
color = (byte) 0;
|
||||
}
|
||||
|
||||
/* TODO Figure out if you want to colorize this pixel
|
||||
{
|
||||
color = MapPalette.matchColor(r, g, b);
|
||||
}*/
|
||||
|
||||
canvas.setPixel(mapX, mapZ, color);
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMap(mapView);
|
||||
}
|
||||
|
||||
MapCursorCollection cursors = canvas.getCursors();
|
||||
|
||||
while (cursors.size() > 0)
|
||||
|
||||
{
|
||||
cursors.removeCursor(cursors.getCursor(0));
|
||||
}
|
||||
|
||||
Location l = player.getLocation().clone();
|
||||
l.setX((((int)l.getX()) % 1000) + (l.getX() - ((int) l.getX())));
|
||||
l.setZ((((int)l.getZ()) % 1000) + (l.getZ() - ((int) l.getZ())));
|
||||
|
||||
double mapX = (l.getX() - tutorialMap.getX()) / zoom;
|
||||
double mapZ = (l.getZ() - tutorialMap.getZ()) / zoom;
|
||||
|
||||
if (mapX > -64 && mapX < 64 && mapZ > -64 && mapZ < 64)
|
||||
{
|
||||
byte b0 = (byte) (int) Math.min(127, (double) (mapX * 2.0F) + 0.5D);
|
||||
byte b1 = (byte) (int) Math.max(-127, (double) (mapZ * 2.0F) + 0.5D);
|
||||
|
||||
byte rotation = (byte) (int) ((l.getYaw() * 16D) / 360D);
|
||||
|
||||
MapCursor cursor = new MapCursor(b0, b1, (byte) (rotation & 0xF), MapCursor.Type.WHITE_POINTER.getValue(), true);
|
||||
|
||||
cursors.addCursor(cursor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -292,7 +221,6 @@ public class ItemMapRenderer extends MapRenderer
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Inside
|
||||
else
|
||||
{
|
||||
|
@ -13,7 +13,6 @@ import mineplex.core.task.TaskManager;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.ClansPlayerStats;
|
||||
import mineplex.game.clans.clans.playtime.command.PlayTimeCommand;
|
||||
import mineplex.game.clans.clans.playtime.command.cemde;
|
||||
|
||||
public class Playtime extends MiniClientPlugin<PlayingClient>
|
||||
{
|
||||
|
@ -1,30 +0,0 @@
|
||||
package mineplex.game.clans.clans.playtime.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.game.clans.clans.ClansPlayerStats;
|
||||
import mineplex.game.clans.clans.pvptimer.PvpTimer;
|
||||
|
||||
public class cemde extends CommandBase<StatsManager>
|
||||
{
|
||||
PvpTimer _timer;
|
||||
public cemde(StatsManager plugin, PvpTimer timer)
|
||||
{
|
||||
super(plugin, Rank.SNR_MODERATOR, "rstime");
|
||||
_timer = timer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, final String[] args)
|
||||
{
|
||||
Plugin.Get(caller).setStat(ClansPlayerStats.PLAY_TIME.id(), args.length == 0 ? 0 : Integer.parseInt(args[0]));
|
||||
_timer.Get(caller).Skipped = false;
|
||||
_timer.Get(caller).InformedTimes.clear();
|
||||
|
||||
UtilPlayer.message(caller, "Reset time.");
|
||||
}
|
||||
}
|
@ -1,364 +0,0 @@
|
||||
package mineplex.game.clans.clans.pvptimer;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
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.EntityShootBowEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
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.stats.StatsManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClanTips.TipType;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.event.ClanTipEvent;
|
||||
import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent;
|
||||
import mineplex.game.clans.clans.playtime.command.cemde;
|
||||
import mineplex.game.clans.clans.pvptimer.command.PvPTimerCommand;
|
||||
import mineplex.game.clans.clans.pvptimer.repository.PvpTimerRepository;
|
||||
import mineplex.game.clans.clans.pvptimer.repository.TimerClientToken;
|
||||
import mineplex.game.clans.core.repository.ClanTerritory;
|
||||
import mineplex.game.clans.spawn.Spawn;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||
import mineplex.minecraft.game.classcombat.event.FireballHitEntityEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
public class PvpTimer extends MiniClientPlugin<PvpTimerClient>
|
||||
{
|
||||
private final int[] DISPLAY_TIMES = {
|
||||
5,
|
||||
10,
|
||||
30,
|
||||
1 * 60,
|
||||
2 * 60,
|
||||
5 * 60,
|
||||
10 * 60,
|
||||
20 * 60
|
||||
};
|
||||
|
||||
private PvpTimerRepository _repository;
|
||||
private CoreClientManager _clientManager;
|
||||
|
||||
private ClansManager _clansManager;
|
||||
|
||||
private static long TIMER_LENGTH = 30 * 60;
|
||||
|
||||
public PvpTimer(ClansManager clans, StatsManager statsManager)
|
||||
{
|
||||
super("PvP Timer", clans.getPlugin());
|
||||
_clansManager = clans;
|
||||
|
||||
_clientManager = clans.getClientManager();
|
||||
|
||||
_repository = new PvpTimerRepository(this, clans.getClientManager());
|
||||
|
||||
addCommand(new cemde(statsManager, this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new PvPTimerCommand(this));
|
||||
}
|
||||
|
||||
public void disableFor(final Player caller)
|
||||
{
|
||||
Get(caller).Skipped = true;
|
||||
caller.playSound(caller.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 0.75f);
|
||||
|
||||
_repository.Save(_clientManager.getAccountId(caller), Get(caller).Skipped, Get(caller).Elapsed);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void fireBow(EntityShootBowEvent event)
|
||||
{
|
||||
if (!(event.getEntity() instanceof Player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasTimer((Player) event.getEntity()))
|
||||
{
|
||||
UtilPlayer.message(event.getEntity(), F.main("Clans", "You may not fire bows while on a PvP timer."));
|
||||
UtilPlayer.message(event.getEntity(), C.cGoldB + "> " + C.cGold + "To permanently disable PvP Safety, type " + C.cGreen + "/pvp" + C.cGold + ".");
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
runAsync(() -> _repository.Save(_clientManager.getAccountId(event.getPlayer()), Get(event.getPlayer()).Skipped, Get(event.getPlayer()).Elapsed + (int) (elapsed(event.getPlayer()) / 1000)));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void outYouGo(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() == UpdateType.SLOWER)
|
||||
{
|
||||
UtilServer.getPlayersCollection().forEach(player -> {
|
||||
PvpTimerClient client = Get(player);
|
||||
|
||||
runAsync(() -> {
|
||||
_repository.Save(_clientManager.getAccountId(player), client.Skipped, client.Elapsed += (int) (elapsed(player) / 1000));
|
||||
|
||||
client.StartTime = System.currentTimeMillis();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (event.getType() == UpdateType.SEC)
|
||||
{
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (!hasTimer(player)) continue;
|
||||
|
||||
ClanTerritory territory = _clansManager.getClanUtility().getClaim(player.getLocation());
|
||||
|
||||
if (territory != null && territory.Owner.equals("Borderlands"))
|
||||
{
|
||||
UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), Spawn.ORIGIN), 2.6, true, 0.5, .2, 1.35, true);
|
||||
player.playSound(player.getLocation(), Sound.NOTE_BASS, 1.0f, 1.0f);
|
||||
|
||||
UtilPlayer.message(player, " ");
|
||||
|
||||
UtilPlayer.message(player, C.cDRedB + ">>" + C.cRed + " You are not permitted to enter the Borderlands while under PvP Safety.");
|
||||
UtilPlayer.message(player, C.cGoldB + "> " + C.cGold + "To permanently disable PvP Safety, type " + C.cGreen + "/pvp" + C.cGold + ".");
|
||||
|
||||
UtilPlayer.message(player, " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void territoryEnter(PlayerEnterTerritoryEvent event)
|
||||
{
|
||||
String from = event.getLastTerritory();
|
||||
String to = event.getNewTerritory();
|
||||
|
||||
if (from == null && "Borderlands".equals(to)
|
||||
|| to == null && "Borderlands".equals(from))
|
||||
{
|
||||
event.setSendMessage(false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void clanTip(ClanTipEvent event)
|
||||
{
|
||||
event.setCancelled(hasTimer(event.getPlayer()) && event.getTip() == TipType.ENTER_BORDERLANDS);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
if (hasTimer(player))
|
||||
{
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() {
|
||||
public void run()
|
||||
{
|
||||
UtilTextMiddle.display(C.cGreen + "PvP Safety", C.cGray + "will end in " + UtilTime.MakeStr(getPvPTimerLeft(player) * 1000), 40, 70, 40, player);
|
||||
|
||||
UtilPlayer.message(player, C.cAqua + "You are currently safe from PvP because you are a new player. This safety will end in " + F.time(UtilTime.MakeStr(getPvPTimerLeft(player) * 1000)));
|
||||
UtilPlayer.message(player, C.cAqua + "Until it ends, you are immune to, and are unable to deal PvP damage.");
|
||||
UtilPlayer.message(player, C.cAqua + "To disable the PvP safety permanently, then type " + F.elem("/pvp") + ".");
|
||||
}
|
||||
}, 3);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void inform(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() == UpdateType.FAST)
|
||||
{
|
||||
GetValues().forEach(client -> {
|
||||
if (client.Paused)
|
||||
{
|
||||
client.StartTime = System.currentTimeMillis();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (event.getType() == UpdateType.TWOSEC)
|
||||
{
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (hasTimer(player))
|
||||
{
|
||||
long time = getPvPTimerLeft(player);
|
||||
PvpTimerClient client = Get(player);
|
||||
|
||||
if (time <= 2)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Clans", "PvP Safety has ended!"));
|
||||
UtilPlayer.message(player, F.main("Clans", "You are now completely open to attacks, and you can also attack others."));
|
||||
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 0.2f, 0.75f);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int unit : DISPLAY_TIMES)
|
||||
{
|
||||
if (time <= unit && !client.InformedTimes.contains(Integer.valueOf(unit)))
|
||||
{
|
||||
if (!_clansManager.getTutorials().isInTutorial(player))
|
||||
{
|
||||
// Only inform if not in tutorial.
|
||||
UtilPlayer.message(player, F.main("Clans", "PvP Safety will end in " + F.time(UtilTime.MakeStr(unit * 1000))));
|
||||
UtilTextMiddle.display(C.cGreen + "Pvp Safety", C.cGray + "ending in " + UtilTime.MakeStr(unit * 1000), 20, 80, 20, player);
|
||||
}
|
||||
|
||||
client.InformedTimes.add(Integer.valueOf(unit));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSkill(SkillTriggerEvent event)
|
||||
{
|
||||
if (event.GetTargets() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.GetTargets().size() == 1
|
||||
&& event.GetTargets().get(0) instanceof Player
|
||||
&& hasTimer((Player) event.GetTargets().get(0)))
|
||||
{
|
||||
event.SetCancelled(true);
|
||||
}
|
||||
|
||||
for (Iterator<Entity> iterator = event.GetTargets().iterator(); iterator.hasNext();)
|
||||
{
|
||||
Entity entity = iterator.next();
|
||||
|
||||
if (entity instanceof Player && hasTimer((Player) entity))
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFireballHit(FireballHitEntityEvent event)
|
||||
{
|
||||
event.setCancelled(event.getHitEntity() instanceof Player && hasTimer((Player) event.getHitEntity()));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerAttack(CustomDamageEvent event)
|
||||
{
|
||||
if (event.GetDamageePlayer() == null || event.GetDamagerEntity(true) == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player victim = event.GetDamageePlayer();
|
||||
Player damager = event.GetDamagerPlayer(true);
|
||||
|
||||
boolean victimTimer = victim != null && hasTimer(victim);
|
||||
boolean damagerTimer = damager != null && hasTimer(damager);
|
||||
boolean bothMsg = false;
|
||||
|
||||
if (victimTimer)
|
||||
{
|
||||
if (damagerTimer)
|
||||
{
|
||||
UtilPlayer.message(damager, F.main("Clans", "You and " + F.name(victim.getName()) + " are still protected from PvP. Type " + F.elem("/pvp") + " to disable."));
|
||||
bothMsg = true;
|
||||
}
|
||||
else if (damager != null)
|
||||
{
|
||||
UtilPlayer.message(damager, F.main("Clans", F.name(victim.getName()) + " is still protected from PvP."));
|
||||
}
|
||||
|
||||
event.SetCancelled("Pvp Timer");
|
||||
}
|
||||
|
||||
if (damagerTimer)
|
||||
{
|
||||
if (victimTimer)
|
||||
{
|
||||
if (!bothMsg)
|
||||
{
|
||||
UtilPlayer.message(damager, F.main("Clans", "You and " + F.name(victim.getName()) + " are still under PvP Safety. Type " + F.elem("/pvp") + " to disable."));
|
||||
}
|
||||
}
|
||||
else if (damager != null)
|
||||
{
|
||||
UtilPlayer.message(damager, F.main("Clans", "You are still under PvP Safety."));
|
||||
}
|
||||
|
||||
event.SetCancelled("PvP Timer");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void ClientLoad(AsyncPlayerPreLoginEvent event)
|
||||
{
|
||||
_clientManager.getRepository().getAccountId(event.getUniqueId(), accountId -> {
|
||||
TimerClientToken token = _repository.Get(accountId.intValue());
|
||||
|
||||
Get(event.getName()).Skipped = token.Skipped;
|
||||
Get(event.getName()).Elapsed = token.Elapsed;
|
||||
});
|
||||
}
|
||||
|
||||
public long getPvPTimerLeft(Player player)
|
||||
{
|
||||
long time = Get(player).Elapsed + (elapsed(player) / 1000);
|
||||
|
||||
return (TIMER_LENGTH <= time ? 0 : TIMER_LENGTH - time);
|
||||
}
|
||||
|
||||
public long elapsed(Player player)
|
||||
{
|
||||
return System.currentTimeMillis() - Get(player).StartTime;
|
||||
}
|
||||
|
||||
public boolean hasTimer(Player player)
|
||||
{
|
||||
return player != null && getPvPTimerLeft(player) > 0 && !Get(player).Skipped && !Get(player).Paused;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PvpTimerClient AddPlayer(String player)
|
||||
{
|
||||
return new PvpTimerClient();
|
||||
}
|
||||
|
||||
public void pause(Player player)
|
||||
{
|
||||
Get(player).Paused = true;
|
||||
}
|
||||
|
||||
public void unpause(Player player)
|
||||
{
|
||||
Get(player).Paused = false;
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package mineplex.game.clans.clans.pvptimer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.task.TaskManager;
|
||||
import mineplex.game.clans.clans.ClansPlayerTasks;
|
||||
|
||||
public class PvpTimerClient
|
||||
{
|
||||
public boolean Skipped;
|
||||
public List<Integer> InformedTimes;
|
||||
public long StartTime;
|
||||
public int Elapsed;
|
||||
public boolean Paused;
|
||||
|
||||
public PvpTimerClient()
|
||||
{
|
||||
StartTime = System.currentTimeMillis();
|
||||
InformedTimes = new ArrayList<>();
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
package mineplex.game.clans.clans.pvptimer.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.jsonchat.ClickEvent;
|
||||
import mineplex.core.common.jsonchat.JsonMessage;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.game.clans.clans.pvptimer.PvpTimer;
|
||||
|
||||
public class PvPTimerCommand extends CommandBase<PvpTimer>
|
||||
{
|
||||
public PvPTimerCommand(PvpTimer plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "pvptimer", "timer", "pvp");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
if (Plugin.Get(caller).Skipped)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You have permanently disabled PvP Safety."));
|
||||
return;
|
||||
}
|
||||
|
||||
long pvpTimerLeft = Plugin.getPvPTimerLeft(caller);
|
||||
|
||||
if (pvpTimerLeft == 0)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "PvP Safety has already ended."));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You have " + F.time(UtilTime.MakeStr(pvpTimerLeft * 1000)) + " before PvP Safety runs out for you."));
|
||||
new JsonMessage(F.main("Clans", "If you would like to permanently disable " + C.mBody + "PvP Safety, click "))
|
||||
.extra("here")
|
||||
.color("green")
|
||||
.click(ClickEvent.RUN_COMMAND, "/pvptimer yesiconfirmthatiwouldliketodisablemypvptimerforever")
|
||||
.extra(".")
|
||||
.color("gray")
|
||||
|
||||
.sendToPlayer(caller);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Plugin.Get(caller).Skipped)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You have already disabled PvP Safety."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("yesiconfirmthatiwouldliketodisablemypvptimerforever"))
|
||||
{
|
||||
Plugin.disableFor(caller);
|
||||
UtilPlayer.message(caller, F.main("Clans", "You have disabled PvP Safety."));
|
||||
UtilPlayer.message(caller, F.main("Clans", "You are now completely open to attacks, and you can also attack others."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
package mineplex.game.clans.clans.pvptimer.repository;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.EnclosedObject;
|
||||
import mineplex.core.common.util.UUIDFetcher;
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import mineplex.core.incognito.IncognitoManager;
|
||||
import mineplex.game.clans.clans.pvptimer.PvpTimer;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
|
||||
public class PvpTimerRepository extends MinecraftRepository
|
||||
{
|
||||
private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS clansPvpTimer (accountId INT NOT NULL, timerElapsed INT NOT NULL DEFAULT '1', hasSkipped TINYINT(1) DEFAULT '0', PRIMARY KEY (accountId));";
|
||||
private static final String GET_STATUS = "SELECT * FROM clansPvpTimer WHERE accountId = ?;";
|
||||
private static final String INSERT_STATUS = "INSERT INTO clansPvpTimer (accountId, timerElapsed, hasSkipped) VALUES (?, ?, ?);";
|
||||
private static final String UPDATE_STATUS = "UPDATE clansPvpTimer SET timerElapsed=?, hasSkipped=? WHERE accountId=?;";
|
||||
|
||||
private PvpTimer _pvpTimer;
|
||||
|
||||
private CoreClientManager _clientManager;
|
||||
|
||||
public PvpTimerRepository(PvpTimer pvpTimer, CoreClientManager clientManager)
|
||||
{
|
||||
super(pvpTimer.getPlugin(), DBPool.getAccount());
|
||||
|
||||
_clientManager = clientManager;
|
||||
|
||||
_pvpTimer = pvpTimer;
|
||||
}
|
||||
|
||||
public void Save(int accountId, boolean skipped, int timerElapsed)
|
||||
{
|
||||
// Prevent duplicate entries for individuals
|
||||
executeQuery(GET_STATUS, result -> {
|
||||
if (result.next())
|
||||
executeUpdate(UPDATE_STATUS, new ColumnInt("timerElapsed", timerElapsed), new ColumnInt("hasSkipped", skipped ? 1 : 0), new ColumnInt("accountId", accountId));
|
||||
else
|
||||
executeUpdate(INSERT_STATUS, new ColumnInt("accountId", accountId), new ColumnInt("timerElapsed", timerElapsed), new ColumnInt("hasSkipped", skipped ? 1 : 0));
|
||||
}, new ColumnInt("accountId", accountId));
|
||||
}
|
||||
|
||||
public TimerClientToken Get(int accountId)
|
||||
{
|
||||
final TimerClientToken token = new TimerClientToken();
|
||||
|
||||
executeQuery(GET_STATUS, result -> {
|
||||
if (result.next())
|
||||
{
|
||||
token.Elapsed = result.getInt("timerElapsed");
|
||||
token.Skipped = result.getInt("hasSkipped") == 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
token.Elapsed = 1;
|
||||
token.Skipped = false;
|
||||
}
|
||||
}, new ColumnInt("accountId", accountId));
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
public TimerClientToken Get(String name)
|
||||
{
|
||||
EnclosedObject<Integer> accountId = new EnclosedObject<>();
|
||||
|
||||
_clientManager.getRepository().getAccountId(UUIDFetcher.getUUIDOf(name), id ->
|
||||
accountId.Set(id)
|
||||
);
|
||||
|
||||
return Get(accountId.Get().intValue());
|
||||
}
|
||||
|
||||
protected void initialize()
|
||||
{
|
||||
executeUpdate(CREATE_TABLE);
|
||||
}
|
||||
|
||||
protected void update()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package mineplex.game.clans.clans.pvptimer.repository;
|
||||
|
||||
public class TimerClientToken
|
||||
{
|
||||
public int Elapsed;
|
||||
public boolean Skipped;
|
||||
}
|
@ -262,7 +262,7 @@ public class SiegeManager extends MiniPlugin
|
||||
return false;
|
||||
}
|
||||
|
||||
if(_clansManager.getPvpTimer().hasTimer(player))
|
||||
if (_clansManager.hasTimer(player))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Clans", "You cannot place a Cannon whilst protected from pvp."));
|
||||
return false;
|
||||
|
@ -267,9 +267,9 @@ public class Outpost implements Listener
|
||||
return;
|
||||
|
||||
|
||||
if(_outpostManager.getClansManager().getPvpTimer().hasTimer(event.getPlayer()))
|
||||
if(_outpostManager.getClansManager().hasTimer(event.getPlayer()))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot activate an Outpost whilst protected from pvp."));
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot activate an Outpost whilst protected from PvP."));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -295,9 +295,9 @@ public class Outpost implements Listener
|
||||
if (event.getBlock().getLocation().equals(_core) && getState() == OutpostState.LIVE)
|
||||
{
|
||||
|
||||
if(_outpostManager.getClansManager().getPvpTimer().hasTimer(event.getPlayer()))
|
||||
if(_outpostManager.getClansManager().hasTimer(event.getPlayer()))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot destroy an Outpost whilst on protected from pvp."));
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot destroy an Outpost whilst protected from PvP."));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -81,9 +81,9 @@ public class OutpostManager extends MiniPlugin
|
||||
return false;
|
||||
}
|
||||
|
||||
if(_clansManager.getPvpTimer().hasTimer(player))
|
||||
if(_clansManager.hasTimer(player))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Clans", "You place an Outpost whilst protected from pvp."));
|
||||
UtilPlayer.message(player, F.main("Clans", "You can't place an Outpost whilst protected from PvP."));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -82,7 +83,7 @@ public class Cannon extends SiegeWeapon
|
||||
return false;
|
||||
}
|
||||
|
||||
if(_clans.getPvpTimer().hasTimer(player))
|
||||
if(_clans.hasTimer(player))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Clans", "You cannot fire a cannon whilst on PvPTimer"));
|
||||
return false;
|
||||
@ -118,7 +119,7 @@ public class Cannon extends SiegeWeapon
|
||||
return false;
|
||||
}
|
||||
|
||||
if(_clans.getPvpTimer().hasTimer(player)) {
|
||||
if(_clans.hasTimer(player)) {
|
||||
UtilPlayer.message(player, F.main("Clans", "You cannot ride on a Cannon whilst on PvPTimer"));
|
||||
return false;
|
||||
}
|
||||
@ -165,7 +166,7 @@ public class Cannon extends SiegeWeapon
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_clans.getPvpTimer().hasTimer(player))
|
||||
if (_clans.hasTimer(player))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Clans", "You cannot fire a Cannon whilst protected from pvp."));
|
||||
return false;
|
||||
@ -201,7 +202,7 @@ public class Cannon extends SiegeWeapon
|
||||
return false;
|
||||
}
|
||||
|
||||
if(_clans.getPvpTimer().hasTimer(player))
|
||||
if(_clans.hasTimer(player))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Clans", "You cannot ride on a Cannon whilst protected from pvp."));
|
||||
return false;
|
||||
@ -218,7 +219,16 @@ public class Cannon extends SiegeWeapon
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (event.getClick() == ClickType.SHIFT_RIGHT)
|
||||
{
|
||||
if(_inventory.getViewers().contains(event.getWhoClicked()))
|
||||
{
|
||||
event.setCancelled(true); //block shift right clicking tnt into this inventory
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.getClickedInventory().equals(_inventory))
|
||||
{
|
||||
return;
|
||||
|
@ -88,7 +88,8 @@ public abstract class SiegeWeapon implements Listener
|
||||
protected int _health;
|
||||
protected String _currentState;
|
||||
protected boolean _alive = true;
|
||||
|
||||
protected boolean _invincible = false;
|
||||
|
||||
// Mechanics
|
||||
protected final NautArrayList<Entity> _comprisedOf;
|
||||
|
||||
@ -568,12 +569,13 @@ public abstract class SiegeWeapon implements Listener
|
||||
|
||||
_infoHologram.setText(_name + " Health", getDisplayHealth());
|
||||
|
||||
if (_health == 0)
|
||||
if (_health == 0 && !_invincible)
|
||||
kill();
|
||||
}
|
||||
|
||||
public final void removeHealth(int health)
|
||||
{
|
||||
if (_invincible) return;
|
||||
setHealth(_health - health);
|
||||
}
|
||||
|
||||
@ -932,5 +934,15 @@ public abstract class SiegeWeapon implements Listener
|
||||
|
||||
return _loadedToken.Entities.values().contains(uniqueId.toString());
|
||||
}
|
||||
|
||||
public void setInvincible(boolean invincible)
|
||||
{
|
||||
_invincible = invincible;
|
||||
}
|
||||
|
||||
public boolean isInvincible()
|
||||
{
|
||||
return _invincible;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -431,7 +431,12 @@ public class Gameplay extends MiniPlugin
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (_clansManager.getTutorials().isInTutorial(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
|
||||
// Knock
|
||||
|
@ -52,7 +52,7 @@ public class MeridianScepter extends LegendaryItem
|
||||
{
|
||||
if ((System.currentTimeMillis() - _lastBlock) < 98 && (System.currentTimeMillis() - _interactWait) >= 98)
|
||||
{
|
||||
if (ClansManager.getInstance().getPvpTimer().hasTimer(wielder))
|
||||
if (ClansManager.getInstance().hasTimer(wielder))
|
||||
{
|
||||
UtilPlayer.message(wielder, F.main("Clans", "You are not allowed to fire the Meridian Scepter whilst under pvp protection."));
|
||||
return;
|
||||
@ -137,7 +137,7 @@ public class MeridianScepter extends LegendaryItem
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ClansManager.getInstance().getPvpTimer().hasTimer(closest))
|
||||
if (ClansManager.getInstance().hasTimer(closest))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -152,13 +152,11 @@ public abstract class Tutorial implements Listener, ObjectiveListener
|
||||
@Override
|
||||
public void onObjectiveStart(Player player, Objective objective)
|
||||
{
|
||||
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onObjectivePlayerUpdate(Player player, Objective objective)
|
||||
{
|
||||
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 1f);
|
||||
}
|
||||
|
||||
private void finish(Player player)
|
||||
@ -253,6 +251,7 @@ public abstract class Tutorial implements Listener, ObjectiveListener
|
||||
|
||||
public TutorialRegion getRegion(Player player)
|
||||
{
|
||||
if(player == null || !player.isOnline() || _playerSessionMap == null || _playerSessionMap.get(player) == null) return null;
|
||||
return _playerSessionMap.get(player).getRegion();
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ public class TutorialSession
|
||||
private Location _homeLocation;
|
||||
private int _colorTick;
|
||||
private int _textSeconds;
|
||||
private Location _mapTargetLocation;
|
||||
|
||||
public TutorialSession()
|
||||
{
|
||||
@ -70,4 +71,14 @@ public class TutorialSession
|
||||
_textSeconds++;
|
||||
return _textSeconds;
|
||||
}
|
||||
|
||||
public void setMapTargetLocation(Location location)
|
||||
{
|
||||
_mapTargetLocation = location;
|
||||
}
|
||||
|
||||
public Location getMapTargetLocation()
|
||||
{
|
||||
return _mapTargetLocation;
|
||||
}
|
||||
}
|
||||
|
@ -21,9 +21,12 @@ import mineplex.game.clans.tutorial.TutorialRegion;
|
||||
|
||||
public class TutorialWorldManager extends MiniPlugin
|
||||
{
|
||||
public static final int BLOCKS_BETWEEN_TUTORIALS = 1200;
|
||||
|
||||
private final World _tutorialWorld;
|
||||
private final Schematic _schematic;
|
||||
private Stack<TutorialRegion> _regionStack;
|
||||
private TutorialRegion _centerRegion;
|
||||
|
||||
public TutorialWorldManager(JavaPlugin plugin, String worldName, String schematicName) throws IOException
|
||||
{
|
||||
@ -56,15 +59,17 @@ public class TutorialWorldManager extends MiniPlugin
|
||||
_regionStack = new Stack<>();
|
||||
|
||||
// Populate the stack with 100 available tutorial regions
|
||||
for (int x = 0; x < 2; x++)
|
||||
for (int x = 0; x < 4; x++)
|
||||
{
|
||||
for (int z = 0; z < 2; z++)
|
||||
for (int z = 0; z < 4; z++)
|
||||
{
|
||||
long time = System.currentTimeMillis();
|
||||
double xLoc = (x) * 1000; // 1000x1000 regions
|
||||
double zLoc = (z) * 1000;
|
||||
double xLoc = (x) * BLOCKS_BETWEEN_TUTORIALS; // 1000x1000 regions
|
||||
double zLoc = (z) * BLOCKS_BETWEEN_TUTORIALS;
|
||||
|
||||
_regionStack.add(new TutorialRegion(_schematic, new Location(_tutorialWorld, xLoc, 30, zLoc)));
|
||||
TutorialRegion region = new TutorialRegion(_schematic, new Location(_tutorialWorld, xLoc, 30, zLoc));
|
||||
if (x == 0 && z == 0) _centerRegion = region;
|
||||
_regionStack.add(region);
|
||||
System.out.println("Finished Generating Region: " + ((x * 10) + z) + ". Took " + (System.currentTimeMillis() - time) + " ms");
|
||||
}
|
||||
}
|
||||
@ -94,4 +99,9 @@ public class TutorialWorldManager extends MiniPlugin
|
||||
{
|
||||
return _tutorialWorld;
|
||||
}
|
||||
|
||||
public TutorialRegion getCenterRegion()
|
||||
{
|
||||
return _centerRegion;
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,8 @@ import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.tutorial.TutorialManager;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Block;
|
||||
import net.minecraft.server.v1_8_R3.BlockPosition;
|
||||
@ -51,6 +53,7 @@ import net.minecraft.server.v1_8_R3.PersistentCollection;
|
||||
|
||||
public class TutorialMapManager extends MiniPlugin
|
||||
{
|
||||
private ClansMainTutorial _tutorial;
|
||||
private int _blocksScan = 16;
|
||||
private Comparator<Entry<Integer, Integer>> _comparator;
|
||||
private int _halfMapSize = 64;
|
||||
@ -63,8 +66,10 @@ public class TutorialMapManager extends MiniPlugin
|
||||
private int _centerX;
|
||||
private int _centerZ;
|
||||
private int _scale = 1;
|
||||
private int _minX;
|
||||
private int _minZ;
|
||||
|
||||
public TutorialMapManager(JavaPlugin plugin, World world, int minX, int minZ, int maxX, int maxZ)
|
||||
public TutorialMapManager(JavaPlugin plugin, ClansMainTutorial tutorial, World world, int minX, int minZ, int maxX, int maxZ)
|
||||
{
|
||||
super("TutorialMapManager", plugin);
|
||||
|
||||
@ -72,6 +77,9 @@ public class TutorialMapManager extends MiniPlugin
|
||||
_centerZ = minZ + ((maxZ - minZ) / 2);
|
||||
_centerX = (int) (Math.round(_centerX / 16D) * 16);
|
||||
_centerZ = (int) (Math.round(_centerZ / 16D) * 16);
|
||||
_tutorial = tutorial;
|
||||
_minX = minX;
|
||||
_minZ = minZ;
|
||||
|
||||
_heightMap = new int[(_halfMapSize * 2) + 16][];
|
||||
|
||||
@ -187,7 +195,7 @@ public class TutorialMapManager extends MiniPlugin
|
||||
view.removeRenderer(renderer);
|
||||
}
|
||||
|
||||
view.addRenderer(new TutorialMapRenderer(this));
|
||||
view.addRenderer(new TutorialMapRenderer(_tutorial, _minX, _minZ));
|
||||
}
|
||||
|
||||
public int getScale()
|
||||
|
@ -1,33 +1,47 @@
|
||||
package mineplex.game.clans.tutorial.map;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.game.clans.tutorial.TutorialManager;
|
||||
import mineplex.game.clans.tutorial.TutorialRegion;
|
||||
import mineplex.game.clans.tutorial.TutorialSession;
|
||||
import mineplex.game.clans.tutorial.TutorialType;
|
||||
import mineplex.game.clans.tutorial.TutorialWorldManager;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.map.MapCanvas;
|
||||
import org.bukkit.map.MapCursor;
|
||||
import org.bukkit.map.MapCursorCollection;
|
||||
import org.bukkit.map.MapPalette;
|
||||
import org.bukkit.map.MapRenderer;
|
||||
import org.bukkit.map.MapView;
|
||||
|
||||
public class TutorialMapRenderer extends MapRenderer
|
||||
{
|
||||
private TutorialMapManager _manager;
|
||||
private ClansMainTutorial _tutorial;
|
||||
private int _minX;
|
||||
private int _minZ;
|
||||
|
||||
public TutorialMapRenderer(TutorialMapManager itemMapManager)
|
||||
public TutorialMapRenderer(ClansMainTutorial tutorialManager, int minX, int minZ)
|
||||
{
|
||||
super(true);
|
||||
|
||||
_manager = itemMapManager;
|
||||
_tutorial = tutorialManager;
|
||||
_minX = minX;
|
||||
_minZ = minZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MapView mapView, MapCanvas canvas, Player player)
|
||||
{
|
||||
int zoom = _manager.getScale();
|
||||
TutorialMapManager tutorialMap = _tutorial.getMapManager();
|
||||
int zoom = tutorialMap.getScale();
|
||||
|
||||
Byte[][] map = _manager.getMap(zoom);
|
||||
Byte[][] map = tutorialMap.getMap(zoom);
|
||||
|
||||
int centerX = 0;
|
||||
int centerZ = 0;
|
||||
@ -35,6 +49,13 @@ public class TutorialMapRenderer extends MapRenderer
|
||||
// We have this cooldown to squeeze out every single bit of performance from the server.
|
||||
if (Recharge.Instance.use(player, "Draw Map", 4000, false, false))
|
||||
{
|
||||
TutorialRegion region = _tutorial.getWorldManager().getCenterRegion();
|
||||
MinMaxArea shops = getArea(region, ClansMainTutorial.Bounds.SHOPS);
|
||||
MinMaxArea fields = getArea(region, ClansMainTutorial.Bounds.FIELDS);
|
||||
MinMaxArea spawn = getArea(region, ClansMainTutorial.Bounds.SPAWN);
|
||||
MinMaxArea claim = getArea(region, ClansMainTutorial.Bounds.LAND_CLAIM);
|
||||
MinMaxArea enemy = getArea(region, ClansMainTutorial.Bounds.ENEMY_LAND);
|
||||
|
||||
for (int mapX = 0; mapX < 128; mapX++)
|
||||
{
|
||||
for (int mapZ = 0; mapZ < 128; mapZ++)
|
||||
@ -45,19 +66,28 @@ public class TutorialMapRenderer extends MapRenderer
|
||||
int pixelX = blockX + (map.length / 2);
|
||||
int pixelZ = blockZ + (map.length / 2);
|
||||
|
||||
Byte color;
|
||||
int xRegion = mapX + _minX - 6;
|
||||
int zRegion = mapZ + _minZ;
|
||||
|
||||
Byte color = 0;
|
||||
|
||||
|
||||
if (!(pixelX < 0 || pixelZ < 0 || pixelX >= map.length || pixelZ >= map.length)
|
||||
&& map[pixelX][pixelZ] != null)
|
||||
{
|
||||
color = map[pixelX][pixelZ];
|
||||
|
||||
if (!((color <= -113 || color >= 0) && color <= 127))
|
||||
color = (byte) 0;
|
||||
|
||||
blockX *= zoom;
|
||||
blockZ *= zoom;
|
||||
}
|
||||
else
|
||||
{
|
||||
color = (byte) 0;
|
||||
|
||||
color = attemptDraw(false, color, Color.WHITE, new Color(50, 150, 255), xRegion, zRegion, shops, mapX, mapZ);
|
||||
color = attemptDraw(false, color, Color.WHITE, new Color(255, 120, 0), xRegion, zRegion, fields, mapX, mapZ);
|
||||
color = attemptDraw(false, color, Color.WHITE, new Color(0, 255, 100), xRegion, zRegion, spawn, mapX, mapZ);
|
||||
color = attemptDraw(true, color, Color.CYAN, null, xRegion, zRegion, claim, mapX, mapZ);
|
||||
color = attemptDraw(true, color, Color.RED, null, xRegion, zRegion, enemy, mapX, mapZ);
|
||||
}
|
||||
|
||||
/* TODO Figure out if you want to colorize this pixel
|
||||
@ -81,11 +111,11 @@ public class TutorialMapRenderer extends MapRenderer
|
||||
}
|
||||
|
||||
Location l = player.getLocation().clone();
|
||||
l.setX((((int)l.getX()) % 1000) + (l.getX() - ((int) l.getX())));
|
||||
l.setZ((((int)l.getZ()) % 1000) + (l.getZ() - ((int) l.getZ())));
|
||||
l.setX((((int)l.getX()) % TutorialWorldManager.BLOCKS_BETWEEN_TUTORIALS) + (l.getX() - ((int) l.getX())));
|
||||
l.setZ((((int)l.getZ()) % TutorialWorldManager.BLOCKS_BETWEEN_TUTORIALS) + (l.getZ() - ((int) l.getZ())));
|
||||
|
||||
double mapX = (l.getX() - _manager.getX()) / zoom;
|
||||
double mapZ = (l.getZ() - _manager.getZ()) / zoom;
|
||||
double mapX = (l.getX() - tutorialMap.getX()) / zoom;
|
||||
double mapZ = (l.getZ() - tutorialMap.getZ()) / zoom;
|
||||
|
||||
if (mapX > -64 && mapX < 64 && mapZ > -64 && mapZ < 64)
|
||||
{
|
||||
@ -98,5 +128,116 @@ public class TutorialMapRenderer extends MapRenderer
|
||||
|
||||
cursors.addCursor(cursor);
|
||||
}
|
||||
|
||||
// Add Tutorial Markers
|
||||
TutorialSession session = _tutorial.getTutorialSession(player);
|
||||
if (session != null)
|
||||
{
|
||||
if (session.getMapTargetLocation() != null)
|
||||
{
|
||||
Location point = session.getMapTargetLocation().clone();
|
||||
point.setX((((int)point.getX()) % TutorialWorldManager.BLOCKS_BETWEEN_TUTORIALS) + (point.getX() - ((int) point.getX())));
|
||||
point.setZ((((int)point.getZ()) % TutorialWorldManager.BLOCKS_BETWEEN_TUTORIALS) + (point.getZ() - ((int) point.getZ())));
|
||||
mapX = (point.getX() - tutorialMap.getX()) / zoom;
|
||||
mapZ = (point.getZ() - tutorialMap.getZ()) / zoom;
|
||||
|
||||
// To make these appear at the edges of the map, just change it from 64 to something like 128 for double the map size
|
||||
if (mapX > -64 && mapX < 64 && mapZ > -64 && mapZ < 64)
|
||||
{
|
||||
byte b0 = (byte) (int) Math.min(127, (double) (mapX * 2.0F) + 0.5D);
|
||||
byte b1 = (byte) (int) Math.max(-127, (double) (mapZ * 2.0F) + 0.5D);
|
||||
|
||||
byte cursorType = 4; // http://i.imgur.com/wpH6PT8.png
|
||||
// Those are byte 5 and 6
|
||||
byte rotation = (byte) ((int) Math.floor(System.currentTimeMillis() / 1000D) % 16);
|
||||
|
||||
MapCursor cursor = new MapCursor(b0, b1, rotation, cursorType, true);
|
||||
|
||||
cursors.addCursor(cursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private byte attemptDraw(boolean colorAll, byte color, Color color1, Color color2, int xRegion, int zRegion, MinMaxArea area, int mapX, int mapZ)
|
||||
{
|
||||
if (xRegion >= area.MinX && xRegion <= area.MaxX && zRegion >= area.MinZ && zRegion <= area.MaxZ)
|
||||
{
|
||||
if (xRegion == area.MinX || xRegion == area.MaxX || zRegion == area.MinZ || zRegion == area.MaxZ)
|
||||
{
|
||||
// Outer Ring
|
||||
Color cColor = MapPalette.getColor(color);
|
||||
double clans = colorAll ? 1 : 0.8;// 0.65;
|
||||
|
||||
//Use clanColor2 no matter what for admins
|
||||
Color drawColor = color1;
|
||||
if (color2 != null)
|
||||
{
|
||||
drawColor = color2;
|
||||
clans = 1;
|
||||
}
|
||||
|
||||
double base = 1 - clans;
|
||||
|
||||
int r = (int) ((cColor.getRed() * base) + (drawColor.getRed() * clans));
|
||||
int b = (int) ((cColor.getBlue() * base) + (drawColor.getBlue() * clans));
|
||||
int g = (int) ((cColor.getGreen() * base) + (drawColor.getGreen() * clans));
|
||||
|
||||
color = MapPalette.matchColor(r, g, b);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Inside
|
||||
Color cColor = MapPalette.getColor(color);
|
||||
|
||||
double clans = 0.065;
|
||||
|
||||
//Stripes
|
||||
boolean checker = (mapX + (mapZ % 4)) % 4 == 0;
|
||||
Color drawColor = color1;
|
||||
// if (colorAll)
|
||||
// {
|
||||
// clans = 0.8;
|
||||
// }
|
||||
if (checker && color2 != null && !colorAll)
|
||||
{
|
||||
drawColor = color2;
|
||||
clans = 1;
|
||||
}
|
||||
|
||||
double base = 1 - clans;
|
||||
|
||||
if (clans != 1 && (color == 0 || color == 1 || color == 2 || color == 3))
|
||||
return color;
|
||||
|
||||
int r = (int) ((cColor.getRed() * base) + (drawColor.getRed() * clans));
|
||||
int b = (int) ((cColor.getBlue() * base) + (drawColor.getBlue() * clans));
|
||||
int g = (int) ((cColor.getGreen() * base) + (drawColor.getGreen() * clans));
|
||||
|
||||
color = MapPalette.matchColor(r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
private MinMaxArea getArea(TutorialRegion region, ClansMainTutorial.Bounds bounds)
|
||||
{
|
||||
MinMaxArea area = new MinMaxArea();
|
||||
List<Location> shopLocations = region.getLocationMap().getGoldLocations(bounds.getDataLocColor());
|
||||
area.MinX = Math.min(shopLocations.get(0).getBlockX(), shopLocations.get(1).getBlockX());
|
||||
area.MaxX = Math.max(shopLocations.get(0).getBlockX(), shopLocations.get(1).getBlockX());
|
||||
area.MinZ = Math.min(shopLocations.get(0).getBlockZ(), shopLocations.get(1).getBlockZ());
|
||||
area.MaxZ = Math.max(shopLocations.get(0).getBlockZ(), shopLocations.get(1).getBlockZ());
|
||||
|
||||
return area;
|
||||
}
|
||||
|
||||
private class MinMaxArea
|
||||
{
|
||||
public int MinX;
|
||||
public int MaxX;
|
||||
public int MinZ;
|
||||
public int MaxZ;
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,19 @@
|
||||
package mineplex.game.clans.tutorial.objective;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.game.clans.tutorial.Tutorial;
|
||||
@ -33,7 +34,7 @@ public abstract class Objective<Plugin extends Tutorial, Data extends ObjectiveD
|
||||
private boolean _displayFinishMessage;
|
||||
private int _finishMessageDelay;
|
||||
|
||||
private HashMap<UUID, Data> _active;
|
||||
private NautHashMap<UUID, Data> _active;
|
||||
private List<ObjectiveListener> _listeners;
|
||||
|
||||
public Objective(Plugin plugin, JavaPlugin javaPlugin, String name, String description, String extraDescription)
|
||||
@ -43,12 +44,12 @@ public abstract class Objective<Plugin extends Tutorial, Data extends ObjectiveD
|
||||
_name = name;
|
||||
_description = description;
|
||||
_extraDescription = extraDescription;
|
||||
_displayStartMessage = true;
|
||||
_displayFinishMessage = true;
|
||||
_displayStartMessage = false;
|
||||
_displayFinishMessage = false;
|
||||
_startMessageDelay = 60;
|
||||
_finishMessageDelay = 1;
|
||||
|
||||
_active = new HashMap<>();
|
||||
_active = new NautHashMap<>();
|
||||
_listeners = new LinkedList<>();
|
||||
|
||||
javaPlugin.getServer().getPluginManager().registerEvents(this, javaPlugin);
|
||||
@ -160,7 +161,7 @@ public abstract class Objective<Plugin extends Tutorial, Data extends ObjectiveD
|
||||
* @param goal
|
||||
* @param player
|
||||
*/
|
||||
protected abstract void completeGoal(ObjectiveGoal goal, Player player);
|
||||
protected abstract void completeGoal(ObjectiveGoal<?> goal, Player player);
|
||||
|
||||
/**
|
||||
* Called when a player is finished the tutorial
|
||||
@ -169,9 +170,11 @@ public abstract class Objective<Plugin extends Tutorial, Data extends ObjectiveD
|
||||
*/
|
||||
public void clean(Player player, TutorialRegion region)
|
||||
{
|
||||
List<ObjectiveGoal> goals = getGoals();
|
||||
List<ObjectiveGoal<?>> goals = getGoals();
|
||||
if (goals != null)
|
||||
goals.forEach(goal -> goal.clean(player, region));
|
||||
|
||||
_active.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -181,7 +184,7 @@ public abstract class Objective<Plugin extends Tutorial, Data extends ObjectiveD
|
||||
*/
|
||||
public void setup(Player player, TutorialRegion region)
|
||||
{
|
||||
List<ObjectiveGoal> goals = getGoals();
|
||||
List<ObjectiveGoal<?>> goals = getGoals();
|
||||
if (goals != null)
|
||||
goals.forEach(goal -> goal.setup(player, region));
|
||||
}
|
||||
@ -190,7 +193,7 @@ public abstract class Objective<Plugin extends Tutorial, Data extends ObjectiveD
|
||||
* Returns a list of all the ObjectiveGoals used by this Objective
|
||||
* Can return <code>null</code>
|
||||
*/
|
||||
protected abstract List<ObjectiveGoal> getGoals();
|
||||
protected abstract List<ObjectiveGoal<?>> getGoals();
|
||||
|
||||
protected final void finish(Player player)
|
||||
{
|
||||
@ -201,7 +204,9 @@ public abstract class Objective<Plugin extends Tutorial, Data extends ObjectiveD
|
||||
_active.remove(player.getUniqueId());
|
||||
|
||||
if (_displayFinishMessage)
|
||||
Bukkit.getServer().getScheduler().runTaskLater(getJavaPlugin(), () -> showFinishMessage(player), _finishMessageDelay);
|
||||
Bukkit.getServer().getScheduler().runTaskLater(getJavaPlugin(), () -> showFinishMessage(player), _finishMessageDelay);
|
||||
|
||||
player.playSound(player.getEyeLocation(), Sound.LEVEL_UP, 1f, 1f);
|
||||
|
||||
customFinish(player);
|
||||
|
||||
@ -256,7 +261,7 @@ public abstract class Objective<Plugin extends Tutorial, Data extends ObjectiveD
|
||||
{
|
||||
HandlerList.unregisterAll(this);
|
||||
|
||||
List<ObjectiveGoal> goals = getGoals();
|
||||
List<ObjectiveGoal<?>> goals = getGoals();
|
||||
if (goals != null) goals.forEach(HandlerList::unregisterAll);
|
||||
}
|
||||
|
||||
@ -264,12 +269,12 @@ public abstract class Objective<Plugin extends Tutorial, Data extends ObjectiveD
|
||||
|
||||
private void showStartMessage(Player player)
|
||||
{
|
||||
UtilTextMiddle.display(C.cAqua + "Tutorial", getName(player), player);
|
||||
UtilTextMiddle.display(C.cAqua + "Next Tutorial", getName(player), 20, 60, 20, player);
|
||||
}
|
||||
|
||||
private void showFinishMessage(Player player)
|
||||
{
|
||||
UtilTextMiddle.display(C.cGreen + "Tutorial Completed", getName(player), player);
|
||||
UtilTextMiddle.display(C.cGreen + "Tutorial Completed", getName(player), 20, 60, 20, player);
|
||||
}
|
||||
|
||||
public void setDisplayStartMessage(boolean displayStartMessage)
|
||||
|
@ -1,23 +1,29 @@
|
||||
package mineplex.game.clans.tutorial.objective;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.Sound;
|
||||
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.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.tutorial.TutorialRegion;
|
||||
|
||||
public abstract class ObjectiveGoal <T extends Objective> implements Listener
|
||||
public abstract class ObjectiveGoal <T extends Objective<?, ?>> implements Listener
|
||||
{
|
||||
private T _objective;
|
||||
|
||||
private HashSet<UUID> _active;
|
||||
private HashSet<UUID> _removeList;
|
||||
private String _name;
|
||||
private String _description;
|
||||
private String _extraDescription;
|
||||
@ -25,24 +31,27 @@ public abstract class ObjectiveGoal <T extends Objective> implements Listener
|
||||
private int _startMessageDelay;
|
||||
private boolean _displayFinishMessage;
|
||||
private int _finishMessageDelay;
|
||||
private DyeColor _fireworkLocations;
|
||||
|
||||
public ObjectiveGoal(T objective, String name, String description)
|
||||
{
|
||||
this(objective, name, description, null);
|
||||
this(objective, name, description, null, null);
|
||||
}
|
||||
|
||||
public ObjectiveGoal(T objective, String name, String description, String extraDescription)
|
||||
public ObjectiveGoal(T objective, String name, String description, String extraDescription, DyeColor fireworkLocs)
|
||||
{
|
||||
_objective = objective;
|
||||
|
||||
_active = new HashSet<>();
|
||||
_removeList = new HashSet<>();
|
||||
_name = name;
|
||||
_description = description;
|
||||
_extraDescription = extraDescription;
|
||||
_displayStartMessage = true;
|
||||
_startMessageDelay = 40;
|
||||
_displayFinishMessage = true;
|
||||
_startMessageDelay = 1;//40;
|
||||
_displayFinishMessage = false;
|
||||
_finishMessageDelay = 1;
|
||||
_fireworkLocations = fireworkLocs;
|
||||
}
|
||||
|
||||
public String getName(Player player)
|
||||
@ -67,7 +76,7 @@ public abstract class ObjectiveGoal <T extends Objective> implements Listener
|
||||
|
||||
public boolean contains(Player player)
|
||||
{
|
||||
if (player == null)
|
||||
if (player == null || !player.isOnline())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -101,7 +110,7 @@ public abstract class ObjectiveGoal <T extends Objective> implements Listener
|
||||
{
|
||||
System.out.println(String.format("Tutorial> [%s] left objective goal [%s]", player.getName(), getName(player)));
|
||||
|
||||
_active.remove(player.getUniqueId());
|
||||
_removeList.add(player.getUniqueId());
|
||||
}
|
||||
|
||||
customLeave(player);
|
||||
@ -115,13 +124,15 @@ public abstract class ObjectiveGoal <T extends Objective> implements Listener
|
||||
|
||||
getObjective().getPlugin().getTutorialSession(player).setTextSeconds(0);
|
||||
|
||||
_active.remove(player.getUniqueId());
|
||||
_removeList.add(player.getUniqueId());
|
||||
|
||||
if (_displayFinishMessage)
|
||||
{
|
||||
Bukkit.getServer().getScheduler().runTaskLater(_objective.getJavaPlugin(), () -> displayFinishMessage(player), _finishMessageDelay);
|
||||
}
|
||||
|
||||
player.playSound(player.getEyeLocation(), Sound.ORB_PICKUP, 1f, 1f);
|
||||
|
||||
customFinish(player);
|
||||
|
||||
_objective.completeGoal(this, player);
|
||||
@ -165,6 +176,10 @@ public abstract class ObjectiveGoal <T extends Objective> implements Listener
|
||||
|
||||
if (getExtraDescription(player) != null)
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
UtilPlayer.message(player, "");
|
||||
}
|
||||
// Display extra information for the first time.
|
||||
UtilPlayer.message(player, C.cGold + C.Strike + "---------------------------------------------");
|
||||
UtilPlayer.message(player, C.cGray + " " + getExtraDescription(player));
|
||||
@ -192,4 +207,36 @@ public abstract class ObjectiveGoal <T extends Objective> implements Listener
|
||||
{
|
||||
_finishMessageDelay = finishMessageDelay;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (!event.getType().equals(UpdateType.SEC_05)) return;
|
||||
if (_fireworkLocations == null) return;
|
||||
|
||||
for (UUID id : getActivePlayers())
|
||||
{
|
||||
if (Bukkit.getPlayer(id) == null) continue;
|
||||
List<Location> locations = getObjective().getPlugin().getRegion(Bukkit.getPlayer(id)).getLocationMap().getSpongeLocations(_fireworkLocations);
|
||||
if (locations == null) continue;
|
||||
for (Location loc : locations)
|
||||
{
|
||||
UtilFirework.playFirework(loc, FireworkEffect.Type.BURST, Color.AQUA, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void activeCleaner(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
for (UUID uuid : _removeList)
|
||||
{
|
||||
_active.remove(uuid);
|
||||
}
|
||||
|
||||
_removeList.clear();
|
||||
}
|
||||
}
|
||||
|
@ -7,17 +7,17 @@ public interface ObjectiveListener
|
||||
/**
|
||||
* Called when a player starts an objective
|
||||
*/
|
||||
public void onObjectiveStart(Player player, Objective objective);
|
||||
public void onObjectiveStart(Player player, Objective<?, ?> objective);
|
||||
|
||||
/**
|
||||
* Called when a player progresses in an objective
|
||||
* For example, in an OrderedObjective this will be called when the player
|
||||
* moves to the next ObjectiveGoal
|
||||
*/
|
||||
public void onObjectivePlayerUpdate(Player player, Objective objective);
|
||||
public void onObjectivePlayerUpdate(Player player, Objective<?, ?> objective);
|
||||
|
||||
/**
|
||||
* Called when a player finishes an objective
|
||||
*/
|
||||
public void onObjectiveFinish(Player player, Objective objective);
|
||||
public void onObjectiveFinish(Player player, Objective<?, ?> objective);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
public abstract class OrderedObjective<Plugin extends Tutorial> extends Objective<Plugin, OrderedObjectiveData>
|
||||
{
|
||||
private List<ObjectiveGoal> _goals;
|
||||
private List<ObjectiveGoal<?>> _goals;
|
||||
|
||||
public OrderedObjective(Plugin plugin, JavaPlugin javaPlugin, String name, String description, String extraDescription)
|
||||
{
|
||||
@ -25,7 +25,7 @@ public abstract class OrderedObjective<Plugin extends Tutorial> extends Objectiv
|
||||
this(plugin, javaPlugin, name, description, null);
|
||||
}
|
||||
|
||||
protected void addGoal(ObjectiveGoal goal)
|
||||
protected void addGoal(ObjectiveGoal<?> goal)
|
||||
{
|
||||
_goals.add(goal);
|
||||
|
||||
@ -39,7 +39,7 @@ public abstract class OrderedObjective<Plugin extends Tutorial> extends Objectiv
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void completeGoal(ObjectiveGoal goal, Player player)
|
||||
protected void completeGoal(ObjectiveGoal<?> goal, Player player)
|
||||
{
|
||||
int index = _goals.indexOf(goal);
|
||||
|
||||
@ -88,13 +88,13 @@ public abstract class OrderedObjective<Plugin extends Tutorial> extends Objectiv
|
||||
private void setGoal(Player player, int index)
|
||||
{
|
||||
OrderedObjectiveData data = getData(player); // Should never be null!
|
||||
ObjectiveGoal nextGoal = _goals.get(index);
|
||||
ObjectiveGoal<?> nextGoal = _goals.get(index);
|
||||
data.setIndex(index);
|
||||
nextGoal.start(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<ObjectiveGoal> getGoals()
|
||||
protected List<ObjectiveGoal<?>> getGoals()
|
||||
{
|
||||
return _goals;
|
||||
}
|
||||
|
@ -31,13 +31,13 @@ public abstract class SingleObjective<Plugin extends Tutorial> extends Objective
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void completeGoal(ObjectiveGoal goal, Player player)
|
||||
protected void completeGoal(ObjectiveGoal<?> goal, Player player)
|
||||
{
|
||||
// Do Nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<ObjectiveGoal> getGoals()
|
||||
protected List<ObjectiveGoal<?>> getGoals()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
public abstract class UnorderedObjective<Plugin extends Tutorial> extends Objective<Plugin, UnorderedObjectiveData>
|
||||
{
|
||||
private List<ObjectiveGoal> _goals;
|
||||
private List<ObjectiveGoal<?>> _goals;
|
||||
|
||||
public UnorderedObjective(Plugin plugin, JavaPlugin javaPlugin, String name, String description, String extraDescription)
|
||||
{
|
||||
@ -25,7 +25,7 @@ public abstract class UnorderedObjective<Plugin extends Tutorial> extends Object
|
||||
this(plugin, javaPlugin, name, description, null);
|
||||
}
|
||||
|
||||
protected void addGoal(ObjectiveGoal goal)
|
||||
protected void addGoal(ObjectiveGoal<?> goal)
|
||||
{
|
||||
_goals.add(goal);
|
||||
|
||||
@ -39,7 +39,7 @@ public abstract class UnorderedObjective<Plugin extends Tutorial> extends Object
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void completeGoal(ObjectiveGoal goal, Player player)
|
||||
protected void completeGoal(ObjectiveGoal<?> goal, Player player)
|
||||
{
|
||||
int index = _goals.indexOf(goal);
|
||||
|
||||
@ -87,7 +87,7 @@ public abstract class UnorderedObjective<Plugin extends Tutorial> extends Object
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<ObjectiveGoal> getGoals()
|
||||
protected List<ObjectiveGoal<?>> getGoals()
|
||||
{
|
||||
return _goals;
|
||||
}
|
||||
|
@ -1,18 +1,24 @@
|
||||
package mineplex.game.clans.tutorial.tutorials.clans;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent;
|
||||
import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent;
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
@ -27,7 +33,6 @@ import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
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.event.ClansCommandPreExecutedEvent;
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
@ -53,13 +58,15 @@ public class ClansMainTutorial extends Tutorial
|
||||
private static final int GATE_OPEN_DISTANCE = 15;
|
||||
|
||||
private TutorialMapManager _mapManager;
|
||||
|
||||
private List<Player> _fireworks;
|
||||
// private TutorialRepository _repository;
|
||||
|
||||
public ClansMainTutorial(JavaPlugin plugin, ClansMessageManager message, HologramManager hologram, NpcManager npcManager)
|
||||
{
|
||||
super(plugin, message, hologram, "Clans Tutorial", "Clans.MainTutorial", Material.DIAMOND_SWORD, (byte) 0);
|
||||
|
||||
_fireworks = new ArrayList<Player>();
|
||||
|
||||
try
|
||||
{
|
||||
setWorldManager(new TutorialWorldManager(plugin, "main_tutorial", "schematic/ClansTutorial.schematic"));
|
||||
@ -69,7 +76,7 @@ public class ClansMainTutorial extends Tutorial
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
_mapManager = new TutorialMapManager(plugin, getWorldManager().getTutorialWorld(), -10, 0, 117, 127);
|
||||
_mapManager = new TutorialMapManager(plugin, this, getWorldManager().getTutorialWorld(), -10, 0, 117, 127);
|
||||
|
||||
// _repository = new TutorialRepository(ClansManager.getInstance().getClientManager());
|
||||
|
||||
@ -86,18 +93,28 @@ public class ClansMainTutorial extends Tutorial
|
||||
@Override
|
||||
protected void onFinish(Player player)
|
||||
{
|
||||
_fireworks.add(player);
|
||||
UtilTextMiddle.display(C.cYellow + "Congratulations", "You have completed the Tutorial!", 10, 60, 10);
|
||||
Bukkit.getScheduler().runTaskLater(getPlugin(), () -> {
|
||||
_fireworks.remove(player);
|
||||
getMessage().removePlayer(player);
|
||||
|
||||
|
||||
player.teleport(Spawn.getNorthSpawn());
|
||||
|
||||
ClansManager.getInstance().getPvpTimer().unpause(player);
|
||||
UtilInv.Clear(player);
|
||||
|
||||
ClansManager.getInstance().getItemMapManager().setMap(player);
|
||||
}, 20 * 10L);
|
||||
|
||||
|
||||
|
||||
//ClansManager.getInstance().getPvpTimer().unpause(player);
|
||||
|
||||
/*
|
||||
ClansManager.getInstance().runAsync(() -> {
|
||||
_repository.SetTimesPlayed(player.getUniqueId(), _repository.GetTimesPlayed(player.getUniqueId()) + 1);
|
||||
|
||||
|
||||
final int times = _repository.GetTimesPlayed(player.getUniqueId());
|
||||
|
||||
|
||||
if (_repository.GetTimesPlayed(player.getUniqueId()) == 1)
|
||||
{
|
||||
ClansManager.getInstance().runSync(() -> {
|
||||
@ -106,7 +123,7 @@ public class ClansMainTutorial extends Tutorial
|
||||
GoldManager.getInstance().addGold(player, 32000);
|
||||
UtilPlayer.message(player, F.main("Clans", "You have recieved " + F.elem(32000 + " Gold") + " for finishing the tutorial!"));
|
||||
}
|
||||
|
||||
|
||||
UtilInv.give(player, Material.COOKIE);
|
||||
});
|
||||
}
|
||||
@ -128,7 +145,7 @@ public class ClansMainTutorial extends Tutorial
|
||||
player.getInventory().clear();
|
||||
player.getInventory().setArmorContents(new ItemStack[4]);
|
||||
|
||||
ClansManager.getInstance().getPvpTimer().pause(player);
|
||||
//ClansManager.getInstance().getPvpTimer().pause(player);
|
||||
|
||||
// Spawn Holograms
|
||||
addHologram(player,
|
||||
@ -155,6 +172,7 @@ public class ClansMainTutorial extends Tutorial
|
||||
@Override
|
||||
protected void onQuit(Player player)
|
||||
{
|
||||
_fireworks.remove(player);
|
||||
}
|
||||
|
||||
public Location getPoint(TutorialRegion region, Point point)
|
||||
@ -170,16 +188,24 @@ public class ClansMainTutorial extends Tutorial
|
||||
|
||||
public boolean isIn(Player player, Bounds bounds)
|
||||
{
|
||||
if(player == null || !player.isOnline()) return false;
|
||||
TutorialRegion region = getRegion(player);
|
||||
|
||||
if (region != null)
|
||||
{
|
||||
if (player.getLocation() == null) return false;
|
||||
return isIn(player.getLocation(), region, bounds);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Location getCenter(TutorialRegion region, Bounds bounds)
|
||||
{
|
||||
List<Location> locs = region.getLocationMap().getGoldLocations(bounds.getDataLocColor());
|
||||
return UtilAlg.getMidpoint(locs.get(0), locs.get(1));
|
||||
}
|
||||
|
||||
public Location getSpawn(TutorialRegion region)
|
||||
{
|
||||
Location location = region.getLocationMap().getGoldLocations(Point.SPAWN.getDataLocColor()).get(0).clone();
|
||||
@ -257,10 +283,16 @@ public class ClansMainTutorial extends Tutorial
|
||||
@EventHandler
|
||||
public void breakBlock(BlockBreakEvent event)
|
||||
{
|
||||
System.out.println("main break");
|
||||
if (isInTutorial(event.getPlayer()))
|
||||
{
|
||||
System.out.println("cencelled");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void placeBlock(BlockPlaceEvent event) {
|
||||
if (isInTutorial(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -331,7 +363,6 @@ public class ClansMainTutorial extends Tutorial
|
||||
|
||||
if (event.getArguments()[0].equalsIgnoreCase("join")
|
||||
|| event.getArguments()[0].equalsIgnoreCase("leave")
|
||||
|| event.getArguments()[0].equalsIgnoreCase("map")
|
||||
|| event.getArguments()[0].equalsIgnoreCase("stuck")
|
||||
|| event.getArguments()[0].equalsIgnoreCase("promote")
|
||||
|| event.getArguments()[0].equalsIgnoreCase("demote")
|
||||
@ -342,6 +373,7 @@ public class ClansMainTutorial extends Tutorial
|
||||
|| event.getArguments()[0].equalsIgnoreCase("ally")
|
||||
|| event.getArguments()[0].equalsIgnoreCase("trust")
|
||||
|| event.getArguments()[0].equalsIgnoreCase("unclaim")
|
||||
|| event.getArguments()[0].equalsIgnoreCase("claim")
|
||||
|| event.getArguments()[0].equalsIgnoreCase("delete")
|
||||
|| event.getArguments()[0].equalsIgnoreCase("disband")
|
||||
|| event.getArguments()[0].equalsIgnoreCase("admin")
|
||||
@ -361,6 +393,7 @@ public class ClansMainTutorial extends Tutorial
|
||||
|
||||
for (Player player : getPlayers())
|
||||
{
|
||||
if (player == null || !player.isOnline()) continue;
|
||||
if (player.getLocation().getWorld() != getWorldManager().getTutorialWorld())
|
||||
{
|
||||
TutorialRegion region = getRegion(player);
|
||||
@ -369,10 +402,23 @@ public class ClansMainTutorial extends Tutorial
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void fireworkUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST) return;
|
||||
|
||||
for (Player player : _fireworks)
|
||||
{
|
||||
if (player == null || !player.isOnline()) continue;
|
||||
UtilFirework.spawnRandomFirework(UtilAlg.getRandomLocation(player.getLocation(), 10));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event)
|
||||
{
|
||||
start(event.getPlayer());
|
||||
|
||||
/*
|
||||
ClansManager.getInstance().runAsync(() -> {
|
||||
if (_repository.GetTimesPlayed(event.getPlayer().getUniqueId()) == 0)
|
||||
@ -385,7 +431,9 @@ public class ClansMainTutorial extends Tutorial
|
||||
|
||||
public void performGateCheck(Player player, DyeColor key)
|
||||
{
|
||||
if(player == null || !player.isOnline()) return;
|
||||
Location exact = getRegion(player).getLocationMap().getIronLocations(key).get(0);
|
||||
if(exact == null) return;
|
||||
Location fence = UtilAlg.getAverageLocation(getRegion(player).getLocationMap().getIronLocations(key));
|
||||
|
||||
if (exact.getBlock().getType() == Material.AIR)
|
||||
@ -408,7 +456,21 @@ public class ClansMainTutorial extends Tutorial
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onClick(ClansButtonClickEvent event) {
|
||||
if(isInTutorial(event.getPlayer()))
|
||||
if(isInTutorial(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onShop(ClansPlayerBuyItemEvent event)
|
||||
{
|
||||
if(isInTutorial(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onSell(ClansPlayerSellItemEvent event)
|
||||
{
|
||||
if(isInTutorial(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.game.clans.tutorial.TutorialSession;
|
||||
import mineplex.core.common.DefaultHashMap;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.EnclosedObject;
|
||||
@ -78,6 +79,9 @@ public class AttackEnemyObjective extends OrderedObjective<ClansMainTutorial>
|
||||
{
|
||||
super.customStart(player);
|
||||
|
||||
TutorialSession session = getPlugin().getTutorialSession(player);
|
||||
session.setMapTargetLocation(getPlugin().getCenter(session.getRegion(), ClansMainTutorial.Bounds.ENEMY_LAND));
|
||||
|
||||
addShooter("Chiss", getPlugin().getPoint(getPlugin().getRegion(player), ClansMainTutorial.Point.NPC_2), player);
|
||||
addShooter("defek7", getPlugin().getPoint(getPlugin().getRegion(player), ClansMainTutorial.Point.NPC_1), player);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package mineplex.game.clans.tutorial.tutorials.clans.objective;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.game.clans.tutorial.TutorialSession;
|
||||
import mineplex.game.clans.tutorial.objective.OrderedObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.classes.EquipDefaultBuildGoal;
|
||||
@ -22,6 +23,15 @@ public class ClassesObjective extends OrderedObjective<ClansMainTutorial>
|
||||
setStartMessageDelay(60);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customStart(Player player)
|
||||
{
|
||||
super.customStart(player);
|
||||
|
||||
TutorialSession session = getPlugin().getTutorialSession(player);
|
||||
session.setMapTargetLocation(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customLeave(Player player)
|
||||
{
|
||||
|
@ -3,6 +3,7 @@ package mineplex.game.clans.tutorial.tutorials.clans.objective;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.game.clans.tutorial.TutorialSession;
|
||||
import mineplex.game.clans.tutorial.objective.OrderedObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.energy.BuyEnergyGoal;
|
||||
@ -20,6 +21,15 @@ public class EnergyObjective extends OrderedObjective<ClansMainTutorial>
|
||||
setStartMessageDelay(60);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customStart(Player player)
|
||||
{
|
||||
super.customStart(player);
|
||||
|
||||
TutorialSession session = getPlugin().getTutorialSession(player);
|
||||
session.setMapTargetLocation(getPlugin().getPoint(session.getRegion(), ClansMainTutorial.Point.ENERGY_SHOP));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customLeave(Player player)
|
||||
{
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.game.clans.tutorial.TutorialSession;
|
||||
import mineplex.game.clans.tutorial.objective.OrderedObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.HoldItemGoal;
|
||||
@ -30,7 +31,7 @@ public class FieldsObjective extends OrderedObjective<ClansMainTutorial>
|
||||
addGoal(new MineDiamondsGoal(this));
|
||||
addGoal(new SellDiamondsGoal(this));
|
||||
|
||||
setStartMessageDelay(60);
|
||||
// setStartMessageDelay(60);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -47,5 +48,8 @@ public class FieldsObjective extends OrderedObjective<ClansMainTutorial>
|
||||
protected void customStart(Player player)
|
||||
{
|
||||
super.customStart(player);
|
||||
|
||||
TutorialSession session = getPlugin().getTutorialSession(player);
|
||||
session.setMapTargetLocation(getPlugin().getCenter(session.getRegion(), ClansMainTutorial.Bounds.FIELDS));
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package mineplex.game.clans.tutorial.tutorials.clans.objective;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.game.clans.tutorial.TutorialSession;
|
||||
import mineplex.game.clans.tutorial.objective.OrderedObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.finalobj.DisbandClanGoal;
|
||||
@ -20,6 +21,15 @@ public class FinalObjective extends OrderedObjective<ClansMainTutorial>
|
||||
setStartMessageDelay(60);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customStart(Player player)
|
||||
{
|
||||
super.customStart(player);
|
||||
|
||||
TutorialSession session = getPlugin().getTutorialSession(player);
|
||||
session.setMapTargetLocation(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customLeave(Player player)
|
||||
{
|
||||
|
@ -1,13 +1,22 @@
|
||||
package mineplex.game.clans.tutorial.tutorials.clans.objective;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.game.clans.tutorial.TutorialSession;
|
||||
import mineplex.game.clans.tutorial.objective.UnorderedObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.shops.PurchaseGoal;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PurchaseItemsObjective extends UnorderedObjective<ClansMainTutorial>
|
||||
{
|
||||
public PurchaseItemsObjective(ClansMainTutorial clansMainTutorial, JavaPlugin javaPlugin)
|
||||
@ -18,8 +27,8 @@ public class PurchaseItemsObjective extends UnorderedObjective<ClansMainTutorial
|
||||
this,
|
||||
Material.IRON_HELMET,
|
||||
"Purchase Iron Helmet",
|
||||
"Buy an Iron Helmet",
|
||||
"The shops sell everything you could ever need and more."
|
||||
"Buy an Iron Helmet from the PvP Gear NPC",
|
||||
"The shops sell everything you could ever need and more. Buy armour from the " + C.cYellow + "PvP NPC."
|
||||
));
|
||||
addGoal(new PurchaseGoal(this, Material.IRON_CHESTPLATE, "Purchase Iron Chestplate",
|
||||
"Buy an Iron Chestplate"));
|
||||
@ -34,8 +43,33 @@ public class PurchaseItemsObjective extends UnorderedObjective<ClansMainTutorial
|
||||
setStartMessageDelay(60);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customStart(Player player)
|
||||
{
|
||||
super.customStart(player);
|
||||
|
||||
TutorialSession session = getPlugin().getTutorialSession(player);
|
||||
session.setMapTargetLocation(getPlugin().getPoint(session.getRegion(), ClansMainTutorial.Point.PVP_SHOP));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customFinish(Player player)
|
||||
{
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event) {
|
||||
if(!event.getType().equals(UpdateType.SEC_05)) return;
|
||||
|
||||
for (Player player : getActivePlayers())
|
||||
{
|
||||
if (player == null || !player.isOnline()) continue;
|
||||
List<Location> locations = getPlugin().getRegion(player).getLocationMap().getSpongeLocations(DyeColor.BROWN);
|
||||
if (locations == null) continue;
|
||||
for(Location loc : locations)
|
||||
{
|
||||
UtilFirework.playFirework(loc, FireworkEffect.Type.BURST, Color.AQUA, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,11 +13,13 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.npc.Npc;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.database.tables.records.NpcsRecord;
|
||||
import mineplex.game.clans.tutorial.TutorialRegion;
|
||||
import mineplex.game.clans.tutorial.TutorialSession;
|
||||
import mineplex.game.clans.tutorial.objective.OrderedObjective;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.HoldItemGoal;
|
||||
@ -40,8 +42,8 @@ public class ShopsObjective extends OrderedObjective<ClansMainTutorial>
|
||||
this,
|
||||
Material.MAP,
|
||||
"Identify Shops on Map",
|
||||
"Find the Yellow striped area on your map",
|
||||
"Shops are marked on the map by the " + F.elem("Yellow Stripes") + "."
|
||||
"Find the Blue striped area on your map",
|
||||
"Shops are marked on the map by the " + C.cDAqua + "Blue Stripes" + C.mBody + "."
|
||||
));
|
||||
addGoal(new GoToShopsGoal(this));
|
||||
addGoal(new SellPotatoesGoal(this));
|
||||
@ -89,6 +91,10 @@ public class ShopsObjective extends OrderedObjective<ClansMainTutorial>
|
||||
npcs.add(spawnNpc(farmingShop, "Organic Produce"));
|
||||
npcs.add(spawnNpc(miningShop, "Mining Shop"));
|
||||
_npcMap.put(player.getUniqueId(), npcs);
|
||||
|
||||
TutorialSession session = getPlugin().getTutorialSession(player);
|
||||
session.setMapTargetLocation(getPlugin().getCenter(session.getRegion(), ClansMainTutorial.Bounds.SHOPS));
|
||||
|
||||
}
|
||||
|
||||
private Npc spawnNpc(Location location, String name)
|
||||
|
@ -12,21 +12,21 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.tutorial.objective.Objective;
|
||||
import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
|
||||
|
||||
public class HoldItemGoal extends ObjectiveGoal<Objective>
|
||||
public class HoldItemGoal extends ObjectiveGoal<Objective<?, ?>>
|
||||
{
|
||||
private DefaultHashMap<String, EnclosedObject<Integer>> _ticksHeld = new DefaultHashMap<>(key -> new EnclosedObject<>(Integer.valueOf(0)));
|
||||
private Material _material;
|
||||
|
||||
public HoldItemGoal(Objective objective, Material material, String name, String description, String helpText, int startDelay)
|
||||
public HoldItemGoal(Objective<?, ?> objective, Material material, String name, String description, String helpText, int startDelay)
|
||||
{
|
||||
super(objective, name, description, helpText);
|
||||
super(objective, name, description, helpText, null);
|
||||
|
||||
_material = material;
|
||||
|
||||
setStartMessageDelay(startDelay);
|
||||
// setStartMessageDelay(startDelay);
|
||||
}
|
||||
|
||||
public HoldItemGoal(Objective objective, Material material, String name, String description, String helpText)
|
||||
public HoldItemGoal(Objective<?, ?> objective, Material material, String name, String description, String helpText)
|
||||
{
|
||||
this(objective, material, name, description, helpText, 120);
|
||||
}
|
||||
@ -51,7 +51,8 @@ public class HoldItemGoal extends ObjectiveGoal<Objective>
|
||||
return;
|
||||
}
|
||||
|
||||
getActivePlayers().forEach(uuid -> {
|
||||
getActivePlayers().forEach(uuid ->
|
||||
{
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
|
||||
if (player != null && player.isOnline())
|
||||
|
@ -2,6 +2,7 @@ package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -16,6 +17,7 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.fallingblock.FallingBlocks;
|
||||
import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent;
|
||||
import mineplex.game.clans.tutorial.TutorialRegion;
|
||||
import mineplex.game.clans.tutorial.TutorialSession;
|
||||
import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.AttackEnemyObjective;
|
||||
@ -28,22 +30,23 @@ public class BlowUpWallGoal extends ObjectiveGoal<AttackEnemyObjective>
|
||||
objective,
|
||||
"Blow up the Enemy Base",
|
||||
"Left-Click whilst sitting on the cannon to fire",
|
||||
"This is the fun part. Use the Cannon to smash a hole in your enemy’s wall KA-BOOM!"
|
||||
"This is the fun part. Use the Cannon to smash a hole in your enemy’s wall KA-BOOM!",
|
||||
DyeColor.MAGENTA
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customStart(Player player)
|
||||
{
|
||||
TutorialSession session = getObjective().getPlugin().getTutorialSession(player);
|
||||
session.setMapTargetLocation(getObjective().getPlugin().getCenter(session.getRegion(), ClansMainTutorial.Bounds.ENEMY_ATTACK_AREA));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void siegeWeaponExplode(SiegeWeaponExplodeEvent event)
|
||||
{
|
||||
Player shooter = event.getProjectile().getShooter();
|
||||
|
||||
System.out.println(shooter.getName());
|
||||
|
||||
|
||||
if (!contains(shooter))
|
||||
{
|
||||
if (getObjective().getPlugin().isInTutorial(shooter))
|
||||
|
@ -23,10 +23,11 @@ public class GetMapGoal extends ObjectiveGoal<AttackEnemyObjective>
|
||||
"You can get a Map any time you need one. The map will show you who " +
|
||||
"owns the land around the map. Your clan is " + C.cAqua + "aqua" +
|
||||
C.mBody + ", your allies are " + C.cGreen + "green" + C.mBody + ", " +
|
||||
"and your enemies are " + C.cRed + "red" + C.mBody + "."
|
||||
"and your enemies are " + C.cRed + "red" + C.mBody + ".",
|
||||
null
|
||||
);
|
||||
|
||||
setStartMessageDelay(120);
|
||||
// setStartMessageDelay(120);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -42,11 +43,15 @@ public class GetMapGoal extends ObjectiveGoal<AttackEnemyObjective>
|
||||
@EventHandler
|
||||
public void onGetMap(PlayerGetMapEvent event)
|
||||
{
|
||||
if (!contains(event.getPlayer()))
|
||||
if (getObjective().getPlugin().isInTutorial(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
event.setCancelled(true);
|
||||
getObjective().getPlugin().getMapManager().setMap(event.getPlayer());
|
||||
|
||||
if (contains(event.getPlayer()))
|
||||
{
|
||||
finish(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
finish(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,8 @@ public class LoadCannonGoal extends ObjectiveGoal<AttackEnemyObjective>
|
||||
"Load the Cannon",
|
||||
"Right click whilst sitting on the Cannon, and load it with TNT!",
|
||||
"First you’ll need to load this baby up with some TNT. Right click whilst sitting " +
|
||||
"on the Cannon, and load it with TNT!"
|
||||
"on the Cannon, and load it with TNT!",
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -12,7 +13,9 @@ import mineplex.game.clans.clans.siege.SiegeManager;
|
||||
import mineplex.game.clans.clans.siege.events.MountSiegeWeaponEvent;
|
||||
import mineplex.game.clans.clans.siege.weapon.Cannon;
|
||||
import mineplex.game.clans.tutorial.TutorialRegion;
|
||||
import mineplex.game.clans.tutorial.TutorialSession;
|
||||
import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial.Point;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.AttackEnemyObjective;
|
||||
|
||||
@ -25,7 +28,8 @@ public class MountCannonGoal extends ObjectiveGoal<AttackEnemyObjective>
|
||||
"Get on the Cannon",
|
||||
"Right click on the Cannon to hop on!",
|
||||
"To break through an enemy Clan’s fortress you’ll need some serious " +
|
||||
"firepower. Try using this TNT Cannon to get the job done!"
|
||||
"firepower. Try using this TNT Cannon to get the job done!",
|
||||
DyeColor.BLACK
|
||||
);
|
||||
}
|
||||
|
||||
@ -34,6 +38,10 @@ public class MountCannonGoal extends ObjectiveGoal<AttackEnemyObjective>
|
||||
{
|
||||
getObjective().getCannons().put(player.getName(), SiegeManager.Instance.spawnCannon(player, getObjective().getPlugin().getPoint(getObjective().getPlugin().getRegion(player), Point.CANNON), false));
|
||||
getObjective().getCannons().get(player.getName()).SetForcedVelocity(0.4, 2.45);
|
||||
getObjective().getCannons().get(player.getName()).setInvincible(true);
|
||||
|
||||
TutorialSession session = getObjective().getPlugin().getTutorialSession(player);
|
||||
session.setMapTargetLocation(getObjective().getPlugin().getPoint(session.getRegion(), ClansMainTutorial.Point.CANNON));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,6 +4,7 @@ import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -17,6 +18,7 @@ import mineplex.core.common.DefaultHashMap;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.game.clans.tutorial.TutorialRegion;
|
||||
import mineplex.game.clans.tutorial.TutorialSession;
|
||||
import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.AttackEnemyObjective;
|
||||
@ -32,7 +34,8 @@ public class StealEnemyPotatoesGoal extends ObjectiveGoal<AttackEnemyObjective>
|
||||
"Steal Potatoes",
|
||||
"Retrieve the potatoes from the Enemy Clan’s base",
|
||||
"Now that their walls are down, it’s time to get rich! Go steal their " +
|
||||
"potatoes for your Clan!"
|
||||
"potatoes for your Clan!",
|
||||
DyeColor.PURPLE
|
||||
);
|
||||
}
|
||||
|
||||
@ -48,6 +51,9 @@ public class StealEnemyPotatoesGoal extends ObjectiveGoal<AttackEnemyObjective>
|
||||
{
|
||||
_playersMap.put(player.getUniqueId(), new AtomicInteger(0));
|
||||
UtilPlayer.message(player, F.main("Clans", "Now that you have blown a hole in the enemy's base, go and steal their potatoes."));
|
||||
|
||||
TutorialSession session = getObjective().getPlugin().getTutorialSession(player);
|
||||
session.setMapTargetLocation(getObjective().getPlugin().getCenter(session.getRegion(), ClansMainTutorial.Bounds.ENEMY_LAND));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,6 +2,7 @@ package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -40,7 +41,8 @@ public class BuildHouseGoal extends ObjectiveGoal<ClanObjective>
|
||||
"Build a House",
|
||||
"Build a House (place all your blocks)",
|
||||
"The first thing you should do on your land is build a house, even " +
|
||||
"if it’s made of dirt! This will give you a safe place to store your loot!"
|
||||
"if it’s made of dirt! This will give you a safe place to store your loot!",
|
||||
DyeColor.ORANGE
|
||||
);
|
||||
}
|
||||
|
||||
@ -69,7 +71,9 @@ public class BuildHouseGoal extends ObjectiveGoal<ClanObjective>
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
for (ItemStack stack : _items)
|
||||
{
|
||||
if (event.getBlock().getType().equals(stack.getType()) || event.getBlock().getType().equals(Material.IRON_DOOR_BLOCK))
|
||||
@ -84,14 +88,17 @@ public class BuildHouseGoal extends ObjectiveGoal<ClanObjective>
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler (priority = EventPriority.HIGHEST)
|
||||
public void blockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (!contains(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
event.setCancelled(false);
|
||||
|
||||
|
||||
if (isInBuildArea(event.getPlayer(), event.getBlock()))
|
||||
{
|
||||
// Run 1 tick later because inventory doesn't get updated instantly
|
||||
|
@ -2,7 +2,9 @@ package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -27,7 +29,9 @@ public class ClaimLandGoal extends ObjectiveGoal<ClanObjective>
|
||||
"Claim Land",
|
||||
"Claim Land using the Clan Menu ( Type /c )",
|
||||
"The first thing your Clan needs to do before you can start to " +
|
||||
"build your fortress is claim the land in an area for your Clan."
|
||||
"build your fortress is claim the land in an area for your Clan. " +
|
||||
"You must be inside the " + C.cAqua + "blue" + C.cGray + " outline to claim land.",
|
||||
DyeColor.ORANGE
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
|
||||
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
@ -28,7 +29,8 @@ public class ClanInfoGoal extends ObjectiveGoal<AttackEnemyObjective>
|
||||
"View info about the enemy clan by typing /c EnemyClan",
|
||||
"You can lookup details about your enemy before going for an " +
|
||||
"attack! This can give you a crucial advantage before " +
|
||||
"you begin."
|
||||
"you begin.",
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
@ -53,13 +55,13 @@ public class ClanInfoGoal extends ObjectiveGoal<AttackEnemyObjective>
|
||||
|
||||
if (!event.getArguments()[0].equalsIgnoreCase("EnemyClan"))
|
||||
{
|
||||
// Display info
|
||||
event.getPlayer().sendMessage(F.main("Clans", "That clan does not exist."));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanToken token = new ClanToken();
|
||||
token.Name = "EnemyClan";
|
||||
token.Description = "The meanest clan in the world!";
|
||||
token.Description = "Chiss";
|
||||
token.Home = "";
|
||||
token.Admin = false;
|
||||
token.Energy = 4320;
|
||||
|
@ -23,8 +23,9 @@ public class ClanManagementGoal extends ObjectiveGoal<ClanObjective>
|
||||
objective,
|
||||
"Open the Clan Menu",
|
||||
"Open the Clan Menu ( Type /c )",
|
||||
"Clan Menu lets you view all clan information and perform actions: " +
|
||||
"who is online, Claiming Land, Inviting Players and much more."
|
||||
"Clan Menu lets you view all clan information and perform actions such as: " +
|
||||
"who is online, Claiming Land, Inviting Players and much more.",
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,8 @@ public class CreateClanGoal extends ObjectiveGoal<ClanObjective>
|
||||
"Type /c create <name> to create a new Clan",
|
||||
F.elem("Clans") + " are groups of players that can claim land, build fortresses, " +
|
||||
"and fight epic battles. Together they will challenge other clans for " +
|
||||
"control of the land."
|
||||
"control of the land.",
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
@ -47,6 +48,7 @@ public class CreateClanGoal extends ObjectiveGoal<ClanObjective>
|
||||
if (contains(event.getFounder()))
|
||||
{
|
||||
finish(event.getFounder());
|
||||
ClansManager.getInstance().resetLeftTimer(event.getFounder().getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,14 @@
|
||||
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
@ -26,11 +28,12 @@ public class LeaveSpawnGoal extends ObjectiveGoal<ClanObjective>
|
||||
F.elem("Spawn Island") + " is where you will respawn when you die. This area is " +
|
||||
"a " + F.elem("Safe Zone") + ", meaning that players cannot hurt each other. " +
|
||||
"From here, you can teleport to various places, as well as read some helpful " +
|
||||
"hints. To leave " + F.elem("Spawn Island") + ", simply jump off!"
|
||||
"hints. To leave " + F.elem("Spawn Island") + ", simply jump off!",
|
||||
DyeColor.WHITE
|
||||
);
|
||||
|
||||
// 2 seconds after start message
|
||||
setStartMessageDelay(20 * 3);
|
||||
// setStartMessageDelay(20 * 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -42,7 +45,7 @@ public class LeaveSpawnGoal extends ObjectiveGoal<ClanObjective>
|
||||
@Override
|
||||
protected void customStart(Player player)
|
||||
{
|
||||
|
||||
player.getInventory().clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,6 +54,12 @@ public class LeaveSpawnGoal extends ObjectiveGoal<ClanObjective>
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCommand(ClansCommandPreExecutedEvent event)
|
||||
{
|
||||
if(contains(event.getPlayer())) event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void checkRegion(UpdateEvent event)
|
||||
{
|
||||
@ -60,9 +69,10 @@ public class LeaveSpawnGoal extends ObjectiveGoal<ClanObjective>
|
||||
for (UUID uuid : getActivePlayers())
|
||||
{
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if (!getObjective().getPlugin().isIn(player, ClansMainTutorial.Bounds.SPAWN))
|
||||
if(player == null || !player.isOnline()) continue;
|
||||
if (!getObjective().getPlugin().isIn(player, ClansMainTutorial.Bounds.SPAWN))
|
||||
{
|
||||
finish(player);
|
||||
finish(Bukkit.getPlayer(uuid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
|
||||
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import net.minecraft.server.v1_8_R3.EnumDirection;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -24,7 +25,8 @@ public class SetHomeGoal extends ObjectiveGoal<ClanObjective>
|
||||
"Set your Clan's Home ( Type /c sethome )",
|
||||
"Your Clan Home is a special place in your base that you can teleport " +
|
||||
"to from " + F.elem("Spawn Island") + ". You can teleport to it " +
|
||||
"at any time by typing " + F.elem("/c home") + "."
|
||||
"at any time by typing " + F.elem("/c home") + ".",
|
||||
DyeColor.ORANGE
|
||||
);
|
||||
|
||||
setDisplayFinishMessage(false);
|
||||
@ -45,6 +47,8 @@ public class SetHomeGoal extends ObjectiveGoal<ClanObjective>
|
||||
{
|
||||
if (contains(event.getPlayer()) && event.getArguments().length == 1 && event.getArguments()[0].equalsIgnoreCase("sethome"))
|
||||
{
|
||||
event.setCancelled(true); //before checking if bed placed
|
||||
|
||||
if (getObjective().getPlugin().isIn(event.getPlayer(), ClansMainTutorial.Bounds.LAND_CLAIM))
|
||||
{
|
||||
boolean bedPlaced = UtilBlock.placeBed(event.getPlayer().getLocation(), BlockFace.valueOf(EnumDirection.fromAngle(event.getPlayer().getLocation().getYaw()).name()), false, false);
|
||||
@ -67,7 +71,6 @@ public class SetHomeGoal extends ObjectiveGoal<ClanObjective>
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Tutorial", "You must set your home in your own land claim."));
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,10 +16,11 @@ public class EquipDefaultBuildGoal extends ObjectiveGoal<ClassesObjective>
|
||||
"Equip Armor",
|
||||
"Put on your Iron Armor",
|
||||
"When you wear a full set of armor, it will equip a class! The Iron set makes you " +
|
||||
"into a Knight. Each class has different skills and is strong in its own way."
|
||||
"into a Knight. Each class has different skills and is strong in its own way.",
|
||||
null
|
||||
);
|
||||
|
||||
setStartMessageDelay(120);
|
||||
// setStartMessageDelay(120);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.classes;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -20,7 +21,8 @@ public class OpenClassManagerGoal extends ObjectiveGoal<ClassesObjective>
|
||||
"Right-Click on the Enchantment Table",
|
||||
"Each class has lots of different skills, and you can pick which ones you want to " +
|
||||
"equip! Click on an " + F.elem("Enchanting Table") + " to have a look at " +
|
||||
"this menu."
|
||||
"this menu.",
|
||||
DyeColor.CYAN
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class SelectBullsChargeGoal extends ObjectiveGoal<ClassesObjective>
|
||||
getActivePlayers().forEach(uuid -> {
|
||||
Player player = UtilPlayer.searchExact(uuid);
|
||||
|
||||
if (player == null)
|
||||
if (player == null || !player.isOnline())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -1,42 +1,50 @@
|
||||
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.classes;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
||||
import mineplex.minecraft.game.classcombat.Class.IPvpClass;
|
||||
import mineplex.minecraft.game.classcombat.Class.event.ClassEquipEvent;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClassesObjective;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class UseBullsChargeGoal extends ObjectiveGoal<ClassesObjective>
|
||||
{
|
||||
public UseBullsChargeGoal(ClassesObjective objective)
|
||||
{
|
||||
public class UseBullsChargeGoal extends ObjectiveGoal<ClassesObjective> {
|
||||
public UseBullsChargeGoal(ClassesObjective objective) {
|
||||
super(
|
||||
objective,
|
||||
"Use Bulls Charge",
|
||||
"Right-Click with Axe to use Bull's Charge",
|
||||
"One of your default abilities as Knight is Bulls Charge. This ability will make " +
|
||||
"you run faster for a short time, and deal extra damage to enemies."
|
||||
"you run faster for a short time, and deal extra damage to enemies.",
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customStart(Player player)
|
||||
{
|
||||
protected void customStart(Player player) {
|
||||
ClientClass client = ClansManager.getInstance().getClassManager().Get(player);
|
||||
|
||||
client.ResetSkills(player);
|
||||
client.SetActiveCustomBuild(client.GetGameClass(), client.GetGameClass().getDefaultBuild());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customFinish(Player player)
|
||||
{
|
||||
protected void customFinish(Player player) {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void checkSkill(SkillTriggerEvent event)
|
||||
{
|
||||
if (contains(event.GetPlayer()))
|
||||
{
|
||||
if (event.GetSkillName().toLowerCase().contains("bulls charge"))
|
||||
public void checkSkill(SkillTriggerEvent event) {
|
||||
if (contains(event.GetPlayer())) {
|
||||
finish(event.GetPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,11 @@
|
||||
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.energy;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
@ -16,13 +22,20 @@ public class BuyEnergyGoal extends ObjectiveGoal<EnergyObjective>
|
||||
objective,
|
||||
"Buy Energy",
|
||||
"Buy Clan Energy from the Energy Shop",
|
||||
"You can buy Clan Energy at the Shops."
|
||||
"You can buy Clan Energy at the Shops.",
|
||||
DyeColor.RED
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customStart(Player player)
|
||||
{
|
||||
ClansManager.getInstance().runSyncLater(() -> {
|
||||
UtilPlayer.message(player, F.main("Clans", "WARNING: Clan Energy is running very low!"));
|
||||
UtilTextMiddle.display("Clan Energy", "is running very low", 10, 100, 10, player);
|
||||
|
||||
player.playSound(player.getLocation(), Sound.NOTE_BASS, 1.0f, 1.0f);
|
||||
}, 3L);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,18 +23,14 @@ public class ExplainEnergyGoal extends ObjectiveGoal<EnergyObjective>
|
||||
"Look at your energy in your Clans Menu ( Type /c )",
|
||||
"Owning land isn’t free! You will need to buy Energy from the Shops to retain " +
|
||||
"ownership of it. If your Clan Energy ever reaches 0, you will lose your " +
|
||||
"land claims!"
|
||||
"land claims!",
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customStart(Player player)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Clans", "WARNING: Clan Energy is running very low!"));
|
||||
UtilTextMiddle.display("Clan Energy", "is running very low", 10, 100, 10, player);
|
||||
|
||||
player.playSound(player.getLocation(), Sound.NOTE_BASS, 1.0f, 1.0f);
|
||||
|
||||
ClansManager.getInstance().runSyncLater(() -> {
|
||||
// Explain Energy
|
||||
UtilPlayer.message(player, F.main("Clans", "Energy is required to maintain a Clan's territory, without it, any territory that your Clan owns will be claimed by the Wilderness, and anyone will be able to claim that territory. You can buy Energy at the Energy Shop in the Shops."));
|
||||
@ -45,7 +41,7 @@ public class ExplainEnergyGoal extends ObjectiveGoal<EnergyObjective>
|
||||
}, 20 * 10L);
|
||||
}, 20 * 3L);
|
||||
|
||||
setStartMessageDelay(120);
|
||||
// setStartMessageDelay(120);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,7 +25,8 @@ public class GoToFieldsGoal extends ObjectiveGoal<FieldsObjective>
|
||||
"Go to the Fields",
|
||||
"Go to the Fields",
|
||||
"The Fields are a very dangerous place where players come to fight and harvest " +
|
||||
"resources!"
|
||||
"resources!",
|
||||
DyeColor.YELLOW
|
||||
);
|
||||
}
|
||||
|
||||
@ -49,6 +50,8 @@ public class GoToFieldsGoal extends ObjectiveGoal<FieldsObjective>
|
||||
|
||||
for (UUID uuid : getActivePlayers())
|
||||
{
|
||||
if(UtilPlayer.searchExact(uuid) == null) return;
|
||||
|
||||
getObjective().getPlugin().performGateCheck(UtilPlayer.searchExact(uuid), DyeColor.RED);
|
||||
}
|
||||
}
|
||||
@ -62,6 +65,7 @@ public class GoToFieldsGoal extends ObjectiveGoal<FieldsObjective>
|
||||
for (UUID uuid : getActivePlayers())
|
||||
{
|
||||
Player player = UtilPlayer.searchExact(uuid);
|
||||
if(player == null || !player.isOnline()) continue;
|
||||
if (getObjective().getPlugin().isIn(player, ClansMainTutorial.Bounds.FIELDS))
|
||||
{
|
||||
finish(player);
|
||||
|
@ -5,6 +5,7 @@ import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -30,7 +31,8 @@ public class MineDiamondsGoal extends ObjectiveGoal<FieldsObjective>
|
||||
"Mine Diamonds",
|
||||
"Search for some diamonds in the Fields and mine them",
|
||||
"Mining in the Fields is a great way to make lots of money! The ores will " +
|
||||
"regenerate over time. Be careful of enemies though!"
|
||||
"regenerate over time. Be careful of enemies though!",
|
||||
DyeColor.LIME
|
||||
);
|
||||
|
||||
_playersMap = new HashMap<>();
|
||||
@ -59,15 +61,12 @@ public class MineDiamondsGoal extends ObjectiveGoal<FieldsObjective>
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
System.out.println("a");
|
||||
if (!contains(event.getPlayer()) || event.getBlock().getType() != Material.DIAMOND_ORE)
|
||||
return;
|
||||
System.out.println("b");
|
||||
|
||||
TutorialRegion region = getObjective().getPlugin().getRegion(event.getPlayer());
|
||||
if (getObjective().getPlugin().isIn(event.getBlock().getLocation(), region, ClansMainTutorial.Bounds.FIELDS))
|
||||
{
|
||||
System.out.println("c");
|
||||
event.setCancelled(true);
|
||||
event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation().add(0.5, 1.5, 0.5), new ItemStack(Material.DIAMOND));
|
||||
event.getBlock().setType(Material.COBBLESTONE);
|
||||
@ -94,6 +93,7 @@ public class MineDiamondsGoal extends ObjectiveGoal<FieldsObjective>
|
||||
|
||||
if (event.getItem().getItemStack().getType() == Material.DIAMOND)
|
||||
{
|
||||
if(_playersMap.get(event.getPlayer().getUniqueId()) == null) return;
|
||||
int count = _playersMap.get(event.getPlayer().getUniqueId()).incrementAndGet();
|
||||
if (count == 10)
|
||||
finish(event.getPlayer());
|
||||
|
@ -9,8 +9,11 @@ import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent;
|
||||
import mineplex.game.clans.tutorial.TutorialSession;
|
||||
import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.FieldsObjective;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
public class SellDiamondsGoal extends ObjectiveGoal<FieldsObjective>
|
||||
{
|
||||
@ -20,14 +23,16 @@ public class SellDiamondsGoal extends ObjectiveGoal<FieldsObjective>
|
||||
objective,
|
||||
"Sell Diamonds",
|
||||
"Sell your Diamonds to the Mining Shop",
|
||||
"Go back to the Shops and sell your precious diamonds!"
|
||||
"Go back to the Shops and sell your precious diamonds!",
|
||||
DyeColor.SILVER
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customStart(Player player)
|
||||
{
|
||||
|
||||
TutorialSession session = getObjective().getPlugin().getTutorialSession(player);
|
||||
session.setMapTargetLocation(getObjective().getPlugin().getPoint(session.getRegion(), ClansMainTutorial.Point.MINING_SHOP));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -40,21 +45,17 @@ public class SellDiamondsGoal extends ObjectiveGoal<FieldsObjective>
|
||||
getObjective().getPlugin().destroyFences(getObjective().getPlugin().getRegion(player), DyeColor.BLACK);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler (priority = EventPriority.HIGH)
|
||||
public void onSell(ClansPlayerSellItemEvent event)
|
||||
{
|
||||
if (contains(event.getPlayer()))
|
||||
{
|
||||
if (event.getItem().getType() == Material.DIAMOND)
|
||||
{
|
||||
event.setCancelled(false);
|
||||
UtilInv.removeAll(event.getPlayer(), Material.DIAMOND, (byte) 0);
|
||||
finish(event.getPlayer());
|
||||
}
|
||||
else
|
||||
{
|
||||
event.setCancelled(true);
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Tutorial", "You need to sell your diamonds to the Mining Shop NPC!"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -25,7 +25,8 @@ public class DisbandClanGoal extends ObjectiveGoal<FinalObjective>
|
||||
"Disband your Clan ( Type /c )",
|
||||
"Now that the tutorial is almost finished, let’s delete your Clan. Disbanding a " +
|
||||
"Clan will delete it, and unclaim all of your land. Open the Clans Menu " +
|
||||
"and do this now."
|
||||
"and do this now.",
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
@ -37,6 +38,7 @@ public class DisbandClanGoal extends ObjectiveGoal<FinalObjective>
|
||||
@Override
|
||||
protected void customFinish(Player player)
|
||||
{
|
||||
ClansManager.getInstance().resetLeftTimer(player.getUniqueId());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@ -50,6 +52,7 @@ public class DisbandClanGoal extends ObjectiveGoal<FinalObjective>
|
||||
|
||||
UtilPlayer.message(event.getDisbander(), F.main("Clans", "You have disbanded your Tutorial Clan."));
|
||||
ClansManager.getInstance().getClanDataAccess().delete(ClansManager.getInstance().getClan(event.getDisbander()), null);
|
||||
ClansManager.getInstance().resetLeftTimer(event.getDisbander().getUniqueId());
|
||||
finish(event.getDisbander());
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@ import mineplex.game.clans.tutorial.objective.Objective;
|
||||
import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.FinalObjective;
|
||||
|
||||
public class TpClanHomeGoal extends ObjectiveGoal<FinalObjective>
|
||||
@ -24,10 +23,11 @@ public class TpClanHomeGoal extends ObjectiveGoal<FinalObjective>
|
||||
objective,
|
||||
"Teleport to Clan Home",
|
||||
"Teleport back to your Clan Home ( Type /c home )",
|
||||
"You can teleport back to your Clan Home at any time, as long as it's set!"
|
||||
"You can teleport back to your Clan Home at any time, as long as it's set!",
|
||||
null
|
||||
);
|
||||
|
||||
setStartMessageDelay(120);
|
||||
// setStartMessageDelay(120);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,7 +24,8 @@ public class GoToShopsGoal extends ObjectiveGoal<ShopsObjective>
|
||||
objective,
|
||||
"Go to the Shops",
|
||||
"Head over to the Shops (use your map)",
|
||||
"The shops are the place where you can buy and sell all sorts of items!"
|
||||
"The shops are the place where you can buy and sell all sorts of items!",
|
||||
DyeColor.LIGHT_BLUE
|
||||
);
|
||||
}
|
||||
|
||||
@ -50,6 +51,7 @@ public class GoToShopsGoal extends ObjectiveGoal<ShopsObjective>
|
||||
|
||||
for (UUID uuid : getActivePlayers())
|
||||
{
|
||||
if(UtilPlayer.searchExact(uuid) == null) continue;
|
||||
getObjective().getPlugin().performGateCheck(UtilPlayer.searchExact(uuid), DyeColor.BROWN);
|
||||
}
|
||||
}
|
||||
@ -63,6 +65,7 @@ public class GoToShopsGoal extends ObjectiveGoal<ShopsObjective>
|
||||
for (UUID uuid : getActivePlayers())
|
||||
{
|
||||
Player player = UtilPlayer.searchExact(uuid);
|
||||
if(player == null || !player.isOnline()) continue;
|
||||
if (getObjective().getPlugin().isIn(player, ClansMainTutorial.Bounds.SHOPS))
|
||||
{
|
||||
finish(player);
|
||||
|
@ -8,6 +8,7 @@ import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent;
|
||||
import mineplex.game.clans.clans.event.ClansShopAddButtonEvent;
|
||||
import mineplex.game.clans.tutorial.objective.Objective;
|
||||
import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
public class PurchaseGoal extends ObjectiveGoal
|
||||
{
|
||||
@ -25,7 +26,7 @@ public class PurchaseGoal extends ObjectiveGoal
|
||||
public PurchaseGoal(Objective objective, Material material, String name, String description,
|
||||
String helpText)
|
||||
{
|
||||
super(objective, name, description, helpText);
|
||||
super(objective, name, description, helpText, null);
|
||||
_material = material;
|
||||
|
||||
setDisplayStartMessage(false);
|
||||
@ -54,11 +55,12 @@ public class PurchaseGoal extends ObjectiveGoal
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler (priority = EventPriority.HIGH)
|
||||
public void buy(final ClansPlayerBuyItemEvent event)
|
||||
{
|
||||
if (contains(event.getPlayer()) && event.getItem().getType() == _material)
|
||||
{
|
||||
event.setCancelled(false);
|
||||
finish(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
@ -9,8 +9,11 @@ import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent;
|
||||
import mineplex.game.clans.tutorial.TutorialSession;
|
||||
import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.ShopsObjective;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
public class SellPotatoesGoal extends ObjectiveGoal<ShopsObjective>
|
||||
{
|
||||
@ -22,14 +25,16 @@ public class SellPotatoesGoal extends ObjectiveGoal<ShopsObjective>
|
||||
"Sell your Potatoes to the " + F.elem("Organic Produce Shop NPC") + ".",
|
||||
"Farming is a great way to make money in Clans. Build a farm in your land, " +
|
||||
"harvest " +
|
||||
"the crops and sell it to the shops for profit!"
|
||||
"the crops and sell it to the shops for profit!",
|
||||
DyeColor.PINK
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customStart(Player player)
|
||||
{
|
||||
|
||||
TutorialSession session = getObjective().getPlugin().getTutorialSession(player);
|
||||
session.setMapTargetLocation(getObjective().getPlugin().getPoint(session.getRegion(), ClansMainTutorial.Point.FARMING_SHOP));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -42,25 +47,14 @@ public class SellPotatoesGoal extends ObjectiveGoal<ShopsObjective>
|
||||
UtilInv.removeAll(player, Material.POTATO_ITEM, (byte) 0);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler (priority = EventPriority.HIGH)
|
||||
public void onSell(ClansPlayerSellItemEvent event)
|
||||
{
|
||||
if (contains(event.getPlayer()))
|
||||
{
|
||||
if (event.getItem().getType() == Material.POTATO_ITEM)
|
||||
{
|
||||
if (contains(event.getPlayer())) {
|
||||
if (event.getItem().getType() == Material.POTATO_ITEM) {
|
||||
event.setCancelled(false);
|
||||
finish(event.getPlayer());
|
||||
}
|
||||
else
|
||||
{
|
||||
event.setCancelled(true);
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Tutorial", "You need to sell your potatoes to the Organic Produce NPC!"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (event.getItem().getType() == Material.POTATO_ITEM)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user