@EventHandler
public void onExpChange(PlayerExpChangeEvent event) {
if(!plugin.getConfig().getBoolean("Enable")) return; // Don't waste computation power if we're not even enabled
// Gather config variables
List<String> enabledDays = plugin.getConfig().getStringList("DaysToEnable");
int radius = plugin.getConfig().getInt("CheckRadius");
// Get today's day string (US locale) and check if it's enabled in the config, return if it's not
String currentDay = Calendar.getInstance().getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.US);
boolean enabled = false;
for(String day : enabledDays) {
if(day.toLowerCase().contains(currentDay.toLowerCase())) {
enabled = true;
break;
}
}
if(!enabled) return; // Not enabled for today
// Check for spawners nearby and return if we find one
if(plugin.getConfig().getBoolean("CheckForSpawner")
&& plugin.isLocationNearBlock(event.getPlayer().getLocation(), Material.MOB_SPAWNER, radius)) return;
// Multiply the experience gain
Player player = event.getPlayer();
int originalAmount = event.getAmount();
int newAmount = originalAmount;
boolean found = false;
if (plugin.getConfig().getBoolean("EnablePermMultiplier")) {
/* TODO:
* Consider making this go backwards so a permission with a higher multiplier
* will be caught before a permission with a lower multiplier. This is useful
* for servers which use inherited permissions.
*/
for (float temp = 0.0F; temp <= 10.0F; temp += 0.1F) {
if (!player.isOp() && player.hasPermission(Perm.MULTIPLIER + temp)) {
newAmount = (int) (originalAmount * temp);
found = true;
break;
}
}
}
if (!found && player.hasPermission(Perm.ALLOW)) {
newAmount = (int) (originalAmount * plugin.getConfig().getDouble("Multiplier"));
}
event.setAmount(newAmount);
}
PlayerExpListener.java 文件源码
java
阅读 24
收藏 0
点赞 0
评论 0
项目:DoubleYourExperience
作者:
评论列表
文章目录