-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated for the new CommandExecutor interface.
- Loading branch information
1 parent
ea24df7
commit 8419fdb
Showing
5 changed files
with
90 additions
and
38 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/main/java/com/dinnerbone/bukkit/sample/SampleDebugCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
package com.dinnerbone.bukkit.sample; | ||
|
||
import org.bukkit.entity.Player; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
|
||
/** | ||
* Handler for the /debug sample command. | ||
* @author SpaceManiac | ||
*/ | ||
public class SampleDebugCommand implements CommandExecutor { | ||
private final SamplePlugin plugin; | ||
|
||
public SampleDebugCommand(SamplePlugin plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public boolean onCommand(CommandSender sender, Command command, String label, String[] split) { | ||
if (sender instanceof Player) { | ||
Player player = (Player) sender; | ||
plugin.setDebugging(player, !plugin.isDebugging(player)); | ||
|
||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/com/dinnerbone/bukkit/sample/SamplePosCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
package com.dinnerbone.bukkit.sample; | ||
|
||
import org.bukkit.Location; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
|
||
/** | ||
* Handler for the /pos sample command. | ||
* @author SpaceManiac | ||
*/ | ||
public class SamplePosCommand implements CommandExecutor { | ||
private final SamplePlugin plugin; | ||
|
||
public SamplePosCommand(SamplePlugin plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public boolean onCommand(CommandSender sender, Command command, String label, String[] split) { | ||
if (!(sender instanceof Player)) { | ||
return false; | ||
} | ||
Player player = (Player) sender; | ||
|
||
if (split.length == 0) { | ||
Location location = player.getLocation(); | ||
player.sendMessage("You are currently at " + location.getX() +"," + location.getY() + "," + location.getZ() + | ||
" with " + location.getYaw() + " yaw and " + location.getPitch() + " pitch"); | ||
return true; | ||
} else if (split.length == 3) { | ||
try { | ||
double x = Double.parseDouble(split[0]); | ||
double y = Double.parseDouble(split[1]); | ||
double z = Double.parseDouble(split[2]); | ||
|
||
player.teleportTo(new Location(player.getWorld(), x, y, z)); | ||
} catch (NumberFormatException ex) { | ||
player.sendMessage("Given location is invalid"); | ||
} | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
name: Sample Plugin | ||
main: com.dinnerbone.bukkit.sample.SamplePlugin | ||
version: 0.4 | ||
commands: | ||
pos: | ||
description: Displays your position or teleports you to another. | ||
usage: "Usage: '/pos' to get current position, or '/pos x y z' to teleport to x,y,z" | ||
debug: | ||
description: Toggles your debugging status for this plugin. | ||
usage: /debug |