Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MAIN
- package deady;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import org.bukkit.configuration.InvalidConfigurationException;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.plugin.java.JavaPlugin;
- public class Main extends JavaPlugin{
- public static File file = new File("plugins/Dead", "deads.yml");
- public static FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
- public void onEnable(){
- this.getServer().getPluginManager().registerEvents(new Dead(), this);
- this.getServer().getPluginManager().registerEvents(new Kill(), this);
- try {
- cfg.load(file);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (InvalidConfigurationException e) {
- e.printStackTrace();
- }
- try {
- cfg.save(file);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- public void onDisable(){
- try {
- cfg.save(file);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- Dead
- package deady;
- import java.io.File;
- import java.io.IOException;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.entity.PlayerDeathEvent;
- public class Dead implements Listener{
- static File file = new File("plugins/Dead", "deads.yml");
- static FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
- public static int getDeaths() {
- return cfg.getInt("Deads", 0);
- }
- @EventHandler
- public void on(PlayerDeathEvent e){
- Player zg = e.getEntity();
- int dead = getDeaths();
- dead++;
- Main.cfg.getInt("Deads." + zg.getName(), dead+1);
- try {
- Main.cfg.save(Main.file);
- } catch (IOException e1) {
- e1.printStackTrace();
- }
- }
- }
- KILL
- package deady;
- import java.io.File;
- import java.io.IOException;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.entity.PlayerDeathEvent;
- public class Kill implements Listener{
- static File file = new File("plugins/Dead", "deads.yml");
- static FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
- public static int getKills(){
- return cfg.getInt("Kills", 0);
- }
- @EventHandler
- public void on(PlayerDeathEvent e){
- Player za = e.getEntity().getKiller();
- int kill = getKills();
- Main.cfg.getInt("Kills." + za.getName(), kill+1);
- try {
- Main.cfg.save(Main.file);
- } catch (IOException e1) {
- e1.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement