下面列出了org.bukkit.configuration.file.FileConfiguration#getLong ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void sendMessage(Player player) {
if(player == null) return;
UUID uuid = player.getUniqueId();
if(messageCooldownList.contains(uuid)) return;
String message = this.plugin.getLanguageMessageColoredWithPrefix("cheat-prevention.items.no-pickup");
this.plugin.sendMessage(player, message);
messageCooldownList.add(uuid);
BukkitScheduler scheduler = Bukkit.getScheduler();
Runnable task = () -> messageCooldownList.remove(uuid);
FileConfiguration config = this.expansion.getConfig("cheat-prevention.yml");
long messageCooldown = 20L * config.getLong("message-cooldown");
scheduler.runTaskLater(this.plugin.getPlugin(), task, messageCooldown);
}
private void sendMessage(Player player) {
if(player == null) return;
UUID uuid = player.getUniqueId();
if(messageCooldownList.contains(uuid)) return;
String message = this.plugin.getLanguageMessageColoredWithPrefix("cheat-prevention.no-riptide");
this.plugin.sendMessage(player, message);
messageCooldownList.add(uuid);
BukkitScheduler scheduler = Bukkit.getScheduler();
Runnable task = () -> messageCooldownList.remove(uuid);
FileConfiguration config = this.expansion.getConfig("cheat-prevention.yml");
long messageCooldown = 20L * config.getLong("message-cooldown");
scheduler.runTaskLater(this.plugin.getPlugin(), task, messageCooldown);
}
private void sendMessageWithCooldown(Player player, String path) {
if(player == null || path == null || path.isEmpty()) return;
List<UUID> messageCooldownList = messagePathToCooldownList.getOrDefault(path, Util.newList());
UUID uuid = player.getUniqueId();
if(messageCooldownList.contains(uuid)) return;
String message = this.plugin.getLanguageMessageColoredWithPrefix(path);
this.plugin.sendMessage(player, message);
messageCooldownList.add(uuid);
messagePathToCooldownList.put(path, messageCooldownList);
BukkitScheduler scheduler = Bukkit.getScheduler();
Runnable task = () -> removeCooldown(player, path);
FileConfiguration config = this.expansion.getConfig("cheat-prevention.yml");
long messageCooldown = 20L * config.getLong("message-cooldown");
scheduler.runTaskLater(this.plugin.getPlugin(), task, messageCooldown);
}
private void sendMessage(Player player) {
if(player == null) return;
UUID uuid = player.getUniqueId();
if(messageCooldownList.contains(uuid)) return;
String message = this.plugin.getLanguageMessageColoredWithPrefix("cheat-prevention.items.no-pickup");
this.plugin.sendMessage(player, message);
messageCooldownList.add(uuid);
BukkitScheduler scheduler = Bukkit.getScheduler();
Runnable task = () -> messageCooldownList.remove(uuid);
FileConfiguration config = this.expansion.getConfig("cheat-prevention.yml");
long messageCooldown = 20L * config.getLong("message-cooldown");
scheduler.runTaskLater(this.plugin.getPlugin(), task, messageCooldown);
}
private boolean isProtected(Player player) {
if(player == null) return false;
long firstJoinMillis = player.getFirstPlayed();
if(firstJoinMillis == 0) return false;
long systemMillis = System.currentTimeMillis();
long subtract = (systemMillis - firstJoinMillis);
FileConfiguration config = this.expansion.getConfig("newbie-helper.yml");
long protectionTimeMillis = config.getLong("newbie-protection.protection-timer") * 1000L;
if(subtract > protectionTimeMillis) {
removeProtection(player);
return false;
}
YamlConfiguration dataFile = this.plugin.getDataFile(player);
if(!dataFile.isSet("newbie-helper.protected")) {
dataFile.set("newbie-helper.protected", true);
this.plugin.saveDataFile(player, dataFile);
}
return dataFile.getBoolean("newbie-helper.protected");
}
public UhcWorldBorder(){
FileConfiguration cfg = UhcCore.getPlugin().getConfig();
moving = cfg.getBoolean("border.moving",true);
startSize = cfg.getInt("border.start-size",1000);
endSize = cfg.getInt("border.end-size",0);
timeToShrink = cfg.getLong("border.time-to-shrink",3600);
timeBeforeShrink = cfg.getLong("border.time-before-shrink",0);
Bukkit.getLogger().info("[UhcCore] Border start size is "+startSize);
Bukkit.getLogger().info("[UhcCore] Border end size is "+startSize);
Bukkit.getLogger().info("[UhcCore] Border moves : "+moving);
Bukkit.getLogger().info("[UhcCore] Border timeBeforeEnd : "+timeToShrink);
}
private void addCooldown(Player player) {
if(player == null) return;
FileConfiguration config = this.expansion.getConfig("cheat-prevention.yml");
long cooldownSeconds = config.getLong("command-blocker.delay-after-combat");
if(cooldownSeconds <= 0) return;
long cooldownMillis = TimeUnit.SECONDS.toMillis(cooldownSeconds);
long systemTime = System.currentTimeMillis();
long expireTime = (systemTime + cooldownMillis);
UUID uuid = player.getUniqueId();
cooldownMap.put(uuid, expireTime);
}
@SuppressWarnings("unchecked")
private Region loadRegion(File regionFile) {
FileConfiguration regionConfig = new YamlConfiguration();
Region region;
try {
regionConfig.load(regionFile);
int[] radii = new int[6];
radii[0] = regionConfig.getInt("xp-radius");
radii[1] = regionConfig.getInt("zp-radius");
radii[2] = regionConfig.getInt("xn-radius");
radii[3] = regionConfig.getInt("zn-radius");
radii[4] = regionConfig.getInt("yp-radius");
radii[5] = regionConfig.getInt("yn-radius");
Location location = Region.idToLocation(Objects.requireNonNull(regionConfig.getString("location")));
if (location == null) {
throw new NullPointerException();
}
double exp = regionConfig.getDouble("exp");
HashMap<UUID, String> people = new HashMap<>();
for (String s : Objects.requireNonNull(regionConfig.getConfigurationSection("people")).getKeys(false)) {
people.put(UUID.fromString(s), regionConfig.getString("people." + s));
}
RegionType regionType = (RegionType) ItemManager.getInstance()
.getItemType(Objects.requireNonNull(regionConfig.getString("type")).toLowerCase());
region = new Region(
Objects.requireNonNull(regionConfig.getString("type")).toLowerCase(),
people,
location,
radii,
(HashMap<String, String>) regionType.getEffects().clone(),
exp);
region.setWarehouseEnabled(regionConfig.getBoolean("warehouse-enabled", true));
double forSale = regionConfig.getDouble("sale", -1);
if (forSale != -1) {
region.setForSale(forSale);
}
long lastActive = regionConfig.getLong(ActiveEffect.LAST_ACTIVE_KEY, -1);
if (lastActive > -1) {
region.setLastActive(lastActive);
}
if (regionConfig.isSet("upkeep-history")) {
for (String timeString : Objects.requireNonNull(regionConfig
.getConfigurationSection("upkeep-history")).getKeys(false)) {
Long time = Long.parseLong(timeString);
region.getUpkeepHistory().put(time, regionConfig.getInt("upkeep-history." + timeString));
}
}
} catch (Exception e) {
Civs.logger.log(Level.SEVERE, "Unable to read " + regionFile.getName(), e);
return null;
}
return region;
}
private long getSurvivalSeconds() {
FileConfiguration config = this.expansion.getConfig("citizens-compatibility.yml");
return config.getLong("npc-options.survival-seconds", 30L);
}