Java Code Examples for com.griefcraft.model.Protection#Type
The following examples show how to use
com.griefcraft.model.Protection#Type .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PhysDB.java From Modern-LWC with MIT License | 6 votes |
/** * Load protections using a specific type * * @param type * @return the Protection object */ public List<Protection> loadProtectionsUsingType(Protection.Type type) { PreparedStatement statement; try { statement = prepare( "SELECT id, owner, type, x, y, z, data, blockId, world, password, date, last_accessed FROM " + prefix + "protections WHERE type = ?"); statement.setInt(1, type.ordinal()); return resolveProtections(statement); } catch (SQLException e) { printException(e); } return new ArrayList<Protection>(); }
Example 2
Source File: PhysDB.java From Modern-LWC with MIT License | 4 votes |
/** * Register a protection * * @param blockId * @param type * @param world * @param player * @param data * @param x * @param y * @param z * @return */ public Protection registerProtection(int blockId, Protection.Type type, String world, String player, String data, int x, int y, int z) { ProtectionCache cache = LWC.getInstance().getProtectionCache(); try { statement = prepare("INSERT INTO " + prefix + "protections (blockId, type, world, owner, password, x, y, z, date, last_accessed) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); statement.setInt(1, blockId); statement.setInt(2, type.ordinal()); statement.setString(3, world); statement.setString(4, player); statement.setString(5, data); statement.setInt(6, x); statement.setInt(7, y); statement.setInt(8, z); statement.setString(9, new Timestamp(new Date().getTime()).toString()); statement.setLong(10, System.currentTimeMillis() / 1000L); statement.executeUpdate(); statement = null; // We need to create the initial transaction for this protection // this transaction is viewable and modifiable during // POST_REGISTRATION Protection protection = loadProtection(world, x, y, z, true); protection.removeCache(); // if history logging is enabled, create it if (LWC.getInstance().isHistoryEnabled() && protection != null) { History transaction = protection.createHistoryObject(); transaction.setPlayer(player); transaction.setType(History.Type.TRANSACTION); transaction.setStatus(History.Status.ACTIVE); // store the player that created the protection transaction.addMetaData("creator=" + player); // now sync the history object to the database transaction.saveNow(); } // Cache it if (protection != null) { cache.addProtection(protection); protectionCount++; } // return the newly created protection return protection; } catch (SQLException e) { printException(e); } return null; }
Example 3
Source File: PhysDB.java From Modern-LWC with MIT License | 2 votes |
/** * Get the amount of protections for the given protection type * * @param type * @return the number of protected chests */ public int getProtectionCount(Protection.Type type) { return Integer.decode( fetch("SELECT COUNT(*) AS count FROM " + prefix + "protections WHERE type = " + type.ordinal(), "count") .toString()); }