Solved Urgent Server Plugin Help

Discussion in 'Plugin Development' started by MCJoshua345, May 8, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    MCJoshua345

    Hello. I recently upgraded my private SMP server, and it now has Spigot. So I made a plugin for it. Unfortunately, it doesn't work. I would love help with this, and I need it urgently. I'll post the classes and the log below. Remember, my server is hosted with MCProhosting, so the log is backwards.
    Log:
    http://pastebin.com/0Pd7MTSc
    Main Class (open)

    Code:
    package com.infinity.smp.main;
    
    import org.bukkit.Bukkit;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import com.infinity.smp.commands.RulesCommand;
    import com.infinity.smp.listeners.PlayerListener;
    
    public class Main extends JavaPlugin{
    
        public static Main instance;
    
        public static Main getInstance(){
            return instance;
        }
    
        public void consoleBroadcast(String s){
            Bukkit.getServer().getLogger().info(s);
        }
    
        public void registerCommands(){
            getCommand("rules").setExecutor(new RulesCommand());
        }
    
        public void registerClasses(){
            PluginManager pm = getServer().getPluginManager();
        
            //Listener Classes
            pm.registerEvents(new PlayerListener(), this);
        
            //Command Classes
            pm.registerEvents(new RulesCommand(), this);
        
        }
    
        @Override
        public void onEnable(){
            PluginDescriptionFile pdf = getDescription();
            consoleBroadcast("[RiotCentralSMP] RiotCentralSMP v" + pdf.getVersion() + " by xXInfinityXx has been enabled.");
            consoleBroadcast("Description: " + pdf.getDescription());
            instance = this;
            registerCommands();
            registerClasses();
        }
    
        @Override
        public void onDisable(){
            PluginDescriptionFile pdf = getDescription();
            consoleBroadcast("[RiotCentralSMP] RiotCentralSMP v" + pdf.getVersion() + " by xXInfinityXx has been disabled.");
            consoleBroadcast("Description: " + pdf.getDescription());
            instance = null;
        }
    
    }

    PlayerListener (open)

    Code:
    package com.infinity.smp.listeners;
    
    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerQuitEvent;
    
    public class PlayerListener implements Listener{
    
        String smpt = ChatColor.BLACK + "[" + ChatColor.GOLD + "SMP" + ChatColor.BLACK + "]" + ChatColor.RESET + " ";
    
        @EventHandler
        public void pJoinEvent(PlayerJoinEvent e){
            Player p = e.getPlayer();
            if(p.hasPlayedBefore() == true){
                e.setJoinMessage(smpt + ChatColor.AQUA + p.getName() + ChatColor.GREEN + " has joined the game!");
                p.sendMessage(smpt + ChatColor.GREEN + "Welcome back to the RiotCentral SMP, " + ChatColor.AQUA + p.getName() + ChatColor.GREEN + "!");
            }else if(p.hasPlayedBefore() == false){
                e.setJoinMessage(smpt + ChatColor.AQUA + p.getName() + ChatColor.GOLD + " has joined for the first time!");
                p.sendMessage(smpt + ChatColor.GREEN + "Welcome to RiotCentral SMP, " + ChatColor.AQUA + p.getName() + ChatColor.GREEN + "!");
                p.sendMessage(smpt + ChatColor.GREEN + "To see the rules, use \"/rules\"!");
                p.sendMessage(smpt + ChatColor.GREEN + "For tips, I suggest asking a player, or if the Owner is online, ask him!");
            }
        }
    
        @EventHandler
        public void pQuitEvent(PlayerQuitEvent e){
            Player p = e.getPlayer();
            e.setQuitMessage(smpt + ChatColor.AQUA + p.getName() + ChatColor.RED + " has left the game!");
        }
    
    }
    

    RulesCommand (open)

    Code:
    package com.infinity.smp.commands;
    
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Listener;
    
    public class RulesCommand implements CommandExecutor, Listener{
    
        String smpt = ChatColor.BLACK + "[" + ChatColor.GOLD + "SMP" + ChatColor.BLACK + "]" + ChatColor.RESET + " ";
    
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
        
            if(!(sender instanceof Player)){
                sender.sendMessage(smpt + ChatColor.RED + "You must be a player to use this command!");
                return true;
            }
        
            Player p = (Player) sender;
        
            if(cmd.getName().equalsIgnoreCase("rules")){
                p.sendMessage(smpt + ChatColor.GOLD + "The rules are:");
                p.sendMessage(smpt + ChatColor.RED + "NO GRIEFING");
                p.sendMessage(smpt + ChatColor.RED + "NO STEALING");
                p.sendMessage(smpt + ChatColor.RED + "PRANKING ALLOWED, BUT LIGHT PRANKING (Blocking the door, filling the room with dirt, etc.)");
                p.sendMessage(smpt + ChatColor.RED + "IF SOMEONE HAS A NAME ON SOMETHING (Like \"Infinity's Mine\") YOU CANNOT USE IT WITHOUT THEIR PERMISSION!");
                p.sendMessage(smpt + ChatColor.RED + "**Breaking any of these rules may result in a ban, depending on the crime commited and the level of damage/trespassing done.");
                return true;
            }
        
            return false;
        }
    
    }
    

    plugin.yml (open)

    Code:
    name: RiotCentralSMP
    main: com.infinity.smp.main.Main
    version: 1.0
    author: xXInfinityXx
    description: SMP Plugin for RiotCentral.
    commands:
      rules:
        description: Lists the rules.
        usage: /<command> 


    Server Stats:
    Dirt Plan
    RAM: 512 MB
    Server Type: Spigot 1.8.3

    I would appreciate any help, and preferably I'd like it quickly.

    Thank You, And Keep Blocking!
    - xXInfinityXx (Formerly MCJoshua345)
     
  2. Offline

    caderape

    @MCJoshua345

    Caused by: java.lang.UnsupportedClassVersionError: com/infinity/smp/main/Main : Unsupported major.minor

    I guess it's your package name
     
  3. @MCJoshua345 You're using Java 8 when you need to use Java 7.
     
  4. Offline

    MCJoshua345

    @CodePlaysMinecraft
    :confused: Is there a way to have Java 7 & Java 8, and just use Java 7 for that plugin?
     
  5. Offline

    CoolGamerXD

    @MCJoshua345 Your all classes are fine. And in case of version of java... You need java 7
     
  6. Offline

    mythbusterma

    @CoolGamerXD

    No, you don't.


    @MCJoshua345

    Yes, there is. All you need to do is set your build version specifier to Java 7.

    Alternatively, set your server to run Java 8, either solution would work.
     
  7. Offline

    MCJoshua345

    @mythbusterma
    Can you do that with MCProhosting?

    Alternatively, I can use a virtual machine to install Java 7 Runtime & JDK along with Eclipse, copy the project over to Eclipse on the virtual machine, export it, copy it, and put it in the server's plugins folder. But I'm hoping I don't have to do that.
     
  8. Offline

    Konato_K

    @MCJoshua345 The first yes, the second I don't think so
     
  9. Offline

    mythbusterma

    @MCJoshua345

    That's a massive waste of time, just change your build settings to build against Java 7 and it will work fine.

    Also, you can install Java 7 and 8 JDKs on the same machine.

    I don't think your server host will update their Java version just for you (although you really should push them to do so, not updating to 8 is pretty dumb).
     
  10. Offline

    MCJoshua345

    @mythbusterma
    I know you can install both 7 & 8 JDKs, but I kinda already did the virtual machine thing. I love working with them :D.
    Setting the thread as solved.
     
Thread Status:
Not open for further replies.

Share This Page