code cleanups and stuff

This commit is contained in:
Flemmli97 2020-10-30 15:38:24 +01:00
parent a4ddd89988
commit db6fb6d131
13 changed files with 56 additions and 73 deletions

View File

@ -10,7 +10,6 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
@ -240,7 +239,7 @@ public class Claim implements IPermissionContainer{
UUID uuid = UUID.randomUUID(); UUID uuid = UUID.randomUUID();
for (Claim claim : this.subClaims) for (Claim claim : this.subClaims)
if (claim.claimID.equals(uuid)) { if (claim.claimID.equals(uuid)) {
return generateUUID(); return this.generateUUID();
} }
return uuid; return uuid;
} }

View File

@ -62,13 +62,13 @@ public class ClaimStorage {
public UUID generateUUID() { public UUID generateUUID() {
UUID uuid = UUID.randomUUID(); UUID uuid = UUID.randomUUID();
if (this.claimUUIDMap.containsKey(uuid)) if (this.claimUUIDMap.containsKey(uuid))
return generateUUID(); return this.generateUUID();
return uuid; return uuid;
} }
public boolean createClaim(BlockPos pos1, BlockPos pos2, ServerPlayerEntity player) { public boolean createClaim(BlockPos pos1, BlockPos pos2, ServerPlayerEntity player) {
Claim claim = new Claim(pos1.down(ConfigHandler.config.defaultClaimDepth), pos2.down(ConfigHandler.config.defaultClaimDepth), player.getUuid(), player.getServerWorld()); Claim claim = new Claim(pos1.down(ConfigHandler.config.defaultClaimDepth), pos2.down(ConfigHandler.config.defaultClaimDepth), player.getUuid(), player.getServerWorld());
Set<Claim> conflicts = conflicts(claim, null); Set<Claim> conflicts = this.conflicts(claim, null);
if (conflicts.isEmpty()) { if (conflicts.isEmpty()) {
PlayerClaimData data = PlayerClaimData.get(player); PlayerClaimData data = PlayerClaimData.get(player);
if (claim.getPlane() < ConfigHandler.config.minClaimsize) { if (claim.getPlane() < ConfigHandler.config.minClaimsize) {
@ -143,7 +143,7 @@ public class ClaimStorage {
int[] dims = claim.getDimensions(); int[] dims = claim.getDimensions();
BlockPos opposite = new BlockPos(dims[0] == from.getX() ? dims[1] : dims[0], dims[4], dims[2] == from.getZ() ? dims[3] : dims[2]); BlockPos opposite = new BlockPos(dims[0] == from.getX() ? dims[1] : dims[0], dims[4], dims[2] == from.getZ() ? dims[3] : dims[2]);
Claim newClaim = new Claim(opposite, to, player.getUuid(), player.getServerWorld()); Claim newClaim = new Claim(opposite, to, player.getUuid(), player.getServerWorld());
Set<Claim> conflicts = conflicts(newClaim, claim); Set<Claim> conflicts = this.conflicts(newClaim, claim);
if (!conflicts.isEmpty()) { if (!conflicts.isEmpty()) {
conflicts.forEach(conf -> PlayerClaimData.get(player).addDisplayClaim(conf, EnumDisplayType.CONFLICT, player.getBlockPos().getY())); conflicts.forEach(conf -> PlayerClaimData.get(player).addDisplayClaim(conf, EnumDisplayType.CONFLICT, player.getBlockPos().getY()));
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.conflictOther, Formatting.RED), false); player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.conflictOther, Formatting.RED), false);

View File

@ -45,39 +45,38 @@ import java.util.concurrent.CompletableFuture;
public class CommandClaim { public class CommandClaim {
@SuppressWarnings("unchecked")
public static void register(CommandDispatcher<ServerCommandSource> dispatcher, boolean dedicated) { public static void register(CommandDispatcher<ServerCommandSource> dispatcher, boolean dedicated) {
dispatcher.register(addToMainCommand(CommandManager.literal("flan"), dispatcher.register(CommandManager.literal("flan")
CommandManager.literal("reload").executes(CommandClaim::reloadConfig), .then(CommandManager.literal("reload").executes(CommandClaim::reloadConfig))
CommandManager.literal("addClaim").then(CommandManager.argument("from", BlockPosArgumentType.blockPos()).then(CommandManager.argument("to", BlockPosArgumentType.blockPos()).executes(CommandClaim::addClaim))), .then(CommandManager.literal("addClaim").then(CommandManager.argument("from", BlockPosArgumentType.blockPos()).then(CommandManager.argument("to", BlockPosArgumentType.blockPos()).executes(CommandClaim::addClaim))))
CommandManager.literal("menu").executes(CommandClaim::openMenu), .then(CommandManager.literal("menu").executes(CommandClaim::openMenu))
CommandManager.literal("claimInfo").executes(CommandClaim::claimInfo), .then(CommandManager.literal("claimInfo").executes(CommandClaim::claimInfo))
CommandManager.literal("transferClaim").then(CommandManager.argument("player", GameProfileArgumentType.gameProfile()).executes(CommandClaim::transferClaim)), .then(CommandManager.literal("transferClaim").then(CommandManager.argument("player", GameProfileArgumentType.gameProfile()).executes(CommandClaim::transferClaim)))
CommandManager.literal("delete").executes(CommandClaim::deleteClaim), .then(CommandManager.literal("delete").executes(CommandClaim::deleteClaim))
CommandManager.literal("deleteAll").executes(CommandClaim::deleteAllClaim), .then(CommandManager.literal("deleteAll").executes(CommandClaim::deleteAllClaim))
CommandManager.literal("deleteSubClaim").executes(CommandClaim::deleteSubClaim), .then(CommandManager.literal("deleteSubClaim").executes(CommandClaim::deleteSubClaim))
CommandManager.literal("deleteAllSubClaims").executes(CommandClaim::deleteAllSubClaim), .then(CommandManager.literal("deleteAllSubClaims").executes(CommandClaim::deleteAllSubClaim))
CommandManager.literal("list").executes(CommandClaim::listClaims).then(CommandManager.argument("player", GameProfileArgumentType.gameProfile()).requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel)) .then(CommandManager.literal("list").executes(CommandClaim::listClaims).then(CommandManager.argument("player", GameProfileArgumentType.gameProfile()).requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel))
.executes(cmd -> listClaims(cmd, GameProfileArgumentType.getProfileArgument(cmd, "player")))), .executes(cmd -> listClaims(cmd, GameProfileArgumentType.getProfileArgument(cmd, "player")))))
CommandManager.literal("switchMode").executes(CommandClaim::switchClaimMode), .then(CommandManager.literal("switchMode").executes(CommandClaim::switchClaimMode))
CommandManager.literal("adminMode").requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel)).executes(CommandClaim::switchAdminMode), .then(CommandManager.literal("adminMode").requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel)).executes(CommandClaim::switchAdminMode))
CommandManager.literal("readGriefPrevention").requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel)).executes(CommandClaim::readGriefPreventionData), .then(CommandManager.literal("readGriefPrevention").requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel)).executes(CommandClaim::readGriefPreventionData))
CommandManager.literal("setAdminClaim").requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel)).then(CommandManager.argument("toggle", BoolArgumentType.bool()).executes(CommandClaim::toggleAdminClaim)), .then(CommandManager.literal("setAdminClaim").requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel)).then(CommandManager.argument("toggle", BoolArgumentType.bool()).executes(CommandClaim::toggleAdminClaim)))
CommandManager.literal("listAdminClaims").requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel)).executes(CommandClaim::listAdminClaims), .then(CommandManager.literal("listAdminClaims").requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel)).executes(CommandClaim::listAdminClaims))
CommandManager.literal("adminDelete").requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel)).executes(CommandClaim::adminDelete) .then(CommandManager.literal("adminDelete").requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel)).executes(CommandClaim::adminDelete)
.then(CommandManager.literal("all").then(CommandManager.argument("players", GameProfileArgumentType.gameProfile()) .then(CommandManager.literal("all").then(CommandManager.argument("players", GameProfileArgumentType.gameProfile())
.executes(CommandClaim::adminDeleteAll))), .executes(CommandClaim::adminDeleteAll))))
CommandManager.literal("giveClaimBlocks").requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel)).then(CommandManager.argument("players", GameProfileArgumentType.gameProfile()) .then(CommandManager.literal("giveClaimBlocks").requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel)).then(CommandManager.argument("players", GameProfileArgumentType.gameProfile())
.then(CommandManager.argument("amount", IntegerArgumentType.integer()).executes(CommandClaim::giveClaimBlocks))), .then(CommandManager.argument("amount", IntegerArgumentType.integer()).executes(CommandClaim::giveClaimBlocks))))
addToMainCommand(CommandManager.literal("group"), .then(CommandManager.literal("group")
CommandManager.literal("add").then(CommandManager.argument("group", StringArgumentType.word()).executes(CommandClaim::addGroup)), .then(CommandManager.literal("add").then(CommandManager.argument("group", StringArgumentType.word()).executes(CommandClaim::addGroup)))
CommandManager.literal("remove").then(CommandManager.argument("group", StringArgumentType.word()) .then(CommandManager.literal("remove").then(CommandManager.argument("group", StringArgumentType.word())
.suggests(CommandClaim::groupSuggestion).executes(CommandClaim::removeGroup)), .suggests(CommandClaim::groupSuggestion).executes(CommandClaim::removeGroup)))
addToMainCommand(CommandManager.literal("players"), .then(CommandManager.literal("players")
CommandManager.literal("add").then(CommandManager.argument("group", StringArgumentType.word()).suggests(CommandClaim::groupSuggestion) .then(CommandManager.literal("add").then(CommandManager.argument("group", StringArgumentType.word()).suggests(CommandClaim::groupSuggestion)
.then(CommandManager.argument("players", GameProfileArgumentType.gameProfile()).executes(CommandClaim::addPlayer) .then(CommandManager.argument("players", GameProfileArgumentType.gameProfile()).executes(CommandClaim::addPlayer)
.then(CommandManager.literal("overwrite").executes(CommandClaim::forceAddPlayer)))), .then(CommandManager.literal("overwrite").executes(CommandClaim::forceAddPlayer)))))
CommandManager.literal("remove").then(CommandManager.argument("group", StringArgumentType.word()).suggests(CommandClaim::groupSuggestion) .then(CommandManager.literal("remove").then(CommandManager.argument("group", StringArgumentType.word()).suggests(CommandClaim::groupSuggestion)
.then(CommandManager.argument("players", GameProfileArgumentType.gameProfile()).suggests((context, build) -> { .then(CommandManager.argument("players", GameProfileArgumentType.gameProfile()).suggests((context, build) -> {
ServerPlayerEntity player = context.getSource().getPlayer(); ServerPlayerEntity player = context.getSource().getPlayer();
List<String> list = Lists.newArrayList(); List<String> list = Lists.newArrayList();
@ -88,22 +87,15 @@ public class CommandClaim {
list = claim.playersFromGroup(player.getServer(), ""); list = claim.playersFromGroup(player.getServer(), "");
} }
return CommandSource.suggestMatching(list, build); return CommandSource.suggestMatching(list, build);
}).executes(CommandClaim::removePlayer))))), }).executes(CommandClaim::removePlayer))))))
addToMainCommand(CommandManager.literal("permission"), .then(CommandManager.literal("permission")
CommandManager.literal("global").then(CommandManager.argument("permission", StringArgumentType.word()).suggests((ctx, b) -> permSuggestions(ctx, b, false)) .then(CommandManager.literal("global").then(CommandManager.argument("permission", StringArgumentType.word()).suggests((ctx, b) -> permSuggestions(ctx, b, false))
.then(CommandManager.argument("toggle", StringArgumentType.word()).suggests((ctx, b) -> CommandSource.suggestMatching(new String[]{"default", "true", "false"}, b)).executes(CommandClaim::editGlobalPerm))), .then(CommandManager.argument("toggle", StringArgumentType.word()).suggests((ctx, b) -> CommandSource.suggestMatching(new String[]{"default", "true", "false"}, b)).executes(CommandClaim::editGlobalPerm))))
CommandManager.literal("group").then(CommandManager.argument("group", StringArgumentType.word()).suggests(CommandClaim::groupSuggestion) .then(CommandManager.literal("group").then(CommandManager.argument("group", StringArgumentType.word()).suggests(CommandClaim::groupSuggestion)
.then(CommandManager.argument("permission", StringArgumentType.word()).suggests((ctx, b) -> permSuggestions(ctx, b, true)) .then(CommandManager.argument("permission", StringArgumentType.word()).suggests((ctx, b) -> permSuggestions(ctx, b, true))
.then(CommandManager.argument("toggle", StringArgumentType.word()) .then(CommandManager.argument("toggle", StringArgumentType.word())
.suggests((ctx, b) -> CommandSource.suggestMatching(new String[]{"default", "true", "false"}, b)).executes(CommandClaim::editGroupPerm))))) .suggests((ctx, b) -> CommandSource.suggestMatching(new String[]{"default", "true", "false"}, b)).executes(CommandClaim::editGroupPerm))))))
)); );
}
private static <S, T extends ArgumentBuilder<S, T>> T addToMainCommand(T main, T... other) {
if (other != null)
for (T o : other)
main.then(o);
return main;
} }
private static int reloadConfig(CommandContext<ServerCommandSource> context) { private static int reloadConfig(CommandContext<ServerCommandSource> context) {

View File

@ -12,14 +12,12 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import org.lwjgl.system.CallbackI;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.EnumSet;
import java.util.Map; import java.util.Map;
public class Config { public class Config {
@ -43,7 +41,7 @@ public class Config {
public boolean log; public boolean log;
public Map<String,EnumMap<EnumPermission,Boolean>> globalDefaultPerms = Maps.newHashMap(); public final Map<String,EnumMap<EnumPermission,Boolean>> globalDefaultPerms = Maps.newHashMap();
public Config(MinecraftServer server) { public Config(MinecraftServer server) {
File configDir = FabricLoader.getInstance().getConfigDir().resolve("flan").toFile(); File configDir = FabricLoader.getInstance().getConfigDir().resolve("flan").toFile();
@ -121,10 +119,10 @@ public class Config {
obj.addProperty("claimDisplayTime", this.claimDisplayTime); obj.addProperty("claimDisplayTime", this.claimDisplayTime);
obj.addProperty("permissionLevel", this.permissionLevel); obj.addProperty("permissionLevel", this.permissionLevel);
JsonObject global = new JsonObject(); JsonObject global = new JsonObject();
this.globalDefaultPerms.entrySet().forEach(e->{ this.globalDefaultPerms.forEach((key, value) -> {
JsonObject perm = new JsonObject(); JsonObject perm = new JsonObject();
e.getValue().entrySet().forEach(eperm->perm.addProperty(eperm.getKey().toString(), eperm.getValue().booleanValue())); value.entrySet().forEach(eperm -> perm.addProperty(eperm.getKey().toString(), eperm.getValue()));
global.add(e.getKey(), perm); global.add(key, perm);
}); });
obj.add("globalDefaultPerms", global); obj.add("globalDefaultPerms", global);
obj.addProperty("enableLogs", this.log); obj.addProperty("enableLogs", this.log);
@ -139,8 +137,5 @@ public class Config {
public boolean globallyDefined(ServerWorld world, EnumPermission perm){ public boolean globallyDefined(ServerWorld world, EnumPermission perm){
EnumMap<EnumPermission,Boolean> global = ConfigHandler.config.globalDefaultPerms.get(world.getRegistryKey().getValue().toString()); EnumMap<EnumPermission,Boolean> global = ConfigHandler.config.globalDefaultPerms.get(world.getRegistryKey().getValue().toString());
if(global!=null && global.containsKey(perm)) { return global != null && global.containsKey(perm);
return true;
}
return false;
}} }}

View File

@ -1,7 +1,6 @@
package com.flemmli97.flan.event; package com.flemmli97.flan.event;
import com.flemmli97.flan.claim.BlockToPermissionMap; import com.flemmli97.flan.claim.BlockToPermissionMap;
import com.flemmli97.flan.claim.Claim;
import com.flemmli97.flan.claim.ClaimStorage; import com.flemmli97.flan.claim.ClaimStorage;
import com.flemmli97.flan.claim.EnumPermission; import com.flemmli97.flan.claim.EnumPermission;
import com.flemmli97.flan.claim.IPermissionContainer; import com.flemmli97.flan.claim.IPermissionContainer;

View File

@ -1,7 +1,6 @@
package com.flemmli97.flan.event; package com.flemmli97.flan.event;
import com.flemmli97.flan.claim.BlockToPermissionMap; import com.flemmli97.flan.claim.BlockToPermissionMap;
import com.flemmli97.flan.claim.Claim;
import com.flemmli97.flan.claim.ClaimStorage; import com.flemmli97.flan.claim.ClaimStorage;
import com.flemmli97.flan.claim.EnumPermission; import com.flemmli97.flan.claim.EnumPermission;
import com.flemmli97.flan.claim.IPermissionContainer; import com.flemmli97.flan.claim.IPermissionContainer;

View File

@ -1,6 +1,5 @@
package com.flemmli97.flan.event; package com.flemmli97.flan.event;
import com.flemmli97.flan.claim.Claim;
import com.flemmli97.flan.claim.ClaimStorage; import com.flemmli97.flan.claim.ClaimStorage;
import com.flemmli97.flan.claim.EnumPermission; import com.flemmli97.flan.claim.EnumPermission;
import com.flemmli97.flan.claim.IPermissionContainer; import com.flemmli97.flan.claim.IPermissionContainer;

View File

@ -105,7 +105,7 @@ public class GroupPlayerScreenHandler extends ServerOnlyScreenHandler {
GameProfile prof = player.getServer().getUserCache().findByName(s); GameProfile prof = player.getServer().getUserCache().findByName(s);
boolean fl = prof == null || this.claim.setPlayerGroup(prof.getId(), this.group, false); boolean fl = prof == null || this.claim.setPlayerGroup(prof.getId(), this.group, false);
player.closeHandledScreen(); player.closeHandledScreen();
player.getServer().execute(() -> GroupPlayerScreenHandler.openPlayerGroupMenu(player, claim, group)); player.getServer().execute(() -> GroupPlayerScreenHandler.openPlayerGroupMenu(player, this.claim, this.group));
if (fl) if (fl)
ServerScreenHelper.playSongToPlayer(player, SoundEvents.BLOCK_ANVIL_USE, 1, 1f); ServerScreenHelper.playSongToPlayer(player, SoundEvents.BLOCK_ANVIL_USE, 1, 1f);
else { else {
@ -114,7 +114,7 @@ public class GroupPlayerScreenHandler extends ServerOnlyScreenHandler {
} }
}, () -> { }, () -> {
player.closeHandledScreen(); player.closeHandledScreen();
player.getServer().execute(() -> GroupPlayerScreenHandler.openPlayerGroupMenu(player, claim, group)); player.getServer().execute(() -> GroupPlayerScreenHandler.openPlayerGroupMenu(player, this.claim, this.group));
ServerScreenHelper.playSongToPlayer(player, SoundEvents.ENTITY_VILLAGER_NO, 1, 1f); ServerScreenHelper.playSongToPlayer(player, SoundEvents.ENTITY_VILLAGER_NO, 1, 1f);
})); }));
ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f);

View File

@ -83,7 +83,7 @@ public class PermissionScreenHandler extends ServerOnlyScreenHandler {
int row = i / 9 - 1; int row = i / 9 - 1;
int id = (i % 9) + row * 7 - 1 + page * 28; int id = (i % 9) + row * 7 - 1 + page * 28;
int length = EnumPermission.values().length; int length = EnumPermission.values().length;
if (group != null) if (this.group != null)
length -= EnumPermission.alwaysGlobalLength(); length -= EnumPermission.alwaysGlobalLength();
if (id < length) if (id < length)
inv.setStack(i, ServerScreenHelper.fromPermission((Claim) additionalData[0], EnumPermission.values()[id], additionalData[1] == null ? null : additionalData[1].toString())); inv.setStack(i, ServerScreenHelper.fromPermission((Claim) additionalData[0], EnumPermission.values()[id], additionalData[1] == null ? null : additionalData[1].toString()));
@ -117,7 +117,7 @@ public class PermissionScreenHandler extends ServerOnlyScreenHandler {
int row = i / 9 - 1; int row = i / 9 - 1;
int id = (i % 9) + row * 7 - 1 + this.page * 28; int id = (i % 9) + row * 7 - 1 + this.page * 28;
int length = EnumPermission.values().length; int length = EnumPermission.values().length;
if (group != null) if (this.group != null)
length -= EnumPermission.alwaysGlobalLength(); length -= EnumPermission.alwaysGlobalLength();
if (id < length) { if (id < length) {
this.slots.get(i).setStack(ServerScreenHelper.fromPermission(this.claim, EnumPermission.values()[id], this.group)); this.slots.get(i).setStack(ServerScreenHelper.fromPermission(this.claim, EnumPermission.values()[id], this.group));

View File

@ -122,7 +122,7 @@ public class StringResultScreenHandler extends AnvilScreenHandler {
@Override @Override
public void updateResult() { public void updateResult() {
if (!init) if (!this.init)
this.init = true; this.init = true;
else { else {
ItemStack out = this.slots.get(2).getStack(); ItemStack out = this.slots.get(2).getStack();

View File

@ -24,10 +24,10 @@ public abstract class ServerPlayNetworkHandlerMixin {
@Inject(method = "onPlayerInteractEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;interact(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;"), cancellable = true) @Inject(method = "onPlayerInteractEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;interact(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;"), cancellable = true)
public void onPlayerInteractEntity(PlayerInteractEntityC2SPacket packet, CallbackInfo info) { public void onPlayerInteractEntity(PlayerInteractEntityC2SPacket packet, CallbackInfo info) {
World world = player.getEntityWorld(); World world = this.player.getEntityWorld();
Entity entity = packet.getEntity(world); Entity entity = packet.getEntity(world);
if (entity != null) { if (entity != null) {
ActionResult result = EntityInteractEvents.useEntity(player, world, packet.getHand(), entity); ActionResult result = EntityInteractEvents.useEntity(this.player, world, packet.getHand(), entity);
if (result != ActionResult.PASS) { if (result != ActionResult.PASS) {
info.cancel(); info.cancel();
} }

View File

@ -57,7 +57,7 @@ public class ClaimDisplay {
public boolean display(ServerPlayerEntity player) { public boolean display(ServerPlayerEntity player) {
if (--this.displayTime % 2 == 0) if (--this.displayTime % 2 == 0)
return toDisplay.isRemoved(); return this.toDisplay.isRemoved();
int[] dims = this.toDisplay.getDimensions(); int[] dims = this.toDisplay.getDimensions();
if (this.poss == null || this.changed(dims)) { if (this.poss == null || this.changed(dims)) {
this.middlePoss = calculateDisplayPos(player.getServerWorld(), dims, this.height); this.middlePoss = calculateDisplayPos(player.getServerWorld(), dims, this.height);
@ -80,7 +80,7 @@ public class ClaimDisplay {
player.networkHandler.sendPacket(new ParticleS2CPacket(this.middle, true, pos[0] + 0.5, pos[1] + 0.25, pos[3] + 0.5, 0, 0.5f, 0, 0, 1)); player.networkHandler.sendPacket(new ParticleS2CPacket(this.middle, true, pos[0] + 0.5, pos[1] + 0.25, pos[3] + 0.5, 0, 0.5f, 0, 0, 1));
} }
this.prevDims = dims; this.prevDims = dims;
return toDisplay.isRemoved() || displayTime < 0; return this.toDisplay.isRemoved() || this.displayTime < 0;
} }
private boolean changed(int[] dims) { private boolean changed(int[] dims) {

View File

@ -190,8 +190,8 @@ public class PlayerClaimData {
} }
if (this.cornerRenderPos != null) { if (this.cornerRenderPos != null) {
if (this.cornerRenderPos[1] != this.cornerRenderPos[2]) if (this.cornerRenderPos[1] != this.cornerRenderPos[2])
player.networkHandler.sendPacket(new ParticleS2CPacket(ParticleIndicators.SETCORNER, true, this.cornerRenderPos[0] + 0.5, this.cornerRenderPos[2] + 0.25, this.cornerRenderPos[3] + 0.5, 0, 0.25f, 0, 0, 2)); this.player.networkHandler.sendPacket(new ParticleS2CPacket(ParticleIndicators.SETCORNER, true, this.cornerRenderPos[0] + 0.5, this.cornerRenderPos[2] + 0.25, this.cornerRenderPos[3] + 0.5, 0, 0.25f, 0, 0, 2));
player.networkHandler.sendPacket(new ParticleS2CPacket(ParticleIndicators.SETCORNER, true, this.cornerRenderPos[0] + 0.5, this.cornerRenderPos[1] + 0.25, this.cornerRenderPos[3] + 0.5, 0, 0.25f, 0, 0, 2)); this.player.networkHandler.sendPacket(new ParticleS2CPacket(ParticleIndicators.SETCORNER, true, this.cornerRenderPos[0] + 0.5, this.cornerRenderPos[1] + 0.25, this.cornerRenderPos[3] + 0.5, 0, 0.25f, 0, 0, 2));
} }
if (--this.confirmTick < 0) if (--this.confirmTick < 0)
this.confirmDeleteAll = false; this.confirmDeleteAll = false;