mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-25 03:55:22 +01:00
Added console commands
This commit is contained in:
parent
3dd7c0fcb2
commit
6e47010e26
@ -6,8 +6,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -189,7 +187,7 @@ public class DMobType {
|
||||
itemMeta.addEnchant(Enchantment.getByName(splittedEnchantment[0].toUpperCase()), 1, true);
|
||||
}
|
||||
} else {
|
||||
P.p.log(Level.WARNING, P.p.language.get("Log_Error_MobEnchantment",splittedEnchantment[0]));
|
||||
P.p.log(P.p.language.get("Log_Error_MobEnchantment",splittedEnchantment[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -221,7 +219,7 @@ public class DMobType {
|
||||
mobType.spoutSkinURL = configFile.getString(mobName+".spoutSkinURL");
|
||||
}
|
||||
} else {
|
||||
P.p.log(Level.WARNING, P.p.language.get("Log_Error_MobType",configFile.getString(mobName+".Type")));
|
||||
P.p.log(P.p.language.get("Log_Error_MobType",configFile.getString(mobName+".Type")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,13 +36,14 @@ public class LanguageReader {
|
||||
private void setDefaults(){
|
||||
|
||||
/* Log */
|
||||
defaults.put("Log_NewDungeon","New Dungeon: ");
|
||||
defaults.put("Log_GenerateNewWorld","Generate new world...");
|
||||
defaults.put("Log_WorldGenerationFinished","World generation finished!");
|
||||
defaults.put("Log_Error_MobEnchantment","Error at loading mob.yml: Enchantmet &v1 doesn't exist!");
|
||||
defaults.put("Log_Error_MobType","Error at loading mob.yml: Mob &v1 doesn't exist!");
|
||||
defaults.put("Log_Error_Spout","Spout wurde nicht gefunden!");
|
||||
defaults.put("Log_Error_Spout_Skin","Der Spout Skin von &v1 ist kein png!");
|
||||
defaults.put("Log_NewDungeon","&6New Dungeon");
|
||||
defaults.put("Log_GenerateNewWorld","&6Generate new world...");
|
||||
defaults.put("Log_WorldGenerationFinished","&6World generation finished!");
|
||||
defaults.put("Log_Error_MobEnchantment","&4Error at loading mob.yml: Enchantmet &6&v1&4 doesn't exist!");
|
||||
defaults.put("Log_Error_MobType","&4Error at loading mob.yml: Mob &6&v1&4 doesn't exist!");
|
||||
defaults.put("Log_Error_Spout","&4Spout wurde nicht gefunden!");
|
||||
defaults.put("Log_Error_Spout_Skin","&4Der Spout Skin von &6&v1&4 ist kein png!");
|
||||
defaults.put("Log_Error_NoConsoleCommand","&6/dxl &v1&4 kann man nicht als Konsole ausführen!");
|
||||
|
||||
/* Player */
|
||||
defaults.put("Player_CheckpointReached","&6Checkpoint erreicht!");
|
||||
@ -99,6 +100,7 @@ public class LanguageReader {
|
||||
defaults.put("Error_TutorialNotExist","&4Tutorial Dungeon existiert nicht!");
|
||||
defaults.put("Error_SpoutCraftOnly","&4Du brauchst SpoutCraft um diesen Dungeon spielen zu können!");
|
||||
defaults.put("Error_NoPortal","&4Du musst ein Portal anschauen!");
|
||||
defaults.put("Error_NoPlayerCommand","&6/dxl &v1&4 kann man nicht als Spieler ausführen!");
|
||||
|
||||
/* Help */
|
||||
defaults.put("Help_Cmd_Chat","/dxl chat - Ändert den Chat-Modus");
|
||||
|
@ -8,9 +8,6 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import net.minecraft.server.v1_4_6.EntityPlayer;
|
||||
import net.minecraft.server.v1_4_6.MinecraftServer;
|
||||
@ -19,6 +16,7 @@ import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.craftbukkit.v1_4_6.CraftServer;
|
||||
@ -365,17 +363,17 @@ public class P extends JavaPlugin{
|
||||
}
|
||||
|
||||
//Msg
|
||||
public void msg(Player player,String msg){
|
||||
public void msg(CommandSender sender,String msg){
|
||||
msg = replaceColors(msg);
|
||||
player.sendMessage(ChatColor.DARK_GREEN+"[DXL] "+ChatColor.WHITE+msg);
|
||||
sender.sendMessage(ChatColor.DARK_GREEN+"[DXL] "+ChatColor.WHITE+msg);
|
||||
}
|
||||
|
||||
public void msg(Player player,String msg, boolean zusatz){
|
||||
public void msg(CommandSender sender,String msg, boolean zusatz){
|
||||
msg = replaceColors(msg);
|
||||
if(zusatz){
|
||||
player.sendMessage(ChatColor.DARK_GREEN+"[DXL]"+ChatColor.WHITE+msg);
|
||||
sender.sendMessage(ChatColor.DARK_GREEN+"[DXL]"+ChatColor.WHITE+msg);
|
||||
}else{
|
||||
player.sendMessage(ChatColor.WHITE+msg);
|
||||
sender.sendMessage(ChatColor.WHITE+msg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -490,14 +488,8 @@ public class P extends JavaPlugin{
|
||||
// -------------------------------------------- //
|
||||
// LOGGING
|
||||
// -------------------------------------------- //
|
||||
public void log(Object msg)
|
||||
public void log(String msg)
|
||||
{
|
||||
log(Level.INFO, msg);
|
||||
this.msg(Bukkit.getConsoleSender(), msg);
|
||||
}
|
||||
|
||||
public void log(Level level, Object msg)
|
||||
{
|
||||
Logger.getLogger("Minecraft").log(level, "["+this.getDescription().getFullName()+"] "+msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.dre.dungeonsxl.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.dre.dungeonsxl.DPlayer;
|
||||
@ -10,12 +11,15 @@ public class CMDChat extends DCommand{
|
||||
this.command="chat";
|
||||
this.args=0;
|
||||
this.help=p.language.get("Help_Cmd_Chat");
|
||||
this.isPlayerCommand = true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, Player player) {
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
DPlayer dplayer=DPlayer.get(player);
|
||||
|
||||
if(dplayer!=null){
|
||||
if(dplayer.isInDungeonChat) {
|
||||
dplayer.isInDungeonChat=false;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.dre.dungeonsxl.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CMDChatSpy extends DCommand{
|
||||
@ -8,16 +9,17 @@ public class CMDChatSpy extends DCommand{
|
||||
this.args=0;
|
||||
this.help=p.language.get("Help_Cmd_Chatspy");
|
||||
this.permissions="dxl.chatspy";
|
||||
this.isPlayerCommand = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, Player player) {
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(p.chatSpyer.contains(player)){
|
||||
p.chatSpyer.remove(player);
|
||||
p.msg(player, p.language.get("Cmd_Chatspy_Stopped"));
|
||||
}
|
||||
|
||||
else{
|
||||
} else {
|
||||
p.chatSpyer.add(player);
|
||||
p.msg(player, p.language.get("Cmd_Chatspy_Start"));
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.dre.dungeonsxl.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.dre.dungeonsxl.DPlayer;
|
||||
@ -12,15 +14,16 @@ public class CMDCreate extends DCommand {
|
||||
this.command="create";
|
||||
this.help=p.language.get("Help_Cmd_Create");
|
||||
this.permissions="dxl.create";
|
||||
this.isPlayerCommand = true;
|
||||
this.isConsoleCommand = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, Player player) {
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
String name=args[1];
|
||||
|
||||
if(DPlayer.get(player)==null){
|
||||
if(sender instanceof ConsoleCommandSender){
|
||||
if(name.length()<=15){
|
||||
|
||||
//Msg create
|
||||
p.log(p.language.get("Log_NewDungeon"));
|
||||
p.log(p.language.get("Log_GenerateNewWorld"));
|
||||
@ -29,23 +32,44 @@ public class CMDCreate extends DCommand {
|
||||
EditWorld eworld=new EditWorld();
|
||||
eworld.generate();
|
||||
eworld.dungeonname=name;
|
||||
eworld.save();
|
||||
eworld.delete();
|
||||
|
||||
//MSG Done
|
||||
p.log(p.language.get("Log_WorldGenerationFinished"));
|
||||
}else{
|
||||
p.msg(sender, p.language.get("Error_NameToLong"));
|
||||
}
|
||||
} else if(sender instanceof Player){
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(DPlayer.get(player)==null){
|
||||
if(name.length()<=15){
|
||||
//Msg create
|
||||
p.log(p.language.get("Log_NewDungeon"));
|
||||
p.log(p.language.get("Log_GenerateNewWorld"));
|
||||
|
||||
//Tp Player
|
||||
if(eworld.lobby==null){
|
||||
new DPlayer(player,eworld.world,eworld.world.getSpawnLocation(), true);
|
||||
//Create World
|
||||
EditWorld eworld=new EditWorld();
|
||||
eworld.generate();
|
||||
eworld.dungeonname=name;
|
||||
|
||||
//MSG Done
|
||||
p.log(p.language.get("Log_WorldGenerationFinished"));
|
||||
|
||||
//Tp Player
|
||||
if(eworld.lobby==null){
|
||||
new DPlayer(player,eworld.world,eworld.world.getSpawnLocation(), true);
|
||||
}else{
|
||||
new DPlayer(player,eworld.world,eworld.lobby, true);
|
||||
}
|
||||
}else{
|
||||
new DPlayer(player,eworld.world,eworld.lobby, true);
|
||||
p.msg(player, p.language.get("Error_NameToLong"));
|
||||
}
|
||||
}else{
|
||||
p.msg(player, p.language.get("Error_NameToLong"));
|
||||
p.msg(player, p.language.get("Error_LeaveDungeon"));
|
||||
}
|
||||
}else{
|
||||
p.msg(player, p.language.get("Error_LeaveDungeon"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.dre.dungeonsxl.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.dre.dungeonsxl.DPortal;
|
||||
|
||||
@ -10,11 +11,14 @@ public class CMDDeletePortal extends DCommand{
|
||||
this.args = 0;
|
||||
this.help = p.language.get("Help_Cmd_DeletePortal");
|
||||
this.permissions = "dxl.deleteportal";
|
||||
this.isPlayerCommand = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, Player player) {
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
DPortal dPortal = DPortal.get(player.getTargetBlock(null, 20).getLocation());
|
||||
|
||||
if(dPortal!=null){
|
||||
dPortal.delete();
|
||||
p.msg(player, p.language.get("Player_PortalDeleted"));
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.dre.dungeonsxl.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.dre.dungeonsxl.DGroup;
|
||||
@ -12,19 +13,19 @@ public class CMDEdit extends DCommand{
|
||||
this.command="edit";
|
||||
this.args=1;
|
||||
this.help=p.language.get("Help_Cmd_Edit");
|
||||
this.isPlayerCommand = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, Player player) {
|
||||
String dungeonname=args[1];
|
||||
|
||||
EditWorld eworld=EditWorld.load(dungeonname);
|
||||
|
||||
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
String dungeonName=args[1];
|
||||
EditWorld eworld=EditWorld.load(dungeonName);
|
||||
DGroup dgroup=DGroup.get(player);
|
||||
DPlayer dplayer=DPlayer.get(player);
|
||||
|
||||
if(EditWorld.isInvitedPlayer(dungeonname,player.getName())||p.permission.has(player, "dxl.edit")||player.isOp()){
|
||||
if(EditWorld.isInvitedPlayer(dungeonName,player.getName())||p.permission.has(player, "dxl.edit")||player.isOp()){
|
||||
if(dplayer==null){
|
||||
if(dgroup==null){
|
||||
if(eworld!=null){
|
||||
@ -34,7 +35,7 @@ public class CMDEdit extends DCommand{
|
||||
new DPlayer(player,eworld.world,eworld.lobby, true);
|
||||
}
|
||||
}else{
|
||||
p.msg(player,p.language.get("Error_DungeonNotExist",dungeonname));
|
||||
p.msg(player,p.language.get("Error_DungeonNotExist",dungeonName));
|
||||
}
|
||||
}else{
|
||||
p.msg(player,p.language.get("Error_LeaveGroup"));
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.dre.dungeonsxl.commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CMDHelp extends DCommand{
|
||||
@ -9,10 +11,20 @@ public class CMDHelp extends DCommand{
|
||||
this.command="help";
|
||||
this.args=-1;
|
||||
this.help=p.language.get("Help_Cmd_Help");
|
||||
this.isPlayerCommand = true;
|
||||
this.isConsoleCommand = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, Player player) {
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
boolean isConsole = false, isPlayer = false;
|
||||
|
||||
if(sender instanceof ConsoleCommandSender){
|
||||
isConsole = true;
|
||||
}else if(sender instanceof Player){
|
||||
isPlayer = true;
|
||||
}
|
||||
|
||||
int page=1;
|
||||
int pages=(int)(DCommandRoot.root.commands.size()/6);
|
||||
|
||||
@ -26,22 +38,24 @@ public class CMDHelp extends DCommand{
|
||||
if(page>pages) page=pages;
|
||||
}
|
||||
|
||||
p.msg(player, ChatColor.GREEN+"============[ "+ChatColor.GOLD+"Help DungeonsXL - "+page+"/"+pages+ChatColor.GREEN+" ]============",false);
|
||||
p.msg(sender, ChatColor.GREEN+"============[ "+ChatColor.GOLD+"Help DungeonsXL - "+page+"/"+pages+ChatColor.GREEN+" ]============",false);
|
||||
|
||||
int i=0;
|
||||
int ipage=1;
|
||||
for(DCommand command:DCommandRoot.root.commands){
|
||||
i++;
|
||||
if(i>6){
|
||||
i=0;
|
||||
ipage++;
|
||||
}
|
||||
if(ipage==page){
|
||||
p.msg(player, ChatColor.YELLOW+command.help,false);
|
||||
if((command.isConsoleCommand && isConsole) || (command.isPlayerCommand && isPlayer)){
|
||||
i++;
|
||||
if(i>6){
|
||||
i=0;
|
||||
ipage++;
|
||||
}
|
||||
if(ipage==page){
|
||||
p.msg(sender, ChatColor.YELLOW+command.help,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
p.msg(player, ChatColor.GREEN+"==============[ "+ChatColor.GOLD+"By Frank Baumann"+ChatColor.GREEN+" ]==============",false);
|
||||
p.msg(sender, ChatColor.GREEN+"==============[ "+ChatColor.GOLD+"By Frank Baumann"+ChatColor.GREEN+" ]==============",false);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,24 +1,25 @@
|
||||
package com.dre.dungeonsxl.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.dre.dungeonsxl.EditWorld;
|
||||
|
||||
public class CMDInvite extends DCommand{
|
||||
|
||||
public CMDInvite(){
|
||||
this.args=2;
|
||||
this.command="invite";
|
||||
this.help=p.language.get("Help_Cmd_Invite");
|
||||
this.permissions="dxl.invite";
|
||||
this.isPlayerCommand = true;
|
||||
this.isConsoleCommand = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, Player player) {
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
if(EditWorld.addInvitedPlayer(args[2], args[1])){
|
||||
p.msg(player, p.language.get("Cmd_Invite_Success",args[1],args[2]));
|
||||
p.msg(sender, p.language.get("Cmd_Invite_Success",args[1],args[2]));
|
||||
}else{
|
||||
p.msg(player, p.language.get("Error_DungeonNotExist",args[2]));
|
||||
p.msg(sender, p.language.get("Error_DungeonNotExist",args[2]));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.dre.dungeonsxl.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.dre.dungeonsxl.DGroup;
|
||||
@ -12,10 +13,12 @@ public class CMDLeave extends DCommand {
|
||||
this.command="leave";
|
||||
this.args=0;
|
||||
this.help=p.language.get("Help_Cmd_Leave");
|
||||
this.isPlayerCommand = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, Player player) {
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
DPlayer dplayer=DPlayer.get(player);
|
||||
|
||||
if(GameWorld.get(player.getWorld())!=null){
|
||||
|
@ -3,7 +3,7 @@ package com.dre.dungeonsxl.commands;
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class CMDList extends DCommand{
|
||||
|
||||
@ -11,18 +11,20 @@ public class CMDList extends DCommand{
|
||||
this.command="list";
|
||||
this.args=0;
|
||||
this.help=p.language.get("Help_Cmd_List");
|
||||
this.isPlayerCommand = true;
|
||||
this.isConsoleCommand = true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, Player player) {
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
|
||||
File dungeonsfolder=new File(p.getDataFolder()+"/dungeons");
|
||||
if(dungeonsfolder.exists()){
|
||||
p.msg(player, ChatColor.DARK_GREEN+"-----[ "+ChatColor.GOLD+"Dungeons "+ChatColor.RED+dungeonsfolder.list().length+ChatColor.DARK_GREEN+"]-----");
|
||||
p.msg(sender, ChatColor.DARK_GREEN+"-----[ "+ChatColor.GOLD+"Dungeons "+ChatColor.RED+dungeonsfolder.list().length+ChatColor.DARK_GREEN+"]-----");
|
||||
|
||||
for(String dungeon:dungeonsfolder.list()){
|
||||
p.msg(player, dungeon);
|
||||
p.msg(sender, dungeon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.dre.dungeonsxl.commands;
|
||||
|
||||
import java.io.File;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.dre.dungeonsxl.DConfig;
|
||||
@ -14,10 +15,12 @@ public class CMDMsg extends DCommand{
|
||||
this.command="msg";
|
||||
this.help=p.language.get("Help_Cmd_Msg");
|
||||
this.permissions="dxl.msg";
|
||||
this.isPlayerCommand = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, Player player) {
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
EditWorld eworld=EditWorld.get(player.getWorld());
|
||||
|
||||
if(eworld!=null){
|
||||
@ -66,7 +69,7 @@ public class CMDMsg extends DCommand{
|
||||
}
|
||||
|
||||
}else{
|
||||
this.displayhelp(player);
|
||||
this.displayHelp(player);
|
||||
}
|
||||
}else{
|
||||
p.msg(player, p.language.get("Error_NotInDungeon"));
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.dre.dungeonsxl.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -13,10 +14,12 @@ public class CMDPortal extends DCommand{
|
||||
this.args = 0;
|
||||
this.help = p.language.get("Help_Cmd_Portal");
|
||||
this.permissions = "dxl.portal";
|
||||
this.isPlayerCommand = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, Player player) {
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
DPlayer dplayer = DPlayer.get(player);
|
||||
if(dplayer == null){
|
||||
DPortal dportal = DPortal.get(player);
|
||||
|
@ -3,8 +3,7 @@ package com.dre.dungeonsxl.commands;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.dre.dungeonsxl.DMobType;
|
||||
import com.dre.dungeonsxl.LanguageReader;
|
||||
import com.dre.dungeonsxl.MainConfig;
|
||||
@ -16,11 +15,13 @@ public class CMDReload extends DCommand{
|
||||
this.args=0;
|
||||
this.help=p.language.get("Help_Cmd_Reload");
|
||||
this.permissions="dxl.reload";
|
||||
this.isPlayerCommand = true;
|
||||
this.isConsoleCommand = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, Player player) {
|
||||
p.msg(player, p.language.get("Cmd_Reload_Start"));
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
p.msg(sender, p.language.get("Cmd_Reload_Start"));
|
||||
|
||||
//Save
|
||||
p.saveData();
|
||||
@ -36,6 +37,6 @@ public class CMDReload extends DCommand{
|
||||
DMobType.clear();
|
||||
DMobType.load(new File(p.getDataFolder(), "mobs.yml"));
|
||||
|
||||
p.msg(player, p.language.get("Cmd_Reload_Done"));
|
||||
p.msg(sender, p.language.get("Cmd_Reload_Done"));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.dre.dungeonsxl.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.dre.dungeonsxl.EditWorld;
|
||||
@ -11,11 +12,12 @@ public class CMDSave extends DCommand{
|
||||
this.args=0;
|
||||
this.help=p.language.get("Help_Cmd_Save");
|
||||
this.permissions="dxl.save";
|
||||
this.isPlayerCommand = true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, Player player) {
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
EditWorld eworld=EditWorld.get(player.getWorld());
|
||||
if(eworld!=null){
|
||||
eworld.save();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.dre.dungeonsxl.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.dre.dungeonsxl.DGroup;
|
||||
@ -14,10 +15,12 @@ public class CMDTest extends DCommand {
|
||||
this.args=-1;
|
||||
this.help=p.language.get("Help_Cmd_Test");
|
||||
this.permissions="dxl.test";
|
||||
this.isPlayerCommand = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, Player player) {
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
DPlayer dplayer=DPlayer.get(player);
|
||||
String dungeonname;
|
||||
|
||||
@ -45,7 +48,7 @@ public class CMDTest extends DCommand {
|
||||
p.msg(player, p.language.get("Error_DungeonNotExist",dungeonname));
|
||||
}
|
||||
}else{
|
||||
this.displayhelp(player);
|
||||
this.displayHelp(player);
|
||||
}
|
||||
}else{
|
||||
p.msg(player, p.language.get("Error_LeaveDungeon"));
|
||||
|
@ -1,23 +1,25 @@
|
||||
package com.dre.dungeonsxl.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.dre.dungeonsxl.EditWorld;
|
||||
|
||||
public class CMDUninvite extends DCommand{
|
||||
|
||||
public CMDUninvite(){
|
||||
this.args=2;
|
||||
this.command="uninvite";
|
||||
this.help=p.language.get("Help_Cmd_Uninvite");
|
||||
this.permissions="dxl.uninvite";
|
||||
this.args = 2;
|
||||
this.command = "uninvite";
|
||||
this.help = p.language.get("Help_Cmd_Uninvite");
|
||||
this.permissions = "dxl.uninvite";
|
||||
this.isPlayerCommand = true;
|
||||
this.isConsoleCommand = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, Player player) {
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
if(EditWorld.removeInvitedPlayer(args[2], args[1])){
|
||||
p.msg(player, p.language.get("Cmd_Uninvite_Success",args[1],args[2]));
|
||||
p.msg(sender, p.language.get("Cmd_Uninvite_Success",args[1],args[2]));
|
||||
}else{
|
||||
p.msg(player, p.language.get("Error_DungeonNotExist",args[2]));
|
||||
p.msg(sender, p.language.get("Error_DungeonNotExist",args[2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.dre.dungeonsxl.commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.dre.dungeonsxl.P;
|
||||
@ -8,12 +9,13 @@ import com.dre.dungeonsxl.P;
|
||||
public abstract class DCommand {
|
||||
public P p=P.p;
|
||||
|
||||
public Player player;
|
||||
public boolean costsMoney;
|
||||
public String command;
|
||||
public int args;
|
||||
public String help;
|
||||
public String permissions;
|
||||
public boolean isPlayerCommand = false;
|
||||
public boolean isConsoleCommand = false;
|
||||
|
||||
// TODO : Add Aliases
|
||||
|
||||
@ -21,8 +23,8 @@ public abstract class DCommand {
|
||||
costsMoney = false;
|
||||
}
|
||||
|
||||
public void displayhelp(Player player){
|
||||
p.msg(player,ChatColor.RED+this.help);
|
||||
public void displayHelp(CommandSender sender){
|
||||
p.msg(sender,ChatColor.RED+this.help);
|
||||
}
|
||||
|
||||
public boolean playerHasPermissions(Player player){
|
||||
@ -37,7 +39,7 @@ public abstract class DCommand {
|
||||
}
|
||||
|
||||
//Abstracts
|
||||
public abstract void onExecute(String[] args, Player player);
|
||||
public abstract void onExecute(String[] args, CommandSender sender);
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.dre.dungeonsxl.listener;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.dre.dungeonsxl.P;
|
||||
@ -13,35 +14,46 @@ public class CommandListener implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd_notused, String arg, String[] args) {
|
||||
if(args.length > 0){
|
||||
String cmd = args[0];
|
||||
|
||||
//Only Playercommands
|
||||
if(sender instanceof Player){
|
||||
Player player = (Player) sender;
|
||||
if(args.length > 0){
|
||||
String cmd = args[0];
|
||||
for(DCommand command:DCommandRoot.root.commands){
|
||||
if(cmd.equals(command.command)){
|
||||
if(sender instanceof ConsoleCommandSender){
|
||||
if(!command.isConsoleCommand){
|
||||
P.p.msg(sender, P.p.language.get("Log_Error_NoConsoleCommand", command.command));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(sender instanceof Player){
|
||||
Player player = (Player) sender;
|
||||
if(!command.isPlayerCommand){
|
||||
P.p.msg(player, P.p.language.get("Error_NoPlayerCommand", command.command));
|
||||
return false;
|
||||
} else {
|
||||
if(!command.playerHasPermissions(player)){
|
||||
P.p.msg(player, P.p.language.get("Error_NoPermissions"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(command.args == args.length-1 || command.args == -1){
|
||||
command.onExecute(args,sender);
|
||||
return true;
|
||||
} else {
|
||||
command.displayHelp(sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(DCommand command:DCommandRoot.root.commands){
|
||||
if(cmd.equals(command.command)){
|
||||
if(command.playerHasPermissions(player)){
|
||||
if(command.args==args.length-1||command.args==-1){
|
||||
command.onExecute(args,player);
|
||||
}else{
|
||||
command.displayhelp(player);
|
||||
}
|
||||
}
|
||||
else{
|
||||
P.p.msg(player, P.p.language.get("Error_NoPermissions"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
P.p.msg(player, P.p.language.get("Error_CmdNotExist1",cmd));
|
||||
P.p.msg(player, P.p.language.get("Error_CmdNotExist2"));
|
||||
}else{
|
||||
DCommandRoot.root.cmdHelp.onExecute(args,player);
|
||||
}
|
||||
P.p.msg(sender, P.p.language.get("Error_CmdNotExist1",cmd));
|
||||
P.p.msg(sender, P.p.language.get("Error_CmdNotExist2"));
|
||||
}else{
|
||||
DCommandRoot.root.cmdHelp.onExecute(args,sender);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user