1
0
mirror of https://e.coding.net/circlecloud/RocketJump.git synced 2024-12-28 20:58:49 +00:00

添加混淆 修复命令处理...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2016-02-23 13:30:37 +08:00
parent 04d2c516b6
commit 5cdbe152d4
5 changed files with 106 additions and 43 deletions

28
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>RocketJump</artifactId> <artifactId>RocketJump</artifactId>
<version>1.1</version> <version>1.2</version>
<name>RocketJump</name> <name>RocketJump</name>
<build> <build>
<finalName>${project.name}</finalName> <finalName>${project.name}</finalName>
@ -50,11 +50,32 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<options>
<option>-repackageclasses ${project.groupId}.${project.artifactId}</option>
<option>-keep class ${project.groupId}.${project.artifactId}.${project.artifactId}</option>
</options>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
</libs>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
<properties> <properties>
<jenkins.url>http://ci.citycraft.cn:8080</jenkins.url> <jenkins.url>http://hs.citycraft.cn:8080</jenkins.url>
<update.description></update.description> <update.description>&amp;c修复命令部分代码...</update.description>
<update.changes></update.changes> <update.changes></update.changes>
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT> <env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -83,4 +104,5 @@
<version>1.0</version> <version>1.0</version>
</dependency> </dependency>
</dependencies> </dependencies>
<description>火箭跳跃 特效Duang...</description>
</project> </project>

33
proguard.conf Normal file
View File

@ -0,0 +1,33 @@
# -----不优化-----
-dontoptimize
# -----忽略所有警告-----
-ignorewarnings
# -----混淆时应用侵入式重载-----
-overloadaggressively
# -----保留所有属性
-keepattributes **
# -----公共数据不混淆-----
-keep class cn.citycraft.CommonData.** {*;}
# -----保护所有实体中的字段名称-----
-keepclassmembers class * implements java.io.Serializable { <fields>; }
# -----保护监听方法不被清理-----
-keepclassmembers class * implements org.bukkit.event.Listener
{
@org.bukkit.event.EventHandler <methods>;
}
# -----保护注解命令方法不被清理-----
-keepclassmembers class * implements **.commands.HandlerCommands
{
@**.commands.HandlerCommand <methods>;
@**.commands.HandlerTabComplete <methods>;
}
# -----保护命令解析正常-----
-keepnames class * extends **.commands.BaseCommand

View File

