mirror of
https://github.com/ViaVersion/ViaLegacy.git
synced 2025-01-24 22:01:28 +01:00
Improved classic block permissions handling
This commit is contained in:
parent
3cb326f9c1
commit
6b057a255c
@ -316,7 +316,7 @@ public class Protocolc0_30toc0_30cpe extends AbstractProtocol<ClientboundPackets
|
|||||||
final int blockId = wrapper.get(Type.BYTE, 0);
|
final int blockId = wrapper.get(Type.BYTE, 0);
|
||||||
|
|
||||||
int block = level.getBlock(position);
|
int block = level.getBlock(position);
|
||||||
final boolean disallow = (placeBlock && !blockPermissions.isPlacingAllowed(blockId)) || (!placeBlock && !blockPermissions.isBreakingAllowed(block));
|
final boolean disallow = (placeBlock && blockPermissions.isPlacingDenied(blockId)) || (!placeBlock && blockPermissions.isBreakingDenied(block));
|
||||||
|
|
||||||
if (disallow) {
|
if (disallow) {
|
||||||
wrapper.cancel();
|
wrapper.cancel();
|
||||||
|
@ -24,35 +24,35 @@ import com.viaversion.viaversion.libs.fastutil.ints.IntSet;
|
|||||||
|
|
||||||
public class ExtBlockPermissionsStorage extends StoredObject {
|
public class ExtBlockPermissionsStorage extends StoredObject {
|
||||||
|
|
||||||
private final IntSet placingAllowed = new IntOpenHashSet();
|
private final IntSet placingDenied = new IntOpenHashSet();
|
||||||
private final IntSet breakingAllowed = new IntOpenHashSet();
|
private final IntSet breakingDenied = new IntOpenHashSet();
|
||||||
|
|
||||||
public ExtBlockPermissionsStorage(final UserConnection user) {
|
public ExtBlockPermissionsStorage(final UserConnection user) {
|
||||||
super(user);
|
super(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlaceable(final int block) {
|
public void addPlaceable(final int block) {
|
||||||
this.placingAllowed.add(block);
|
this.placingDenied.remove(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBreakable(final int block) {
|
public void addBreakable(final int block) {
|
||||||
this.breakingAllowed.add(block);
|
this.breakingDenied.remove(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePlaceable(final int block) {
|
public void removePlaceable(final int block) {
|
||||||
this.placingAllowed.remove(block);
|
this.placingDenied.add(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeBreakable(final int block) {
|
public void removeBreakable(final int block) {
|
||||||
this.breakingAllowed.remove(block);
|
this.breakingDenied.add(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlacingAllowed(final int block) {
|
public boolean isPlacingDenied(final int block) {
|
||||||
return this.placingAllowed.contains(block);
|
return this.placingDenied.contains(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBreakingAllowed(final int block) {
|
public boolean isBreakingDenied(final int block) {
|
||||||
return this.breakingAllowed.contains(block);
|
return this.breakingDenied.contains(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user