Solved combining plugins (essentials)

Discussion in 'Plugin Development' started by skullboneslayer, Mar 9, 2014.

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

    Wolfey

    skullboneslayer Register the listeners in that class, then you'll be fine.
     
  2. Offline

    skullboneslayer

    Wolfey alright soo move that plugin to the Listener package
     
  3. Offline

    Barinade

    You have no idea what you're doing.

    Are you trying to get all plugins in the same file or trying to access them from separate plugins?
     
  4. Offline

    Wolfey

    He wants to take a bunch of plugins and combine them into one.
     
  5. Offline

    Barinade

    But claims he knows what he's doing, right
     
  6. Offline

    skullboneslayer

    Barinade i have never combined plugins befor IN MY LIFE i have made plugins but have never combined plugins
     
  7. Offline

    Barinade

    I've never combined a plugin either, but I can tell you right now I'd be able to do it rather quickly.
    It has nothing to do with having done it before, it's Java and the Bukkit API, you either know how or you should get back to the basics.
     
  8. Offline

    skullboneslayer

    Barinade good for you i happen to be a slow learner well for java and i did not understand how to do this ENSE i came to the fourms for help
     
  9. Offline

    Barinade

    Then don't claim to know what you're doing because you've made 10 plugins, lol
     
  10. Offline

    skullboneslayer

    Barinade i know what im doing for creating plugins i hvae no clue on combining plugins i hvae stated that like 100 times so what else o you want from me?
     
  11. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    Let's relax a little, ok? This is getting a bit tense.
     
    TheKomputerKing likes this.
  12. Offline

    Squawkers13

    Why would you even need to do this??
     
  13. Offline

    skullboneslayer

    mbaxter i agree

    Squawkers13 anostly its just to orginise it and it will be easier to upload all my plugins

    Wolfey my duble jump plugin still wont work and im not getting any errors
     
  14. Offline

    Wolfey

    Can I see the update code?
     
  15. Offline

    skullboneslayer

    Wolfey sure thing man

    Code:java
    1. package Listeners;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.block.Sign;
    5. import org.bukkit.event.EventHandler;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.event.block.Action;
    8. import org.bukkit.event.block.SignChangeEvent;
    9. import org.bukkit.event.player.PlayerInteractEvent;
    10.  
    11.  
    12. public class HealSign implements Listener {
    13.  
    14. @EventHandler
    15. public void onSignChange(SignChangeEvent e) {
    16. if (e.getLine(0).equalsIgnoreCase("[skullHeal]")) {
    17. if (e.getPlayer().hasPermission("skull.skullheal.sign.heal")) {
    18. e.setLine(0, "§4[skullHeal]");
    19. e.setLine(1, "§4Click here");
    20. e.setLine(2, "§4to get healed!");
    21. }else{
    22. e.setLine(0, "§4You");
    23. e.setLine(1, "§4Dont");
    24. e.setLine(2, "§4Have");
    25. e.setLine(3, "§4Permission");
    26.  
    27. }
    28. }
    29. }
    30. @EventHandler
    31. public void onPlayerInteract(PlayerInteractEvent e) {
    32. if (!(e.getAction() == Action.RIGHT_CLICK_BLOCK)) return;
    33. if (e.getClickedBlock().getState() instanceof Sign) {
    34. Sign s = (Sign) e.getClickedBlock().getState();
    35. if (s.getLine(0).equalsIgnoreCase("§4[SkullHeal]")) {
    36. e.getPlayer().setHealth(20);
    37. e.getPlayer().sendMessage(ChatColor.GREEN + "[SkullHeal] Was created by: skullboneslayer!");
    38. }
    39. }
    40. }
    41. }


    omg thats the wrong code

    Wolfey here is the code "FOR REAL THIS TIME" xD

    Code:java
    1. package plugins;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.GameMode;
    5. import org.bukkit.Material;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.event.EventHandler;
    10. import org.bukkit.event.Listener;
    11. import org.bukkit.event.player.PlayerMoveEvent;
    12. import org.bukkit.event.player.PlayerToggleFlightEvent;
    13.  
    14. public class skulljump implements Listener {
    15.  
    16. @EventHandler
    17. public void onPlayerToggleFlight(PlayerToggleFlightEvent event) {
    18. Player player = event.getPlayer();
    19. if (player.getGameMode() == GameMode.CREATIVE)
    20. return;
    21. event.setCancelled(true);
    22. player.setAllowFlight(false);
    23. player.setFlying(false);
    24. player.setVelocity(player.getLocation().getDirection().multiply(1.5)
    25. .setY(1));
    26. }
    27.  
    28. @EventHandler
    29. public void onPlayerMove(PlayerMoveEvent event) {
    30. Player player = event.getPlayer();
    31. if((player.getGameMode() != GameMode.CREATIVE)
    32. && (player.getLocation().subtract(0, 1, 0).getBlock().getType() != Material.AIR)
    33. && (!player.isFlying()))
    34. player.setAllowFlight(true);
    35. }
    36.  
    37. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String [] args){
    38. Player player = (Player) sender;
    39. if(commandLabel.equalsIgnoreCase("skulljump")){
    40. player.sendMessage(ChatColor.GOLD + " To use this plugin simply double jump!");
    41. player.sendMessage(ChatColor.GOLD + " [SkullJump] was created bye skullboneslayer!");
    42.  
    43.  
    44. }
    45. return false;
    46.  
    47. }
    48. }


    mbaxter i have a question how long does it uselly take for the admins to review your plugin? becuse i submited mine almost a week ago?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  16. Offline

    Wolfey

    Since that class also has an onCommand(), it has to implement CommandExecutor. But I was asking for the main class.
     
  17. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    skullboneslayer You were sent a PM 5 hours ago with information. You can reply to that PM for more info.
     
  18. Offline

    skullboneslayer

    Wolfey my main class i chose my skullheal plugin here

    Code:java
    1. package plugins;
    2.  
    3.  
    4. import org.bukkit.Bukkit;
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.plugin.java.JavaPlugin;
    10.  
    11. import Listeners.FeedSign;
    12. import Listeners.HealSign;
    13.  
    14. public class skullheal extends JavaPlugin {
    15.  
    16. public void onEnable() { // enable main
    17. Bukkit.getServer().getPluginManager().registerEvents(new HealSign(), this);
    18. Bukkit.getServer().getPluginManager().registerEvents(new FeedSign(), this);
    19. }
    20.  
    21. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    22.  
    23. if (!(sender instanceof Player)) {
    24. sender.sendMessage(ChatColor.RED + "The console cannot use skullheal/skullfeed!!!");
    25. return true;
    26. }
    27.  
    28. Player player = (Player) sender;
    29.  
    30. if (cmd.getName().equalsIgnoreCase("skullheal")) {
    31. if (args.length == 0) {
    32. player.setHealth(20);
    33. player.sendMessage(ChatColor.GREEN + "[skullheal] created by skullboneslayer!");
    34. return true;
    35. }
    36. Player target = Bukkit.getServer().getPlayer(args[0]);
    37. if (target == null) {
    38. player.sendMessage(ChatColor.RED + "Could not find player!");
    39. return true;
    40. }
    41. target.setHealth(20);
    42. target.sendMessage(ChatColor.GREEN + "[skullheal] created by skullboneslayer!");
    43. }
    44.  
    45. if (cmd.getName().equalsIgnoreCase("skullfeed")) {
    46. if (args.length == 0) {
    47. player.setFoodLevel(20);
    48. player.sendMessage(ChatColor.GREEN + "[skullfeed] created by skullboneslayer!");
    49. return true;
    50. }
    51. Player target = Bukkit.getServer().getPlayer(args[0]);
    52. if (target == null) {
    53. player.sendMessage(ChatColor.RED + "Could not find player!");
    54. return true;
    55. }
    56. target.setFoodLevel(20);
    57. target.sendMessage(ChatColor.GREEN + "[skullfeed] created by skullboneslayer!");
    58. player.sendMessage(ChatColor.GREEN + "[skullfeed] created by skullboneslayer!");
    59. }
    60.  
    61. return true;
    62. }
    63. }


    also this will make me sound like a noob but i dont know what a "CommandExecuter" is :(

    mbaxter ok thanks ill look now

    mbaxter how do i change what my plugin says because i noticed that but i dont know how to edit this projct????

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  19. Offline

    Wolfey

    Implement your skulljump class to CommandExecutor.
    Then, add this to your onEnable()
    Code:text
    1. Bukkit.getServer().getPluginManager().registerEvents(new skulljump(), this);
    2. getCommand("skulljump").setExecutor(new skulljump());
     
  20. Offline

    skullboneslayer

    Wolfey as i previusly said i dont know what a commandexecutor is am i suppost to make a new class named that?
     
  21. Offline

    Wolfey

    I just said, like your Listener, implement it to CommandExecutor as well...
    Code:java
    1. public class skulljump implements Listener, CommandExecutor {
    2. // rest of class
    3. }
     
  22. Offline

    skullboneslayer

    Wolfey oh im sorry i didnt catch on


    ok so does this look right?

    Code:java
    1. package Listeners;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.GameMode;
    6. import org.bukkit.Material;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandExecutor;
    9. import org.bukkit.command.CommandSender;
    10. import org.bukkit.entity.Player;
    11. import org.bukkit.event.EventHandler;
    12. import org.bukkit.event.Listener;
    13. import org.bukkit.event.player.PlayerMoveEvent;
    14. import org.bukkit.event.player.PlayerToggleFlightEvent;
    15.  
    16. public class skulljump implements Listener, CommandExecutor {
    17.  
    18. public void onEnable() {
    19. Bukkit.getServer().getPluginManager().registerEvents(new skulljump(), this);
    20. getCommand("skulljump").setExecutor(new skulljump());
    21. }
    22.  
    23. @EventHandler
    24. public void onPlayerToggleFlight(PlayerToggleFlightEvent event) {
    25. Player player = event.getPlayer();
    26. if (player.getGameMode() == GameMode.CREATIVE)
    27. return;
    28. event.setCancelled(true);
    29. player.setAllowFlight(false);
    30. player.setFlying(false);
    31. player.setVelocity(player.getLocation().getDirection().multiply(1.5)
    32. .setY(1));
    33. }
    34.  
    35. @EventHandler
    36. public void onPlayerMove(PlayerMoveEvent event) {
    37. Player player = event.getPlayer();
    38. if((player.getGameMode() != GameMode.CREATIVE)
    39. && (player.getLocation().subtract(0, 1, 0).getBlock().getType() != Material.AIR)
    40. && (!player.isFlying()))
    41. player.setAllowFlight(true);
    42. }
    43.  
    44. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String [] args){
    45. Player player = (Player) sender;
    46. if(commandLabel.equalsIgnoreCase("skulljump")){
    47. player.sendMessage(ChatColor.GOLD + " To use this plugin simply double jump!");
    48. player.sendMessage(ChatColor.GOLD + " [SkullJump] was created bye skullboneslayer!");
    49.  
    50.  
    51. }
    52. return false;
    53.  
    54. }
    55. }
    56.  


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  23. Offline

    Wolfey

    skullboneslayer *sigh* no no no, take those two lines from that onEnable(), and add it to your main class... (Afterwards remove that onEnable() in your skulljump class)
     
  24. Offline

    skullboneslayer

    Wolfey ok thanks it worked! thanks for your help and sorry i dont learn vary easy and im attepting Java xD anyway thanks man i really appretiate it and umm yea so thank you man your awsome at coding are you ever gonna post some plugins?
     
  25. Offline

    Wolfey

    Haha, no problem.

    And probably not, I mostly just create plugins for fun. Although I might soon enough.
     
  26. Offline

    skullboneslayer

    Wolfey ok now i have anouther problem im gonna attept to do on my own the thing is i fallowed the exact same thing that i did and now im getting errors xD well ima go try this if it dont work ima tahg you again alright?

    can i truble you for some help again Wolfey ????

    or anyone else really my code i did everything as he told me but it didnt work its a broadcast plugin here it is let me know if you can help me

    Code:java
    1. package me.skull.skullcast;
    2.  
    3.  
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.plugin.java.JavaPlugin;
    10.  
    11. public class main extends JavaPlugin{
    12.  
    13. SettingsManager settings = SettingsManager.getInstance();
    14.  
    15. public void onEnable() {
    16. settings.setup(this);
    17.  
    18. Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    19. public void run() {
    20. Bukkit.getServer().broadcastMessage(ChatColor.GOLD + "[SkullCast] " + ChatColor.GREEN + settings.getConfig().getString("announcement"));
    21. }
    22. }, 80, 1000);
    23. }
    24.  
    25. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    26. if (cmd.getName().equalsIgnoreCase("skullcastreload")) {
    27. settings.reloadConfig();
    28. sender.sendMessage(ChatColor.GOLD + "[skullcast]" + ChatColor.BLUE + " Config Reloaded!");
    29. }
    30. return true;
    31. }
    32. }



    and here is the SettingsManager class that goes with it

    Code:java
    1. package me.skull.skullcast;
    2.  
    3. import java.io.File;
    4. import java.io.IOException;
    5.  
    6. import org.bukkit.Bukkit;
    7. import org.bukkit.ChatColor;
    8. import org.bukkit.configuration.file.FileConfiguration;
    9. import org.bukkit.configuration.file.YamlConfiguration;
    10. import org.bukkit.plugin.Plugin;
    11. import org.bukkit.plugin.PluginDescriptionFile;
    12.  
    13. public class SettingsManager {
    14.  
    15. private SettingsManager() { }
    16.  
    17. static SettingsManager instance = new SettingsManager();
    18.  
    19. public static SettingsManager getInstance() {
    20. return instance;
    21. }
    22.  
    23. Plugin p;
    24. FileConfiguration config;
    25. File cfile;
    26.  
    27. public void setup(Plugin p) {
    28. config = p.getConfig();
    29. config.options().copyDefaults(true);
    30. cfile = new File(p.getDataFolder(), "config.yml");
    31. saveConfig();
    32. }
    33.  
    34. public FileConfiguration getConfig() {
    35. return config;
    36. }
    37.  
    38. public void saveConfig() {
    39. try {
    40. config.save(cfile);
    41. }
    42. catch (IOException e) {
    43. Bukkit.getServer().getLogger().severe(ChatColor.RED + "Could not save config.yml!");
    44. }
    45. }
    46.  
    47. public void reloadConfig() {
    48. config = YamlConfiguration.loadConfiguration(cfile);
    49. }
    50.  
    51. public PluginDescriptionFile getDesc() {
    52. return p.getDescription();
    53. }
    54. }


    im not exacly sure why its not working

    ok i think i got it to import it i need it to be a Listener butttt what if it is not a Listener CAN ANYONE PLS HELP ME WITH THAT??????

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  27. Offline

    MisterPhiloe

    Is it possible to use methods from an another plugin with adding your plugin to IDE and then call it from there or how would i do that? Mysql? File? and what if it is something like a inventory shop?
     
  28. Offline

    skullboneslayer

  29. Offline

    TheKomputerKing

    skullboneslayer

    Just for the love of god learn Java before attempting to make Bukkit plugins. I can see from this thread that you haven't learnt Java but watched some Bukkit API tutorial and you now suddenly know it all.

    Just... learn Java first.
     
  30. Offline

    skullboneslayer

    TheKomputerKing and were do you expect me to learn more then i already know?
     
Thread Status:
Not open for further replies.

Share This Page