Compare commits

...

5 Commits
1.4 ... master

Author SHA1 Message Date
502647092 0ed4c8cd41 清理代码 去除无效else...
Signed-off-by: 502647092 <jtb1@163.com>
2015-12-12 11:56:27 +08:00
502647092 c2b6f00bc2 fix world command and add warp warps command...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-21 20:07:52 +08:00
502647092 e56e6a3134 fix relocations config...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-21 18:07:55 +08:00
502647092 a821285ac3 fix Plugin Command handle error...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-21 17:17:01 +08:00
502647092 6c4009a0ce fix world command AOOB error...
Signed-off-by: 502647092 <jtb1@163.com>
2015-10-19 20:56:41 +08:00
9 changed files with 160 additions and 77 deletions

View File

@ -11,11 +11,6 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
@ -27,5 +22,6 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>
</classpath> </classpath>

12
pom.xml
View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>cn.citycraft</groupId> <groupId>cn.citycraft</groupId>
<artifactId>SimpleEssential</artifactId> <artifactId>SimpleEssential</artifactId>
<version>1.4</version> <version>1.4.1</version>
<name>SimpleEssential</name> <name>SimpleEssential</name>
<description>轻量级基础插件</description> <description>轻量级基础插件</description>
<build> <build>
@ -35,10 +35,12 @@
<include>cn.citycraft:PluginHelper</include> <include>cn.citycraft:PluginHelper</include>
</includes> </includes>
</artifactSet> </artifactSet>
<relocation> <relocations>
<pattern>cn.citycraft.PluginHelper</pattern> <relocation>
<shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern> <pattern>cn.citycraft.PluginHelper</pattern>
</relocation> <shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
</relocation>
</relocations>
</configuration> </configuration>
<executions> <executions>
<execution> <execution>

View File

@ -3,17 +3,12 @@
*/ */
package cn.citycraft.SimpleEssential; package cn.citycraft.SimpleEssential;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import cn.citycraft.PluginHelper.commands.BaseCommand; import cn.citycraft.PluginHelper.commands.HandlerMainCommand;
import cn.citycraft.PluginHelper.config.FileConfig; import cn.citycraft.PluginHelper.config.FileConfig;
import cn.citycraft.PluginHelper.utils.VersionChecker; import cn.citycraft.PluginHelper.utils.VersionChecker;
import cn.citycraft.SimpleEssential.command.CommandBack; import cn.citycraft.SimpleEssential.command.CommandBack;
@ -47,42 +42,30 @@ public class SimpleEssential extends JavaPlugin {
* *
*/ */
public TeleportControl tpcontrol; public TeleportControl tpcontrol;
/** /**
* *
*/ */
private List<BaseCommand> commandlist;
FileConfig config; FileConfig config;
/**
*
*/
HandlerMainCommand hmc;
@Override @Override
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) { public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
for (final BaseCommand command : commandlist) { if (!hmc.onCommand(sender, cmd, label, args)) {
if (command.isValidTrigger(label)) { hmc.sendHelp(sender);
if (!command.hasPermission(sender)) {
sender.sendMessage(I18n.p("Base.no-permission"));
return true;
}
if (command.isOnlyPlayerExecutable() && !(sender instanceof Player)) {
sender.sendMessage(I18n.p("Base.playercommand"));
return true;
}
if (args.length >= command.getMinimumArguments()) {
try {
command.execute(sender, cmd, label, args);
return true;
} catch (final CommandException e) {
sender.sendMessage(e.getMessage());
}
}
}
} }
return false; return true;
} }
@Override @Override
public void onEnable() { public void onEnable() {
this.initTeleportControl(); this.initTeleportControl();
this.registerCommands();
this.registerEvents(); this.registerEvents();
this.registerCommands();
new VersionChecker(this); new VersionChecker(this);
} }
@ -93,37 +76,27 @@ public class SimpleEssential extends JavaPlugin {
} }
/** /**
* *
*
* @param command
* -
*/
public void registerCommand(final BaseCommand command) {
commandlist.add(command);
}
/**
*
*/ */
public void registerCommands() { public void registerCommands() {
commandlist = new ArrayList<BaseCommand>(); hmc = new HandlerMainCommand(this);
registerCommand(new CommandTpa(this)); hmc.registerCommand(new CommandTpa(this));
registerCommand(new CommandTop(this)); hmc.registerCommand(new CommandTop(this));
registerCommand(new CommandTpaccept(this)); hmc.registerCommand(new CommandTpaccept(this));
registerCommand(new CommandTpdeny(this)); hmc.registerCommand(new CommandTpdeny(this));
registerCommand(new CommandTphere(this)); hmc.registerCommand(new CommandTphere(this));
registerCommand(new CommandBack(this)); hmc.registerCommand(new CommandBack(this));
registerCommand(new CommandSetHome(this)); hmc.registerCommand(new CommandSetHome(this));
registerCommand(new CommandHome(this)); hmc.registerCommand(new CommandHome(this));
registerCommand(new CommandHat(this)); hmc.registerCommand(new CommandHat(this));
registerCommand(new CommandSuicide(this)); hmc.registerCommand(new CommandSuicide(this));
registerCommand(new CommandEnchantBench(this)); hmc.registerCommand(new CommandEnchantBench(this));
registerCommand(new CommandWorkBench(this)); hmc.registerCommand(new CommandWorkBench(this));
registerCommand(new CommandSetSpawn(this)); hmc.registerCommand(new CommandSetSpawn(this));
registerCommand(new CommandSpawn(this)); hmc.registerCommand(new CommandSpawn(this));
registerCommand(new CommandGc(this)); hmc.registerCommand(new CommandGc(this));
registerCommand(new CommandWorld(this)); hmc.registerCommand(new CommandWorld(this));
registerCommand(new CommandPing(this)); hmc.registerCommand(new CommandPing(this));
} }
/** /**

View File

@ -0,0 +1,36 @@
/**
*
*/
package cn.citycraft.SimpleEssential.command;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import cn.citycraft.PluginHelper.commands.BaseCommand;
import cn.citycraft.SimpleEssential.SimpleEssential;
/**
*
*
* @author
* 20158122:04:05
*
*/
public class CommandBase extends BaseCommand {
SimpleEssential plugin;
/**
* @param name
*/
public CommandBase(final SimpleEssential main) {
super("warps");
this.plugin = main;
setDescription("查看所有地表");
}
@Override
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
sender.sendMessage("§c当前功能暂未开发...");
}
}

