Fix safe teleport feature

This commit is contained in:
Lennart ten Wolde 2018-06-05 20:29:43 +02:00
parent 2bd8bbdec8
commit 853b73cf32
4 changed files with 72 additions and 128 deletions

View file

@ -2,8 +2,9 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="6524ab32-4c67-47a4-9559-a55b4c68fe83" name="Default" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lenis0012/bukkit/marriage2/commands/CommandTeleport.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lenis0012/bukkit/marriage2/commands/CommandTeleport.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lenis0012/bukkit/marriage2/config/Message.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lenis0012/bukkit/marriage2/config/Message.java" afterDir="false" />
</list>
<ignored path="$PROJECT_DIR$/target/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@ -15,11 +16,11 @@
</component>
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="ChatListener.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/com/lenis0012/bukkit/marriage2/listeners/ChatListener.java">
<file leaf-file-name="pom.xml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/pom.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="748">
<caret line="83" column="37" lean-forward="true" selection-start-line="83" selection-start-column="37" selection-end-line="83" selection-end-column="37" />
<state relative-caret-position="-1071">
<caret line="81" column="27" selection-start-line="81" selection-start-column="27" selection-end-line="81" selection-end-column="27" />
</state>
</provider>
</entry>
@ -27,57 +28,8 @@
<file leaf-file-name="CommandTeleport.java" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/main/java/com/lenis0012/bukkit/marriage2/commands/CommandTeleport.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="663">
<caret line="50" column="9" lean-forward="true" selection-start-line="50" selection-start-column="9" selection-end-line="50" selection-end-column="9" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Message.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/com/lenis0012/bukkit/marriage2/config/Message.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="493">
<caret line="56" column="90" selection-start-line="56" selection-start-column="90" selection-end-line="56" selection-end-column="90" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Location.java" pinned="false" current-in-tab="false">
<entry file="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.11.2-R0.1-SNAPSHOT/spigot-api-1.11.2-R0.1-20170514.012204-124-sources.jar!/org/bukkit/Location.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="442">
<caret line="86" column="25" selection-start-line="86" selection-start-column="25" selection-end-line="86" selection-end-column="25" />
<folding>
<element signature="e#2486#2487#0" expanded="true" />
<element signature="e#2531#2532#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="World.java" pinned="false" current-in-tab="false">
<entry file="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.11.2-R0.1-SNAPSHOT/spigot-api-1.11.2-R0.1-20170514.012204-124-sources.jar!/org/bukkit/World.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="425">
<caret line="46" column="17" selection-start-line="46" selection-start-column="17" selection-end-line="46" selection-end-column="17" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="pom.xml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/pom.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="612">
<caret line="36" column="35" lean-forward="true" selection-start-line="36" selection-start-column="35" selection-end-line="36" selection-end-column="35" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Metadatable.java" pinned="false" current-in-tab="false">
<entry file="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.11.2-R0.1-SNAPSHOT/spigot-api-1.11.2-R0.1-20170514.012204-124-sources.jar!/org/bukkit/metadata/Metadatable.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="612">
<caret line="38" column="19" selection-start-line="38" selection-start-column="19" selection-end-line="38" selection-end-column="19" />
<state relative-caret-position="474">
<caret line="75" column="13" selection-start-line="75" selection-start-column="13" selection-end-line="75" selection-end-column="13" />
</state>
</provider>
</entry>
@ -87,6 +39,7 @@
<component name="FindInProjectRecents">
<findStrings>
<find>marriedTo</find>
<find>solid</find>
</findStrings>
</component>
<component name="Git.Settings">
@ -104,6 +57,7 @@
<list>
<option value="$PROJECT_DIR$/src/main/java/com/lenis0012/bukkit/marriage2/listeners/ChatListener.java" />
<option value="$PROJECT_DIR$/src/main/java/com/lenis0012/bukkit/marriage2/config/Message.java" />
<option value="$PROJECT_DIR$/pom.xml" />
<option value="$PROJECT_DIR$/src/main/java/com/lenis0012/bukkit/marriage2/commands/CommandTeleport.java" />
</list>
</option>
@ -114,6 +68,13 @@
<detection-done>true</detection-done>
<sorting>DEFINITION_ORDER</sorting>
</component>
<component name="MavenImportPreferences">
<option name="importingSettings">
<MavenImportingSettings>
<option name="importAutomatically" value="true" />
</MavenImportingSettings>
</option>
</component>
<component name="NodePackageJsonFileManager">
<packageJsonPaths />
</component>
@ -172,51 +133,6 @@
<item name="marriage2" type="462c0819:PsiDirectoryNode" />
<item name="commands" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="marriage2" type="b2602c69:ProjectViewProjectNode" />
<item name="Marriage" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="main" type="462c0819:PsiDirectoryNode" />
<item name="java" type="462c0819:PsiDirectoryNode" />
<item name="marriage2" type="462c0819:PsiDirectoryNode" />
<item name="config" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="marriage2" type="b2602c69:ProjectViewProjectNode" />
<item name="Marriage" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="main" type="462c0819:PsiDirectoryNode" />
<item name="java" type="462c0819:PsiDirectoryNode" />
<item name="marriage2" type="462c0819:PsiDirectoryNode" />
<item name="events" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="marriage2" type="b2602c69:ProjectViewProjectNode" />
<item name="Marriage" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="main" type="462c0819:PsiDirectoryNode" />
<item name="java" type="462c0819:PsiDirectoryNode" />
<item name="marriage2" type="462c0819:PsiDirectoryNode" />
<item name="internal" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="marriage2" type="b2602c69:ProjectViewProjectNode" />
<item name="Marriage" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="main" type="462c0819:PsiDirectoryNode" />
<item name="java" type="462c0819:PsiDirectoryNode" />
<item name="marriage2" type="462c0819:PsiDirectoryNode" />
<item name="listeners" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="marriage2" type="b2602c69:ProjectViewProjectNode" />
<item name="Marriage" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="main" type="462c0819:PsiDirectoryNode" />
<item name="java" type="462c0819:PsiDirectoryNode" />
<item name="marriage2" type="462c0819:PsiDirectoryNode" />
<item name="misc" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
@ -265,6 +181,33 @@
</option>
<patterns />
</configuration>
<configuration name="clean install" type="MavenRunConfiguration" factoryName="Maven">
<MavenSettings>
<option name="myGeneralSettings" />
<option name="myRunnerSettings" />
<option name="myRunnerParameters">
<MavenRunnerParameters>
<option name="profiles">
<set />
</option>
<option name="goals">
<list>
<option value="clean" />
<option value="install" />
</list>
</option>
<option name="pomFileName" />
<option name="profilesMap">
<map>
<entry key="spigot" value="true" />
</map>
</option>
<option name="resolveToWorkspace" value="false" />
<option name="workingDirPath" value="$PROJECT_DIR$" />
</MavenRunnerParameters>
</option>
</MavenSettings>
</configuration>
<configuration default="true" type="TestNG" factoryName="TestNG">
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
@ -298,12 +241,12 @@
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1528215872017</updated>
<workItem from="1528215876300" duration="2683000" />
<workItem from="1528215876300" duration="5738000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="2683000" />
<option name="totallyTimeSpent" value="5738000" />
</component>
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="2576" height="1416" extended-state="6" />
@ -318,11 +261,11 @@
<window_info anchor="right" id="Maven Projects" />
<window_info anchor="bottom" id="Database Changes" show_stripe_button="false" />
<window_info anchor="bottom" id="Version Control" />
<window_info anchor="bottom" id="Run" order="2" />
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.32974634" />
<window_info anchor="bottom" id="Terminal" />
<window_info id="Capture Tool" />
<window_info id="Designer" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.25" />
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.25" />
<window_info anchor="right" id="Database" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
@ -411,14 +354,7 @@
<entry file="file://$PROJECT_DIR$/src/main/java/com/lenis0012/bukkit/marriage2/listeners/ChatListener.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="748">
<caret line="83" column="37" lean-forward="true" selection-start-line="83" selection-start-column="37" selection-end-line="83" selection-end-column="37" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/pom.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="612">
<caret line="36" column="35" lean-forward="true" selection-start-line="36" selection-start-column="35" selection-end-line="36" selection-end-column="35" />
<caret line="83" column="37" selection-start-line="83" selection-start-column="37" selection-end-line="83" selection-end-column="37" />
</state>
</provider>
</entry>
@ -442,15 +378,29 @@
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/lenis0012/bukkit/marriage2/config/Message.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="493">
<state relative-caret-position="-77">
<caret line="56" column="90" selection-start-line="56" selection-start-column="90" selection-end-line="56" selection-end-column="90" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/pom.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1071">
<caret line="81" column="27" selection-start-line="81" selection-start-column="27" selection-end-line="81" selection-end-column="27" />
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.12.2-R0.1-SNAPSHOT/spigot-api-1.12.2-R0.1-20180527.071454-147-sources.jar!/org/bukkit/block/Block.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="282">
<caret line="337" column="12" selection-start-line="337" selection-start-column="12" selection-end-line="337" selection-end-column="12" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/lenis0012/bukkit/marriage2/commands/CommandTeleport.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="663">
<caret line="50" column="9" lean-forward="true" selection-start-line="50" selection-start-column="9" selection-end-line="50" selection-end-column="9" />
<state relative-caret-position="474">
<caret line="75" column="13" selection-start-line="75" selection-start-column="13" selection-end-line="75" selection-end-column="13" />
</state>
</provider>
</entry>

