Solved Static File

Discussion in 'Plugin Development' started by amatokus, Apr 21, 2015.

Thread Status:
Not open for further replies.
  1. Hi all I have this code:
    Code:
        static File LadderFile = new File(BetterPvP.getPlugin(BetterPvP.class).getDataFolder(), "LadderConfig");
    But when I load my plugin I get this error:

    Log (open)

    Code:
    C:\Users\paul\Desktop\Minecraft stuff\Plugin Test>java -Xms4096M -Xmx6144M -jar
    craftbukkit.jar -o false
    Loading libraries, please wait...
    [21:03:46 INFO]: Starting minecraft server version 1.7.10
    [21:03:46 INFO]: Loading properties
    [21:03:46 INFO]: Default game type: SURVIVAL
    [21:03:46 INFO]: Generating keypair
    [21:03:46 INFO]: Starting Minecraft server on *:25565
    [21:03:46 INFO]: This server is running CraftBukkit version git-Bukkit-1.7.9-R0.
    2-20-g0b2ed13-b3108jnks (MC: 1.7.10) (Implementing API version 1.7.10-R0.1-SNAPS
    HOT)
    [21:03:46 ERROR]: Could not load 'plugins\BPvP2.0.0.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.ExceptionInInitializerError
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:131) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
    java:328) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:251) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at org.bukkit.craftbukkit.v1_7_R4.CraftServer.loadPlugins(CraftServer.ja
    va:364) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at org.bukkit.craftbukkit.v1_7_R4.CraftServer.<init>(CraftServer.java:32
    6) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at net.minecraft.server.v1_7_R4.PlayerList.<init>(PlayerList.java:68) [c
    raftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at net.minecraft.server.v1_7_R4.DedicatedPlayerList.<init>(SourceFile:14
    ) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at net.minecraft.server.v1_7_R4.DedicatedServer.init(DedicatedServer.jav
    a:133) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java
    :436) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:6
    28) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
    Caused by: java.lang.ExceptionInInitializerError
            at java.lang.Class.forName0(Native Method) ~[?:1.8.0_31]
            at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_31]
            at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.jav
    a:40) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:127) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            ... 9 more
    Caused by: java.lang.IllegalStateException: Cannot get plugin for class me.amato
    kus8669.plugin.betterpvp.BetterPvP from a static initializer
            at org.bukkit.plugin.java.JavaPlugin.getPlugin(JavaPlugin.java:519) ~[cr
    aftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at me.amatokus8669.plugin.betterpvp.BetterPvP.<clinit>(BetterPvP.java:54
    ) ~[?:?]
            at java.lang.Class.forName0(Native Method) ~[?:1.8.0_31]
            at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_31]
            at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.jav
    a:40) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:127) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            ... 9 more
    [21:03:46 INFO]: [Mines] Loading Mines v1.0.0
    [21:03:46 WARN]: **** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!
    [21:03:46 WARN]: The server will make no attempt to authenticate usernames. Bewa
    re.
    [21:03:46 WARN]: While this makes the game possible to play without internet acc
    ess, it also opens up the ability for hackers to connect with any username they
    choose.
    [21:03:46 WARN]: To change this, set "online-mode" to "true" in the server.prope
    rties file.
    [21:03:46 INFO]: Preparing level "world"
    [21:03:46 INFO]: Preparing start region for level 0 (Seed: 5159119540391967566)
    [21:03:47 INFO]: Preparing start region for level 1 (Seed: 4540310032595672702)
    [21:03:47 INFO]: Preparing start region for level 2 (Seed: 5159119540391967566)
    [21:03:47 INFO]: [Mines] Enabling Mines v1.0.0
    [21:03:47 INFO]: Server permissions file permissions.yml is empty, ignoring it
    [21:03:48 INFO]: Done (1,366s)! For help, type "help" or "?"
    >



    The reason why I don't want to use "this.getDataFolder()" is that I need the file in another class.

    What should I do?


    love 2 all
     
  2. Offline

    nj2miami

    It does not need to be static, pass the reference along as needed.

    You are also trying to load 'plugins\plugins\BPvP2.0.0.jar'

    "Could not load 'plugins\BPvP2.0.0.jar' in folder 'plugins'"
     
  3. @nj2miami So now I have
    Code:
        File LadderFile = new File(getDataFolder(), "LadderConfig");
        FileConfiguration LadderConfig = YamlConfiguration.loadConfiguration(LadderFile);
    But then I can't use it in my other class. I didn't understand what you want me to do by passing the reference.
     
  4. @amatokus Put that in a constructor. Then get an instance of the class by doing:
    Code:
    ClassName name = new ClassName();
    Put any arguments in the parenthesis.
     
  5. @CodePlaysMinecraft Thanks. But now I'm having an error "Plugin already initialized"

    Error (open)

    Code:
    C:\Users\paul\Desktop\Minecraft stuff\Plugin Test>java -Xms4096M -Xmx6144M -jar
    craftbukkit.jar -o false
    Loading libraries, please wait...
    [22:46:46 INFO]: Starting minecraft server version 1.7.10
    [22:46:46 INFO]: Loading properties
    [22:46:46 INFO]: Default game type: SURVIVAL
    [22:46:46 INFO]: Generating keypair
    [22:46:46 INFO]: Starting Minecraft server on *:25565
    [22:46:46 INFO]: This server is running CraftBukkit version git-Bukkit-1.7.9-R0.
    2-20-g0b2ed13-b3108jnks (MC: 1.7.10) (Implementing API version 1.7.10-R0.1-SNAPS
    HOT)
    [22:46:46 INFO]: [BetterPvP] Loading BetterPvP v2.0.0
    [22:46:46 WARN]: **** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!
    [22:46:46 WARN]: The server will make no attempt to authenticate usernames. Bewa
    re.
    [22:46:46 WARN]: While this makes the game possible to play without internet acc
    ess, it also opens up the ability for hackers to connect with any username they
    choose.
    [22:46:46 WARN]: To change this, set "online-mode" to "true" in the server.prope
    rties file.
    [22:46:46 INFO]: Preparing level "world"
    [22:46:46 INFO]: Preparing start region for level 0 (Seed: 5159119540391967566)
    [22:46:47 INFO]: Preparing start region for level 1 (Seed: 4540310032595672702)
    [22:46:47 INFO]: Preparing start region for level 2 (Seed: 5159119540391967566)
    [22:46:47 INFO]: [BetterPvP] Enabling BetterPvP v2.0.0
    [22:46:47 ERROR]: Error occurred while enabling BetterPvP v2.0.0 (Is it up to da
    te?)
    java.lang.IllegalArgumentException: Plugin already initialized!
            at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader
    .java:98) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:66) ~[craftb
    ukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at me.amatokus8669.plugin.betterpvp.BetterPvP.<init>(BetterPvP.java:22)
    ~[?:?]
            at me.amatokus8669.plugin.betterpvp.Events.<init>(Events.java:39) ~[?:?]
    
            at me.amatokus8669.plugin.betterpvp.BetterPvP.onEnable(BetterPvP.java:64
    ) ~[?:?]
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:316) ~[c
    raftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader
    .java:324) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManage
    r.java:404) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at org.bukkit.craftbukkit.v1_7_R4.CraftServer.loadPlugin(CraftServer.jav
    a:455) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at org.bukkit.craftbukkit.v1_7_R4.CraftServer.enablePlugins(CraftServer.
    java:389) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at net.minecraft.server.v1_7_R4.MinecraftServer.n(MinecraftServer.java:3
    52) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at net.minecraft.server.v1_7_R4.MinecraftServer.g(MinecraftServer.java:3
    26) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at net.minecraft.server.v1_7_R4.MinecraftServer.a(MinecraftServer.java:2
    82) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at net.minecraft.server.v1_7_R4.DedicatedServer.init(DedicatedServer.jav
    a:189) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java
    :436) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:6
    28) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
    Caused by: java.lang.IllegalStateException: Initial initialization
            at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader
    .java:101) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:66) ~[craftb
    ukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at me.amatokus8669.plugin.betterpvp.BetterPvP.<init>(BetterPvP.java:22)
    ~[?:?]
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    ~[?:1.8.0_31]
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    ~[?:1.8.0_31]
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
    rce) ~[?:1.8.0_31]
            at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_3
    1]
            at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_31]
            at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.jav
    a:52) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:127) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
    java:328) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:251) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at org.bukkit.craftbukkit.v1_7_R4.CraftServer.loadPlugins(CraftServer.ja
    va:364) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at org.bukkit.craftbukkit.v1_7_R4.CraftServer.<init>(CraftServer.java:32
    6) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at net.minecraft.server.v1_7_R4.PlayerList.<init>(PlayerList.java:68) ~[
    craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at net.minecraft.server.v1_7_R4.DedicatedPlayerList.<init>(SourceFile:14
    ) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            at net.minecraft.server.v1_7_R4.DedicatedServer.init(DedicatedServer.jav
    a:133) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-20-g0b2ed13-b3108jnks]
            ... 2 more
    [22:46:47 INFO]: Server permissions file permissions.yml is empty, ignoring it
    [22:46:47 INFO]: Done (1,238s)! For help, type "help" or "?"
    >


    BetterPvP.Java:22 is:
    Code:
    public class BetterPvP extends JavaPlugin {
    Events.Java:39 is:
    Code:
            BetterPvP bpvp = new BetterPvP();
    and BetterPvP.Java:64 is:
    Code:
            Listener eventsListener = new Events(this);
    Did I do something wrong ?? if needed here is full code:

    Full code (open)

    BetterPvP.java:
    Code:
    package me.amatokus8669.plugin.betterpvp;
    
    import java.io.File;
    import java.io.IOException;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.Statement;
    import java.util.logging.Logger;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.command.ConsoleCommandSender;
    import org.bukkit.configuration.InvalidConfigurationException;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.configuration.file.YamlConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class BetterPvP extends JavaPlugin {
    
        private static final Logger log = Logger.getLogger("Minecraft");
    
    
        void saveFileConfig(){
            try
            {
                LadderConfig.save(LadderFile);
            }
            catch(IOException ex)
            {
                ex.printStackTrace();
            }
        }
    
        void loadFileConfig(){
            try
            {
                try {
                    LadderConfig.load(LadderFile);
                } catch (InvalidConfigurationException e) {
                    e.printStackTrace();
                }
            }
            catch(IOException ex)
            {
                ex.printStackTrace();
            }
        }
       
        File LadderFile = new File(this.getDataFolder(), "LadderConfig");
        FileConfiguration LadderConfig = YamlConfiguration.loadConfiguration(LadderFile);
        @Override
        public void onEnable() {
    
            LadderConfig.options().copyDefaults(true);
            saveFileConfig();
           
            this.saveDefaultConfig();
            UserConfigClass.setPlugin(this);
    
            Listener eventsListener = new Events(this);
            Bukkit.getServer().getPluginManager().registerEvents(eventsListener, this);
            getLogger().info("Enabling the BetterPvP Plugin");
            getLogger().info("Check bukkit DevPage for updates!");
           
            //MySQL
            String ip = this.getConfig().getString("MySQL.ip");
            Integer port = this.getConfig().getInt("MySQL.port");
            String database = this.getConfig().getString("MySQL.database");
            String USER = this.getConfig().getString("MySQL.user");
            String PASS = this.getConfig().getString("MySQL.password");
            String table_prefix = this.getConfig().getString("MySQL.table_prefix");
            String DB_NAME = "jdbc:mysql://"+ip+":"+port+"/"+database;
            Connection conn;
            Statement s;
           
            try {
                Class.forName("com.mysql.jdbc.Driver"); //Gets the driver class
                getLogger().info("About to connect to database"); //These are just for debugging purposes.
                
                conn = DriverManager.getConnection(DB_NAME, USER, PASS); //Gets a connection to the database using the details you provided.
                
                getLogger().info("Successfully connected.");
                
                getLogger().info("About to create a statement");
                
                s = conn.createStatement(); //Creates a statement. You can execute queries on this.
                
                getLogger().info("Successfully created statement.");
               
                getLogger().info("About to add new row");
                
                String sql = "INSERT INTO "+table_prefix+" (honor, player_name) VALUES ("+Events.getPlayerHonor()+","+Events.getPlayerName()+")";
                s.executeUpdate(sql); //Execute the mysql statement. Remember the s variable we had made earlier? This line uses that.
                
                getLogger().info("Successfully created row.");
                
                getLogger().info("About to close everything");
                }
                catch(Exception ex) {
                ex.printStackTrace();
                }       
            //MySQL
        }
    
    
    
        @Override
        public void onDisable() {
            log.info(String.format("[%s] Disabled Version %s", getDescription()
                    .getName(), getDescription().getVersion()));
        }
    
       
        // COMMANDS - START ===================================================================
    
       
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (cmd.getName().equalsIgnoreCase("honor")) {
                if(sender instanceof Player){
                if(args.length == 0){
                    sender.sendMessage(ChatColor.RED+"You"+ChatColor.GREEN+" "+"actualy have"+" "+ChatColor.RED+""+(new UserConfigClass(((Player) sender).getPlayer().getUniqueId())).getConfig().getDouble("Honor")+ChatColor.GREEN+" "+"honor!");
               
                }
                else {
                    Player target = Bukkit.getPlayerExact(args[0]);
                    if (target == null) {
                        sender.sendMessage("The player you pointed at is not online.");
                    }else{
                        sender.sendMessage(ChatColor.RED+args[0]+" "+ChatColor.GREEN+"actualy"+" "+"has"+" "+ChatColor.RED+""+(new UserConfigClass(target.getUniqueId())).getConfig().getDouble("Honor")+" "+ChatColor.GREEN+"honor!");
                    }
                }
               
           
            }
           
            if(sender instanceof ConsoleCommandSender){
                if(args.length == 0){
                    sender.sendMessage("Please point at a player using honor (player)");
               
                }
                else {
                    Player target = Bukkit.getPlayerExact(args[0]);
                    if (target == null) {
                        sender.sendMessage("The player you pointed at is not online.");
                    }else{
                        sender.sendMessage(args[0]+" actualy has "+(new UserConfigClass(getServer().getPlayer(args[0]).getUniqueId())).getConfig().getDouble("Honor")+" honor!");
                    }
            }
            }
            }
            return false;
    }
    
    // COMMANDS - END ===================================================================   
       
       
    
    }
    Events.Java:
    Code:
    package me.amatokus8669.plugin.betterpvp;
    
    
    
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.Comparator;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import java.util.UUID;
    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.PlayerDeathEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    
    
    // START OF CLASS =========================================================================================================================================
    public class Events implements Listener {
       
       
    
       
       
       
        // GETTING USE OF PLUGIN.
            JavaPlugin plugin;
            public Events(BetterPvP plugin) {
                this.plugin = plugin;
            }
        // GETTING USE OF PLUGIN.
            private static String Killername;
            private static String Killedname;
            private static Double DHonorkiller;
            private static Double DHonorkilled;
            BetterPvP bpvp = new BetterPvP();
           
            Map <String, Double> Rank = new HashMap<String, Double>();
            List<String> Ranklist = new ArrayList<String>(Rank.keySet());
    
        @EventHandler(priority = EventPriority.NORMAL)
        public void onPlayerDeathEvent(PlayerDeathEvent event) {
    
           
            //HONOR
            String killhonortype = plugin.getConfig().getString("onkill.honor.type");
            Double killhonor = plugin.getConfig().getDouble("onkill.honor.honor");
           
            String deathhonortype = plugin.getConfig().getString("ondeath.honor.type");
            Double deathhonor = plugin.getConfig().getDouble("ondeath.honor.honor");
            //HONOR
           
           
           
            //PLAYER TYPE
            if(!(event.getEntity().getKiller() instanceof Player)){return;}
            Player killed = event.getEntity().getPlayer();
            UUID Skilled = killed.getUniqueId();
            Player killer = event.getEntity().getPlayer().getKiller();
            UUID Skiller = killer.getUniqueId();
            //PLAYER TYPE
           
            UserConfigClass uccer = new UserConfigClass(Skiller);
            UserConfigClass ucced = new UserConfigClass(Skilled);
    
    
    //=============================================RANK/NAME================================================================
            Killername = (new UserConfigClass(event.getEntity().getKiller().getUniqueId())).getConfig().getString("Name");
            Killedname = (new UserConfigClass(event.getEntity().getUniqueId())).getConfig().getString("Name");
            DHonorkiller = (uccer).getConfig().getDouble("Honor");
            DHonorkilled = (ucced).getConfig().getDouble("Honor");
    //=============================================RANK/NAME================================================================
           
           
        // ONKILL MESSAGE
            String onkillpremessage = plugin.getConfig().getString("onkill.message");
            String onkillpostmessage = onkillpremessage.replace("%Killed", killed.getName());
            String onkillpostpostmessage = onkillpostmessage.replace("%Killer", killer.getName());
            String onkillpostpostpostmessage = onkillpostpostmessage.replace("%Honor", Double.toString(killhonor));;
            String onkillfinalmessage = ChatColor.translateAlternateColorCodes('&', onkillpostpostpostmessage);
        // ONKILL MESSAGE
           
           
        // ONDEATH MESSAGE
            String ondeathpremessage = plugin.getConfig().getString("ondeath.message");
            String ondeathpostmessage = ondeathpremessage.replace("%Killed", killed.getName());
            String ondeathpostpostmessage = ondeathpostmessage.replace("%Killer", killer.getName());
            String ondeathpostpostpostmessage = ondeathpostpostmessage.replace("%Honor", Double.toString(deathhonor));
            String ondeathpostpostpostpostmessage = ondeathpostpostpostmessage.replace("%TotalHonor", Double.toString(DHonorkilled));
            String ondeathfinalmessage = ChatColor.translateAlternateColorCodes('&', ondeathpostpostpostpostmessage);
        // ONDEATH MESSAGE
           
           
    //ENABLE OPTIONS
            Boolean hon = plugin.getConfig().getBoolean("enable.honor");
    //ENABLE OPTIONS
           
                   
           
           
    // KILLER - PLAYER ===================================================================
           
           
    
    
            // HONOR - START
            if(hon == true){
                if(killhonortype.equals("add")){
                    uccer.getConfig().getDouble("Honor");
                    uccer.getConfig().set("Honor", uccer.getConfig().getDouble("Honor")+killhonor);
                    uccer.save();
                }
                else if(killhonortype.equals("remove")){
                    uccer.getConfig().getDouble("Honor");
                    uccer.getConfig().set("Honor", uccer.getConfig().getDouble("Honor")-killhonor);
                    uccer.save();
                }
            }
            // HONOR - END
           
            //RANK - START
           
            Rank.put(Skilled.toString(), DHonorkilled);
           
            //RANK - END
           
           
            // MESSAGE - START
            killer.sendMessage(onkillfinalmessage);
            // MESSAGE - END
           
    // KILLER - PLAYER ===================================================================
           
           
    // KILLED - PLAYER ===================================================================
    
           
           
            // HONOR - START
            if(hon == true){
    
                if(deathhonortype.equals("add")){
                    ucced.getConfig().getInt("Honor");
                    ucced.getConfig().set("Honor", ucced.getConfig().getInt("Honor")+deathhonor);
                    ucced.save();
                }
                else if(deathhonortype.equals("remove")){
                    ucced.getConfig().getInt("Honor");
                    ucced.getConfig().set("Honor", ucced.getConfig().getInt("Honor")-deathhonor);
                    if(ucced.getConfig().getInt("Honor") < 0){
                        ucced.getConfig().set("Honor", 0);
                    }
                    ucced.save();
                }
            }
            // HONOR - END
           
           
            //RANK - START
           
            Rank.put(Skiller.toString(), DHonorkiller);
           
            //RANK - END
           
           
            // MESSAGE - START
            killed.sendMessage(ondeathfinalmessage);
            // MESSAGE - END
           
           
           
    
           
    // KILLED - PLAYER ===================================================================
           
    // SORTING RANKS
            Comparator<String> cmp = new Comparator<String>(){
               
                @Override
                 public int compare(String s1, String s2) {
                     Double Rank1 = Rank.get(s1);
                     Double Rank2 = Rank.get(s2);
                     return Rank1.compareTo(Rank2);
                 }
               
            };
            Collections.sort(Ranklist, Collections.reverseOrder(cmp));
            bpvp.LadderConfig.set("Ranking", Ranklist);
    // SORTING RANKS
        }
           
        public static Double getPlayerHonor(){
            return DHonorkilled;
        }
        public static String getPlayerName(){
            return Killedname;
        }
       
        }
       
    
    
    // END OF CLASS ===========================================================================================================================================
     
  6. Offline

    teej107

    Yes. Never instansiate a JavaPlugin class.
     
  7. Offline

    sgavster

    @amatokus Because you're calling another BetterPvP class.. Which you can't do. You use this:
    Code:
    public BetterPvP bpvp;
    public eventsListener(BetterPvP class) {
    bpvp = class;
    }
     
  8. Offline

    mythbusterma

    private*
     
  9. @sgavster So how should I do it? :s I'm confused
     
  10. Offline

    mythbusterma

  11. so:
    Code:
            JavaPlugin plugin;
            public Events(BetterPvP plugin) {
                this.plugin = plugin;
            }
    ?
    @mythbusterma
     
  12. Offline

    SuperOriginal

     
    Rocoty and amatokus like this.
Thread Status:
Not open for further replies.

Share This Page