Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package GameHub;
- /**
- * Created by dannysmc95 on 14/06/2016.
- */
- import org.bukkit.block.Block;
- import org.bukkit.command.CommandSender;
- import org.bukkit.command.Command;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.player.PlayerMoveEvent;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.*;
- public final class GameHub extends JavaPlugin {
- @Override
- public void onEnable() {
- getLogger().info("GameHub was loaded successfully.");
- }
- @Override
- public void onDisable() {
- getLogger().info("GameHub was disabled successfully.");
- }
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- if (cmd.getName().equalsIgnoreCase("basic")) {
- // Command was /basic
- return true;
- } else if (cmd.getName().equalsIgnoreCase("basic2")) {
- if (!(sender instanceof Player)) {
- sender.sendMessage("This command can only be run by a player");
- } else {
- Player player = (Player) sender;
- if (player.hasPermission("some.pointless.permission")) {
- sender.sendMessage("Player has permission");
- return false;
- } else {
- sender.sendMessage("Player does not have permission");
- return true;
- }
- return false;
- }
- return false;
- }
- return false;
- }
- @EventHandler
- public void onPlayerMove(PlayerMoveEvent event) {
- // Get the player's location.
- Location loc = event.getPlayer().getLocation();
- // Sets loc to five above where it used to be. Note that this doesn't change the player's position.
- loc.setY(loc.getY() + 5);
- // Gets the block at the new location.
- Block b = loc.getBlock();
- // Sets the block to type id 1 (stone).
- b.setType(Material.STONE);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement