commit 984302a1dc9d7ae36520a010e5298dae00588107 Author: j502647092 Date: Thu May 14 16:32:04 2015 +0800 init project... Signed-off-by: j502647092 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6d80b42 --- /dev/null +++ b/.gitignore @@ -0,0 +1,40 @@ +# Eclipse stuff +/.classpath +/.project +/.settings + +# netbeans +/nbproject + +# we use maven! +/build.xml + +# maven +/target +/repo + +# vim +.*.sw[a-p] + +# various other potential build files +/build +/bin +/dist +/manifest.mf + +/world + +# Mac filesystem dust +*.DS_Store + +# intellij +*.iml +*.ipr +*.iws +.idea/ + +# Project Stuff +/src/main/resources/Soulbound + +# Atlassian Stuff +/atlassian-ide-plugin.xml \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..558e4e8 --- /dev/null +++ b/pom.xml @@ -0,0 +1,40 @@ + + 4.0.0 + RocketJump + RocketJump + 0.0.2-SNAPSHOT + RocketJump + + src + + + src + + **/*.java + + + + + + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + + + + + org.spigotmc + spigot-api + jar + 1.8.3-R0.1-SNAPSHOT + + + + UTF-8 + + \ No newline at end of file diff --git a/src/cn/citycraft/RocketJump/Listen.java b/src/cn/citycraft/RocketJump/Listen.java new file mode 100644 index 0000000..f33e89d --- /dev/null +++ b/src/cn/citycraft/RocketJump/Listen.java @@ -0,0 +1,118 @@ +package cn.citycraft.RocketJump; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerToggleFlightEvent; + +/** + * Created by a08381 on 15-3-28. + */ +public class Listen implements Listener { + Main plugin; + List fall = new ArrayList(); + List efc = new ArrayList(); + int trng; + + public Listen(Main main) { + plugin = main; + } + + @EventHandler(ignoreCancelled = true) + public void MoveEvent(PlayerMoveEvent e) { + Player p = e.getPlayer(); + if (efc.contains(p.getName())) { + trng -= 1; + pEffect(p.getLocation(), trng); + } + if (p.getLocation().add(0, -1, 0).getBlock().getType() != (Material.AIR)) + if (plugin.Dante.contains(p.getName())) { + p.setAllowFlight(true); + if (fall.contains(p.getName())) + fall.remove(p.getName()); + } + } + + @EventHandler(ignoreCancelled = true) + public void ToggleFlightEvent(PlayerToggleFlightEvent e) { + final Player p = e.getPlayer(); + if (plugin.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)) { + e.setCancelled(true); + return; + } + if (!p.isFlying()) { + e.setCancelled(true); + pEffect(p.getLocation(), 80); + p.setVelocity(p.getVelocity().setY(1)); + p.setAllowFlight(false); + plugin.getServer().getScheduler() + .runTaskLaterAsynchronously(plugin, new Runnable() { + @Override + public void run() { + if (p.isOnline()) { + p.setVelocity(p.getVelocity().setY(10)); + final String name = p.getName(); + efcadd(name); + add(name); + plugin.getServer() + .getScheduler() + .runTaskLaterAsynchronously(plugin, + new Runnable() { + @Override + public void run() { + if (efc.contains(name)) + efc.remove(name); + } + }, 30); + } + } + }, 10); + trng = 30; + } + } + } + + void pEffect(Location loc, int range) { + int i; + if (range < 2) + range = 2; + for (i = 0; i < range; i++) { + loc.getWorld().playEffect(loc, Effect.LAVA_POP, 10, 100); + loc.getWorld().playEffect(loc, Effect.PORTAL, 10, 100); + } + } + + @EventHandler + public void onFallDamage(EntityDamageEvent e) { + if (e.getEntity() instanceof Player) { + Player p = (Player) e.getEntity(); + if (e.getCause() == DamageCause.FALL) { + if (fall.contains(p.getName())) { + fall.remove(p.getName()); + e.setCancelled(true); + } + } + } + } + + public void add(String p) { + if (!fall.contains(p)) + fall.add(p); + } + + public void efcadd(String p) { + if (!efc.contains(p)) + efc.add(p); + } +} diff --git a/src/cn/citycraft/RocketJump/Main.java b/src/cn/citycraft/RocketJump/Main.java new file mode 100644 index 0000000..1207f80 --- /dev/null +++ b/src/cn/citycraft/RocketJump/Main.java @@ -0,0 +1,49 @@ +package cn.citycraft.RocketJump; + +import java.util.ArrayList; +import java.util.List; + +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; +/** + * Created by a08381 on 15-3-28. + */ +public class Main extends JavaPlugin { + + List Dante = new ArrayList() ; + + public void onEnable() { + getServer().getPluginManager().registerEvents(new Listen(this), this); + getLogger().info("§aRocketJump已加载..."); + } + + public boolean onCommand(CommandSender sender, Command cmd, String string, + String[] args) { + Player p = (Player) sender; + if (args.length == 1) { + if (args[0].equalsIgnoreCase("on")) { + this.Dante.add(p.getName()); + sender.sendMessage("§6[RocketJump]§a火箭跳跃已开启,双击空格启动。。。"); + p.setAllowFlight(true); + return true; + } + if (args[0].equalsIgnoreCase("off")) { + this.Dante.remove(p.getName()); + sender.sendMessage("§6[RocketJump]§4已关闭..."); + if (p.getGameMode() == GameMode.SURVIVAL) + p.setAllowFlight(false); + return true; + } + } + return false; + } + + + public void onDisable() { + getLogger().info( "§4RocketJump已卸载..."); + } + +} diff --git a/src/plugin.yml b/src/plugin.yml new file mode 100644 index 0000000..8b651e4 --- /dev/null +++ b/src/plugin.yml @@ -0,0 +1,13 @@ +name: RocketJump +main: cn.citycraft.RocketJump.Main +version: 1.1 +author: j502647092 +commands: + rj: + description: RocketJump插件 + usage: 使用/rj 切换RocketJump! + permission: rj.use + permission-message: §c你没有此命令的权限! +permissions: + rj.use: + default: op \ No newline at end of file