diff --git a/common/build/resources/main/config.yml b/common/build/resources/main/config.yml index b796fd5b..84b4ba64 100644 --- a/common/build/resources/main/config.yml +++ b/common/build/resources/main/config.yml @@ -26,10 +26,10 @@ wardrobe: static-radius: 10 # how much yaw should change per tick, set to 0 for none rotation-speed: 3 - # how long in seconds until the wardrobe should be spawned - spawn-delay: 0 - # how long in seconds until the wardrobe should be despawned - despawn-delay: 0 + # how long in ticks until the wardrobe should be spawned + spawn-delay: 40 + # how long in ticks until the wardrobe should be despawned + despawn-delay: 40 # location of static wardrobe, remove for none wardrobe-location: world: "World" @@ -44,4 +44,11 @@ wardrobe: y: 0 z: 5 yaw: 0 + pitch: 0 + leave-location: + world: "World" + x: 5 + y: 5 + z: 5 + yaw: 0 pitch: 0 \ No newline at end of file diff --git a/common/src/main/java/io/github/fisher2911/hmccosmetics/config/WardrobeSettings.java b/common/src/main/java/io/github/fisher2911/hmccosmetics/config/WardrobeSettings.java index 02c70ad4..2522afec 100644 --- a/common/src/main/java/io/github/fisher2911/hmccosmetics/config/WardrobeSettings.java +++ b/common/src/main/java/io/github/fisher2911/hmccosmetics/config/WardrobeSettings.java @@ -23,6 +23,7 @@ public class WardrobeSettings { private static final String DESPAWN_DELAY_PATH = WARDROBE_PATH + ".despawn-delay"; private static final String STATIC_LOCATION_PATH = WARDROBE_PATH + ".wardrobe-location"; private static final String VIEWER_LOCATION_PATH = WARDROBE_PATH + ".viewer-location"; + private static final String LEAVE_LOCATION_PATH = WARDROBE_PATH + ".leave-location"; private static final String WORLD_PATH = "world"; private static final String X_PATH = "x"; private static final String Y_PATH = "y"; @@ -43,6 +44,7 @@ public class WardrobeSettings { private int despawnDelay; private Location wardrobeLocation; private Location viewerLocation; + private Location leaveLocation; public WardrobeSettings(final HMCCosmetics plugin) { this.plugin = plugin; @@ -66,6 +68,13 @@ public class WardrobeSettings { final ConfigurationSection viewerLocationSection = config.getConfigurationSection(VIEWER_LOCATION_PATH); if (viewerLocationSection == null) return; this.viewerLocation = this.loadLocation(viewerLocationSection); + + final ConfigurationSection leaveLocationSection = config.getConfigurationSection(LEAVE_LOCATION_PATH); + if (leaveLocationSection == null) { + this.leaveLocation = this.viewerLocation; + return; + } + this.leaveLocation = this.loadLocation(leaveLocationSection); } @Nullable @@ -123,6 +132,10 @@ public class WardrobeSettings { return viewerLocation; } + public Location getLeaveLocation() { + return leaveLocation; + } + public boolean inDistanceOfWardrobe(final Location wardrobeLocation, final Location playerLocation) { if (this.displayRadius == -1) return true; if (!wardrobeLocation.getWorld().equals(playerLocation.getWorld())) return false; diff --git a/common/src/main/java/io/github/fisher2911/hmccosmetics/user/Wardrobe.java b/common/src/main/java/io/github/fisher2911/hmccosmetics/user/Wardrobe.java index 3fd33377..15a110b5 100644 --- a/common/src/main/java/io/github/fisher2911/hmccosmetics/user/Wardrobe.java +++ b/common/src/main/java/io/github/fisher2911/hmccosmetics/user/Wardrobe.java @@ -146,6 +146,7 @@ public class Wardrobe extends User { this.cameraLocked = false; this.currentLocation = null; this.getPlayerArmor().clear(); + Bukkit.getScheduler().runTask(this.plugin, () -> viewer.teleport(settings.getLeaveLocation())); if (settings.isAlwaysDisplay()) { this.currentLocation = settings.getWardrobeLocation(); diff --git a/common/src/main/resources/config.yml b/common/src/main/resources/config.yml index b796fd5b..84b4ba64 100644 --- a/common/src/main/resources/config.yml +++ b/common/src/main/resources/config.yml @@ -26,10 +26,10 @@ wardrobe: static-radius: 10 # how much yaw should change per tick, set to 0 for none rotation-speed: 3 - # how long in seconds until the wardrobe should be spawned - spawn-delay: 0 - # how long in seconds until the wardrobe should be despawned - despawn-delay: 0 + # how long in ticks until the wardrobe should be spawned + spawn-delay: 40 + # how long in ticks until the wardrobe should be despawned + despawn-delay: 40 # location of static wardrobe, remove for none wardrobe-location: world: "World" @@ -44,4 +44,11 @@ wardrobe: y: 0 z: 5 yaw: 0 + pitch: 0 + leave-location: + world: "World" + x: 5 + y: 5 + z: 5 + yaw: 0 pitch: 0 \ No newline at end of file