More clans bug fixes + message tweaks

This commit is contained in:
phobia 2016-04-03 16:11:47 +10:00
parent 5e41c22fc7
commit 759911396a
12 changed files with 36 additions and 15 deletions

View File

@ -251,7 +251,7 @@ public abstract class Tutorial implements Listener, ObjectiveListener
public TutorialRegion getRegion(Player player)
{
if(player == null || _playerSessionMap == null || _playerSessionMap.get(player) == null) return null;
if(player == null || !player.isOnline() || _playerSessionMap == null || _playerSessionMap.get(player) == null) return null;
return _playerSessionMap.get(player).getRegion();
}

View File

@ -76,7 +76,7 @@ public abstract class ObjectiveGoal <T extends Objective<?, ?>> implements Liste
public boolean contains(Player player)
{
if (player == null)
if (player == null || !player.isOnline())
{
return false;
}

View File

@ -3,6 +3,7 @@ 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 mineplex.core.common.util.*;
@ -181,11 +182,12 @@ public class ClansMainTutorial extends Tutorial
public boolean isIn(Player player, Bounds bounds)
{
if(player == null) return false;
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);
}
@ -351,7 +353,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")
@ -382,6 +383,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);
@ -397,7 +399,7 @@ public class ClansMainTutorial extends Tutorial
for (Player player : _fireworks)
{
if (player == null) continue;
if (player == null || !player.isOnline()) continue;
UtilFirework.spawnRandomFirework(UtilAlg.getRandomLocation(player.getLocation(), 10));
}
}
@ -406,6 +408,7 @@ public class ClansMainTutorial extends Tutorial
public void onJoin(PlayerJoinEvent event)
{
start(event.getPlayer());
/*
ClansManager.getInstance().runAsync(() -> {
if (_repository.GetTimesPlayed(event.getPlayer().getUniqueId()) == 0)
@ -418,7 +421,7 @@ public class ClansMainTutorial extends Tutorial
public void performGateCheck(Player player, DyeColor key)
{
if(player == null) return;
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));
@ -453,4 +456,11 @@ public class ClansMainTutorial extends Tutorial
if(isInTutorial(event.getPlayer()))
event.setCancelled(true);
}
@EventHandler (priority = EventPriority.LOWEST)
public void onSell(ClansPlayerSellItemEvent event)
{
if(isInTutorial(event.getPlayer()))
event.setCancelled(true);
}
}

View File

@ -63,7 +63,7 @@ public class PurchaseItemsObjective extends UnorderedObjective<ClansMainTutorial
for (Player player : getActivePlayers())
{
if (player == null) continue;
if (player == null || !player.isOnline()) continue;
List<Location> locations = getPlugin().getRegion(player).getLocationMap().getSpongeLocations(DyeColor.BROWN);
if (locations == null) continue;
for(Location loc : locations)

View File

@ -2,6 +2,7 @@ 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;
@ -29,7 +30,7 @@ public class ClaimLandGoal extends ObjectiveGoal<ClanObjective>
"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. " +
"You must be inside the blue outline to claim land.",
"You must be inside the " + C.cAqua + "blue" + C.cGray + " outline to claim land.",
DyeColor.ORANGE
);
}

View File

@ -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;
@ -54,7 +55,7 @@ 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;
}

View File

@ -69,7 +69,7 @@ public class LeaveSpawnGoal extends ObjectiveGoal<ClanObjective>
for (UUID uuid : getActivePlayers())
{
Player player = Bukkit.getPlayer(uuid);
if(player == null) continue;
if(player == null || !player.isOnline()) continue;
if (!getObjective().getPlugin().isIn(player, ClansMainTutorial.Bounds.SPAWN))
{
finish(Bukkit.getPlayer(uuid));

View File

@ -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;
}

View File

@ -3,7 +3,9 @@ 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;
@ -28,8 +30,12 @@ public class BuyEnergyGoal extends ObjectiveGoal<EnergyObjective>
@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, 80, 10, 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

View File

@ -31,8 +31,6 @@ public class ExplainEnergyGoal extends ObjectiveGoal<EnergyObjective>
@Override
protected void customStart(Player 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."));

View File

@ -50,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);
}
}
@ -63,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);

View File

@ -51,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);
}
}
@ -64,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);