Skip to content

Commit

Permalink
Update to Minecraft 1.13
Browse files Browse the repository at this point in the history
  • Loading branch information
mc-nekoneko committed Aug 19, 2018
1 parent da05fea commit c3bf2d9
Show file tree
Hide file tree
Showing 12 changed files with 249 additions and 203 deletions.
39 changes: 39 additions & 0 deletions .gitignore
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
7 changes: 0 additions & 7 deletions IronElevators/.classpath

This file was deleted.

1 change: 0 additions & 1 deletion IronElevators/.gitignore

This file was deleted.

17 changes: 0 additions & 17 deletions IronElevators/.project

This file was deleted.

11 changes: 0 additions & 11 deletions IronElevators/.settings/org.eclipse.jdt.core.prefs

This file was deleted.

9 changes: 0 additions & 9 deletions IronElevators/plugin.yml

This file was deleted.

76 changes: 0 additions & 76 deletions IronElevators/src/me/ScarleTomato/IronElevators/EventListener.java

This file was deleted.

82 changes: 0 additions & 82 deletions IronElevators/src/me/ScarleTomato/IronElevators/IronElevators.java

This file was deleted.

62 changes: 62 additions & 0 deletions pom.xml
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 src/main/java/me/ScarleTomato/IronElevators/EventListener.java
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);
}
}
}
}
Loading

0 comments on commit c3bf2d9

Please sign in to comment.