View File

@ -31,16 +31,15 @@ public class CommandHat extends BaseCommand {
if (p.getItemInHand() == null) { if (p.getItemInHand() == null) {
sender.sendMessage(I18n.p("Hat.empty")); sender.sendMessage(I18n.p("Hat.empty"));
return; return;
} else {
final ItemStack hand = p.getItemInHand();
p.setItemInHand(null);
final ItemStack helmet = p.getInventory().getHelmet();
if (!(helmet == null)) {
p.getInventory().addItem(helmet);
}
p.getInventory().setHelmet(hand);
sender.sendMessage(I18n.p("Hat.enjoy"));
} }
final ItemStack hand = p.getItemInHand();
p.setItemInHand(null);
final ItemStack helmet = p.getInventory().getHelmet();
if (!(helmet == null)) {
p.getInventory().addItem(helmet);
}
p.getInventory().setHelmet(hand);
sender.sendMessage(I18n.p("Hat.enjoy"));
} }
} }

View File

@ -0,0 +1,38 @@
/**
*
*/
package cn.citycraft.SimpleEssential.command;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import cn.citycraft.PluginHelper.commands.BaseCommand;
import cn.citycraft.SimpleEssential.SimpleEssential;
/**
*
*
* @author
* 20158122:04:05
*
*/
public class CommandWarp extends BaseCommand {
SimpleEssential plugin;
/**
* @param name
*/
public CommandWarp(final SimpleEssential main) {
super("warp");
this.plugin = main;
setMinimumArguments(1);
setPermission("se.warp");
setDescription("传送至地标");
}
@Override
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
sender.sendMessage("§c当前功能暂未开发...");
}
}

View File

@ -0,0 +1,36 @@
/**
*
*/
package cn.citycraft.SimpleEssential.command;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import cn.citycraft.PluginHelper.commands.BaseCommand;
import cn.citycraft.SimpleEssential.SimpleEssential;
/**
*
*
* @author
* 20158122:04:05
*
*/
public class CommandWarps extends BaseCommand {
SimpleEssential plugin;
/**
* @param name
*/
public CommandWarps(final SimpleEssential main) {
super("warps");
this.plugin = main;
setDescription("查看所有地表");
}
@Override
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
sender.sendMessage("§c当前功能暂未开发...");
}
}

View File

@ -49,8 +49,9 @@ public class CommandWorld extends BaseCommand {
} }
sender.sendMessage(I18n.p("World.info", wd.getName(), wd.getEnvironment().toString(), wd.getLoadedChunks().length, wd.getEntities().size(), tileEntities, wd.getPlayers().size())); sender.sendMessage(I18n.p("World.info", wd.getName(), wd.getEnvironment().toString(), wd.getLoadedChunks().length, wd.getEntities().size(), tileEntities, wd.getPlayers().size()));
} }
break;
case 1: case 1:
final World wd = Bukkit.getWorld(args[1]); final World wd = Bukkit.getWorld(args[0]);
if (wd != null) { if (wd != null) {
if (sender instanceof Player) { if (sender instanceof Player) {
((Player) sender).teleport(wd.getSpawnLocation()); ((Player) sender).teleport(wd.getSpawnLocation());
@ -60,6 +61,7 @@ public class CommandWorld extends BaseCommand {
} else { } else {
sender.sendMessage(I18n.p("World.unknow", args[1])); sender.sendMessage(I18n.p("World.unknow", args[1]));
} }
break;
} }
} }
} }

View File

@ -0,0 +1 @@
warps: