|
5 | 5 | package xzot1k.plugins.ds.core.tasks; |
6 | 6 |
|
7 | 7 | import me.devtec.shared.Ref; |
| 8 | +import org.bukkit.Location; |
8 | 9 | import org.bukkit.World; |
9 | 10 | import org.bukkit.entity.ItemDisplay; |
10 | 11 | import org.bukkit.entity.Player; |
@@ -119,7 +120,27 @@ public void run() { |
119 | 120 |
|
120 | 121 | for (Player player : getPluginInstance().getServer().getOnlinePlayers()) { |
121 | 122 | 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 | + } |
123 | 144 | final Shop foundShopAtLocation = getPluginInstance().getManager().getShopRayTraced(player.getWorld().getName(), |
124 | 145 | player.getEyeLocation().toVector(), player.getEyeLocation().getDirection(), 10/*getViewDistance()*/); |
125 | 146 |
|
@@ -193,25 +214,24 @@ && getPluginInstance().getDisplayPacketMap().get(player.getUniqueId()).containsK |
193 | 214 |
|
194 | 215 | private void rotateDisplay(Display ddisplay, Matrix4f mat, float scale, int duration) { |
195 | 216 | ItemDisplay display = (ItemDisplay) Ref.get(ddisplay, "itemDisplay"); |
196 | | - if(display==null) |
| 217 | + if (display == null) |
197 | 218 | return; |
198 | | - if(!getPluginInstance().isEnabled()) |
| 219 | + if (!getPluginInstance().isEnabled()) |
199 | 220 | return; // Prevent creating tasks if the plugin is disabling (as that would throw exceptions) |
200 | 221 |
|
201 | 222 | final float rotationIncrement = (float) Math.toRadians(10); // Rotate 10 degrees per tick |
202 | 223 | /*float currentAngle = 0F;*/ // Array to hold current angle |
203 | | - float currentAngle = map.getOrDefault(display.getUniqueId(),0F); |
| 224 | + float currentAngle = map.getOrDefault(display.getUniqueId(), 0F); |
204 | 225 |
|
205 | 226 | if (display.isDead() || !display.isValid()) { // display was removed from the world, abort task |
206 | | - cancel(); |
207 | 227 | return; |
208 | 228 | } |
209 | 229 |
|
210 | 230 | currentAngle += rotationIncrement; // Increment the angle |
211 | 231 | if (currentAngle >= Math.toRadians(360)) { |
212 | 232 | currentAngle -= (float) Math.toRadians(360); // Reset the angle if it completes a full rotation |
213 | 233 | } |
214 | | - map.put(display.getUniqueId(),currentAngle); |
| 234 | + map.put(display.getUniqueId(), currentAngle); |
215 | 235 |
|
216 | 236 | ItemStack itemStack = display.getItemStack(); |
217 | 237 | if (itemStack != null) { |
|
0 commit comments