use of sqlite.kripton209.model1.User in project Village_Defense by Plajer.
the class Arena method addExperience.
void addExperience(Player player, int i) {
User user = UserManager.getUser(player.getUniqueId());
user.addInt("xp", i);
if (player.hasPermission(PermissionsManager.getVip())) {
user.addInt("xp", (int) Math.ceil(i / 2));
}
if (player.hasPermission(PermissionsManager.getMvp())) {
user.addInt("xp", (int) Math.ceil(i / 2));
}
if (player.hasPermission(PermissionsManager.getElite())) {
user.addInt("xp", (int) Math.ceil(i / 2));
}
ArenaUtils.updateLevelStat(player, this);
}
use of sqlite.kripton209.model1.User in project Village_Defense by Plajer.
the class FileStats method saveStat.
public void saveStat(Player player, String stat) {
User user = UserManager.getUser(player.getUniqueId());
config.set(player.getUniqueId().toString() + "." + stat, user.getInt(stat));
try {
config.save(ConfigurationManager.getFile("stats"));
} catch (IOException e) {
e.printStackTrace();
BigTextUtils.errorOccured();
Bukkit.getConsoleSender().sendMessage("Cannot save stats.yml file!");
Bukkit.getConsoleSender().sendMessage("Restart the server, file COULD BE OVERRIDDEN!");
}
}
use of sqlite.kripton209.model1.User in project Village_Defense by Plajer.
the class Events method onShop.
@EventHandler
public void onShop(InventoryClickEvent event) {
if (!(event.getWhoClicked() instanceof Player))
return;
Player player = (Player) event.getWhoClicked();
Inventory inv = event.getInventory();
Arena arena = ArenaRegistry.getArena((Player) event.getWhoClicked());
if (arena == null)
return;
User user = UserManager.getUser(player.getUniqueId());
if (user.isFakeDead()) {
event.setCancelled(true);
return;
}
if (inv.getName() == null || !inv.getName().equalsIgnoreCase(ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Shop-GUI-Name")))
return;
event.setCancelled(true);
if (event.getCurrentItem() == null || !event.getCurrentItem().hasItemMeta() || !event.getCurrentItem().getItemMeta().hasLore())
return;
String string = event.getCurrentItem().getItemMeta().getLore().get(0);
string = ChatColor.stripColor(string);
if (!(string.contains(ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Currency-In-Shop")) || string.contains("orbs"))) {
boolean b = false;
for (String s : event.getCurrentItem().getItemMeta().getLore()) {
if (string.contains(ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Currency-In-Shop")) || string.contains("orbs")) {
string = s;
b = true;
}
}
if (!b)
return;
}
int price = Integer.parseInt(string.split(" ")[0]);
if (price > UserManager.getUser(player.getUniqueId()).getInt("orbs")) {
player.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Not-Enough-Orbs"));
return;
}
if (event.getCurrentItem().hasItemMeta() && event.getCurrentItem().getItemMeta().hasDisplayName()) {
if (event.getCurrentItem().getItemMeta().getDisplayName().contains(ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Golem-Item-Name"))) {
arena.spawnGolem(arena.getStartLocation(), player);
player.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("In-Game.Messages.Golem-Spawned"));
UserManager.getUser(player.getUniqueId()).setInt("orbs", UserManager.getUser(player.getUniqueId()).getInt("orbs") - price);
return;
}
if (event.getCurrentItem().getItemMeta().getDisplayName().contains(ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Wolf-Item-Name"))) {
arena.spawnWolf(arena.getStartLocation(), player);
player.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("In-Game.Messages.Wolf-Spawned"));
UserManager.getUser(player.getUniqueId()).setInt("orbs", UserManager.getUser(player.getUniqueId()).getInt("orbs") - price);
return;
}
}
ItemStack itemStack = event.getCurrentItem().clone();
ItemMeta itemMeta = itemStack.getItemMeta();
List<String> lore = new ArrayList<>();
for (String loopLore : lore) {
if (loopLore.contains(ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Currency-In-Shop"))) {
lore.remove(loopLore);
}
}
itemMeta.setLore(lore);
itemStack.setItemMeta(itemMeta);
player.getInventory().addItem(itemStack);
UserManager.getUser(player.getUniqueId()).setInt("orbs", UserManager.getUser(player.getUniqueId()).getInt("orbs") - price);
}
use of sqlite.kripton209.model1.User in project Village_Defense by Plajer.
the class Events method onFriendHurt.
@EventHandler(priority = EventPriority.HIGHEST)
public void onFriendHurt(EntityDamageByEntityEvent event) {
if (!(event.getDamager() instanceof Player))
return;
Arena arena = ArenaRegistry.getArena((Player) event.getDamager());
if (arena == null)
return;
User user = UserManager.getUser(event.getDamager().getUniqueId());
if (user.isFakeDead()) {
event.setCancelled(true);
return;
}
if (!VILLAGE_ENTITIES.contains(event.getEntityType()))
return;
event.setCancelled(true);
}
use of sqlite.kripton209.model1.User in project Village_Defense by Plajer.
the class Events method onEntityInteractEntity.
@EventHandler
public void onEntityInteractEntity(PlayerInteractEntityEvent event) {
Arena arena = ArenaRegistry.getArena(event.getPlayer());
if (arena == null)
return;
User user = UserManager.getUser(event.getPlayer().getUniqueId());
if (user.isFakeDead()) {
event.setCancelled(true);
return;
}
if (event.getPlayer().getItemInHand().getType() == Material.SADDLE) {
if (event.getRightClicked().getType() == EntityType.IRON_GOLEM || event.getRightClicked().getType() == EntityType.VILLAGER) {
event.getRightClicked().setPassenger(event.getPlayer());
event.setCancelled(true);
return;
}
}
if (event.getRightClicked().getType() == EntityType.VILLAGER) {
event.setCancelled(true);
ShopManager.openShop(event.getPlayer());
} else if (event.getRightClicked().getType() == EntityType.IRON_GOLEM) {
IronGolem ironGolem = (IronGolem) event.getRightClicked();
if (ironGolem.getCustomName() != null && ironGolem.getCustomName().contains(event.getPlayer().getName())) {
event.getRightClicked().setPassenger(event.getPlayer());
} else {
event.getPlayer().sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("In-Game.Messages.Cant-Ride-Others-Golem"));
}
}
}
Aggregations