use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class Solinia3CorePlayerListener method onPlayerConsumeEvent.
@EventHandler
public void onPlayerConsumeEvent(PlayerItemConsumeEvent event) {
if (event.isCancelled())
return;
try {
ISoliniaItem item = SoliniaItemAdapter.Adapt(event.getItem());
item.consume(plugin, event.getPlayer());
} catch (SoliniaItemException | CoreStateInitException e) {
}
}
use of com.solinia.solinia.Exceptions.CoreStateInitException 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.Exceptions.CoreStateInitException 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");
}
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class ConfigurationManager method commitPlayersToCharacterLists.
private void commitPlayersToCharacterLists() {
try {
int count = 0;
for (ISoliniaPlayer player : StateManager.getInstance().getPlayerManager().getPlayers()) {
commitPlayerToCharacterLists(player);
count++;
}
System.out.println("Commited " + count + " characters to the CharacterList repository");
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class ChannelManager method sendItemListToDiscordChannel.
private void sendItemListToDiscordChannel(DiscordChannel discordChannel, String itemMatch) {
try {
String targetChannelId = getDefaultDiscordChannel();
if (discordChannel.equals(DiscordChannel.ADMIN))
targetChannelId = getAdminDiscordChannel();
int itemId = 0;
try {
itemId = StateManager.getInstance().getConfigurationManager().getItem(Integer.parseInt(itemMatch)).getId();
} catch (Exception e) {
}
if (itemId > 0) {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(itemId);
sendItemToDiscordChannel(discordChannel, item);
return;
}
if (itemMatch.length() < 3) {
sendToDiscordMC(null, targetChannelId, "Item search must be at least 3 characters: " + itemMatch);
return;
}
List<ISoliniaItem> items = StateManager.getInstance().getConfigurationManager().getItemsByPartialName(itemMatch);
if (items.size() > 20) {
sendToDiscordMC(null, targetChannelId, "Item matched more than 20 items, please be more specific than " + itemMatch);
return;
}
if (items.size() != 1) {
List<String> matchingItemList = new ArrayList<String>();
String currentLine = "";
for (ISoliniaItem item : items) {
if ((currentLine + "[" + item.getId() + "] " + item.getDisplayname() + " ").length() > 2000) {
matchingItemList.add(currentLine);
currentLine = "";
}
currentLine += "[" + item.getId() + "] " + item.getDisplayname() + " ";
}
if (!currentLine.equals("")) {
matchingItemList.add(currentLine);
}
for (String line : matchingItemList) {
sendToDiscordMC(null, targetChannelId, "Item [" + itemMatch + "] matched with: " + line);
}
} else {
for (ISoliniaItem item : items) {
sendItemToDiscordChannel(discordChannel, item);
}
}
} catch (CoreStateInitException e) {
// ignore it
}
}
Aggregations