Skip to content
This repository has been archived by the owner on Jul 3, 2021. It is now read-only.

Commit

Permalink
Implemented commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Gunnar Gudvardarson committed Jul 29, 2013
1 parent 86edea2 commit a457832
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 12 deletions.
30 changes: 21 additions & 9 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
name: coordfuscation
main: cc.kjarni.aetherous.coordfuscation.Coordfuscation
version: 1
version: 2.0
depend:
- ProtocolLib
commands:
/getoffsets:
description: Get Coordfuscation offset for player
usage: /getoffsets [Player]
permission: coordfuscation.getoffset
permission-message: Offsets are secret, access denied...
getoffset:
description: Get coordfuscation offsets
permission: coordfuscation.getoffset.self
permission-message: The offset is secret, access denied...
usage: Syntax error! Just type /getoffset [username]

permissions:
coordfuscation.*:
description: All commands of Coordfuscation
children:
coordfuscation.getoffset: true
coordfuscation.getoffset:
description: Get the offset for yourself or others
coordfuscation.getoffset.self: true
coordfuscation.getoffset.others: true
coordfuscation.getoffset.disable: false

coordfuscation.getoffset.self:
description: Get the offsets for the user
default: op

coordfuscation.getoffset.others:
description: Get the offsets for other users
default: op

coordfuscation.getoffset.disable:
description: Create no offset for users with this
default: op
40 changes: 37 additions & 3 deletions src/cc/kjarni/aetherous/coordfuscation/Coordfuscation.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package cc.kjarni.aetherous.coordfuscation;

import java.util.HashMap;
import java.util.List;

import org.bukkit.Location;
import org.bukkit.command.Command;
Expand Down Expand Up @@ -394,11 +395,44 @@ public void kickAll()

public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
{
if(cmd.getName().equalsIgnoreCase("/getoffsets"))
String prefix = "[Coordfuscation]";

if(cmd.getName().equalsIgnoreCase("getoffset"))
{
if(sender.hasPermission("coordfuscation.getoffset"))
if (sender.hasPermission("coordfuscation.getoffset.self") && args.length == 0)
{
if (sender instanceof Player)
{
sender.sendMessage(String.format("%s Your offsets are:", prefix));
sender.sendMessage(String.format("%s X: %d", prefix, offsetCoords(((Player) sender).getPlayer()).X));
sender.sendMessage(String.format("%s Z: %d", prefix, offsetCoords(((Player) sender).getPlayer()).Y));
}
else
{
sender.sendMessage(String.format("%s Only players can use this command as the server has no offset for himself :P", prefix));
sender.sendMessage(String.format("%s Try /getoffset username", prefix));
}
}
else if (sender.hasPermission("coordfuscation.getoffset.others"))
{
List<Player> pl = getServer().matchPlayer(args[0]);

if (pl != null && pl.size() == 1)
{
Player p = pl.get(0);

sender.sendMessage(String.format("%s %s's offsets are:", prefix, p.getDisplayName()));
sender.sendMessage(String.format("%s X: %d", prefix, offsetCoords(p).X));
sender.sendMessage(String.format("%s Z: %d", prefix, offsetCoords(p).Y));
}
else
{
sender.sendMessage(String.format("%s User not found, or result contained multiple users", prefix));
}
}
else
{
sender.sendMessage("getcoordfuscationoffsets command invoked!");
sender.sendMessage(String.format("%s Access denied", prefix));
}

return true;
Expand Down

0 comments on commit a457832

Please sign in to comment.