clean ups

This commit is contained in:
Flemmli97 2020-08-23 15:16:26 +02:00
parent 014f65bc86
commit fdbdd5cfb0
19 changed files with 51 additions and 68 deletions

1
.gitignore vendored
View File

@ -27,3 +27,4 @@ bin/
# fabric # fabric
run/ run/
logs/

View File

@ -1,9 +1,3 @@
# Fabric Example Mod # Flan
## Setup Server side land claiming mod for fabric
For setup instructions please see the [fabric wiki page](https://fabricmc.net/wiki/tutorial:setup) that relates to the IDE that you are using.
## License
This template is available under the CC0 license. Feel free to learn from it and incorporate it in your own projects.

View File

@ -205,8 +205,8 @@ public class Claim {
if (player.getUuid().equals(this.owner) || this.canInteract(player, EnumPermission.EDITPERMS, player.getBlockPos())) { if (player.getUuid().equals(this.owner) || this.canInteract(player, EnumPermission.EDITPERMS, player.getBlockPos())) {
if (mode > 1) if (mode > 1)
mode = -1; mode = -1;
boolean has = this.permissions.containsKey(perm); boolean has = this.permissions.containsKey(group);
EnumMap<EnumPermission, Boolean> perms = has ? this.permissions.get(group) : new EnumMap(EnumPermission.class); EnumMap<EnumPermission, Boolean> perms = has ? this.permissions.get(group) : new EnumMap<>(EnumPermission.class);
if (mode == -1) if (mode == -1)
perms.remove(perm); perms.remove(perm);
else else
@ -227,7 +227,7 @@ public class Claim {
if (g.equals(group)) if (g.equals(group))
toRemove.add(uuid); toRemove.add(uuid);
}); });
toRemove.forEach(uuid -> this.playersGroups.remove(uuid)); toRemove.forEach(this.playersGroups::remove);
this.setDirty(); this.setDirty();
return true; return true;
} }
@ -276,7 +276,7 @@ public class Claim {
if (obj.has("PermGroup")) { if (obj.has("PermGroup")) {
JsonObject perms = obj.getAsJsonObject("PermGroup"); JsonObject perms = obj.getAsJsonObject("PermGroup");
perms.entrySet().forEach(key -> { perms.entrySet().forEach(key -> {
EnumMap<EnumPermission, Boolean> map = new EnumMap(EnumPermission.class); EnumMap<EnumPermission, Boolean> map = new EnumMap<>(EnumPermission.class);
JsonObject group = key.getValue().getAsJsonObject(); JsonObject group = key.getValue().getAsJsonObject();
group.entrySet().forEach(gkey -> map.put(EnumPermission.valueOf(gkey.getKey()), gkey.getValue().getAsBoolean())); group.entrySet().forEach(gkey -> map.put(EnumPermission.valueOf(gkey.getKey()), gkey.getValue().getAsBoolean()));
this.permissions.put(key.getKey(), map); this.permissions.put(key.getKey(), map);
@ -377,7 +377,7 @@ public class Claim {
if (tag.contains("PermGroup")) { if (tag.contains("PermGroup")) {
CompoundTag perms = tag.getCompound("PermGroup"); CompoundTag perms = tag.getCompound("PermGroup");
perms.getKeys().forEach(key -> { perms.getKeys().forEach(key -> {
EnumMap<EnumPermission, Boolean> map = new EnumMap(EnumPermission.class); EnumMap<EnumPermission, Boolean> map = new EnumMap<>(EnumPermission.class);
CompoundTag group = perms.getCompound(key); CompoundTag group = perms.getCompound(key);
group.getKeys().forEach(gkey -> map.put(EnumPermission.valueOf(gkey), group.getBoolean(gkey))); group.getKeys().forEach(gkey -> map.put(EnumPermission.valueOf(gkey), group.getBoolean(gkey)));
this.permissions.put(key, map); this.permissions.put(key, map);

View File

@ -41,7 +41,7 @@ public class ClaimStorage {
public static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); public static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
public final Long2ObjectArrayMap<List<Claim>> claims = new Long2ObjectArrayMap(); public final Long2ObjectArrayMap<List<Claim>> claims = new Long2ObjectArrayMap<>();
public final Map<UUID, Claim> claimUUIDMap = Maps.newHashMap(); public final Map<UUID, Claim> claimUUIDMap = Maps.newHashMap();
public final Map<UUID, Set<Claim>> playerClaimMap = Maps.newHashMap(); public final Map<UUID, Set<Claim>> playerClaimMap = Maps.newHashMap();
@ -240,7 +240,7 @@ public class ClaimStorage {
if (f.getName().endsWith(".yml")) { if (f.getName().endsWith(".yml")) {
FileReader reader = new FileReader(f); FileReader reader = new FileReader(f);
Map<String, Object> values = yml.load(reader); Map<String, Object> values = yml.load(reader);
if (values.get("Parent Claim ID").equals(Integer.valueOf(-1))) { if (values.get("Parent Claim ID").equals(-1)) {
intFileMap.put(Integer.valueOf(values.get("Parent Claim ID").toString()), f); intFileMap.put(Integer.valueOf(values.get("Parent Claim ID").toString()), f);
} }
} }
@ -250,7 +250,7 @@ public class ClaimStorage {
if (f.getName().endsWith(".yml")) { if (f.getName().endsWith(".yml")) {
FileReader reader = new FileReader(f); FileReader reader = new FileReader(f);
Map<String, Object> values = yml.load(reader); Map<String, Object> values = yml.load(reader);
if (!values.get("Parent Claim ID").equals(Integer.valueOf(-1))) { if (!values.get("Parent Claim ID").equals(-1)) {
subClaimMap.merge(intFileMap.get(Integer.valueOf(values.get("Parent Claim ID").toString())) subClaimMap.merge(intFileMap.get(Integer.valueOf(values.get("Parent Claim ID").toString()))
, Lists.newArrayList(f), (key, val) -> { , Lists.newArrayList(f), (key, val) -> {
val.add(f); val.add(f);

View File

@ -41,7 +41,7 @@ public enum EnumPermission {
ARMORSTAND(Items.ARMOR_STAND), ARMORSTAND(Items.ARMOR_STAND),
BREAKNONLIVING(Items.COMMAND_BLOCK_MINECART); BREAKNONLIVING(Items.COMMAND_BLOCK_MINECART);
private Item item; private final Item item;
EnumPermission(Item item) { EnumPermission(Item item) {
this.item = item; this.item = item;

View File

@ -31,7 +31,7 @@ import java.util.Map;
public class ObjectToPermissionMap { public class ObjectToPermissionMap {
private static Map<Block, EnumPermission> blockToPermission = Maps.newHashMap(); private static final Map<Block, EnumPermission> blockToPermission = Maps.newHashMap();
public static void reload(MinecraftServer server) { public static void reload(MinecraftServer server) {
blockToPermission.clear(); blockToPermission.clear();

View File

@ -71,7 +71,7 @@ public class CommandClaim {
if (data.confirmedDeleteAll()) { if (data.confirmedDeleteAll()) {
for (ServerWorld world : src.getWorld().getServer().getWorlds()) { for (ServerWorld world : src.getWorld().getServer().getWorlds()) {
ClaimStorage storage = ClaimStorage.get(world); ClaimStorage storage = ClaimStorage.get(world);
storage.allClaimsFromPlayer(src.getPlayer().getUuid()).forEach(claim -> storage.deleteClaim(claim)); storage.allClaimsFromPlayer(src.getPlayer().getUuid()).forEach(storage::deleteClaim);
} }
src.getPlayer().sendMessage(Text.of(ConfigHandler.lang.deleteAllClaim), false); src.getPlayer().sendMessage(Text.of(ConfigHandler.lang.deleteAllClaim), false);
data.setConfirmDeleteAll(false); data.setConfirmDeleteAll(false);
@ -133,7 +133,7 @@ public class CommandClaim {
GameProfile prof = it.next(); GameProfile prof = it.next();
for (ServerWorld world : src.getWorld().getServer().getWorlds()) { for (ServerWorld world : src.getWorld().getServer().getWorlds()) {
ClaimStorage storage = ClaimStorage.get(world); ClaimStorage storage = ClaimStorage.get(world);
storage.allClaimsFromPlayer(prof.getId()).forEach(claim -> storage.deleteClaim(claim)); storage.allClaimsFromPlayer(prof.getId()).forEach(storage::deleteClaim);
} }
players.add(prof.getName()); players.add(prof.getName());
} }

View File

@ -9,7 +9,7 @@ import java.io.File;
public class Config { public class Config {
private File configDir; private final File configDir;
public int startingBlocks = 500; public int startingBlocks = 500;
public int maxClaimBlocks = 5000; public int maxClaimBlocks = 5000;

View File

@ -7,7 +7,7 @@ import java.io.File;
public class LangConfig { public class LangConfig {
private File configDir; private final File configDir;
public String inspectBlockOwner = "This is %1$s's claim"; public String inspectBlockOwner = "This is %1$s's claim";
public String inspectNoClaim = "Nobody owns this block"; public String inspectNoClaim = "Nobody owns this block";

View File

@ -69,7 +69,7 @@ public class BlockInteractEvents {
return false; return false;
if (entity instanceof PlayerEntity) { if (entity instanceof PlayerEntity) {
EnumPermission perm = ObjectToPermissionMap.getFromBlock(state.getBlock()); EnumPermission perm = ObjectToPermissionMap.getFromBlock(state.getBlock());
if (perm == null || (perm != EnumPermission.PRESSUREPLATE && perm != EnumPermission.PORTAL)) if (perm != EnumPermission.PRESSUREPLATE && perm != EnumPermission.PORTAL)
return false; return false;
ClaimStorage storage = ClaimStorage.get((ServerWorld) world); ClaimStorage storage = ClaimStorage.get((ServerWorld) world);
Claim claim = storage.getClaimAt(pos); Claim claim = storage.getClaimAt(pos);
@ -77,7 +77,7 @@ public class BlockInteractEvents {
return !claim.canInteract((PlayerEntity) entity, perm, pos); return !claim.canInteract((PlayerEntity) entity, perm, pos);
} else if (entity instanceof ProjectileEntity) { } else if (entity instanceof ProjectileEntity) {
EnumPermission perm = ObjectToPermissionMap.getFromBlock(state.getBlock()); EnumPermission perm = ObjectToPermissionMap.getFromBlock(state.getBlock());
if (perm == null || (perm != EnumPermission.PRESSUREPLATE && perm != EnumPermission.BUTTONLEVER)) if (perm != EnumPermission.PRESSUREPLATE && perm != EnumPermission.BUTTONLEVER)
return false; return false;
Entity owner = ((ProjectileEntity) entity).getOwner(); Entity owner = ((ProjectileEntity) entity).getOwner();
if (owner instanceof PlayerEntity) { if (owner instanceof PlayerEntity) {
@ -97,7 +97,7 @@ public class BlockInteractEvents {
ClaimStorage storage = ClaimStorage.get((ServerWorld) entity.world); ClaimStorage storage = ClaimStorage.get((ServerWorld) entity.world);
Claim claim = storage.getClaimAt(landedPosition); Claim claim = storage.getClaimAt(landedPosition);
EnumPermission perm = ObjectToPermissionMap.getFromBlock(landedState.getBlock()); EnumPermission perm = ObjectToPermissionMap.getFromBlock(landedState.getBlock());
if (perm != null && perm == EnumPermission.TRAMPLE) if (perm == EnumPermission.TRAMPLE)
return !claim.canInteract((PlayerEntity) entity, perm, landedPosition); return !claim.canInteract((PlayerEntity) entity, perm, landedPosition);
} else if (entity instanceof ProjectileEntity) { } else if (entity instanceof ProjectileEntity) {
Entity owner = ((ProjectileEntity) entity).getOwner(); Entity owner = ((ProjectileEntity) entity).getOwner();
@ -105,7 +105,7 @@ public class BlockInteractEvents {
ClaimStorage storage = ClaimStorage.get((ServerWorld) entity.world); ClaimStorage storage = ClaimStorage.get((ServerWorld) entity.world);
Claim claim = storage.getClaimAt(landedPosition); Claim claim = storage.getClaimAt(landedPosition);
EnumPermission perm = ObjectToPermissionMap.getFromBlock(landedState.getBlock()); EnumPermission perm = ObjectToPermissionMap.getFromBlock(landedState.getBlock());
if (perm != null && perm == EnumPermission.TRAMPLE) if (perm == EnumPermission.TRAMPLE)
return !claim.canInteract((PlayerEntity) owner, perm, landedPosition); return !claim.canInteract((PlayerEntity) owner, perm, landedPosition);
} }
} }

View File

@ -16,10 +16,10 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.PersistentProjectileEntity; import net.minecraft.entity.projectile.PersistentProjectileEntity;
import net.minecraft.entity.projectile.ProjectileEntity; import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.entity.projectile.thrown.EnderPearlEntity; import net.minecraft.entity.projectile.thrown.EnderPearlEntity;
import net.minecraft.entity.vehicle.AbstractMinecartEntity;
import net.minecraft.entity.vehicle.BoatEntity; import net.minecraft.entity.vehicle.BoatEntity;
import net.minecraft.entity.vehicle.ChestMinecartEntity;
import net.minecraft.entity.vehicle.HopperMinecartEntity;
import net.minecraft.entity.vehicle.MinecartEntity; import net.minecraft.entity.vehicle.MinecartEntity;
import net.minecraft.entity.vehicle.StorageMinecartEntity;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundEvents; import net.minecraft.sound.SoundEvents;
@ -61,8 +61,8 @@ public class EntityInteractEvents {
//works //works
if (entity instanceof BoatEntity) if (entity instanceof BoatEntity)
return claim.canInteract(player, EnumPermission.BOAT, pos) ? ActionResult.PASS : ActionResult.FAIL; return claim.canInteract(player, EnumPermission.BOAT, pos) ? ActionResult.PASS : ActionResult.FAIL;
if (entity instanceof MinecartEntity) { if (entity instanceof AbstractMinecartEntity) {
if (entity instanceof HopperMinecartEntity || entity instanceof ChestMinecartEntity) if (entity instanceof StorageMinecartEntity)
return claim.canInteract(player, EnumPermission.OPENCONTAINER, pos) ? ActionResult.PASS : ActionResult.FAIL; return claim.canInteract(player, EnumPermission.OPENCONTAINER, pos) ? ActionResult.PASS : ActionResult.FAIL;
return claim.canInteract(player, EnumPermission.MINECART, pos) ? ActionResult.PASS : ActionResult.FAIL; return claim.canInteract(player, EnumPermission.MINECART, pos) ? ActionResult.PASS : ActionResult.FAIL;
} }
@ -89,7 +89,7 @@ public class EntityInteractEvents {
EnumPermission perm = ObjectToPermissionMap.getFromBlock(state.getBlock()); EnumPermission perm = ObjectToPermissionMap.getFromBlock(state.getBlock());
if (proj instanceof EnderPearlEntity) if (proj instanceof EnderPearlEntity)
perm = EnumPermission.ENDERPEARL; perm = EnumPermission.ENDERPEARL;
if (perm == null || (perm != EnumPermission.ENDERPEARL && perm != EnumPermission.TARGETBLOCK && perm != EnumPermission.PROJECTILES)) if (perm != EnumPermission.ENDERPEARL && perm != EnumPermission.TARGETBLOCK && perm != EnumPermission.PROJECTILES)
return false; return false;
ClaimStorage storage = ClaimStorage.get((ServerWorld) proj.world); ClaimStorage storage = ClaimStorage.get((ServerWorld) proj.world);
Claim claim = storage.getClaimAt(pos); Claim claim = storage.getClaimAt(pos);

View File

@ -20,7 +20,7 @@ import net.minecraft.util.Formatting;
public class ClaimMenuScreenHandler extends ServerOnlyScreenHandler { public class ClaimMenuScreenHandler extends ServerOnlyScreenHandler {
private Claim claim; private final Claim claim;
private ClaimMenuScreenHandler(int syncId, PlayerInventory playerInventory, Claim claim) { private ClaimMenuScreenHandler(int syncId, PlayerInventory playerInventory, Claim claim) {
super(syncId, playerInventory, 1); super(syncId, playerInventory, 1);

View File

@ -25,8 +25,8 @@ import java.util.List;
public class GroupPlayerScreenHandler extends ServerOnlyScreenHandler { public class GroupPlayerScreenHandler extends ServerOnlyScreenHandler {
private Claim claim; private final Claim claim;
private String group; private final String group;
private boolean removeMode; private boolean removeMode;
private GroupPlayerScreenHandler(int syncId, PlayerInventory playerInventory, Claim claim, String group) { private GroupPlayerScreenHandler(int syncId, PlayerInventory playerInventory, Claim claim, String group) {

View File

@ -21,7 +21,7 @@ import java.util.List;
public class GroupScreenHandler extends ServerOnlyScreenHandler { public class GroupScreenHandler extends ServerOnlyScreenHandler {
private Claim claim; private final Claim claim;
private boolean removeMode; private boolean removeMode;
@ -125,12 +125,11 @@ public class GroupScreenHandler extends ServerOnlyScreenHandler {
if (clickType == 1) { if (clickType == 1) {
player.closeHandledScreen(); player.closeHandledScreen();
player.getServer().execute(() -> PermissionScreenHandler.openClaimMenu(player, this.claim, name)); player.getServer().execute(() -> PermissionScreenHandler.openClaimMenu(player, this.claim, name));
ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f);
} else { } else {
player.closeHandledScreen(); player.closeHandledScreen();
player.getServer().execute(() -> GroupPlayerScreenHandler.openPlayerGroupMenu(player, this.claim, name)); player.getServer().execute(() -> GroupPlayerScreenHandler.openPlayerGroupMenu(player, this.claim, name));
ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f);
} }
ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f);
} }
} }
return false; return false;

View File

@ -19,9 +19,9 @@ import net.minecraft.util.Formatting;
public class PermissionScreenHandler extends ServerOnlyScreenHandler { public class PermissionScreenHandler extends ServerOnlyScreenHandler {
private Claim claim; private final Claim claim;
private String group; private final String group;
private int page; private final int page;
private PermissionScreenHandler(int syncId, PlayerInventory playerInventory, Claim claim, String group, int page) { private PermissionScreenHandler(int syncId, PlayerInventory playerInventory, Claim claim, String group, int page) {
super(syncId, playerInventory, 6, claim, group, page); super(syncId, playerInventory, 6, claim, group, page);
@ -62,8 +62,6 @@ public class PermissionScreenHandler extends ServerOnlyScreenHandler {
@Override @Override
protected void fillInventoryWith(PlayerEntity player, Inventory inv, Object... additionalData) { protected void fillInventoryWith(PlayerEntity player, Inventory inv, Object... additionalData) {
if (additionalData == null)
return;
for (int i = 0; i < 54; i++) { for (int i = 0; i < 54; i++) {
int page = (int) additionalData[2]; int page = (int) additionalData[2];
if (i == 0) { if (i == 0) {
@ -84,7 +82,7 @@ public class PermissionScreenHandler extends ServerOnlyScreenHandler {
int row = i / 9 - 1; int row = i / 9 - 1;
int id = (i % 9) + row * 7 - 1 + page * 54; int id = (i % 9) + row * 7 - 1 + page * 54;
if (id < EnumPermission.values().length) if (id < EnumPermission.values().length)
inv.setStack(i, ServerScreenHelper.fromPermission((Claim) additionalData[0], EnumPermission.values()[id], additionalData.length == 1 ? null : String.valueOf(additionalData[1]))); inv.setStack(i, ServerScreenHelper.fromPermission((Claim) additionalData[0], EnumPermission.values()[id], String.valueOf(additionalData[1])));
} }
} }
} }
@ -95,12 +93,11 @@ public class PermissionScreenHandler extends ServerOnlyScreenHandler {
if (this.group == null) { if (this.group == null) {
player.closeHandledScreen(); player.closeHandledScreen();
player.getServer().execute(() -> ClaimMenuScreenHandler.openClaimMenu(player, this.claim)); player.getServer().execute(() -> ClaimMenuScreenHandler.openClaimMenu(player, this.claim));
ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f);
} else { } else {
player.closeHandledScreen(); player.closeHandledScreen();
player.getServer().execute(() -> GroupScreenHandler.openGroupMenu(player, this.claim)); player.getServer().execute(() -> GroupScreenHandler.openGroupMenu(player, this.claim));
ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f);
} }
ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f);
return true; return true;
} }
if (index == 47) { if (index == 47) {

View File

@ -6,6 +6,7 @@ import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventory; import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.SimpleInventory; import net.minecraft.inventory.SimpleInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.screen.GenericContainerScreenHandler;
import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.ScreenHandlerListener; import net.minecraft.screen.ScreenHandlerListener;
import net.minecraft.screen.ScreenHandlerType; import net.minecraft.screen.ScreenHandlerType;
@ -13,7 +14,6 @@ import net.minecraft.screen.slot.Slot;
import net.minecraft.screen.slot.SlotActionType; import net.minecraft.screen.slot.SlotActionType;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import java.util.Iterator;
import java.util.List; import java.util.List;
public abstract class ServerOnlyScreenHandler extends ScreenHandler { public abstract class ServerOnlyScreenHandler extends ScreenHandler {
@ -45,7 +45,7 @@ public abstract class ServerOnlyScreenHandler extends ScreenHandler {
} }
} }
private static ScreenHandlerType fromRows(int rows) { private static ScreenHandlerType<GenericContainerScreenHandler> fromRows(int rows) {
switch (rows) { switch (rows) {
case 2: case 2:
return ScreenHandlerType.GENERIC_9X2; return ScreenHandlerType.GENERIC_9X2;
@ -104,10 +104,8 @@ public abstract class ServerOnlyScreenHandler extends ScreenHandler {
int j; int j;
for (j = 0; j < this.slots.size(); ++j) { for (j = 0; j < this.slots.size(); ++j) {
ItemStack itemStack = this.slots.get(j).getStack(); ItemStack itemStack = this.slots.get(j).getStack();
Iterator var5 = this.listeners.iterator();
while (var5.hasNext()) { for (ScreenHandlerListener screenHandlerListener : this.listeners) {
ScreenHandlerListener screenHandlerListener = (ScreenHandlerListener) var5.next();
screenHandlerListener.onSlotUpdate(this, j, itemStack.copy()); screenHandlerListener.onSlotUpdate(this, j, itemStack.copy());
} }
} }

View File

@ -17,7 +17,6 @@ import net.minecraft.text.LiteralText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -113,10 +112,8 @@ public class StringResultScreenHandler extends AnvilScreenHandler {
int j; int j;
for (j = 0; j < this.slots.size(); ++j) { for (j = 0; j < this.slots.size(); ++j) {
ItemStack itemStack = this.slots.get(j).getStack(); ItemStack itemStack = this.slots.get(j).getStack();
Iterator var5 = this.listeners.iterator();
while (var5.hasNext()) { for (ScreenHandlerListener screenHandlerListener : this.listeners) {
ScreenHandlerListener screenHandlerListener = (ScreenHandlerListener) var5.next();
screenHandlerListener.onSlotUpdate(this, j, itemStack.copy()); screenHandlerListener.onSlotUpdate(this, j, itemStack.copy());
} }
} }

View File

@ -16,7 +16,7 @@ import java.util.Set;
public class ClaimDisplay { public class ClaimDisplay {
private int displayTime; private int displayTime;
private Claim toDisplay; private final Claim toDisplay;
private int[][] poss; private int[][] poss;
private int[][] middlePoss; private int[][] middlePoss;
@ -42,14 +42,12 @@ public class ClaimDisplay {
}; };
} }
if (this.poss != null) for (int[] pos : this.poss) {
for (int[] pos : this.poss) { player.networkHandler.sendPacket(new ParticleS2CPacket(ParticleIndicators.CLAIMCORNER, true, pos[0] + 0.5, pos[1] + 0.25, pos[2] + 0.5, 0, 0.25f, 0, 0, 1));
player.networkHandler.sendPacket(new ParticleS2CPacket(ParticleIndicators.CLAIMCORNER, true, pos[0] + 0.5, pos[1] + 0.25, pos[2] + 0.5, 0, 0.25f, 0, 0, 1)); }
} for (int[] pos : this.middlePoss) {
if (this.middlePoss != null) player.networkHandler.sendPacket(new ParticleS2CPacket(ParticleIndicators.CLAIMMIDDLE, true, pos[0] + 0.5, pos[1] + 0.25, pos[2] + 0.5, 0, 0.25f, 0, 0, 1));
for (int[] pos : this.middlePoss) { }
player.networkHandler.sendPacket(new ParticleS2CPacket(ParticleIndicators.CLAIMMIDDLE, true, pos[0] + 0.5, pos[1] + 0.25, pos[2] + 0.5, 0, 0.25f, 0, 0, 1));
}
this.prevDims = dims; this.prevDims = dims;
return toDisplay.isRemoved() || displayTime < 0; return toDisplay.isRemoved() || displayTime < 0;
} }

View File

@ -35,10 +35,10 @@ public class PlayerClaimData {
private BlockPos firstCorner; private BlockPos firstCorner;
private Set<ClaimDisplay> claimDisplayList = Sets.newHashSet(); private final Set<ClaimDisplay> claimDisplayList = Sets.newHashSet();
private Set<ClaimDisplay> displayToAdd = Sets.newHashSet(); private final Set<ClaimDisplay> displayToAdd = Sets.newHashSet();
private ServerPlayerEntity player; private final ServerPlayerEntity player;
private boolean confirmDeleteAll, adminIgnoreClaim; private boolean confirmDeleteAll, adminIgnoreClaim;
private boolean dirty; private boolean dirty;
@ -141,10 +141,9 @@ public class PlayerClaimData {
} }
public void tick() { public void tick() {
ServerPlayerEntity sPlayer = this.player;
this.claimDisplayList.addAll(this.displayToAdd); this.claimDisplayList.addAll(this.displayToAdd);
this.displayToAdd.clear(); this.displayToAdd.clear();
this.claimDisplayList.removeIf(d -> d.display(sPlayer)); this.claimDisplayList.removeIf(d -> d.display(this.player));
if (++this.lastBlockTick > ConfigHandler.config.ticksForNextBlock) { if (++this.lastBlockTick > ConfigHandler.config.ticksForNextBlock) {
this.addClaimBlocks(1); this.addClaimBlocks(1);
this.lastBlockTick = 0; this.lastBlockTick = 0;