use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class ChannelManager method sendToLocalChannelDecorated.
@Override
public void sendToLocalChannelDecorated(ISoliniaPlayer source, String message) {
message = decorateLocalPlayerMessage(source, message);
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.getLocation().distance(source.getBukkitPlayer().getLocation()) <= 100) {
try {
ISoliniaPlayer solTargetPlayer = SoliniaPlayerAdapter.Adapt(player);
if (solTargetPlayer.hasIgnored(source.getBukkitPlayer().getUniqueId()))
continue;
if (player.isOp() || source.getBukkitPlayer().isOp() || SoliniaPlayerAdapter.Adapt(player).understandsLanguage(source.getLanguage())) {
player.sendMessage(message);
} else {
player.sendMessage(ChatColor.AQUA + " * " + source.getFullNameWithTitle() + " says something in a language you do not understand" + ChatColor.RESET);
SoliniaPlayerAdapter.Adapt(player).tryImproveLanguage(source.getLanguage());
}
} catch (CoreStateInitException e) {
player.sendMessage("You could not understand what " + source.getFullNameWithTitle() + " was saying as your character is currently uninitialised");
e.printStackTrace();
}
}
}
System.out.println(message);
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class ChannelManager method sendOnlineToDiscordChannel.
private void sendOnlineToDiscordChannel(DiscordChannel discordChannel) {
String list = "";
String targetChannelId = getDefaultDiscordChannel();
if (discordChannel.equals(DiscordChannel.ADMIN))
targetChannelId = getAdminDiscordChannel();
try {
for (Player currentplayer : Bukkit.getServer().getOnlinePlayers()) {
ISoliniaPlayer solplayer;
try {
solplayer = SoliniaPlayerAdapter.Adapt(currentplayer);
int lvl = (int) Math.floor(solplayer.getLevel());
String racename = "UNKNOWN";
String classname = "UNKNOWN";
if (solplayer.getRace() != null)
racename = solplayer.getRace().getName();
if (solplayer.getClassObj() != null)
classname = solplayer.getClassObj().getName();
sendToDiscordMC(null, targetChannelId, "[" + currentplayer.getName() + "]" + solplayer.getFullName().toUpperCase() + " [" + currentplayer.getWorld().getName() + "] - LVL " + lvl + " " + racename + " " + classname);
} catch (CoreStateInitException e) {
}
}
} catch (Exception e) {
// ignore it
}
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class ChannelManager method sendToGlobalChannelDecorated.
@Override
public void sendToGlobalChannelDecorated(ISoliniaPlayer source, String message) {
String originalmessage = message;
message = decorateGlobalPlayerMessage(source, message);
for (Player player : Bukkit.getOnlinePlayers()) {
try {
ISoliniaPlayer solTargetPlayer = SoliniaPlayerAdapter.Adapt(player);
if (!solTargetPlayer.isOocEnabled())
continue;
if (solTargetPlayer.hasIgnored(source.getBukkitPlayer().getUniqueId()))
continue;
} catch (CoreStateInitException e) {
continue;
}
player.sendMessage(message);
}
System.out.println(message);
sendToDiscordMC(source, getDefaultDiscordChannel(), source.getFullNameWithTitle() + ": " + originalmessage);
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class CommandAA method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player))
return false;
Player player = (Player) sender;
try {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
player.sendMessage("Current AA Points: " + solplayer.getAAPoints());
if (args.length < 1) {
player.sendMessage(ChatColor.GRAY + "Insufficient arguments (list,buy)");
return true;
}
switch(args[0]) {
case "list":
int pageno = 1;
if (args.length > 1)
pageno = Integer.parseInt(args[1]);
pageno = pageno - 1;
int sizePerPage = 8;
List<ISoliniaAARank> fullaaranks = solplayer.getBuyableAARanks();
List<ISoliniaAARank> aaranks = fullaaranks.stream().skip(pageno * sizePerPage).limit(sizePerPage).collect(Collectors.toCollection(ArrayList::new));
for (ISoliniaAARank aarank : aaranks) {
ISoliniaAAAbility aaAbility = StateManager.getInstance().getConfigurationManager().getAAAbility(aarank.getAbilityid());
if (aaAbility != null)
if (!aaAbility.isEnabled())
continue;
if (aarank.getCost() <= solplayer.getAAPoints()) {
if (solplayer.canPurchaseAlternateAdvancementRank(aaAbility, aarank)) {
TextComponent tc = new TextComponent();
tc.setText(ChatColor.LIGHT_PURPLE + aaAbility.getName() + " Rank " + aarank.getPosition() + ChatColor.RESET + " Cost: " + ChatColor.YELLOW + aarank.getCost() + ChatColor.RESET + " AA points /aa buy " + aarank.getId());
String details = ChatColor.GOLD + aaAbility.getName() + " Rank: " + aarank.getPosition() + ChatColor.RESET + "\n" + aarank.getDescription() + ChatColor.RESET;
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(details).create()));
sender.spigot().sendMessage(tc);
} else {
TextComponent tc = new TextComponent();
tc.setText(ChatColor.GRAY + "[NB] " + aaAbility.getName() + " Rank " + aarank.getPosition() + ChatColor.GRAY + " Cost: " + ChatColor.GRAY + aarank.getCost() + ChatColor.GRAY + " Cannot purchase yet");
String details = ChatColor.GOLD + aaAbility.getName() + " Rank: " + aarank.getPosition() + ChatColor.RESET + "\n" + aarank.getDescription() + ChatColor.RESET;
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(details).create()));
sender.spigot().sendMessage(tc);
}
} else {
TextComponent tc = new TextComponent();
tc.setText(ChatColor.GRAY + "[NA] " + aaAbility.getName() + " Rank " + aarank.getPosition() + ChatColor.GRAY + " Cost: " + ChatColor.RED + aarank.getCost() + ChatColor.GRAY + " Insufficient AA points");
String details = ChatColor.GOLD + aaAbility.getName() + " Rank: " + aarank.getPosition() + ChatColor.RESET + "\n" + aarank.getDescription() + ChatColor.RESET;
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(details).create()));
sender.spigot().sendMessage(tc);
}
}
player.sendMessage("Displayed Page " + ChatColor.GOLD + (pageno + 1) + ChatColor.RESET + "/" + ChatColor.GOLD + Math.ceil((float) fullaaranks.size() / (float) sizePerPage) + ChatColor.RESET + " (See /aa list <pageno>");
player.sendMessage("More items may appear when you have more AA points available to spend");
break;
case "give":
if (args.length < 3) {
player.sendMessage("That is not a valid player name and amount /aa give playername amount");
return true;
}
if (!player.isOp()) {
player.sendMessage("Op only command");
return true;
}
Player targetplayer = Bukkit.getPlayer(args[1]);
if (targetplayer == null) {
player.sendMessage("Cannot find player");
return true;
}
int newpoints = Integer.parseInt(args[2]);
if (newpoints < 1) {
player.sendMessage("Too few points never give them less than 1");
return true;
}
if (newpoints > 5) {
player.sendMessage("Too many points man.... never give them more than 5, its supposed to be hard to achieve");
return true;
}
ISoliniaPlayer targetsolplayer = SoliniaPlayerAdapter.Adapt(targetplayer);
targetsolplayer.setAAPoints(targetsolplayer.getAAPoints() + newpoints);
player.sendMessage("* Granted player " + newpoints + " aa points");
targetplayer.sendMessage("* You have been granted " + newpoints + " AA points by Operator " + player.getName());
break;
case "buy":
if (args.length < 2) {
player.sendMessage("That is not a valid AA rank id - /aa buy aaabilityrankid (see /aa list)");
return true;
}
int seekRankId = Integer.parseInt(args[1].toUpperCase());
ISoliniaAARank aarank = StateManager.getInstance().getConfigurationManager().getAARank(seekRankId);
if (aarank == null) {
player.sendMessage("That is not a valid AA rank id - /aa buy aaabilityrankid (see /aa list)");
return true;
}
ISoliniaAAAbility aa = StateManager.getInstance().getConfigurationManager().getAAAbility(aarank.getAbilityid());
if (aa == null) {
player.sendMessage("That is not a valid AA rank id - /aa buy aaabilityrankid (see /aa list)");
return true;
}
if (!solplayer.canPurchaseAlternateAdvancementRank(aa, aarank)) {
player.sendMessage("You cannot buy that AA");
return true;
}
solplayer.purchaseAlternateAdvancementRank(aa, aarank);
try {
ISoliniaLivingEntity solentity = SoliniaLivingEntityAdapter.Adapt(player);
if (player.getMaxHealth() < solentity.getMaxHP()) {
solplayer.updateMaxHp();
}
} catch (CoreStateInitException e) {
}
return true;
default:
player.sendMessage(ChatColor.GRAY + "Invalid arguments (list,buy)");
return true;
}
} catch (CoreStateInitException e) {
}
return true;
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class CommandBite method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This is a Player only command");
return false;
}
if (args.length < 1)
return false;
if (Bukkit.getPlayer(args[0]) == null) {
sender.sendMessage("Cannot find player");
return true;
}
try {
Player biten = Bukkit.getPlayer(args[0]);
if (((Player) sender).getLocation().distance(biten.getLocation()) > 2) {
sender.sendMessage("You are too far from that person");
return true;
}
ISoliniaPlayer sourcePlayer = SoliniaPlayerAdapter.Adapt((Player) sender);
ISoliniaPlayer bitenPlayer = SoliniaPlayerAdapter.Adapt(biten);
sourcePlayer.emote("* " + sourcePlayer.getFullNameWithTitle() + " sinks their teeth into " + bitenPlayer.getFullNameWithTitle());
if (sourcePlayer.isVampire()) {
bitenPlayer.setVampire(true);
}
return true;
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
sender.sendMessage(e.getMessage());
return true;
}
}
Aggregations