public boolean canFly(Player player) { if (carpets.getGiven(player)) { return true; } String s = "magiccarpet.mc"; if (vault != null && vault.isPermissionsEnabled()) { return vault.getPermissionProvider().has(player, s); } return player.hasPermission(s); }
public void loadCarpets() { File carpetDat = carpetsFile(); if (!carpetDat.exists()) { return; } log.info("Loading carpets..."); try { FileInputStream file = new FileInputStream(carpetDat); ObjectInputStream in = new ObjectInputStream(file); carpets = (CarpetStorage) in.readObject(); carpets.attach(this); in.close(); } catch (IOException e) { log.warning("Error loading carpets.dat; carpets data has not been loaded."); } catch (ClassNotFoundException e) { log.severe("CarpetStorage class not found! This should never happen!"); } carpets.checkCarpets(); }
@Override public void onDisable() { if (saveCarpets) { saveCarpets(); } else { for (Carpet c : carpets.all()) { if (c == null || !c.isVisible()) { continue; } c.hide(); } } log.info("is now disabled!"); }
public boolean canFlyAt(Player player, int i) { if (i == carpSize) { return true; } if (carpets.getGiven(player)) { return true; } String s = "magiccarpet.mc."; Permission permission = new Permission(s + i, "Allows the carpet to operate at size " + i, PermissionDefault.OP); permission.addParent("magiccarpet.*", true); if (vault != null && vault.isPermissionsEnabled()) { return vault.getPermissionProvider().has(player, s + i); } return player.hasPermission(permission); }
public void saveCarpets() { File carpetDat = carpetsFile(); log.info("Saving carpets..."); if (!carpetDat.exists()) { try { carpetDat.createNewFile(); } catch (IOException e) { log.severe("Unable to create carpets.dat; IOException"); } } try { FileOutputStream file = new FileOutputStream(carpetDat); ObjectOutputStream out = new ObjectOutputStream(file); out.writeObject(carpets); out.close(); } catch (IOException e) { log.warning("Error writing to carpets.dat; carpets data has not been saved!"); } carpets.clear(); }