-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added EnderPearlCooldowns and Anti Vehicle Phasing
- Loading branch information
Showing
7 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/pw/saber/corex/listeners/AntiVehicleTeleport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package pw.saber.corex.listeners; | ||
|
||
import com.massivecraft.factions.util.CC; | ||
import com.massivecraft.factions.zcore.util.TL; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerTeleportEvent; | ||
|
||
public class AntiVehicleTeleport implements Listener { | ||
|
||
@EventHandler | ||
public void onVehicleExit(PlayerTeleportEvent e){ | ||
Player player = e.getPlayer(); | ||
if(player.getVehicle() == null) return; | ||
|
||
if (player.isInsideVehicle()) { | ||
player.sendMessage(CC.translate(TL.VEHICLE_TELEPORT_BLOCK.toString())); | ||
e.setCancelled(true); | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/pw/saber/corex/listeners/EnderPearlCooldown.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package pw.saber.corex.listeners; | ||
|
||
import com.cryptomorin.xseries.XMaterial; | ||
import com.massivecraft.factions.util.CC; | ||
import com.massivecraft.factions.util.Cooldown; | ||
import com.massivecraft.factions.util.TimeUtil; | ||
import com.massivecraft.factions.zcore.util.TL; | ||
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.player.PlayerInteractEvent; | ||
import pw.saber.corex.CoreX; | ||
|
||
import javax.swing.*; | ||
|
||
public class EnderPearlCooldown implements Listener { | ||
|
||
|
||
@EventHandler | ||
public void onPearl(PlayerInteractEvent e){ | ||
Action action = e.getAction(); | ||
Player player = e.getPlayer(); | ||
if(action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK && e.getItem() != null && e.getItem().getType() == XMaterial.ENDER_PEARL.parseMaterial()) { | ||
if(Cooldown.isOnCooldown(player, "enderPearlCooldown")) { | ||
e.setCancelled(true); | ||
long remaining = player.getMetadata("enderPearlCooldown").get(0).asLong() - System.currentTimeMillis(); | ||
int remainSec = (int) (remaining / 1000L); | ||
e.getPlayer().sendMessage(CC.translate(TL.ENDER_PEARL_COOLDOWN.toString().replace("{seconds}", TimeUtil.formatSeconds(remainSec)))); | ||
} else { | ||
Cooldown.setCooldown(player, "enderPearlCooldown", CoreX.getConfig().fetchInt("Cooldowns.EnderPearl")); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters