Skip to content

Commit 49d827c

Browse files
committed
Make forcefield radius configurable
Bump default up to 50
1 parent dcc091e commit 49d827c

File tree

3 files changed

+7
-19
lines changed

3 files changed

+7
-19
lines changed

src/main/java/net/techcable/spawnshield/SpawnShieldPlayer.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,4 @@ public SpawnShield getPlugin() {
6262
private Location lastLocationOutsideSafezone = null;
6363
private long lastCantEnterMessageTime = -1;
6464
private Collection<BlockPos> lastShownBlocks; //The forcefield blocks last shown to this player
65-
/**
66-
* OMG, there can only be one update request at a time, why did you do that Techcable?
67-
* I did it because PlayerMoveEvents are triggered by packets, which could be fired multiple times a tick
68-
* If there were 30 entries in the theoretical queue, then the ForceFieldUpdateTask would have to do a lot of work every tick.
69-
* This ensures that each player only has one forcefieldupdate a tick
70-
*/
71-
@Setter(AccessLevel.NONE)
72-
private volatile ForceFieldUpdateRequest updateRequest;
73-
74-
private final Object forceFieldUpdateLock = new Object();
75-
@Synchronized("forceFieldUpdateLock")
76-
public void updateForceField(ForceFieldUpdateRequest request) {
77-
if (updateRequest == null || updateRequest.isCompleted()) {
78-
updateRequest = request;
79-
}
80-
}
8165
}

src/main/java/net/techcable/spawnshield/config/SpawnShieldConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ public void removeRegionToBlock(ProtectedRegion r) {
126126
})
127127
private boolean debug = false;
128128

129+
@Comments(
130+
"The range in which players will see a forcefield"
131+
)
132+
private int forcefieldRange = 50;
133+
129134
@Synchronized("lock")
130135
public void refreshRegionsToBlock() {
131136
this.cachedRegionsToBlock = null;

src/main/java/net/techcable/spawnshield/forcefield/ForceFieldListener.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
import java.util.concurrent.ConcurrentMap;
6161

6262
public class ForceFieldListener implements Listener {
63-
public static final int DEFAULT_UPDATE_RADIUS = 20;
6463
private final Set<UUID> currentlyProcessing = Sets.newSetFromMap(Maps.<UUID, Boolean>newConcurrentMap());
6564
@EventHandler(priority = EventPriority.MONITOR)
6665
public void onMove(PlayerMoveEvent event) {
@@ -91,15 +90,15 @@ public void run() {
9190
ProtectedRegionRegion region = new ProtectedRegionRegion(wgRegion.getSecond(), wgRegion.getFirst());
9291
toUpdate.add(region);
9392
}
94-
ForceFieldUpdateRequest request = new ForceFieldUpdateRequest(pos, toUpdate, player, DEFAULT_UPDATE_RADIUS);
93+
ForceFieldUpdateRequest request = new ForceFieldUpdateRequest(pos, toUpdate, player, SpawnShield.getInstance().getSettings().getForcefieldRange());
9594
final ForceFieldUpdateTask task = new ForceFieldUpdateTask(request);
9695
Bukkit.getScheduler().runTaskAsynchronously(SpawnShield.getInstance(), task);
9796
task.addListener(new Runnable() {
9897
@Override
9998
public void run() {
10099
currentlyProcessing.remove(player.getId());
101100
}
102-
}, MoreExecutors.sameThreadExecutor());;
101+
}, MoreExecutors.sameThreadExecutor());
103102
}
104103

105104
@EventHandler(priority = EventPriority.MONITOR)

0 commit comments

Comments
 (0)