View file

@ -33,7 +33,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.11.2-R0.1-SNAPSHOT</version>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
@ -61,12 +61,6 @@
<version>1.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>

View file

@ -52,7 +52,7 @@ public class CommandTeleport extends Command {
if(!payFee()) return;
player.teleport(partner);
player.teleport(destination);
reply(Message.TELEPORTED);
partner.sendMessage(ChatColor.translateAlternateColorCodes('&', Message.TELEPORTED_2.toString()));
}
@ -69,7 +69,7 @@ public class CommandTeleport extends Command {
}
// Find next potentially safe block
while(!block.getType().isSolid() && block.getY() > 0) {
while(!(block.getType().isSolid() || block.isLiquid()) && block.getY() > 0) {
block = block.getRelative(BlockFace.DOWN);
if(UNSAFE_TYPES.contains(block.getType())) {
return null; // Obstructed by unsafe block
@ -87,8 +87,8 @@ public class CommandTeleport extends Command {
}
private boolean isSafeGround(Block block) {
return block.getType().isSolid()
return (block.getType().isSolid() || block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER)
&& !UNSAFE_TYPES.contains(block.getRelative(0, 1, 0).getType())
&& !UNSAFE_TYPES.contains(block.getRelative(0, 2, 0).getType()
&& !UNSAFE_TYPES.contains(block.getRelative(0, 2, 0).getType());
}
}

View file

@ -54,7 +54,7 @@ public enum Message {
BONUS_EXP("&aYou gained %s extra EXP for leveling with your partner!"),
CONFIG_RELOAD("&aConfiguration settings were reloaded, please note that some settings may not apply until reboot."),
GENDER_ALREADY_CHANGED("&cYou have already specified your gender, you can only do this once."),
TELEPORT_UNSAFE("The location you are trying to teleport to is unsafe or obstructed"),
TELEPORT_UNSAFE("&cThe location you are trying to teleport to is unsafe or obstructed"),
// COMMANDS
COMMAND_MARRY("Request a marriage with another player"),