use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class PlayerData method setDatabaseValue.
public static void setDatabaseValue(UUID uuid, String key, Object value) {
new BukkitRunnable() {
@Override
public void run() {
Statement statement = null;
try {
statement = getConnection().createStatement();
String sql;
if (value instanceof String)
sql = "UPDATE " + PLAYER_DATA_TABLE_NAME + " SET " + key + " = '" + value + "' WHERE PlayerUUID = '" + uuid.toString() + "';";
else
sql = "UPDATE " + PLAYER_DATA_TABLE_NAME + " SET " + key + " = " + value + " WHERE PlayerUUID = '" + uuid.toString() + "';";
statement.executeUpdate(sql);
statement.close();
} catch (Exception e) {
new WarningMessage("Failed to update database value.");
e.printStackTrace();
}
}
}.runTaskAsynchronously(MetadataHandler.PLUGIN);
}
use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class BossTrackingPage method bossTrackingPage.
protected static TextComponent[] bossTrackingPage(Player player) {
TextComponent configTextComponent = new TextComponent();
for (int i = 0; i < 3; i++) {
TextComponent line = new TextComponent(PlayerStatusMenuConfig.getBossTrackerTextLines()[i] + "\n");
if (!PlayerStatusMenuConfig.getBossTrackerHoverLines()[i].isEmpty())
PlayerStatusScreen.setHoverText(line, PlayerStatusMenuConfig.getBossTrackerHoverLines()[i]);
if (!PlayerStatusMenuConfig.getBossTrackerCommandLines()[i].isEmpty())
line.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, PlayerStatusMenuConfig.getBossTrackerCommandLines()[i]));
configTextComponent.addExtra(line);
}
ArrayList<TextComponent> textComponents = new ArrayList<>();
int counter = 0;
for (CustomBossEntity customBossEntity : CustomBossEntity.getTrackableCustomBosses()) {
try {
textComponents.add(SpigotMessage.commandHoverMessage(customBossEntity.getCustomBossBossBar().bossBarMessage(player, customBossEntity.getCustomBossesConfigFields().getLocationMessage()) + "\n", PlayerStatusMenuConfig.getOnBossTrackHover(), "/elitemobs trackcustomboss " + customBossEntity.getEliteUUID()));
counter++;
} catch (Exception ex) {
new WarningMessage("Failed to correctly get elements for boss tracking page!");
ex.printStackTrace();
}
}
TextComponent[] textComponent;
if (counter == 0) {
textComponent = new TextComponent[1];
textComponent[0] = configTextComponent;
} else {
textComponent = new TextComponent[(int) Math.floor(counter / 6D) + 1];
int internalCounter = 0;
textComponent[0] = configTextComponent;
for (TextComponent text : textComponents) {
int currentPage = (int) Math.floor(internalCounter / 6D);
if (textComponent[currentPage] == null)
textComponent[currentPage] = new TextComponent();
textComponent[currentPage].addExtra(text);
internalCounter++;
}
}
return textComponent;
}
use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class NPCEntity method setDisguise.
private void setDisguise(LivingEntity livingEntity) {
if (npCsConfigFields.getDisguise() == null)
return;
if (!Bukkit.getPluginManager().isPluginEnabled("LibsDisguises"))
return;
try {
DisguiseEntity.disguise(npCsConfigFields.getDisguise(), livingEntity, npCsConfigFields.getCustomDisguiseData(), npCsConfigFields.getFilename());
DisguiseEntity.setDisguiseNameVisibility(true, livingEntity);
livingEntity.setCustomNameVisible(true);
isDisguised = true;
} catch (Exception ex) {
new WarningMessage("Failed to load LibsDisguises disguise correctly!");
ex.printStackTrace();
}
}
use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class GenerateDatabase method addEntryIfEmpty.
private static void addEntryIfEmpty(String columnName, ColumnValues columnValues) {
try {
DatabaseMetaData metaData = PlayerData.getConnection().getMetaData();
ResultSet resultSet = metaData.getColumns(null, null, PlayerData.getPLAYER_DATA_TABLE_NAME(), columnName);
if (resultSet.next()) {
// Developer.message("Database already had " + columnName);
} else {
new InfoMessage("Adding new database column " + columnName);
addColumn(columnName, columnValues);
}
resultSet.close();
} catch (Exception ex) {
new WarningMessage("Could not process column " + columnName);
ex.printStackTrace();
}
}
use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class CustomWorldLoading method startupWorldInitialization.
public static void startupWorldInitialization() {
File folder = new File(Bukkit.getWorldContainer().getAbsolutePath());
File[] listOfFiles = folder.listFiles();
assert listOfFiles != null;
for (File listOfFile : listOfFiles) {
if (listOfFile.isDirectory() && listOfFile.getName().equals(AdventurersGuildConfig.getGuildWorldName())) {
new InfoMessage("[EliteMobs] World " + AdventurersGuildConfig.getGuildWorldName() + " found! Loading it in...");
try {
WorldCreator worldCreator = new WorldCreator(AdventurersGuildConfig.getGuildWorldName());
Objects.requireNonNull(Bukkit.createWorld(worldCreator)).setKeepSpawnInMemory(false);
new InfoMessage("[EliteMobs] World " + AdventurersGuildConfig.getGuildWorldName() + " has been successfully loaded! It can be accessed through the '/ag' command, unless you changed that config option!");
} catch (Exception ex) {
new WarningMessage("Failed to generate Adventurer's Guild World!");
ex.printStackTrace();
}
break;
}
}
}
Aggregations