mirror of
https://e.coding.net/circlecloud/JumpPlate.git
synced 2024-11-23 02:08:49 +00:00
调整文件结构 添加混淆机制...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
69ed966373
commit
4785040c3e
21
pom.xml
21
pom.xml
@ -50,6 +50,27 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</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>
|
||||
</build>
|
||||
<properties>
|
||||
|
33
proguard.conf
Normal file
33
proguard.conf
Normal 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
|
@ -1,148 +1,36 @@
|
||||
package cn.citycraft.JumpPlate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.HandlerCommand;
|
||||
import cn.citycraft.PluginHelper.commands.HandlerCommands;
|
||||
import cn.citycraft.PluginHelper.commands.HandlerSubCommand;
|
||||
import cn.citycraft.PluginHelper.commands.InvokeSubCommand;
|
||||
import cn.citycraft.PluginHelper.config.FileConfig;
|
||||
import cn.citycraft.PluginHelper.utils.VersionChecker;
|
||||
|
||||
public class JumpPlate extends JavaPlugin implements Listener, HandlerCommands {
|
||||
Set<String> fall = new HashSet<>();
|
||||
List<Material> ml = new ArrayList<>();
|
||||
static JumpPlate instence;
|
||||
String pluginname;
|
||||
FileConfig config;
|
||||
boolean removedamage;
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onCreate(final BlockPlaceEvent e) {
|
||||
final Player p = e.getPlayer();
|
||||
if (e.getBlockPlaced().getType() == Material.GOLD_PLATE) {
|
||||
final Location gb = e.getBlockPlaced().getLocation();
|
||||
final Block loc = gb.add(0.0D, -1.0D, 0.0D).getBlock();
|
||||
final Block loc_1 = gb.add(0.0D, -1.0D, 0.0D).getBlock();
|
||||
final Block loc_2 = gb.add(0.0D, -1.0D, 0.0D).getBlock();
|
||||
if (loc_1.getType() == Material.GLASS && loc_2.getType() == Material.LAPIS_BLOCK && ml.contains(loc.getType())) {
|
||||
if (p.hasPermission("JumpPlate.create")) {
|
||||
p.sendMessage(pluginname + config.getMessage("create"));
|
||||
} else {
|
||||
e.setCancelled(true);
|
||||
p.sendMessage(pluginname + config.getMessage("no-permission"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public FileConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
ml.add(Material.IRON_BLOCK);
|
||||
ml.add(Material.GOLD_BLOCK);
|
||||
ml.add(Material.DIAMOND_BLOCK);
|
||||
ml.add(Material.EMERALD_BLOCK);
|
||||
ml.add(Material.BEDROCK);
|
||||
new HandlerSubCommand(this, "jp").registerCommands(this);
|
||||
this.getServer().getPluginManager().registerEvents(this, this);
|
||||
instence = this;
|
||||
new InvokeSubCommand(this, "jp").registerCommands(new JumpPlateCommand());
|
||||
this.getServer().getPluginManager().registerEvents(new JumpPlateListener(), this);
|
||||
new VersionChecker(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFallDamage(final EntityDamageEvent e) {
|
||||
if (e.getEntity() instanceof Player) {
|
||||
final Player p = (Player) e.getEntity();
|
||||
if (e.getCause() == DamageCause.FALL && fall.contains(p.getName())) {
|
||||
final Block gb = p.getLocation().getBlock();
|
||||
final Block loc = gb.getRelative(BlockFace.DOWN);
|
||||
final Block loc_1 = gb.getRelative(BlockFace.DOWN, 2);
|
||||
final Block loc_2 = gb.getRelative(BlockFace.DOWN, 3);
|
||||
if (loc_1.getType() != Material.GLASS || loc_2.getType() != Material.LAPIS_BLOCK || !ml.contains(loc.getType())) {
|
||||
fall.remove(p.getName());
|
||||
}
|
||||
e.setDamage(DamageModifier.BASE, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJump(final PlayerInteractEvent e) {
|
||||
final Player p = e.getPlayer();
|
||||
if (e.getAction() != Action.PHYSICAL) {
|
||||
return;
|
||||
}
|
||||
final Block gb = e.getClickedBlock();
|
||||
if (gb.getType() != Material.GOLD_PLATE) {
|
||||
return;
|
||||
}
|
||||
final Block loc = gb.getRelative(BlockFace.DOWN);
|
||||
final Block loc_1 = gb.getRelative(BlockFace.DOWN, 2);
|
||||
final Block loc_2 = gb.getRelative(BlockFace.DOWN, 3);
|
||||
if (loc_1.getType() == Material.GLASS && loc_2.getType() == Material.LAPIS_BLOCK && ml.contains(loc.getType())) {
|
||||
if (!p.hasPermission("JumpPlate.use")) {
|
||||
p.sendMessage(pluginname + config.getMessage("no-permission"));
|
||||
return;
|
||||
}
|
||||
switch (loc.getType()) {
|
||||
case IRON_BLOCK:
|
||||
p.setVelocity(p.getVelocity().setY(1));
|
||||
break;
|
||||
case GOLD_BLOCK:
|
||||
p.setVelocity(p.getVelocity().setY(1.5));
|
||||
break;
|
||||
case DIAMOND_BLOCK:
|
||||
p.setVelocity(p.getVelocity().setY(2));
|
||||
break;
|
||||
case EMERALD_BLOCK:
|
||||
p.setVelocity(p.getVelocity().setY(2.5));
|
||||
break;
|
||||
case BEDROCK:
|
||||
p.setVelocity(p.getVelocity().setY(config.getDouble("BEDROCK")));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
fall.add(p.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
config = new FileConfig(this);
|
||||
pluginname = config.getMessage("pluginname");
|
||||
}
|
||||
|
||||
@HandlerCommand(name = "reload", description = "重载插件配置", permission = "JumpPlate.reload")
|
||||
public void reloadCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
|
||||
this.onLoad();
|
||||
sender.sendMessage(pluginname + "§a配置文件已重载!");
|
||||
}
|
||||
|
||||
@HandlerCommand(name = "set", description = "设置基岩跳板高度", minimumArguments = 1, onlyPlayerExecutable = true, permission = "JumpPlate.reload", possibleArguments = "<跳板高度(1-10)>")
|
||||
public void setCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
|
||||
try {
|
||||
final double drb = Double.parseDouble(args[0]);
|
||||
config.set("BEDROCK", drb);
|
||||
sender.sendMessage("§a基岩的跳板弹跳倍数已设置为 " + drb + "倍!");
|
||||
} catch (final NumberFormatException e) {
|
||||
sender.sendMessage("§c参数非法 请输入数字 1-10");
|
||||
}
|
||||
removedamage = JumpPlate.instence.getConfig().getBoolean("removedamage");
|
||||
}
|
||||
}
|
||||
|
31
src/main/java/cn/citycraft/JumpPlate/JumpPlateCommand.java
Normal file
31
src/main/java/cn/citycraft/JumpPlate/JumpPlateCommand.java
Normal file
@ -0,0 +1,31 @@
|
||||
package cn.citycraft.JumpPlate;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.HandlerCommand;
|
||||
import cn.citycraft.PluginHelper.commands.HandlerCommands;
|
||||
import cn.citycraft.PluginHelper.commands.InvokeCommandEvent;
|
||||
|
||||
/**
|
||||
* 跳板命令
|
||||
*
|
||||
* @since 2016年2月22日 上午11:00:52
|
||||
* @author 喵♂呜
|
||||
*/
|
||||
public class JumpPlateCommand implements HandlerCommands {
|
||||
|
||||
@HandlerCommand(name = "reload", description = "重载插件配置", permission = "JumpPlate.reload")
|
||||
public void reloadCommand(final InvokeCommandEvent e) {
|
||||
JumpPlate.instence.onLoad();
|
||||
e.getSender().sendMessage(JumpPlate.instence.pluginname + "§a配置文件已重载!");
|
||||
}
|
||||
|
||||
@HandlerCommand(name = "set", description = "设置基岩跳板高度", minimumArguments = 1, onlyPlayerExecutable = true, permission = "JumpPlate.reload", possibleArguments = "<跳板高度(1-10)>")
|
||||
public void setCommand(final InvokeCommandEvent e) {
|
||||
try {
|
||||
final double drb = Double.parseDouble(e.getArgs()[0]);
|
||||
JumpPlate.instence.getConfig().set("BEDROCK", drb);
|
||||
e.getSender().sendMessage(JumpPlate.instence.pluginname + "§a基岩的跳板弹跳倍数已设置为 " + drb + "倍!");
|
||||
} catch (final NumberFormatException ex) {
|
||||
e.getSender().sendMessage(JumpPlate.instence.pluginname + "§c参数非法 请输入数字 1-10");
|
||||
}
|
||||
}
|
||||
}
|
121
src/main/java/cn/citycraft/JumpPlate/JumpPlateListener.java
Normal file
121
src/main/java/cn/citycraft/JumpPlate/JumpPlateListener.java
Normal file
@ -0,0 +1,121 @@
|
||||
package cn.citycraft.JumpPlate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 2016年2月22日 上午10:57:37
|
||||
* @author 喵♂呜
|
||||
*/
|
||||
public class JumpPlateListener implements Listener {
|
||||
Set<String> fall = new HashSet<>();
|
||||
List<Material> ml = new ArrayList<>();
|
||||
|
||||
public JumpPlateListener() {
|
||||
ml.add(Material.IRON_BLOCK);
|
||||
ml.add(Material.GOLD_BLOCK);
|
||||
ml.add(Material.DIAMOND_BLOCK);
|
||||
ml.add(Material.EMERALD_BLOCK);
|
||||
ml.add(Material.BEDROCK);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onCreate(final BlockPlaceEvent e) {
|
||||
final Player p = e.getPlayer();
|
||||
if (e.getBlockPlaced().getType() == Material.GOLD_PLATE) {
|
||||
final Location gb = e.getBlockPlaced().getLocation();
|
||||
final Block loc = gb.add(0.0D, -1.0D, 0.0D).getBlock();
|
||||
final Block loc_1 = gb.add(0.0D, -1.0D, 0.0D).getBlock();
|
||||
final Block loc_2 = gb.add(0.0D, -1.0D, 0.0D).getBlock();
|
||||
if (loc_1.getType() == Material.GLASS && loc_2.getType() == Material.LAPIS_BLOCK && ml.contains(loc.getType())) {
|
||||
if (p.hasPermission("JumpPlate.create")) {
|
||||
p.sendMessage(JumpPlate.instence.pluginname + JumpPlate.instence.getConfig().getMessage("create"));
|
||||
} else {
|
||||
e.setCancelled(true);
|
||||
p.sendMessage(JumpPlate.instence.pluginname + JumpPlate.instence.getConfig().getMessage("no-permission"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFallDamage(final EntityDamageEvent e) {
|
||||
if (!JumpPlate.instence.removedamage) {
|
||||
return;
|
||||
}
|
||||
if (e.getEntity() instanceof Player) {
|
||||
final Player p = (Player) e.getEntity();
|
||||
if (e.getCause() == DamageCause.FALL && fall.contains(p.getName())) {
|
||||
final Block gb = p.getLocation().getBlock();
|
||||
final Block loc = gb.getRelative(BlockFace.DOWN);
|
||||
final Block loc_1 = gb.getRelative(BlockFace.DOWN, 2);
|
||||
final Block loc_2 = gb.getRelative(BlockFace.DOWN, 3);
|
||||
if (loc_1.getType() != Material.GLASS || loc_2.getType() != Material.LAPIS_BLOCK || !ml.contains(loc.getType())) {
|
||||
fall.remove(p.getName());
|
||||
}
|
||||
e.setDamage(DamageModifier.BASE, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJump(final PlayerInteractEvent e) {
|
||||
final Player p = e.getPlayer();
|
||||
if (e.getAction() != Action.PHYSICAL) {
|
||||
return;
|
||||
}
|
||||
final Block gb = e.getClickedBlock();
|
||||
if (gb.getType() != Material.GOLD_PLATE) {
|
||||
return;
|
||||
}
|
||||
final Block loc = gb.getRelative(BlockFace.DOWN);
|
||||
final Block loc_1 = gb.getRelative(BlockFace.DOWN, 2);
|
||||
final Block loc_2 = gb.getRelative(BlockFace.DOWN, 3);
|
||||
if (loc_1.getType() == Material.GLASS && loc_2.getType() == Material.LAPIS_BLOCK && ml.contains(loc.getType())) {
|
||||
if (!p.hasPermission("JumpPlate.use")) {
|
||||
p.sendMessage(JumpPlate.instence.pluginname + JumpPlate.instence.getConfig().getMessage("no-permission"));
|
||||
return;
|
||||
}
|
||||
switch (loc.getType()) {
|
||||
case IRON_BLOCK:
|
||||
p.setVelocity(p.getVelocity().setY(1));
|
||||
break;
|
||||
case GOLD_BLOCK:
|
||||
p.setVelocity(p.getVelocity().setY(1.5));
|
||||
break;
|
||||
case DIAMOND_BLOCK:
|
||||
p.setVelocity(p.getVelocity().setY(2));
|
||||
break;
|
||||
case EMERALD_BLOCK:
|
||||
p.setVelocity(p.getVelocity().setY(2.5));
|
||||
break;
|
||||
case BEDROCK:
|
||||
p.setVelocity(p.getVelocity().setY(JumpPlate.instence.getConfig().getDouble("BEDROCK")));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (JumpPlate.instence.removedamage) {
|
||||
fall.add(p.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,7 @@
|
||||
pluginname: '&6[&b超级跳板&6]&r '
|
||||
no-permission: '&c你没有使用跳板的权限!'
|
||||
create: '&a您成功创建了一个跳板!'
|
||||
BEDROCK: 10
|
||||
# 基岩跳板高度
|
||||
BEDROCK: 10
|
||||
# 是否取消伤害
|
||||
removedamage: true
|
Loading…
Reference in New Issue
Block a user