Solved Getting errors? D:

Discussion in 'Plugin Development' started by ZygoZ, Apr 7, 2014.

Thread Status:
Not open for further replies.
  1. ZygoZ Code0 You two should so get a conversation!
     
  2. Offline

    ZygoZ

  3. Offline

    Code0

    I'm taking a break ZygoZ. You'll receive both Plugins fully functional in some time.

    This means:

    On Flash, sound and particle

    On NoWorkBench, sound, particle and player gets the workbench back
     
  4. Offline

    ZygoZ

    Thanks man! :D
     
  5. Offline

    Code0

    Here's your fully working NoWorkBench:

    Code:java
    1. package me.ZygoZ;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Effect;
    6. import org.bukkit.Location;
    7. import org.bukkit.Material;
    8. import org.bukkit.Sound;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.event.EventHandler;
    11. import org.bukkit.event.Listener;
    12. import org.bukkit.event.block.BlockPlaceEvent;
    13. import org.bukkit.inventory.ItemStack;
    14. import org.bukkit.plugin.PluginManager;
    15. import org.bukkit.plugin.java.JavaPlugin;
    16.  
    17. public class NoWorkBench extends JavaPlugin implements Listener {
    18.  
    19. public static Material[] banList = {Material.WORKBENCH};
    20.  
    21. public void onEnable(){
    22. PluginManager pm = Bukkit.getPluginManager();
    23. pm.registerEvents(this, this);
    24. }
    25.  
    26. @EventHandler
    27. public void onBlockPlace(BlockPlaceEvent event) {
    28. Material block = event.getBlock().getType();
    29. Player player = event.getPlayer();
    30.  
    31. for(Material blocked : banList) {
    32. if(blocked == block) {
    33. if(player.isOp()) {
    34.  
    35. }
    36. else {
    37. event.getBlock().setType(Material.AIR);
    38. Location eventLocation = event.getBlock().getLocation();
    39. player.playEffect(eventLocation,Effect.MOBSPAWNER_FLAMES,5);
    40. player.playSound(eventLocation,Sound.FIREWORK_BLAST,1,5);
    41. player.sendMessage(ChatColor.RED + "[NoWorkBench]" + ChatColor.DARK_RED + " Du må ikke crafte!");
    42. player.getInventory().addItem(new ItemStack(Material.WORKBENCH,1));
    43. }
    44. }
    45.  
    46.  
    47. }
    48. }
    49.  
    50.  
    51. }


    And here's the perfected Flash Plugin :)

    Code:java
    1. package me.ZygoZ;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Effect;
    6. import org.bukkit.Location;
    7. import org.bukkit.Sound;
    8. import org.bukkit.World;
    9. import org.bukkit.command.Command;
    10. import org.bukkit.command.CommandSender;
    11. import org.bukkit.entity.Player;
    12. import org.bukkit.event.world.WorldEvent;
    13. import org.bukkit.plugin.PluginManager;
    14. import org.bukkit.plugin.java.JavaPlugin;
    15.  
    16. @SuppressWarnings("unused")
    17. public class Flash extends JavaPlugin {
    18.  
    19. @Override
    20. public void onDisable() {
    21.  
    22. }
    23.  
    24. @Override
    25. public void onEnable() {
    26.  
    27. }
    28.  
    29. @SuppressWarnings("deprecation")
    30. public boolean onCommand (CommandSender sender, Command cmd, String label, String[] args) {
    31. Player player = (Player) sender;
    32. if(label.equalsIgnoreCase("flash")) {
    33. if (args.length == 0) {
    34. player.sendMessage(ChatColor.DARK_RED + "Forkert! Brug:" + ChatColor.GOLD + ChatColor.BOLD + " '/flash <Navn>'");
    35. }if(args.length == 1){
    36. Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
    37. if(targetPlayer != null) {
    38. Location targetLocation = targetPlayer.getLocation(); //gets the location of the target player
    39. player.teleport(targetLocation); //Teleports the player to the target Location
    40. for(int i = 0; i < 20; i++) { //loop (doing this command 20 times)
    41. player.playEffect(targetLocation, Effect.ENDER_SIGNAL,5);
    42. player.playSound(targetLocation,Sound.ENDERMAN_TELEPORT,(float)0.1,3);
    43. }
    44. player.sendMessage(ChatColor.GREEN + "Du er blevet flashed hen til " + ChatColor.AQUA + ChatColor.BOLD + targetPlayer.getName() + ChatColor.RESET + ChatColor.GREEN + "!");
    45. targetPlayer.sendMessage(ChatColor.BOLD + player.getName() + ChatColor.RESET + ChatColor.GREEN + " har flashed sig hen til dig!");
    46.  
    47. }
    48. else {
    49. player.sendMessage(ChatColor.RED+"Could not find Player!");
    50. }
    51. }
    52. }
    53. return true;
    54. }
    55. }


    I hope they work!

    List of features just for your info:

    NoWorkBench: When you place a workbench and you're not OP, the workbench dissapears, makes a sound and goes back in your inventory saying the danish message :D.

    Flash: When you teleport, the danish message appears and you get teleported to the player you specified. Also ender particles appear and there is a ender sound.

    :) If you need help with more, just tag me! I'd love to do more stuff with you!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
Thread Status:
Not open for further replies.

Share This Page