Fixes to Clan info goal

This commit is contained in:
phobia 2016-03-30 23:01:39 +11:00
parent cd2d4c0f37
commit d6560fcf5c

View File

@ -1,25 +1,25 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan; package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
/**
* Created by Adam on 29/03/2016.
*/
import mineplex.core.common.util.Callback; import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.game.clans.Clans; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime;
import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClanRole;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClientClan; import mineplex.game.clans.clans.ClansPlayer;
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent; import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent;
import mineplex.game.clans.core.repository.tokens.ClanToken;
import mineplex.game.clans.tutorial.objective.ObjectiveGoal; import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective; import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
/** import java.sql.Timestamp;
* Created by Adam on 29/03/2016. import java.util.UUID;
*/
public class ClanInfoGoal extends ObjectiveGoal<ClanObjective> public class ClanInfoGoal extends ObjectiveGoal<ClanObjective>
{ {
public ClanInfoGoal(ClanObjective objective) public ClanInfoGoal(ClanObjective objective)
@ -43,33 +43,40 @@ public class ClanInfoGoal extends ObjectiveGoal<ClanObjective>
{ {
if (contains(event.getPlayer())) if (contains(event.getPlayer()))
{ {
event.setCancelled(true);
if(event.getArguments().length < 1) return; if(event.getArguments().length < 1) return;
event.setCancelled(true); event.setCancelled(true);
ClanInfo clan = ClansManager.getInstance().getClan(event.getArguments()[0]); event.setCancelled(true);
if(clan == null)
{
ClansManager.getInstance().getClanDataAccess().create("Chiss", event.getArguments()[0], false, new Callback<ClanInfo>() {
@Override
public void run(ClanInfo data) {
ClansManager.getInstance().getClanShop().openClanWho(event.getPlayer(), clan);
finish(event.getPlayer());
ClansManager.getInstance().runSyncLater(() -> {
ClansManager.getInstance().getClanDataAccess().delete(ClansManager.getInstance().getClan(event.getArguments()[0]), null);
}, 100L);
}
});
} else {
ClansManager.getInstance().getClanShop().openClanWho(event.getPlayer(), clan);
finish(event.getPlayer());
}
ClanToken token = new ClanToken();
token.Name = event.getArguments()[0];
token.Description = "Best clan ever!";
token.Home = "";
token.Admin = false;
token.Energy = 4320;
token.Id = UtilMath.random.nextInt(100);
token.Energy = UtilMath.random.nextInt(1000);
token.Kills = UtilMath.random.nextInt(100);
token.Murder = UtilMath.random.nextInt(100);
token.Deaths = UtilMath.random.nextInt(100);
token.WarWins = UtilMath.random.nextInt(100);
token.WarLosses = UtilMath.random.nextInt(100);
token.DateCreated = new Timestamp(System.currentTimeMillis());
token.LastOnline = new Timestamp(System.currentTimeMillis());
ClanInfo clan = new ClanInfo(ClansManager.getInstance(), token);
ClansPlayer chiss = new ClansPlayer("Chiss", UUID.fromString("1d2bfe61-7ebd-445d-ba7d-8354a0ffd1ea"), ClanRole.LEADER);
ClansPlayer jon = new ClansPlayer("defek7", UUID.fromString("89d463f7-23ec-470a-8244-457f0c8d861c"), ClanRole.MEMBER);
chiss.setOnline(true);
jon.setOnline(true);
clan.getMembers().put(chiss.getUuid(), chiss);
clan.getMembers().put(jon.getUuid(), jon);
ClansManager.getInstance().getClanShop().openClanWho(event.getPlayer(), clan);
finish(event.getPlayer());
//TODO finish
finish(event.getPlayer());
} }
} }
} }