-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b359e9
commit bcaf9d1
Showing
3 changed files
with
123 additions
and
11 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package de.thexxturboxx.autonick; | ||
|
||
import java.util.Arrays; | ||
|
||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
|
||
public class NickCmd extends Command { | ||
|
||
AutoNick plugin; | ||
CommandExecutor exe = null; | ||
|
||
public NickCmd(AutoNick plugin) { | ||
super("xnick", "Sich einen Nickname reservieren", "/xnick <Name>", Arrays.asList(new String[]{})); | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public boolean execute(CommandSender sender, String commandLabel, String[] args) { | ||
if(exe != null) { | ||
return exe.onCommand(sender, this, commandLabel, args); | ||
} | ||
return false; | ||
} | ||
|
||
public void setExecutor(CommandExecutor exe){ | ||
this.exe = exe; | ||
} | ||
|
||
} |
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,47 @@ | ||
package de.thexxturboxx.autonick; | ||
|
||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
|
||
import org.bukkit.ChatColor; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
public class NickCmdExec implements CommandExecutor { | ||
|
||
AutoNick plugin; | ||
Statement s; | ||
|
||
public NickCmdExec(AutoNick plugin, Statement s) { | ||
this.plugin = plugin; | ||
this.s = s; | ||
} | ||
|
||
@Override | ||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { | ||
if(sender instanceof Player) { | ||
Player p = (Player) sender; | ||
if(p.hasPermission("nick.cmd.nick")) { | ||
if(args.length == 1) { | ||
try { | ||
s.executeUpdate("UPDATE " + AutoNick.TABLE + " SET nicked = '2' WHERE UUID = '" + p.getName() + "'"); | ||
s.executeUpdate("UPDATE " + AutoNick.TABLE + " SET name = '" + args[0] + "' WHERE UUID = '" + p.getName() + "'"); | ||
p.sendMessage(AutoNick.getPrefix() + ChatColor.DARK_RED + "Du wirst als " + ChatColor.GOLD + args[0] + ChatColor.DARK_RED + " spielen!"); | ||
} catch (SQLException e) { | ||
e.printStackTrace(); | ||
} | ||
} else { | ||
p.sendMessage(AutoNick.getPrefix() + ChatColor.DARK_RED + "Nutze /xnick <Name>"); | ||
} | ||
} else { | ||
p.sendMessage(AutoNick.getPrefix() + ChatColor.DARK_RED + "Dazu hast du keine Erlaubnis!"); | ||
} | ||
} else { | ||
plugin.getServer().getLogger().info("Das kann nur ein Spieler machen, du Schlingel ;)"); | ||
} | ||
return true; | ||
} | ||
|
||
} |