use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class SoliniaPlayerFactory method CreatePlayer.
public static ISoliniaPlayer CreatePlayer(Player player, boolean main) throws CoreStateInitException {
// A player is different to a players entity
ISoliniaPlayer soliniaPlayer = new SoliniaPlayer();
soliniaPlayer.setUUID(player.getUniqueId());
soliniaPlayer.setMain(main);
String forename = getRandomNames(5, 1)[0];
String lastname = "";
try {
while (StateManager.getInstance().getPlayerManager().IsNewNameValid(forename, lastname) == false) {
forename = getRandomNames(5, 1)[0];
}
soliniaPlayer.setForename(forename);
soliniaPlayer.setLastname(lastname);
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
StateManager.getInstance().getPlayerManager().addPlayer(soliniaPlayer);
soliniaPlayer = SoliniaPlayerAdapter.Adapt(player);
soliniaPlayer.setExperience(0d);
soliniaPlayer.setAAExperience(0d);
soliniaPlayer.setMana(0);
return soliniaPlayer;
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class SoliniaNPCEventHandler method awardPlayer.
@Override
public void awardPlayer(Player triggerentity) {
try {
ISoliniaPlayer player = SoliniaPlayerAdapter.Adapt(triggerentity);
if (getAwardsQuest() > 0) {
boolean foundQuest = false;
for (PlayerQuest playerQuest : player.getPlayerQuests()) {
if (playerQuest.getQuestId() == getAwardsQuest()) {
foundQuest = true;
}
}
if (foundQuest == false)
player.addPlayerQuest(getAwardsQuest());
}
if (getAwardsQuestFlag() != null && !getAwardsQuestFlag().equals("")) {
boolean foundQuestFlag = false;
for (String playerQuestFlag : player.getPlayerQuestFlags()) {
if (playerQuestFlag.equals(getAwardsQuestFlag())) {
foundQuestFlag = true;
}
}
if (foundQuestFlag == false) {
player.addPlayerQuestFlag(getAwardsQuestFlag());
// All item awards must be accompanied with a quest flag else they will repeat the item return over and over
if (getAwardsItem() > 0) {
System.out.println("Awarding item with awardquestflag: " + getAwardsQuestFlag());
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(getAwardsItem());
final int awarditemid = getAwardsItem();
final UUID uuid = player.getBukkitPlayer().getUniqueId();
if (item != null) {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("Solinia3Core"), new Runnable() {
public void run() {
try {
ItemStack itemStack = item.asItemStack();
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(awarditemid);
Bukkit.getPlayer(uuid).getWorld().dropItem(Bukkit.getPlayer(uuid).getLocation(), itemStack);
System.out.println("Awarded item: " + item.getDisplayname());
} catch (CoreStateInitException e) {
// skip
}
}
});
}
}
if (this.isAwardsTitle() == true) {
if (this.getTitle() != null) {
if (!this.getTitle().equals("")) {
player.grantTitle(this.getTitle());
}
}
}
if (isAwardsRandomisedGear() == true) {
String suffix = "of Randomisation";
if (getRandomisedGearSuffix() != null) {
if (!getRandomisedGearSuffix().equals("")) {
suffix = getRandomisedGearSuffix();
}
}
System.out.println("Awarding randomisedgear with awardquestflag: " + getAwardsQuestFlag());
int playertier = 1;
if (player.getLevel() >= 1 && player.getLevel() < 11)
playertier = 1;
if (player.getLevel() >= 11 && player.getLevel() < 21)
playertier = 2;
if (player.getLevel() >= 21 && player.getLevel() < 31)
playertier = 3;
if (player.getLevel() >= 31 && player.getLevel() < 41)
playertier = 4;
if (player.getLevel() >= 41 && player.getLevel() < 51)
playertier = 5;
if (player.getLevel() >= 51 && player.getLevel() < 61)
playertier = 6;
try {
// always give the next tier up and then we will reset the player requirements ot current level
// this ability is for special seasonal rewards only
playertier += 1;
List<Integer> items = SoliniaItemFactory.CreateClassItemSet(player.getClassObj(), playertier, suffix, false, true);
for (int itemid : items) {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(itemid);
final String playerName = player.getBukkitPlayer().getName();
final int minLevel = player.getLevel();
final int finalitemid = itemid;
if (item != null) {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("Solinia3Core"), new Runnable() {
public void run() {
try {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(finalitemid);
item.setMinLevel(minLevel);
SoliniaAccountClaim claim = new SoliniaAccountClaim();
claim.setId(StateManager.getInstance().getConfigurationManager().getNextAccountClaimId());
claim.setMcname(playerName);
claim.setItemid(finalitemid);
claim.setClaimed(false);
Player claimPlayer = Bukkit.getPlayer(playerName);
if (claimPlayer != null) {
claimPlayer.sendMessage(ChatColor.GOLD + "You have been awarded with a claim item! See /claim");
}
StateManager.getInstance().getConfigurationManager().addAccountClaim(claim);
System.out.println("Awarded Claim: " + item.getDisplayname() + " to " + playerName);
} catch (CoreStateInitException e) {
// skip
}
}
});
}
}
} catch (SoliniaItemException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
}
} catch (CoreStateInitException e) {
System.out.println(e.getMessage());
return;
}
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class SoliniaLivingEntity method doCheckForEnemies.
@Override
public void doCheckForEnemies() {
if (isPlayer())
return;
if (this.getNpcid() < 1)
return;
if (getBukkitLivingEntity().isDead())
return;
if (!(getBukkitLivingEntity() instanceof Creature))
return;
if (((Creature) getBukkitLivingEntity()).getTarget() != null)
return;
try {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(this.getNpcid());
if (npc.getFactionid() == 0)
return;
ISoliniaFaction faction = StateManager.getInstance().getConfigurationManager().getFaction(npc.getFactionid());
if (faction.getName().equals("NEUTRAL") || faction.getName().equals("KOS"))
return;
for (Entity entity : getBukkitLivingEntity().getNearbyEntities(10, 10, 10)) {
if (!(entity instanceof Player))
continue;
if (entity.isDead())
continue;
Player player = (Player) entity;
ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt(player);
PlayerFactionEntry factionEntry = solPlayer.getFactionEntry(npc.getFactionid());
if (factionEntry != null) {
switch(Utils.getFactionStandingType(factionEntry.getFactionId(), factionEntry.getValue())) {
case FACTION_THREATENLY:
case FACTION_SCOWLS:
if (Utils.isEntityInLineOfSight(player, getBukkitLivingEntity())) {
((Creature) getBukkitLivingEntity()).setTarget(player);
return;
} else {
continue;
}
default:
break;
}
}
}
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class CommandGroupChat method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
// TODO Auto-generated method stub
if (!(sender instanceof Player)) {
return false;
}
Player player = (Player) sender;
if (args.length == 0) {
player.sendMessage("You did not supply a message to send");
return true;
}
try {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
if (solplayer.getGroup() == null) {
player.sendMessage("Group does not exist");
return true;
}
if (solplayer.getGroup().getMembers().size() < 2) {
player.sendMessage("There is only 1 person in the group");
return true;
}
String message = arrayToString(args, " ");
solplayer.getGroup().sendGroupMessage(player, ChatColor.AQUA + message + ChatColor.RESET);
return true;
} catch (CoreStateInitException e) {
player.sendMessage(e.getMessage());
return true;
}
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class CoreState method sendGroupMessage.
public void sendGroupMessage(Player player, String message) {
if (message == null || message.equals("")) {
player.sendMessage("You cannot send an empty message");
return;
}
try {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
ISoliniaGroup group = getGroupByMember(player.getUniqueId());
if (group == null) {
player.sendMessage("You are not in a group");
return;
}
String type = "";
if (group.getOwner().equals(player.getUniqueId())) {
type = "[" + ChatColor.LIGHT_PURPLE + "L" + ChatColor.RESET + "]";
} else {
type = "[" + ChatColor.LIGHT_PURPLE + "M" + ChatColor.RESET + "]";
}
if (group.getMembers().size() > 0) {
for (UUID memberid : group.getMembers()) {
Player groupplayer = Bukkit.getPlayer(memberid);
if (groupplayer != null) {
System.out.println("group: " + group.getId() + ":" + player.getDisplayName() + ": " + ChatColor.AQUA + message);
groupplayer.sendMessage(type + " " + ChatColor.WHITE + solplayer.getFullName() + ChatColor.RESET + " [" + ChatColor.RED + (int) player.getHealth() + ChatColor.RESET + "/" + ChatColor.BLUE + solplayer.getMana() + ChatColor.RESET + "]: " + ChatColor.AQUA + message);
}
}
} else {
player.sendMessage("There were no members of that group");
return;
}
} catch (CoreStateInitException e) {
e.printStackTrace();
}
}
Aggregations