I'm stuck, No clue where to go from here

Discussion in 'Plugin Development' started by Fallen_Advent, Sep 1, 2011.

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

    Fallen_Advent

    Ok, So I believe I hooked into it Adamki11s Extra's src right, I am just having trouble allowing the onPlayerMove to grab the values from the arguments so that I can get the onPlayerMove event to change the value of the material and the size of the radius.

    If anyone can give me some tips it would be really useful. I feel like this is the last thing I need to do before this will be ready for release.

    FallenBlocks.java
    Show Spoiler

    Code:java
    1.  
    2.  
    3. package me.fallenadvent.plugins.fallenblocks;
    4.  
    5.  
    6. import couk.Adamki11s.Extras.Extras.Extras;
    7. import java.util.HashSet;
    8. import java.util.Set;
    9. import org.bukkit.ChatColor;
    10. import org.bukkit.Material;
    11. import org.bukkit.command.Command;
    12. import org.bukkit.command.CommandExecutor;
    13. import org.bukkit.command.CommandSender;
    14. import org.bukkit.entity.Player;
    15. import org.bukkit.event.Event.Priority;
    16. import org.bukkit.event.Event.Type;
    17. import org.bukkit.event.player.PlayerListener;
    18. import org.bukkit.plugin.PluginDescriptionFile;
    19. import org.bukkit.plugin.PluginManager;
    20. import org.bukkit.plugin.java.JavaPlugin;
    21.  
    22. public class FallenBlocks extends JavaPlugin {
    23. private PluginDescriptionFile info;
    24. private PluginManager manager;
    25. private PlayerListener playerListener = new FBPlayerListener(this);
    26. private Set<Player> FbBuilder = new HashSet<Player>();
    27.  
    28. @Override
    29. public void onDisable() {
    30. info = getDescription();
    31. System.out.println("[" + info.getName() + " " + info.getVersion() + "] has been disabled.");
    32. }
    33. @Override
    34. public void onEnable() {
    35. Extras ex = new Extras("FallenBlocks");
    36. info = getDescription();
    37. getServer().getPluginManager().registerEvent(Type.PLAYER_MOVE, playerListener, Priority.Highest, this);
    38. System.out.println("[" + info.getName() + " " + info.getVersion() + "] has been enabled.");
    39. getCommand("fallenbuild").setExecutor(new CommandExecutor() {
    40.  
    41. @Override
    42. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    43. if(label.equalsIgnoreCase("Fallenbuild")){
    44. if(args.length == 1){
    45. if(!(sender instanceof Player)){
    46. sender.sendMessage(ChatColor.RED + "That command must be used by a player.");
    47. return false;//No Console Commands
    48. } else {
    49. Player player = (Player)sender;//Cast to a player object
    50. Material materialtype = Material.getMaterial(args[0]);
    51. Integer radius = Integer.getInteger(args[1]);
    52. if (player.hasPermission("fallenbuild.build")){
    53. setFbBuilder(player, !hasFbBuilder(player));
    54. } else {
    55. player.sendMessage(ChatColor.RED + "You aren't special enough for a red carpet.");
    56. }
    57. if (materialtype == null){
    58. sender.sendMessage(ChatColor.RED + "That is not a valid material type.");
    59. return false; }//Invalid material
    60. if (radius == null){
    61. sender.sendMessage(ChatColor.RED + "That is not a valid size.");
    62. return false;}//Invalid material
    63. return true;
    64. }
    65. }
    66. }
    67. return false;
    68. }
    69. });
    70. }
    71. public boolean hasFbBuilder(Player player) {
    72. return FbBuilder.contains(player);
    73. }
    74. public void setFbBuilder(Player player, boolean enabled) {
    75. if (enabled) {
    76. FbBuilder.add(player);
    77. } else {
    78. FbBuilder.remove(player);
    79. }
    80. }
    81. }
    82.  


    FBPlayerListener.java

    Show Spoiler

    Code:java
    1.  
    2.  
    3. package me.fallenadvent.plugins.fallenblocks;
    4.  
    5. import org.bukkit.block.Block;
    6. import org.bukkit.block.BlockFace;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.event.player.PlayerListener;
    9. import org.bukkit.event.player.PlayerMoveEvent;
    10.  
    11. public class FBPlayerListener extends PlayerListener{
    12. private final FallenBlocks plugin;
    13. public FBPlayerListener(FallenBlocks plugin) {
    14. this.plugin = plugin;
    15. }
    16.  
    17. @Override
    18. public void onPlayerMove(PlayerMoveEvent event) {
    19. Player player = event.getPlayer();
    20. Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
    21. if (!player.hasPermission("fallenbuild.build")) {
    22. return;
    23. }
    24. if (!plugin.hasFbBuilder(player)) {
    25. return;
    26. }
    27. }
    28.  
    29. }
    30.  
    31.  


    plugin.yml
    Show Spoiler

    Code:yml
    1.  
    2. author: Fallen Advent
    3. database: false
    4. description: Simple but flexible underfoot building for your server's players.
    5. generator: [URL]http://dinnerbone.com/minecraft/tools/pluginator/[/URL]
    6. main: me.fallenadvent.plugins.fallenblocks.FallenBlocks
    7. name: Fallen Blocks
    8. startup: postworld
    9. version: '1.0'
    10. permissions:
    11. fallenbuild.build:
    12. default: op
    13. description: Allows the player to use the /fallenbuild command.
    14. commands:
    15. fallenbuild:
    16. usage: | /<command> [material] [radius]
    17. description: Allows the player to build using the block directly underfoot, Similar to a magic carpet that is persistant.
    18.  



    I would be really grateful if someone can help me out with this, I have been working all day to try and figure this out and I have no clue where to go from here.

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

    dbizzzle

    So, Whats the plugin supposed to do?
     
  3. Offline

    Fallen_Advent

    Its supposed to allow the user to type something like
    /fallenblocks [material] [radius]

    and have the block below them change into that material type and replace all blocks (including air and water) that they step on. They also could specify a radius, so developing roads, bridges, castle walls, and stuff like that would be made simple and easy.

    This is my first plugin so I thought I would pick something that sounded easy, but this has turned out a tad bit more complicated than I expected. (Yes I know, to some of you this is pre-school level work)
     
  4. Offline

    dbizzzle

    Oh, so something similar to magiccarpet? or more like lazyroads?

    And believe me, I don't know how I would do this, I am quite new to plugins as well.
     
  5. Offline

    Fallen_Advent

    @dbizzzle

    Kind of a mix between the two, It can achieve a result similar to magic carpet but it is persistant, so the blocks are left behind like in LazyRoads,

    Magic Carpet Simularities --

    Custom range.

    LazyRoads Simularities --

    Persistent changes at the players feet.
    Will follow you whether you jump or walk into water (so really good for those annoying water builds)
     
  6. Offline

    dbizzzle

Thread Status:
Not open for further replies.

Share This Page