Skip to content

Commit 6158b94

Browse files
committed
- Fixed command /ds reload, now Displays are rotating after executing this command
- Implemented AlwaysDisplay for Displays + made the range adjustable by config key (this previously only worked, for Armorstand based shops) Signed-off-by: petulikan1 <petulikan@gmail.com> Took 4 minutes
1 parent 93226c4 commit 6158b94

3 files changed

Lines changed: 28 additions & 8 deletions

File tree

Core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<modelVersion>4.0.0</modelVersion>
1212
<artifactId>Core</artifactId>
13-
<version>2.0.3</version>
13+
<version>2.0.4</version>
1414

1515
<properties>
1616
<maven.compiler.source>8</maven.compiler.source>

Core/src/main/java/xzot1k/plugins/ds/core/Commands.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1863,7 +1863,7 @@ private void runReload(CommandSender commandSender) {
18631863

18641864
Appearance.getAppearances().clear();
18651865
getPluginInstance().getServer().getScheduler().runTaskAsynchronously(getPluginInstance(), () -> {
1866-
getPluginInstance().getManager().getShopMap().entrySet().parallelStream().forEach(entry -> entry.getValue().killAll());
1866+
getPluginInstance().getManager().getShopMap().forEach((key, value) -> value.killAll());
18671867
DAppearance.loadAppearances();
18681868
});
18691869

Core/src/main/java/xzot1k/plugins/ds/core/tasks/VisualTask.java

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package xzot1k.plugins.ds.core.tasks;
66

77
import me.devtec.shared.Ref;
8+
import org.bukkit.Location;
89
import org.bukkit.World;
910
import org.bukkit.entity.ItemDisplay;
1011
import org.bukkit.entity.Player;
@@ -119,7 +120,27 @@ public void run() {
119120

120121
for (Player player : getPluginInstance().getServer().getOnlinePlayers()) {
121122
if (player == null || !player.isOnline()) {continue;}
122-
123+
if (isAlwaysDisplay()) {
124+
double value = (double) DisplayShops.getPluginInstance().getConfig().getInt("always-display-radius", 15) / 2;
125+
Location min = shop.getBaseLocation().asBukkitLocation().clone().subtract(value, value, value);
126+
Location max = shop.getBaseLocation().asBukkitLocation().clone().add(value, value, value);
127+
boolean found = false;
128+
for (x = min.getBlockX(); x <= max.getBlockY(); x++) {
129+
for (y = min.getBlockY(); y <= max.getBlockY(); y++) {
130+
for (z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
131+
if (player.getLocation().getBlockX() == x && player.getLocation().getBlockY() == y && player.getLocation().getBlockZ() == z) {
132+
found = true;
133+
break;
134+
}
135+
}
136+
}
137+
}
138+
boolean finalFound = found;
139+
DisplayShops.getPluginInstance().getServer().getScheduler().runTask(DisplayShops.getPluginInstance(), () -> {
140+
display.show(player, finalFound);
141+
});
142+
continue;
143+
}
123144
final Shop foundShopAtLocation = getPluginInstance().getManager().getShopRayTraced(player.getWorld().getName(),
124145
player.getEyeLocation().toVector(), player.getEyeLocation().getDirection(), 10/*getViewDistance()*/);
125146

@@ -193,25 +214,24 @@ && getPluginInstance().getDisplayPacketMap().get(player.getUniqueId()).containsK
193214

194215
private void rotateDisplay(Display ddisplay, Matrix4f mat, float scale, int duration) {
195216
ItemDisplay display = (ItemDisplay) Ref.get(ddisplay, "itemDisplay");
196-
if(display==null)
217+
if (display == null)
197218
return;
198-
if(!getPluginInstance().isEnabled())
219+
if (!getPluginInstance().isEnabled())
199220
return; // Prevent creating tasks if the plugin is disabling (as that would throw exceptions)
200221

201222
final float rotationIncrement = (float) Math.toRadians(10); // Rotate 10 degrees per tick
202223
/*float currentAngle = 0F;*/ // Array to hold current angle
203-
float currentAngle = map.getOrDefault(display.getUniqueId(),0F);
224+
float currentAngle = map.getOrDefault(display.getUniqueId(), 0F);
204225

205226
if (display.isDead() || !display.isValid()) { // display was removed from the world, abort task
206-
cancel();
207227
return;
208228
}
209229

210230
currentAngle += rotationIncrement; // Increment the angle
211231
if (currentAngle >= Math.toRadians(360)) {
212232
currentAngle -= (float) Math.toRadians(360); // Reset the angle if it completes a full rotation
213233
}
214-
map.put(display.getUniqueId(),currentAngle);
234+
map.put(display.getUniqueId(), currentAngle);
215235

216236
ItemStack itemStack = display.getItemStack();
217237
if (itemStack != null) {

0 commit comments

Comments
 (0)