Solved combining plugins (essentials)

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

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

    skullboneslayer

    ok so i am planing to do a total essentials move and i am combining someof my plugins what i mena is i want it to be all one plugin. so i was wondering if i copy my code and make a bunch of classes and pasting in my code willl that work or should i create a pckege for each indevidule plugin.?
     
  2. Offline

    Wolfey

    Well you could copy over all your codes, but remember, a plugin only has one class extending to JavaPlugin, so if you have a bunch of main classes, then you're screwed.
     
  3. Offline

    skullboneslayer

    Wolfey do you got skype so i can show you what im plaining to do?
     
  4. Offline

    Wolfey

    Sorry, I'm way too busy to help you on skype. If you get any errors or can't get something to work, then you can ask here.
     
  5. Offline

    skullboneslayer

    Wolfey alrighty thanks anyway alright so i simply remove the extends JavaPlugin from it and it should work?
     
  6. Offline

    Wolfey

    Remove all that, yes, and combine all your onEnable() methods from each of those classes into one.
     
  7. Offline

    skullboneslayer

    Wolfey what do you mean combine them?

    yo???????

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

    Monkey_Swag

    Sorry, skullboneslayer but you clearly don't know what you're doing. For this reason Wolfey didn't reply to this anymore.
     
  9. Offline

    skullboneslayer

    Monkey_Swag I actually do no what i am doing i have made 10 plugins but i have never cumbined any of them befor
     
  10. Offline

    GaaTavares

    Try to figure out. What do you need? Register all events of all plugins, register commands, etc.. There is nothing really that we can explain. More than we already did.
     
  11. Offline

    Wolfey

    Whoops, my bad, for some reason I didn't see this alert.

    Basically combining is like this.
    Code:java
    1. public void onEnable() { // enable 1
    2. someMethod();
    3. }
    4.  
    5. ///////////////////////////////////
    6.  
    7. public void onEnable() { // enable 2
    8. someOtherMethod();
    9. }

    Code:java
    1.  
    2. public void onEnable() { // main enable
    3. someMethod();
    4. someOtherMethod();
    5. }

    Should look something like that.
     
  12. Offline

    skullboneslayer

    ok thanks :) ill let you know how it works Wolfey

    Wolfey what do i do for multiple packages because the other packege is not working in game

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

    Wolfey

    Put all your command classes in a cmd package, all your listeners in a listener package, your utils in a util package, etc...
     
  14. Offline

    skullboneslayer

    oh ok what i was doing is i was making a diffrent packege for each difffrent plugin

    Wolfey what should i out as my main? in the plugin.yml

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

    Wolfey

    Put all your commands in the plugin.yml, and your main class like you usually would.
     
  16. Offline

    skullboneslayer

    Wolfey oh ok and i just choose one to make my main class?
     
  17. Offline

    Wolfey

    Precisely.
     
  18. Offline

    skullboneslayer

    Wolfey allright so this would be in a listener packege

    Code:java
    1. package skullheal;
    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. public class FoodSign implements Listener {
    12.  
    13. @EventHandler
    14. public void onSignChange(SignChangeEvent e) {
    15. if (e.getLine(0).equalsIgnoreCase("[skullfeed]")) {
    16. if (e.getPlayer().hasPermission("skull.skullheal.sign.feed")) {
    17. e.setLine(0, "§4[skullFeed]");
    18. e.setLine(1, "§4Click here");
    19. e.setLine(2, "§4to get healed!");
    20. }else{
    21. e.setLine(0, "§4You");
    22. e.setLine(1, "§4Dont");
    23. e.setLine(2, "§4Have");
    24. e.setLine(3, "§4Permission");
    25.  
    26. }
    27. }
    28. }
    29. @EventHandler
    30. public void onPlayerInteract(PlayerInteractEvent e) {
    31. if (!(e.getAction() == Action.RIGHT_CLICK_BLOCK)) return;
    32. if (e.getClickedBlock().getState() instanceof Sign) {
    33. Sign s = (Sign) e.getClickedBlock().getState();
    34. if (s.getLine(0).equalsIgnoreCase("§4[Skullfeed]")) {
    35. e.getPlayer().setFoodLevel(20);
    36. e.getPlayer().sendMessage(ChatColor.GREEN + "[Skullfeed] Was created by: skullboneslayer!");
    37. }
    38. }
    39. }
    40. }
     
  19. Offline

    Wolfey

  20. Offline

    skullboneslayer

    alright Wolfey

    Wolfey it says that there is a error when i do it like that here it is

    View attachment 18507

    i believe that i am suppost to thing "this" into something else but what?

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

    Wolfey

    Did you import them?
     
  22. Offline

    skullboneslayer

    Wolfey yes i did but they are now working however my other plugin "skulljump" is not
    there is a plugin.yml problem apperntly so to get help with that here is a pic :D

    Capture.PNG


    and here is the code

    Code:java
    1. name: SkullBase
    2. version: 3.0
    3. main: plugins.skullheal
    4. author: skullboneslayer
    5. description: A bunch of plugins in 1!
    6.  
    7. commands:
    8. skullheal:
    9. usage: /<command>
    10. description: Heal.
    11. skullfeed:
    12. usage: /<command>
    13. description: Feed.
    14.  
    15. permissions:
    16. skull.skullheal.sign.heal:
    17. description: permission for making a heal sign!
    18. default: op
    19. skull.skullheal.sign.feed:
    20. description: permission for making feed signs!
    21. default: op


    Wolfey

    well the Listeners keep working fine and skullheal works good but skulljump dosent

    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 I fail to understand what's wrong, can you explain again?
     
  24. Offline

    skullboneslayer

    Wolfey alright well skullheal is a plugin that heal or feeds you on command and you can make signs plus it has permissions and skulljump is a dublejump plugin that u can duble click space and u go flying a little bit but skulljump is not working however skullheal is working perfectly?!?!?!?!?!
     
  25. Offline

    Wolfey

  26. Offline

    skullboneslayer

    Wolfey sure thing

    skullheal:
    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. }


    Skullheal, Healsign,

    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. }


    skullheal, feedsign:

    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. public class FeedSign implements Listener {
    12.  
    13. @EventHandler
    14. public void onSignChange(SignChangeEvent e) {
    15. if (e.getLine(0).equalsIgnoreCase("[skullfeed]")) {
    16. if (e.getPlayer().hasPermission("skull.skullheal.sign.feed")) {
    17. e.setLine(0, "§4[skullFeed]");
    18. e.setLine(1, "§4Click here");
    19. e.setLine(2, "§4to get healed!");
    20. }else{
    21. e.setLine(0, "§4You");
    22. e.setLine(1, "§4Dont");
    23. e.setLine(2, "§4Have");
    24. e.setLine(3, "§4Permission");
    25.  
    26. }
    27. }
    28. }
    29. @EventHandler
    30. public void onPlayerInteract(PlayerInteractEvent e) {
    31. if (!(e.getAction() == Action.RIGHT_CLICK_BLOCK)) return;
    32. if (e.getClickedBlock().getState() instanceof Sign) {
    33. Sign s = (Sign) e.getClickedBlock().getState();
    34. if (s.getLine(0).equalsIgnoreCase("§4[Skullfeed]")) {
    35. e.getPlayer().setFoodLevel(20);
    36. e.getPlayer().sendMessage(ChatColor.GREEN + "[Skullfeed] Was created by: skullboneslayer!");
    37. }
    38. }
    39. }
    40. }


    and finally skulljump:

    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. import org.bukkit.plugin.java.JavaPlugin;
    14.  
    15. public class skulljump extends JavaPlugin implements Listener {
    16.  
    17. public void onEnable() {// enable 1
    18. getServer().getPluginManager().registerEvents(this, this);
    19. }
    20.  
    21. @EventHandler
    22. public void onPlayerToggleFlight(PlayerToggleFlightEvent event) {
    23. Player player = event.getPlayer();
    24. if (player.getGameMode() == GameMode.CREATIVE)
    25. return;
    26. event.setCancelled(true);
    27. player.setAllowFlight(false);
    28. player.setFlying(false);
    29. player.setVelocity(player.getLocation().getDirection().multiply(1.5)
    30. .setY(1));
    31. }
    32.  
    33. @EventHandler
    34. public void onPlayerMove(PlayerMoveEvent event) {
    35. Player player = event.getPlayer();
    36. if((player.getGameMode() != GameMode.CREATIVE)
    37. && (player.getLocation().subtract(0, 1, 0).getBlock().getType() != Material.AIR)
    38. && (!player.isFlying()))
    39. player.setAllowFlight(true);
    40. }
    41.  
    42. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String [] args){
    43. Player player = (Player) sender;
    44. if(commandLabel.equalsIgnoreCase("skulljump")){
    45. player.sendMessage(ChatColor.GOLD + " To use this plugin simply double jump!");
    46. player.sendMessage(ChatColor.GOLD + " [SkullJump] was created bye skullboneslayer!");
    47.  
    48.  
    49. }
    50. return false;
    51.  
    52. }
    53. }
    54.  


    is this what you want?

    Wolfey is that what you want?

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

    Wolfey

    I told you not to have 2 onEnables()... (Or two classes that extend to JavaPlugin) ;p
     
  28. Offline

    skullboneslayer

    Wolfey but i did // enable main and //enable 1
     
  29. Offline

    Wolfey

    That was an example on how to combine the onEnable()s lol.
     
  30. Offline

    skullboneslayer

    Wolfey then how should i do his / does this look right?

    Capture.PNG
     
Thread Status:
Not open for further replies.

Share This Page