Added configs
This commit is contained in:
parent
a8f779957c
commit
ebf979f4b6
@ -6,7 +6,8 @@ public final class MagicalCampfire extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getServer().getPluginManager().registerEvents(new MagicalCampfireListener(), this);
|
||||
saveDefaultConfig();
|
||||
getServer().getPluginManager().registerEvents(new MagicalCampfireListener(this), this);
|
||||
getLogger().info("MagicalCampfire Plugin Enabled!");
|
||||
}
|
||||
|
||||
@ -14,5 +15,4 @@ public final class MagicalCampfire extends JavaPlugin {
|
||||
public void onDisable() {
|
||||
getLogger().info("MagicalCampfire Plugin Disabled!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -3,6 +3,7 @@ package org.twipnetwork.magicalCampfire;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.type.Campfire;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -11,9 +12,14 @@ import org.bukkit.Location;
|
||||
|
||||
public class MagicalCampfireListener implements Listener {
|
||||
private final Plugin plugin;
|
||||
private final int regenInterval;
|
||||
private final boolean worksWithSoul;
|
||||
|
||||
public MagicalCampfireListener() {
|
||||
this.plugin = Bukkit.getPluginManager().getPlugin("MagicalCampfire");
|
||||
public MagicalCampfireListener(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
FileConfiguration config = plugin.getConfig();
|
||||
this.regenInterval = config.getInt("regenInterval", 40);
|
||||
this.worksWithSoul = config.getBoolean("worksWithSoul", false);
|
||||
startRegenTask();
|
||||
}
|
||||
|
||||
@ -28,7 +34,7 @@ public class MagicalCampfireListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(plugin, 0L, 40L);
|
||||
}.runTaskTimer(plugin, 0L, regenInterval);
|
||||
}
|
||||
|
||||
private boolean isNearLitCampfire(Player player) {
|
||||
@ -37,7 +43,7 @@ public class MagicalCampfireListener implements Listener {
|
||||
for (int y = -2; y <= 2; y++) {
|
||||
for (int z = -2; z <= 2; z++) {
|
||||
Location loc = playerLoc.clone().add(x, y, z);
|
||||
if (loc.getBlock().getType() == Material.CAMPFIRE) {
|
||||
if (loc.getBlock().getType() == Material.CAMPFIRE || (worksWithSoul && loc.getBlock().getType() == Material.SOUL_CAMPFIRE)) {
|
||||
Campfire campfire = (Campfire) loc.getBlock().getBlockData();
|
||||
if (campfire.isLit()) {
|
||||
return true;
|
||||
|
8
src/main/resources/config.yml
Normal file
8
src/main/resources/config.yml
Normal file
@ -0,0 +1,8 @@
|
||||
# config.yml
|
||||
|
||||
# regenInterval sets how often the regen task should run (in ticks, 20 ticks = 1 second)
|
||||
# everytime the task runs it regenerates half a heart. (default: 40)
|
||||
regenInterval: 40
|
||||
|
||||
# worksWithSoul defines whether soul campfires regen as well. (default: false)
|
||||
worksWithSoul: false
|
Loading…
Reference in New Issue
Block a user