예제 #1
0
 private static String getLowest(Plugin plugin, Material shopType, short durability) {
   ItemStack itemStack = ItemUtil.getLowest();
   ItemMeta itemMeta = itemStack.getItemMeta();
   Trade trade =
       SqlUtil.getFirst(
           plugin
               .getDatabase()
               .find(Trade.class)
               .where()
               .ieq("material", shopType.name())
               .ieq("durability", durability + "")
               .ieq("sell", "1")
               .orderBy()
               .asc("price")
               .findList());
   if (trade != null) {
     itemMeta.setDisplayName(
         String.format(
             "Lowest sell price: %d:%d by %s",
             trade.getItemPrice(), trade.getMoneyPrice(), trade.getPlayer()));
   } else {
     itemMeta.setDisplayName("Nobody selling");
   }
   itemStack.setItemMeta(itemMeta);
   return itemMeta.getDisplayName();
 }
예제 #2
0
 private void checkDDL() {
   try {
     plugin.getDatabase().find(IntUserValue.class).findRowCount();
   } catch (PersistenceException e) {
     try {
       Method method = JavaPlugin.class.getDeclaredMethod("installDDL");
       method.setAccessible(true);
       method.invoke(plugin);
     } catch (ReflectiveOperationException e1) {
       e1.printStackTrace();
     }
   }
 }
예제 #3
0
  @Override
  public void run() {
    while (!stop) {
      DatabaseTask task;

      while ((task = threadTasks.poll()) != null) {
        try {
          task.run(plugin.getDatabase());
        } catch (Exception e) {
          System.out.println("Exception while doing DatabaseTask");
          e.printStackTrace();
        }
      }

      try {
        Thread.sleep(5);
      } catch (InterruptedException e) {
        e.printStackTrace();
        return;
      }
    }
  }