Advertisement
dannysmc95

java_example.java

Jun 14th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.16 KB | None | 0 0
  1. package GameHub;
  2.  
  3. /**
  4.  * Created by dannysmc95 on 14/06/2016.
  5.  */
  6.  
  7. import org.bukkit.block.Block;
  8. import org.bukkit.command.CommandSender;
  9. import org.bukkit.command.Command;
  10. import org.bukkit.entity.Player;
  11. import org.bukkit.event.EventHandler;
  12. import org.bukkit.event.player.PlayerMoveEvent;
  13. import org.bukkit.plugin.java.JavaPlugin;
  14. import org.bukkit.*;
  15.  
  16. public final class GameHub extends JavaPlugin {
  17.  
  18.         @Override
  19.         public void onEnable() {
  20.             getLogger().info("GameHub was loaded successfully.");
  21.         }
  22.  
  23.         @Override
  24.         public void onDisable() {
  25.             getLogger().info("GameHub was disabled successfully.");
  26.         }
  27.  
  28.         @Override
  29.         public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  30.             if (cmd.getName().equalsIgnoreCase("basic")) {
  31.                 // Command was /basic
  32.                 return true;
  33.             } else if (cmd.getName().equalsIgnoreCase("basic2")) {
  34.                 if (!(sender instanceof Player)) {
  35.                     sender.sendMessage("This command can only be run by a player");
  36.                 } else {
  37.                     Player player = (Player) sender;
  38.                     if (player.hasPermission("some.pointless.permission")) {
  39.                         sender.sendMessage("Player has permission");
  40.                         return false;
  41.                     } else {
  42.                         sender.sendMessage("Player does not have permission");
  43.                         return true;
  44.                     }
  45.                     return false;
  46.                 }
  47.                 return false;
  48.             }
  49.             return false;
  50.         }
  51.  
  52.     @EventHandler
  53.     public void onPlayerMove(PlayerMoveEvent event) {
  54.         // Get the player's location.
  55.         Location loc = event.getPlayer().getLocation();
  56.         // Sets loc to five above where it used to be. Note that this doesn't change the player's position.
  57.         loc.setY(loc.getY() + 5);
  58.         // Gets the block at the new location.
  59.         Block b = loc.getBlock();
  60.         // Sets the block to type id 1 (stone).
  61.         b.setType(Material.STONE);
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement