You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
3.1 KiB
Java
89 lines
3.1 KiB
Java
package com.zivilon.dungeontools;
|
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
import org.bukkit.configuration.file.FileConfiguration;
|
|
import org.bukkit.configuration.file.YamlConfiguration;
|
|
|
|
import java.io.File;
|
|
import java.util.HashMap;
|
|
|
|
import com.zivilon.dungeontools.Area;
|
|
import com.zivilon.dungeontools.listeners.kill_tracker_listener;
|
|
import com.zivilon.dungeontools.listeners.barrow_wight_teleport_listener;
|
|
import com.zivilon.dungeontools.listeners.aggression_listener;
|
|
import com.zivilon.dungeontools.commands.kill_tracker_command;
|
|
import com.zivilon.dungeontools.commands.loot_chest_command;
|
|
import com.zivilon.dungeontools.commands.playsound_command;
|
|
|
|
public class DungeonTools extends JavaPlugin {
|
|
public FileConfiguration loot_chest_config;
|
|
public FileConfiguration items_config;
|
|
public FileConfiguration areas_config;
|
|
|
|
public boolean enable_specific_listeners = false;
|
|
|
|
public HashMap<String, Area> tracking_areas = new HashMap<>();
|
|
|
|
@Override
|
|
public void onEnable() {
|
|
save_default_items_config();
|
|
|
|
this.loot_chest_config = load_config_file("loot_chests.yml");
|
|
this.items_config = load_config_file("items.yml");
|
|
this.areas_config = load_config_file("areas.yml");
|
|
|
|
|
|
// Fired when the server enables the plugin
|
|
getLogger().info("DungeonTools v1.4 enabled!");
|
|
// Register the /loot_chest command
|
|
this.getCommand("loot_chest").setExecutor(new loot_chest_command(this));
|
|
// Register the /track_kills command
|
|
this.getCommand("track_kills").setExecutor(new kill_tracker_command(this, tracking_areas));
|
|
// Register the /playsound_loc command
|
|
getCommand("playsound_loc").setExecutor(new playsound_command());
|
|
// Register the EntityDeath event listener
|
|
getServer().getPluginManager().registerEvents(new kill_tracker_listener(tracking_areas), this);
|
|
// Register the EntityDamage event listener for aggression control
|
|
getServer().getPluginManager().registerEvents(new aggression_listener(this), this);
|
|
|
|
if (enable_specific_listeners) {
|
|
// Register the EntityDamage event listener
|
|
getServer().getPluginManager().registerEvents(new barrow_wight_teleport_listener(), this);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onDisable() {
|
|
getLogger().info("DungeonTools disabled!");
|
|
}
|
|
|
|
public FileConfiguration get_loot_chest_config() {
|
|
return this.loot_chest_config;
|
|
}
|
|
|
|
public FileConfiguration get_items_config() {
|
|
return items_config;
|
|
}
|
|
|
|
public FileConfiguration get_areas_config() {
|
|
return areas_config;
|
|
}
|
|
|
|
public FileConfiguration load_config_file(String file_name) {
|
|
File file = new File(getDataFolder(), file_name);
|
|
if (!file.exists()) {
|
|
saveResource(file_name, false);
|
|
}
|
|
return YamlConfiguration.loadConfiguration(file);
|
|
}
|
|
|
|
public void save_default_items_config() {
|
|
File items_file = new File(getDataFolder(), "items.yml");
|
|
if (!items_file.exists()) {
|
|
saveResource("items.yml", false);
|
|
}
|
|
items_config = YamlConfiguration.loadConfiguration(items_file);
|
|
}
|
|
|
|
}
|