@ -4,15 +4,9 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import cn.citycraft.PluginHelper.commands.HandlerCommand; import cn.citycraft.PluginHelper.commands.InvokeSubCommand;
import cn.citycraft.PluginHelper.commands.HandlerCommands;
import cn.citycraft.PluginHelper.commands.HandlerSubCommand;
import cn.citycraft.PluginHelper.utils.VersionChecker; import cn.citycraft.PluginHelper.utils.VersionChecker;
/** /**
@ -21,27 +15,9 @@ import cn.citycraft.PluginHelper.utils.VersionChecker;
* @author * @author
* @since 2016年2月9日 下午8:50:50 * @since 2016年2月9日 下午8:50:50
*/ */
public class RocketJump extends JavaPlugin implements HandlerCommands { public class RocketJump extends JavaPlugin {
static RocketJump instence;
List<String> Dante = new ArrayList<String>(); static List<String> Dante = new ArrayList<String>();
@HandlerCommand(name = "off", description = "§a开启火箭跳跃", permission = "rj.use", onlyPlayerExecutable = true)
public void off(final CommandSender sender, final Command cmd, final String string, final String[] args) {
final Player p = (Player) sender;
this.Dante.remove(p.getName());
sender.sendMessage("§6[RocketJump]§4已关闭...");
if (p.getGameMode() == GameMode.SURVIVAL) {
p.setAllowFlight(false);
}
}
@HandlerCommand(name = "on", description = "§c关闭火箭跳跃", permission = "rj.use", onlyPlayerExecutable = true)
public void on(final CommandSender sender, final Command cmd, final String string, final String[] args) {
final Player p = (Player) sender;
this.Dante.add(p.getName());
sender.sendMessage("§6[RocketJump]§a火箭跳跃已开启,双击空格启动。。。");
p.setAllowFlight(true);
}
@Override @Override
public void onDisable() { public void onDisable() {
@ -50,8 +26,11 @@ public class RocketJump extends JavaPlugin implements HandlerCommands {
@Override @Override
public void onEnable() { public void onEnable() {
new HandlerSubCommand(this, "rj").registerCommands(this); instence = this;
getServer().getPluginManager().registerEvents(new Listen(this), this); final InvokeSubCommand isc = new InvokeSubCommand(this, "rj");
isc.registerCommands(new RocketJumpCommands());
isc.setAllCommandOnlyPlayer(true);
getServer().getPluginManager().registerEvents(new RocketJumpListen(), this);
Bukkit.getConsoleSender().sendMessage("§aRocketJump已加载..."); Bukkit.getConsoleSender().sendMessage("§aRocketJump已加载...");
new VersionChecker(this); new VersionChecker(this);
} }

View File

@ -0,0 +1,34 @@
package cn.citycraft.RocketJump;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import cn.citycraft.PluginHelper.commands.HandlerCommand;
import cn.citycraft.PluginHelper.commands.HandlerCommands;
/**
*
* @since 2016年2月23日 上午11:20:51
* @author
*/
public class RocketJumpCommands implements HandlerCommands {
@HandlerCommand(name = "off", description = "§a开启火箭跳跃")
public void off(final CommandSender sender, final Command cmd, final String string, final String[] args) {
final Player p = (Player) sender;
RocketJump.Dante.remove(p.getName());
sender.sendMessage("§6[RocketJump]§4已关闭...");
if (p.getGameMode() == GameMode.SURVIVAL) {
p.setAllowFlight(false);
}
}
@HandlerCommand(name = "on", description = "§c关闭火箭跳跃")
public void on(final CommandSender sender, final Command cmd, final String string, final String[] args) {
final Player p = (Player) sender;
RocketJump.Dante.add(p.getName());
sender.sendMessage("§6[RocketJump]§a火箭跳跃已开启,双击空格启动。。。");
p.setAllowFlight(true);
}
}

View File

@ -17,16 +17,11 @@ import org.bukkit.event.player.PlayerToggleFlightEvent;
/** /**
* Created by a08381 on 15-3-28. * Created by a08381 on 15-3-28.
*/ */
public class Listen implements Listener { public class RocketJumpListen implements Listener {
RocketJump plugin;
List<String> fall = new ArrayList<String>(); List<String> fall = new ArrayList<String>();
List<String> efc = new ArrayList<String>(); List<String> efc = new ArrayList<String>();
int trng; int trng;
public Listen(final RocketJump main) {
plugin = main;
}
public void add(final String p) { public void add(final String p) {
if (!fall.contains(p)) { if (!fall.contains(p)) {
fall.add(p); fall.add(p);
@ -47,7 +42,7 @@ public class Listen implements Listener {
pEffect(p.getLocation(), trng); pEffect(p.getLocation(), trng);
} }
if (p.getLocation().add(0, -1, 0).getBlock().getType() != (Material.AIR)) { if (p.getLocation().add(0, -1, 0).getBlock().getType() != (Material.AIR)) {
if (plugin.Dante.contains(p.getName())) { if (RocketJump.Dante.contains(p.getName())) {
p.setAllowFlight(true); p.setAllowFlight(true);
if (fall.contains(p.getName())) { if (fall.contains(p.getName())) {
fall.remove(p.getName()); fall.remove(p.getName());
@ -72,7 +67,7 @@ public class Listen implements Listener {
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void ToggleFlightEvent(final PlayerToggleFlightEvent e) { public void ToggleFlightEvent(final PlayerToggleFlightEvent e) {
final Player p = e.getPlayer(); final Player p = e.getPlayer();
if (plugin.Dante.contains(p.getName())) { if (RocketJump.Dante.contains(p.getName())) {
if (p.getLocation().add(0, -1, 0).getBlock().getType() == (Material.AIR) && p.getLocation().add(0, -2, 0).getBlock().getType() == (Material.AIR)) { if (p.getLocation().add(0, -1, 0).getBlock().getType() == (Material.AIR) && p.getLocation().add(0, -2, 0).getBlock().getType() == (Material.AIR)) {
e.setCancelled(true); e.setCancelled(true);
return; return;
@ -82,7 +77,7 @@ public class Listen implements Listener {
pEffect(p.getLocation(), 80); pEffect(p.getLocation(), 80);
p.setVelocity(p.getVelocity().setY(1)); p.setVelocity(p.getVelocity().setY(1));
p.setAllowFlight(false); p.setAllowFlight(false);
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() { RocketJump.instence.getServer().getScheduler().runTaskLaterAsynchronously(RocketJump.instence, new Runnable() {
@Override @Override
public void run() { public void run() {
if (p.isOnline()) { if (p.isOnline()) {
@ -90,7 +85,7 @@ public class Listen implements Listener {
final String name = p.getName(); final String name = p.getName();
efcadd(name); efcadd(name);
add(name); add(name);
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() { RocketJump.instence.getServer().getScheduler().runTaskLaterAsynchronously(RocketJump.instence, new Runnable() {
@Override @Override
public void run() { public void run() {
if (efc.contains(name)) { if (efc.contains(name)) {