Skip to content

Commit b56ed25

Browse files
committed
zHomes 2.1.5
1 parent 3b68dec commit b56ed25

7 files changed

Lines changed: 56 additions & 39 deletions

File tree

.github/workflows/test-compile.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,14 @@ jobs:
3232
- name: Compile and Test with Maven
3333
run: mvn clean install -DskipTests=false -Dgpg.skip=true
3434

35+
- name: Get project version
36+
id: get_version
37+
run: |
38+
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
39+
echo "version=$VERSION" >> $GITHUB_OUTPUT
40+
3541
- name: Upload target artifact
3642
uses: actions/upload-artifact@v4
3743
with:
38-
name: target-artifact
44+
name: zHomes ${{ steps.get_version.outputs.version }}
3945
path: target/

.idea/modules.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

changelog.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
## Dependency Changes
2-
- Plugin now uses [zAPI 1.4.4](https://github.com/yL3oft/zAPI/releases/tag/1.4.4)
2+
- Plugin now uses [zAPI 1.4.6](https://github.com/yL3oft/zAPI/releases/tag/1.4.6)
33

44
## General Changes
5-
- Fixed folia support (Finally!)
6-
- Fixed permission registration
7-
- Code cleanup and optimizations
5+
- Fixed and optimized safe location finding on teleport, special thanks for `coldironzz` and `Don (deadeye22122)` for reporting
6+
- You can now use chances on commands in the items from custom menus: `[<chance (ex: 30.0)>] [CON|INV] (command)`
87

9-
**zAPI Changelog**: https://github.com/yL3oft/zAPI/compare/1.4.3...1.4.4
10-
**Full Changelog**: https://github.com/yL3oft/zHomes/compare/2.1.3...2.1.4
8+
**zAPI Changelog**: https://github.com/yL3oft/zAPI/compare/1.4.4...1.4.6
9+
**Full Changelog**: https://github.com/yL3oft/zHomes/compare/2.1.4...2.1.5

dependency-reduced-pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>me.yleoft</groupId>
55
<artifactId>zHomes</artifactId>
66
<name>zHomes</name>
7-
<version>2.1.4</version>
7+
<version>2.1.5-SNAPSHOT</version>
88
<description>Your new favorite homes plugin</description>
99
<url>https://github.com/yL3oft/zHomes</url>
1010
<developers>

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>me.yleoft</groupId>
88
<artifactId>zHomes</artifactId>
9-
<version>2.1.4</version>
9+
<version>2.1.5</version>
1010
<description>Your new favorite homes plugin</description>
1111
<url>https://github.com/yL3oft/zHomes</url>
1212
<packaging>jar</packaging>
@@ -261,7 +261,7 @@
261261
<dependency>
262262
<groupId>me.yleoft</groupId>
263263
<artifactId>zAPI</artifactId>
264-
<version>1.4.4</version>
264+
<version>1.4.6</version>
265265
<scope>compile</scope>
266266
</dependency>
267267
<dependency>

src/main/java/me/yleoft/zHomes/Main.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ public void loadCommands() {
370370
registerPermission(cfgu.CmdHomeOthersPermission(), "Permission to use the '/" + cfgu.CmdHomeCommand() + " (Player:Home)' command", PermissionDefault.OP);
371371
registerPermission(cfgu.PermissionBypassLimit(), "Bypass homes limit", PermissionDefault.OP);
372372
registerPermission(cfgu.PermissionBypassDT(), "Bypass dimensional teleportation config", PermissionDefault.OP);
373+
registerPermission(cfgu.PermissionBypassWarmup(), "Bypass teleportation warmup time", PermissionDefault.OP);
373374
} catch (Exception e) {
374375
helper.sendMsg(getServer().getConsoleSender(), this.coloredPluginName + "§cError registering permissions (This doesn't affect anything in general)!");
375376
}

src/main/java/me/yleoft/zHomes/utils/HomesUtils.java

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package me.yleoft.zHomes.utils;
22

3+
import java.lang.reflect.InvocationTargetException;
34
import java.lang.reflect.Method;
45
import java.util.*;
56

@@ -15,6 +16,7 @@
1516
import org.bukkit.OfflinePlayer;
1617
import org.bukkit.Sound;
1718
import org.bukkit.entity.Player;
19+
import org.bukkit.event.player.PlayerTeleportEvent;
1820

1921
import static me.yleoft.zAPI.utils.LocationUtils.*;
2022

@@ -83,37 +85,46 @@ public void teleportPlayer(Player p, OfflinePlayer t, String home) {
8385
lang.sendMsg(p, lang.getCantDimensionalTeleport());
8486
return;
8587
}
86-
findNearestSafeLocationAsync(loc, 4, 50, tpLoc -> {
87-
if (tpLoc == null) {
88-
new LanguageUtils.CommandsMSG().sendMsg(p, "Unable to find a safe location");
89-
return;
90-
}
91-
String homeString = p.getUniqueId() == t.getUniqueId() ? home : t.getName() + ":" + home;
92-
Runnable task = () -> {
93-
Sound sound = getTeleportSound();
94-
if (zAPI.isFolia()) {
95-
try {
96-
Method teleportAsyncMethod = Player.class.getMethod("teleportAsync", Location.class);
97-
teleportAsyncMethod.invoke(p, tpLoc);
98-
} catch (Exception e) {
99-
throw new RuntimeException("Unable to teleport player", e);
88+
SchedulerUtils.runTask(loc, new FoliaRunnable() {
89+
@Override
90+
public void run() {
91+
Location tpLoc = findNearestSafeLocation(loc, 4, 50);
92+
if(tpLoc == null) {
93+
LanguageUtils.CommandsMSG cmdm = new LanguageUtils.CommandsMSG();
94+
cmdm.sendMsg(p, cmdm.getUnableToFindSafeLocation());
95+
return;
96+
}
97+
String homeString = p.getUniqueId() == t.getUniqueId() ? home : t.getName() + ":" + home;
98+
Runnable task = () -> {
99+
Sound sound = getTeleportSound();
100+
if (zAPI.isFolia()) {
101+
try {
102+
Method teleportAsyncMethod = Player.class.getMethod("teleportAsync", Location.class);
103+
teleportAsyncMethod.invoke(p, tpLoc);
104+
SchedulerUtils.runTask(tpLoc, () -> {
105+
if (sound != null && playSound()) p.playSound(p.getLocation(), sound, 1.0F, 1.0F);
106+
});
107+
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
108+
throw new RuntimeException("Unable to teleport player to home", e);
109+
}
110+
}else {
111+
SchedulerUtils.runTaskLater(tpLoc, () -> {
112+
p.teleport(tpLoc, PlayerTeleportEvent.TeleportCause.PLUGIN);
113+
SchedulerUtils.runTask(tpLoc, () -> {
114+
if (sound != null && playSound()) p.playSound(p.getLocation(), sound, 1.0F, 1.0F);
115+
});
116+
}, 1L);
100117
}
101-
} else {
102-
SchedulerUtils.runTaskLater(tpLoc, () -> p.teleport(tpLoc), 1L);
118+
lang.sendMsg(p, lang.getOutput(homeString));
119+
};
120+
if(doWarmup() && !p.hasPermission(PermissionBypassWarmup()) && warmupTime() > 0) {
121+
LanguageUtils.TeleportWarmupMSG langWarmup = new LanguageUtils.TeleportWarmupMSG();
122+
lang.sendMsg(p, langWarmup.getWarmup(warmupTime()));
123+
startWarmup(p, langWarmup, lang, homeString, task);
124+
return;
103125
}
104-
105-
lang.sendMsg(p, lang.getOutput(homeString));
106-
if (sound != null && playSound()) p.playSound(p.getLocation(), sound, 1.0F, 1.0F);
107-
};
108-
109-
if (doWarmup() && !p.hasPermission(PermissionBypassWarmup()) && warmupTime() > 0) {
110-
LanguageUtils.TeleportWarmupMSG warmupMsg = new LanguageUtils.TeleportWarmupMSG();
111-
lang.sendMsg(p, warmupMsg.getWarmup(warmupTime()));
112-
startWarmup(p, warmupMsg, lang, homeString, task);
113-
return;
126+
task.run();
114127
}
115-
116-
task.run();
117128
});
118129
}
119130
public void teleportPlayer(Player p, String home) {

0 commit comments

Comments
 (0)