use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class CommandCharacter 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);
if (args.length == 0) {
player.sendMessage("Your Characters: ");
String main = "ALT";
if (solplayer.isMain()) {
main = "MAIN";
}
player.sendMessage("- " + ChatColor.LIGHT_PURPLE + solplayer.getFullNameWithTitle() + ChatColor.RESET + " " + main + " - " + ChatColor.GREEN + "ACTIVE" + ChatColor.RESET);
for (ISoliniaPlayer character : StateManager.getInstance().getPlayerManager().getCharactersByPlayerUUID(player.getUniqueId())) {
if (character.getCharacterId().equals(solplayer.getCharacterId()))
continue;
if (character.isMain()) {
main = "MAIN";
} else {
main = "ALT";
}
TextComponent tc = new TextComponent();
tc.setText("- " + ChatColor.LIGHT_PURPLE + character.getFullNameWithTitle() + ChatColor.RESET + " " + main + " - ");
String details = ChatColor.GOLD + character.getFullNameWithTitle() + " Level: " + character.getLevel() + ChatColor.RESET;
TextComponent tc2 = new TextComponent();
String changetext = "/character load " + character.getCharacterId().toString();
if (StateManager.getInstance().getPlayerManager().getPlayerLastChangeChar(player.getUniqueId()) != null) {
tc2.setText(ChatColor.RED + "Already changed this session" + ChatColor.RESET);
} else {
tc2.setText(ChatColor.AQUA + "[Click to Switch]" + ChatColor.RESET);
tc2.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, changetext));
}
tc.addExtra(tc2);
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(details).create()));
sender.spigot().sendMessage(tc);
}
player.sendMessage("Note, new characters may not be visible for up to 15 minutes");
player.sendMessage("Use '/character new' to create a new character");
} else {
switch(args[0].toUpperCase()) {
case "NEW":
if (StateManager.getInstance().getPlayerManager().getPlayerLastChangeChar(player.getUniqueId()) != null) {
player.sendMessage("You can only change your character once per server session. Please wait for the next 4 hourly restart");
return true;
}
ISoliniaPlayer newPlayer = StateManager.getInstance().getPlayerManager().createNewPlayerAlt(plugin, player);
if (newPlayer != null) {
player.sendMessage("Your character has been stored and a new character created");
player.sendMessage("Please check you have not dropped any items due to your character change");
} else {
player.sendMessage("Problem creating your new character");
}
break;
case "LOAD":
if (args.length < 2) {
player.sendMessage("You must provide the character UUID");
return true;
}
if (StateManager.getInstance().getPlayerManager().getPlayerLastChangeChar(player.getUniqueId()) != null) {
player.sendMessage("You can only change your character once per server session. Please wait for the next 4 hourly restart");
return true;
}
UUID characterUUID = UUID.fromString(args[1]);
ISoliniaPlayer loadedPlayer = StateManager.getInstance().getPlayerManager().loadPlayerAlt(plugin, player, characterUUID);
if (loadedPlayer != null) {
player.sendMessage("Your character has been stored and your new character loaded");
player.sendMessage("Please check you have not dropped any items due to your character change");
} else {
player.sendMessage("Problem loading requested character");
}
break;
default:
player.sendMessage("Unknown character subcommand");
break;
}
}
} catch (CoreStateInitException e) {
}
return true;
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class ChannelManager method sendToGlobalChannel.
@Override
public void sendToGlobalChannel(ISoliniaPlayer source, String message) {
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(message);
}
System.out.println(message);
sendToDiscordMC(source, getDefaultDiscordChannel(), source.getFullNameWithTitle() + ": " + message);
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class Solinia3CorePlayerListener method onPlayerSwapHandItems.
@EventHandler
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
if (event.isCancelled())
return;
try {
ItemStack itemstack = event.getOffHandItem();
if (itemstack == null)
return;
if (Utils.IsSoliniaItem(itemstack) && !itemstack.getType().equals(Material.ENCHANTED_BOOK)) {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) event.getPlayer());
ISoliniaItem soliniaitem = StateManager.getInstance().getConfigurationManager().getItem(itemstack);
if (soliniaitem.getAllowedClassNames().size() == 0)
return;
if (solplayer.getClassObj() == null) {
Utils.CancelEvent(event);
;
event.getPlayer().sendMessage(ChatColor.GRAY + "Your class cannot wear this armour");
return;
}
if (!soliniaitem.getAllowedClassNames().contains(solplayer.getClassObj().getName().toUpperCase())) {
Utils.CancelEvent(event);
;
event.getPlayer().getPlayer().sendMessage(ChatColor.GRAY + "Your class cannot wear this armour");
return;
}
if (soliniaitem.getMinLevel() > solplayer.getLevel()) {
Utils.CancelEvent(event);
;
event.getPlayer().getPlayer().sendMessage(ChatColor.GRAY + "Your are not sufficient level wear this armour");
return;
}
solplayer.updateMaxHp();
}
} catch (CoreStateInitException e) {
}
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class Solinia3CorePlayerListener method onChat.
@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
if (event.isCancelled())
return;
SoliniaAsyncPlayerChatEvent soliniaevent;
try {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(event.getPlayer());
if (solplayer.getLanguage() == null || solplayer.getLanguage().equals("UNKNOWN")) {
if (solplayer.getRace() == null) {
event.getPlayer().sendMessage("You cannot speak until you set a race /setrace");
Utils.CancelEvent(event);
;
return;
} else {
solplayer.setLanguage(solplayer.getRace().getName().toUpperCase());
}
}
soliniaevent = new SoliniaAsyncPlayerChatEvent(event, solplayer, event.getMessage());
Bukkit.getPluginManager().callEvent(soliniaevent);
} 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 Solinia3CorePlayerListener method onPlayerJoin.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
SoliniaPlayerJoinEvent soliniaevent;
try {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(event.getPlayer());
soliniaevent = new SoliniaPlayerJoinEvent(event, solplayer);
solplayer.updateDisplayName();
solplayer.updateMaxHp();
Bukkit.getPluginManager().callEvent(soliniaevent);
// patch
if (solplayer.getClassObj() != null)
solplayer.setChosenClass(true);
else
solplayer.setChosenClass(false);
// patch
if (solplayer.getRace() != null)
solplayer.setChosenRace(true);
else
solplayer.setChosenRace(false);
StateManager.getInstance().getChannelManager().sendToDiscordMC(solplayer, StateManager.getInstance().getChannelManager().getDefaultDiscordChannel(), event.getPlayer().getName() + "(" + solplayer.getFullName() + ") has joined the game");
} catch (CoreStateInitException e) {
event.getPlayer().kickPlayer("Server initialising");
}
}
Aggregations