1
0
mirror of https://e.coding.net/circlecloud/RocketJump.git synced 2024-11-23 15:08:51 +00:00

Update...

This commit is contained in:
502647092 2015-09-02 18:21:31 +08:00
parent 4ea7b265e2
commit 1bf2e39a10
2 changed files with 53 additions and 60 deletions

View File

@ -7,7 +7,6 @@
<name>RocketJump</name> <name>RocketJump</name>
<build> <build>
<finalName>${project.name}</finalName> <finalName>${project.name}</finalName>
<sourceDirectory>src</sourceDirectory>
<resources> <resources>
<resource> <resource>
<directory>src/main/resources</directory> <directory>src/main/resources</directory>
@ -19,8 +18,8 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version> <version>3.1</version>
<configuration> <configuration>
<source>1.7</source> <source>1.8</source>
<target>1.7</target> <target>1.8</target>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>

View File

@ -27,6 +27,16 @@ public class Listen implements Listener {
plugin = main; plugin = main;
} }
public void add(String p) {
if (!fall.contains(p))
fall.add(p);
}
public void efcadd(String p) {
if (!efc.contains(p))
efc.add(p);
}
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void MoveEvent(PlayerMoveEvent e) { public void MoveEvent(PlayerMoveEvent e) {
Player p = e.getPlayer(); Player p = e.getPlayer();
@ -42,43 +52,14 @@ public class Listen implements Listener {
} }
} }
@EventHandler(ignoreCancelled = true) @EventHandler
public void ToggleFlightEvent(PlayerToggleFlightEvent e) { public void onFallDamage(EntityDamageEvent e) {
final Player p = e.getPlayer(); if (e.getEntity() instanceof Player) {
if (plugin.Dante.contains(p.getName())) { Player p = (Player) e.getEntity();
if (p.getLocation().add(0, -1, 0).getBlock().getType() == (Material.AIR) if (e.getCause() == DamageCause.FALL)
&& p.getLocation().add(0, -2, 0).getBlock().getType() == (Material.AIR)) { if (fall.contains(p.getName())) {
fall.remove(p.getName());
e.setCancelled(true); 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;
} }
} }
} }
@ -93,26 +74,39 @@ public class Listen implements Listener {
} }
} }
@EventHandler @EventHandler(ignoreCancelled = true)
public void onFallDamage(EntityDamageEvent e) { public void ToggleFlightEvent(PlayerToggleFlightEvent e) {
if (e.getEntity() instanceof Player) { final Player p = e.getPlayer();
Player p = (Player) e.getEntity(); if (plugin.Dante.contains(p.getName())) {
if (e.getCause() == DamageCause.FALL) { if (p.getLocation().add(0, -1, 0).getBlock().getType() == (Material.AIR) && p.getLocation().add(0, -2, 0).getBlock().getType() == (Material.AIR)) {
if (fall.contains(p.getName())) {
fall.remove(p.getName());
e.setCancelled(true); 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;
} }
} }
} }
} }
public void add(String p) {
if (!fall.contains(p))
fall.add(p);
}
public void efcadd(String p) {
if (!efc.contains(p))
efc.add(p);
}
}