forked from ScarleTomato/IronElevators
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da05fea
commit c3bf2d9
Showing
12 changed files
with
249 additions
and
203 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Eclipse stuff | ||
.classpath | ||
.project | ||
.settings/ | ||
|
||
# netbeans | ||
nbproject/ | ||
nbactions.xml | ||
|
||
# we use maven! | ||
build.xml | ||
|
||
# maven | ||
target/ | ||
dependency-reduced-pom.xml | ||
|
||
# vim | ||
.*.sw[a-p] | ||
|
||
# various other potential build files | ||
build/ | ||
bin/ | ||
dist/ | ||
manifest.mf | ||
|
||
# Mac filesystem dust | ||
.DS_Store/ | ||
|
||
# intellij | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# other files | ||
*.log* | ||
|
||
# delombok | ||
*/src/main/lombok |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
76 changes: 0 additions & 76 deletions
76
IronElevators/src/me/ScarleTomato/IronElevators/EventListener.java
This file was deleted.
Oops, something went wrong.
82 changes: 0 additions & 82 deletions
82
IronElevators/src/me/ScarleTomato/IronElevators/IronElevators.java
This file was deleted.
Oops, something went wrong.
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,62 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>net.nekonekoserver</groupId> | ||
<artifactId>IronElevators</artifactId> | ||
<version>1.13</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>IronElevators</name> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<build> | ||
<defaultGoal>clean package</defaultGoal> | ||
<finalName>${project.artifactId}</finalName> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.6.0</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
<encoding>${project.build.sourceEncoding}</encoding> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<repositories> | ||
<repository> | ||
<id>spigotmc-public</id> | ||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.bukkit</groupId> | ||
<artifactId>bukkit</artifactId> | ||
<version>1.13-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>1.18.0</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
66 changes: 66 additions & 0 deletions
66
src/main/java/me/ScarleTomato/IronElevators/EventListener.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,66 @@ | ||
package me.ScarleTomato.IronElevators; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.bukkit.Location; | ||
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.player.PlayerMoveEvent; | ||
import org.bukkit.event.player.PlayerToggleSneakEvent; | ||
|
||
@RequiredArgsConstructor | ||
public final class EventListener implements Listener { | ||
|
||
private final IronElevators plugin; | ||
|
||
private boolean searchFloor(Block floor) { | ||
return floor.getType() == plugin.ELEVATOR_MATERIAL | ||
&& floor.getRelative(BlockFace.UP).getType().isTransparent() | ||
&& floor.getRelative(BlockFace.UP, 2).getType().isTransparent(); | ||
} | ||
|
||
private void teleport(Player player, Location to) { | ||
player.teleport(to); | ||
player.getWorld().playSound(to, plugin.ELEVATOR_WHOOSH, 1, 0); | ||
} | ||
|
||
@EventHandler | ||
public void downElevator(PlayerToggleSneakEvent event) { | ||
Player player = event.getPlayer(); | ||
Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN); | ||
if (player.hasPermission("ironelevators.use") && !player.isSneaking() && block.getType() == plugin.ELEVATOR_MATERIAL) { | ||
block = block.getRelative(BlockFace.DOWN, plugin.MIN_ELEVATION); | ||
int search = plugin.MAX_ELEVATION; | ||
while (search > 0 && !(searchFloor(block))) { | ||
search--; | ||
block = block.getRelative(BlockFace.DOWN); | ||
} | ||
if (search > 0) { | ||
Location loc = player.getLocation(); | ||
loc.setY(loc.getY() - plugin.MAX_ELEVATION - 3 + search); | ||
teleport(player, loc); | ||
} | ||
} | ||
} | ||
|
||
@EventHandler | ||
public void upElevator(PlayerMoveEvent event) { | ||
Player player = event.getPlayer(); | ||
Block block = event.getTo().getBlock().getRelative(BlockFace.DOWN); | ||
if (player.hasPermission("ironelevators.use") && event.getFrom().getY() < event.getTo().getY() && block.getType() == plugin.ELEVATOR_MATERIAL) { | ||
block = block.getRelative(BlockFace.UP, plugin.MIN_ELEVATION); | ||
int search = plugin.MAX_ELEVATION; | ||
while (search > 0 && !(searchFloor(block))) { | ||
search--; | ||
block = block.getRelative(BlockFace.UP); | ||
} | ||
if (search > 0) { | ||
Location loc = player.getLocation(); | ||
loc.setY(loc.getY() + plugin.MAX_ELEVATION + 3 - search); | ||
teleport(player, loc); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.