code cleanups
This commit is contained in:
parent
3c659c8d4a
commit
f0a1203f84
@ -79,7 +79,7 @@ public class Claim {
|
|||||||
this.setDirty(true);
|
this.setDirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void extendDownwards(BlockPos pos){
|
public void extendDownwards(BlockPos pos) {
|
||||||
this.minY = pos.getY();
|
this.minY = pos.getY();
|
||||||
this.setDirty(true);
|
this.setDirty(true);
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ public class Claim {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void toggleAdminClaim(ServerPlayerEntity player, boolean flag) {
|
public void toggleAdminClaim(ServerPlayerEntity player, boolean flag) {
|
||||||
if(!flag)
|
if (!flag)
|
||||||
this.transferOwner(player);
|
this.transferOwner(player);
|
||||||
else {
|
else {
|
||||||
this.owner = null;
|
this.owner = null;
|
||||||
@ -122,13 +122,13 @@ public class Claim {
|
|||||||
this.setDirty(true);
|
this.setDirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAdminClaim(){
|
public boolean isAdminClaim() {
|
||||||
return this.owner==null;
|
return this.owner == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transferOwner(ServerPlayerEntity player){
|
public void transferOwner(ServerPlayerEntity player) {
|
||||||
this.owner = player.getUuid();
|
this.owner = player.getUuid();
|
||||||
this.subClaims.forEach(claim->claim.owner = player.getUuid());
|
this.subClaims.forEach(claim -> claim.owner = player.getUuid());
|
||||||
this.setDirty(true);
|
this.setDirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,6 +337,7 @@ public class Claim {
|
|||||||
public boolean editPerms(ServerPlayerEntity player, String group, EnumPermission perm, int mode) {
|
public boolean editPerms(ServerPlayerEntity player, String group, EnumPermission perm, int mode) {
|
||||||
return this.editPerms(player, group, perm, mode, false);
|
return this.editPerms(player, group, perm, mode, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit the permissions for a group. If not defined for the group creates a new default permission map for that group
|
* Edit the permissions for a group. If not defined for the group creates a new default permission map for that group
|
||||||
*
|
*
|
||||||
@ -344,7 +345,7 @@ public class Claim {
|
|||||||
* @return If editing was successful or not
|
* @return If editing was successful or not
|
||||||
*/
|
*/
|
||||||
public boolean editPerms(ServerPlayerEntity player, String group, EnumPermission perm, int mode, boolean griefPrevention) {
|
public boolean editPerms(ServerPlayerEntity player, String group, EnumPermission perm, int mode, boolean griefPrevention) {
|
||||||
if(perm.isAlwaysGlobalPerm())
|
if (perm.isAlwaysGlobalPerm())
|
||||||
return false;
|
return false;
|
||||||
if (griefPrevention || this.canInteract(player, EnumPermission.EDITPERMS, player.getBlockPos())) {
|
if (griefPrevention || this.canInteract(player, EnumPermission.EDITPERMS, player.getBlockPos())) {
|
||||||
if (mode > 1)
|
if (mode > 1)
|
||||||
@ -394,7 +395,7 @@ public class Claim {
|
|||||||
* Only marks non sub claims
|
* Only marks non sub claims
|
||||||
*/
|
*/
|
||||||
public void setDirty(boolean flag) {
|
public void setDirty(boolean flag) {
|
||||||
if(this.parentClaim()!=null)
|
if (this.parentClaim() != null)
|
||||||
this.parentClaim().setDirty(flag);
|
this.parentClaim().setDirty(flag);
|
||||||
else
|
else
|
||||||
this.dirty = flag;
|
this.dirty = flag;
|
||||||
@ -412,7 +413,7 @@ public class Claim {
|
|||||||
this.minZ = pos.get(2).getAsInt();
|
this.minZ = pos.get(2).getAsInt();
|
||||||
this.maxZ = pos.get(3).getAsInt();
|
this.maxZ = pos.get(3).getAsInt();
|
||||||
this.minY = pos.get(4).getAsInt();
|
this.minY = pos.get(4).getAsInt();
|
||||||
if(obj.has("AdminClaim")?obj.get("AdminClaim").getAsBoolean():false)
|
if (obj.has("AdminClaim") ? obj.get("AdminClaim").getAsBoolean() : false)
|
||||||
this.owner = null;
|
this.owner = null;
|
||||||
else
|
else
|
||||||
this.owner = uuid;
|
this.owner = uuid;
|
||||||
@ -514,7 +515,7 @@ public class Claim {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("Claim:[ID=%s, Owner=%s, from: x=%d; z=%d, to: x=%d, z=%d", this.claimID != null ? this.claimID.toString() : "null", this.owner!=null?this.owner.toString():"Admin", this.minX, this.minZ, this.maxX, this.maxZ);
|
return String.format("Claim:[ID=%s, Owner=%s, from: x=%d; z=%d, to: x=%d, z=%d", this.claimID != null ? this.claimID.toString() : "null", this.owner != null ? this.owner.toString() : "Admin", this.minX, this.minZ, this.maxX, this.maxZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String formattedClaim() {
|
public String formattedClaim() {
|
||||||
@ -525,9 +526,9 @@ public class Claim {
|
|||||||
boolean perms = this.canInteract(player, EnumPermission.EDITPERMS, player.getBlockPos());
|
boolean perms = this.canInteract(player, EnumPermission.EDITPERMS, player.getBlockPos());
|
||||||
List<Text> l = Lists.newArrayList();
|
List<Text> l = Lists.newArrayList();
|
||||||
l.add(PermHelper.simpleColoredText("=============================================", Formatting.GREEN));
|
l.add(PermHelper.simpleColoredText("=============================================", Formatting.GREEN));
|
||||||
GameProfile prof = this.owner!=null?player.getServer().getUserCache().getByUuid(this.owner):null;
|
GameProfile prof = this.owner != null ? player.getServer().getUserCache().getByUuid(this.owner) : null;
|
||||||
String ownerName = this.isAdminClaim() ? "Admin" : prof != null ? prof.getName() : "<UNKNOWN>";
|
String ownerName = this.isAdminClaim() ? "Admin" : prof != null ? prof.getName() : "<UNKNOWN>";
|
||||||
if(this.parent==null)
|
if (this.parent == null)
|
||||||
l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBasicInfo, ownerName, this.minX, this.minZ, this.maxX, this.maxZ, this.subClaims.size()), Formatting.GOLD));
|
l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBasicInfo, ownerName, this.minX, this.minZ, this.maxX, this.maxZ, this.subClaims.size()), Formatting.GOLD));
|
||||||
else
|
else
|
||||||
l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBasicInfoSub, ownerName, this.minX, this.minZ, this.maxX, this.maxZ), Formatting.GOLD));
|
l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBasicInfoSub, ownerName, this.minX, this.minZ, this.maxX, this.maxZ), Formatting.GOLD));
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.flemmli97.flan.claim;
|
package com.flemmli97.flan.claim;
|
||||||
|
|
||||||
import com.flemmli97.flan.Flan;
|
|
||||||
import com.flemmli97.flan.IClaimData;
|
import com.flemmli97.flan.IClaimData;
|
||||||
import com.flemmli97.flan.config.ConfigHandler;
|
import com.flemmli97.flan.config.ConfigHandler;
|
||||||
import com.flemmli97.flan.player.EnumDisplayType;
|
import com.flemmli97.flan.player.EnumDisplayType;
|
||||||
@ -15,16 +14,12 @@ import com.google.gson.JsonObject;
|
|||||||
import com.ibm.icu.impl.Pair;
|
import com.ibm.icu.impl.Pair;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectArrayMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectArrayMap;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.command.LocateBiomeCommand;
|
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
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.text.BaseText;
|
|
||||||
import net.minecraft.text.ClickEvent;
|
import net.minecraft.text.ClickEvent;
|
||||||
import net.minecraft.text.HoverEvent;
|
import net.minecraft.text.HoverEvent;
|
||||||
import net.minecraft.text.LiteralText;
|
|
||||||
import net.minecraft.text.MutableText;
|
import net.minecraft.text.MutableText;
|
||||||
import net.minecraft.text.Text;
|
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.Formatting;
|
import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.util.WorldSavePath;
|
import net.minecraft.util.WorldSavePath;
|
||||||
@ -40,13 +35,11 @@ import java.io.FileReader;
|
|||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.EnumMap;
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
public class ClaimStorage {
|
public class ClaimStorage {
|
||||||
|
|
||||||
@ -55,6 +48,7 @@ public class ClaimStorage {
|
|||||||
private final Map<UUID, Claim> claimUUIDMap = Maps.newHashMap();
|
private final Map<UUID, Claim> claimUUIDMap = Maps.newHashMap();
|
||||||
private final Map<UUID, Set<Claim>> playerClaimMap = Maps.newHashMap();
|
private final Map<UUID, Set<Claim>> playerClaimMap = Maps.newHashMap();
|
||||||
private final Set<UUID> dirty = Sets.newHashSet();
|
private final Set<UUID> dirty = Sets.newHashSet();
|
||||||
|
|
||||||
public static ClaimStorage get(ServerWorld world) {
|
public static ClaimStorage get(ServerWorld world) {
|
||||||
return (ClaimStorage) ((IClaimData) world).getClaimData();
|
return (ClaimStorage) ((IClaimData) world).getClaimData();
|
||||||
}
|
}
|
||||||
@ -135,7 +129,7 @@ public class ClaimStorage {
|
|||||||
return this.claimUUIDMap.remove(claim.getClaimID()) != null;
|
return this.claimUUIDMap.remove(claim.getClaimID()) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleAdminClaim(ServerPlayerEntity player, Claim claim, boolean toggle){
|
public void toggleAdminClaim(ServerPlayerEntity player, Claim claim, boolean toggle) {
|
||||||
this.deleteClaim(claim, false, EnumEditMode.DEFAULT, player.getServerWorld());
|
this.deleteClaim(claim, false, EnumEditMode.DEFAULT, player.getServerWorld());
|
||||||
claim.toggleAdminClaim(player, toggle);
|
claim.toggleAdminClaim(player, toggle);
|
||||||
this.addClaim(claim);
|
this.addClaim(claim);
|
||||||
@ -200,7 +194,7 @@ public class ClaimStorage {
|
|||||||
return this.playerClaimMap.containsKey(player) ? ImmutableSet.copyOf(this.playerClaimMap.get(player)) : ImmutableSet.of();
|
return this.playerClaimMap.containsKey(player) ? ImmutableSet.copyOf(this.playerClaimMap.get(player)) : ImmutableSet.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<Claim> getAdminClaims(){
|
public Collection<Claim> getAdminClaims() {
|
||||||
return ImmutableSet.copyOf(this.playerClaimMap.get(null));
|
return ImmutableSet.copyOf(this.playerClaimMap.get(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +216,7 @@ public class ClaimStorage {
|
|||||||
if (!file.getName().endsWith(".json"))
|
if (!file.getName().endsWith(".json"))
|
||||||
continue;
|
continue;
|
||||||
String realName = file.getName().replace(".json", "");
|
String realName = file.getName().replace(".json", "");
|
||||||
UUID uuid = realName.equals(adminClaimString)?null:UUID.fromString(file.getName().replace(".json", ""));
|
UUID uuid = realName.equals(adminClaimString) ? null : UUID.fromString(file.getName().replace(".json", ""));
|
||||||
FileReader reader = new FileReader(file);
|
FileReader reader = new FileReader(file);
|
||||||
JsonArray arr = ConfigHandler.GSON.fromJson(reader, JsonArray.class);
|
JsonArray arr = ConfigHandler.GSON.fromJson(reader, JsonArray.class);
|
||||||
if (arr == null)
|
if (arr == null)
|
||||||
@ -246,7 +240,7 @@ public class ClaimStorage {
|
|||||||
dir.mkdir();
|
dir.mkdir();
|
||||||
try {
|
try {
|
||||||
for (Map.Entry<UUID, Set<Claim>> e : this.playerClaimMap.entrySet()) {
|
for (Map.Entry<UUID, Set<Claim>> e : this.playerClaimMap.entrySet()) {
|
||||||
String owner = e.getKey()==null?adminClaimString:e.getKey().toString();
|
String owner = e.getKey() == null ? adminClaimString : e.getKey().toString();
|
||||||
File file = new File(dir, owner + ".json");
|
File file = new File(dir, owner + ".json");
|
||||||
boolean dirty = false;
|
boolean dirty = false;
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
@ -255,11 +249,10 @@ public class ClaimStorage {
|
|||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
dirty = true;
|
dirty = true;
|
||||||
} else {
|
} else {
|
||||||
if(this.dirty.contains(owner.equals(adminClaimString)?null:e.getKey())) {
|
if (this.dirty.contains(owner.equals(adminClaimString) ? null : e.getKey())) {
|
||||||
dirty = true;
|
dirty = true;
|
||||||
this.dirty.clear();
|
this.dirty.clear();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
for (Claim claim : e.getValue())
|
for (Claim claim : e.getValue())
|
||||||
if (claim.isDirty()) {
|
if (claim.isDirty()) {
|
||||||
dirty = true;
|
dirty = true;
|
||||||
@ -315,8 +308,7 @@ public class ClaimStorage {
|
|||||||
if (values.get("Parent Claim ID").equals(-1)) {
|
if (values.get("Parent Claim ID").equals(-1)) {
|
||||||
try {
|
try {
|
||||||
intFileMap.put(Integer.valueOf(f.getName().replace(".yml", "")), f);
|
intFileMap.put(Integer.valueOf(f.getName().replace(".yml", "")), f);
|
||||||
}
|
} catch (NumberFormatException e) {
|
||||||
catch (NumberFormatException e){
|
|
||||||
src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.errorFile, f.getName(), Formatting.RED)), false);
|
src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.errorFile, f.getName(), Formatting.RED)), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -351,15 +343,14 @@ public class ClaimStorage {
|
|||||||
storage.addClaim(parentClaim.second);
|
storage.addClaim(parentClaim.second);
|
||||||
} else {
|
} else {
|
||||||
src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.readConflict, parent.getName(), conflicts), Formatting.DARK_RED), false);
|
src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.readConflict, parent.getName(), conflicts), Formatting.DARK_RED), false);
|
||||||
for(Claim claim : conflicts){
|
for (Claim claim : conflicts) {
|
||||||
int[] dim = claim.getDimensions();
|
int[] dim = claim.getDimensions();
|
||||||
MutableText text = PermHelper.simpleColoredText(String.format("@[x=%d;z=%d]", dim[0], dim[2]), Formatting.RED);
|
MutableText text = PermHelper.simpleColoredText(String.format("@[x=%d;z=%d]", dim[0], dim[2]), Formatting.RED);
|
||||||
text.setStyle(text.getStyle().withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/tp @s " + dim[0] + " ~ " + dim[2])).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("chat.coordinates.tooltip"))));
|
text.setStyle(text.getStyle().withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/tp @s " + dim[0] + " ~ " + dim[2])).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("chat.coordinates.tooltip"))));
|
||||||
src.sendFeedback(text, false);
|
src.sendFeedback(text, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e){
|
|
||||||
src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.errorFile, parent.getName(), Formatting.RED)), false);
|
src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.errorFile, parent.getName(), Formatting.RED)), false);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -376,7 +367,7 @@ public class ClaimStorage {
|
|||||||
reader.close();
|
reader.close();
|
||||||
String ownerString = (String) values.get("Owner");
|
String ownerString = (String) values.get("Owner");
|
||||||
|
|
||||||
UUID owner = ownerString.isEmpty()?null:UUID.fromString(ownerString);
|
UUID owner = ownerString.isEmpty() ? null : UUID.fromString(ownerString);
|
||||||
List<String> builders = readList(values, "Builders");
|
List<String> builders = readList(values, "Builders");
|
||||||
List<String> managers = readList(values, "Managers");
|
List<String> managers = readList(values, "Managers");
|
||||||
List<String> containers = readList(values, "Containers");
|
List<String> containers = readList(values, "Containers");
|
||||||
@ -385,52 +376,48 @@ public class ClaimStorage {
|
|||||||
String[] greaterCorner = values.get("Greater Boundary Corner").toString().split(";");
|
String[] greaterCorner = values.get("Greater Boundary Corner").toString().split(";");
|
||||||
ServerWorld world = server.getWorld(worldRegFromString(lesserCorner[0]));
|
ServerWorld world = server.getWorld(worldRegFromString(lesserCorner[0]));
|
||||||
Claim claim = new Claim(Integer.parseInt(lesserCorner[1]), Integer.parseInt(greaterCorner[1]),
|
Claim claim = new Claim(Integer.parseInt(lesserCorner[1]), Integer.parseInt(greaterCorner[1]),
|
||||||
Integer.parseInt(lesserCorner[3]), Integer.parseInt(greaterCorner[3]), ConfigHandler.config.defaultClaimDepth == 255?0:
|
Integer.parseInt(lesserCorner[3]), Integer.parseInt(greaterCorner[3]), ConfigHandler.config.defaultClaimDepth == 255 ? 0 :
|
||||||
Integer.parseInt(lesserCorner[2]), owner, world);
|
Integer.parseInt(lesserCorner[2]), owner, world);
|
||||||
if(!builders.isEmpty() && !builders.contains(ownerString)) {
|
if (!builders.isEmpty() && !builders.contains(ownerString)) {
|
||||||
if(builders.contains("public")){
|
if (builders.contains("public")) {
|
||||||
perms.get("builders").forEach(perm -> {
|
perms.get("builders").forEach(perm -> {
|
||||||
if(!perm.isAlwaysGlobalPerm())
|
if (!perm.isAlwaysGlobalPerm())
|
||||||
claim.editGlobalPerms(perm, 1);
|
claim.editGlobalPerms(perm, 1);
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
perms.get("builders").forEach(perm -> claim.editPerms(null, "Builders", perm, 1, true));
|
perms.get("builders").forEach(perm -> claim.editPerms(null, "Builders", perm, 1, true));
|
||||||
builders.forEach(s -> claim.setPlayerGroup(UUID.fromString(s), "Builders", true));
|
builders.forEach(s -> claim.setPlayerGroup(UUID.fromString(s), "Builders", true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!managers.isEmpty() && !managers.contains(ownerString)) {
|
if (!managers.isEmpty() && !managers.contains(ownerString)) {
|
||||||
if(managers.contains("public")){
|
if (managers.contains("public")) {
|
||||||
perms.get("managers").forEach(perm -> {
|
perms.get("managers").forEach(perm -> {
|
||||||
if(!perm.isAlwaysGlobalPerm())
|
if (!perm.isAlwaysGlobalPerm())
|
||||||
claim.editGlobalPerms(perm, 1);
|
claim.editGlobalPerms(perm, 1);
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
perms.get("managers").forEach(perm -> claim.editPerms(null, "Managers", perm, 1, true));
|
perms.get("managers").forEach(perm -> claim.editPerms(null, "Managers", perm, 1, true));
|
||||||
managers.forEach(s -> claim.setPlayerGroup(UUID.fromString(s), "Managers", true));
|
managers.forEach(s -> claim.setPlayerGroup(UUID.fromString(s), "Managers", true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!containers.isEmpty() && !containers.contains(ownerString)) {
|
if (!containers.isEmpty() && !containers.contains(ownerString)) {
|
||||||
if(containers.contains("public")){
|
if (containers.contains("public")) {
|
||||||
perms.get("containers").forEach(perm -> {
|
perms.get("containers").forEach(perm -> {
|
||||||
if(!perm.isAlwaysGlobalPerm())
|
if (!perm.isAlwaysGlobalPerm())
|
||||||
claim.editGlobalPerms(perm, 1);
|
claim.editGlobalPerms(perm, 1);
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
perms.get("containers").forEach(perm -> claim.editPerms(null, "Containers", perm, 1, true));
|
perms.get("containers").forEach(perm -> claim.editPerms(null, "Containers", perm, 1, true));
|
||||||
containers.forEach(s -> claim.setPlayerGroup(UUID.fromString(s), "Containers", true));
|
containers.forEach(s -> claim.setPlayerGroup(UUID.fromString(s), "Containers", true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!accessors.isEmpty() && !accessors.contains(ownerString)) {
|
if (!accessors.isEmpty() && !accessors.contains(ownerString)) {
|
||||||
if(accessors.contains("public")){
|
if (accessors.contains("public")) {
|
||||||
perms.get("accessors").forEach(perm -> {
|
perms.get("accessors").forEach(perm -> {
|
||||||
if(!perm.isAlwaysGlobalPerm())
|
if (!perm.isAlwaysGlobalPerm())
|
||||||
claim.editGlobalPerms(perm, 1);
|
claim.editGlobalPerms(perm, 1);
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
perms.get("accessors").forEach(perm -> claim.editPerms(null, "Accessors", perm, 1, true));
|
perms.get("accessors").forEach(perm -> claim.editPerms(null, "Accessors", perm, 1, true));
|
||||||
accessors.forEach(s -> claim.setPlayerGroup(UUID.fromString(s), "Accessors", true));
|
accessors.forEach(s -> claim.setPlayerGroup(UUID.fromString(s), "Accessors", true));
|
||||||
}
|
}
|
||||||
@ -438,9 +425,9 @@ public class ClaimStorage {
|
|||||||
return Pair.of(world, claim);
|
return Pair.of(world, claim);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> List<T> readList(Map<String, Object> values, String key){
|
private static <T> List<T> readList(Map<String, Object> values, String key) {
|
||||||
Object obj = values.get(key);
|
Object obj = values.get(key);
|
||||||
if(obj instanceof List)
|
if (obj instanceof List)
|
||||||
return (List<T>) obj;
|
return (List<T>) obj;
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
|
@ -58,16 +58,16 @@ public enum EnumPermission {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItem() {
|
public ItemStack getItem() {
|
||||||
if(this==RAID)
|
if (this == RAID)
|
||||||
return Raid.getOminousBanner();
|
return Raid.getOminousBanner();
|
||||||
return new ItemStack(this.item);
|
return new ItemStack(this.item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAlwaysGlobalPerm(){
|
public boolean isAlwaysGlobalPerm() {
|
||||||
return alwaysGlobal.contains(this);
|
return alwaysGlobal.contains(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int alwaysGlobalLength(){
|
public static int alwaysGlobalLength() {
|
||||||
return alwaysGlobal.size();
|
return alwaysGlobal.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import net.minecraft.server.network.ServerPlayerEntity;
|
|||||||
import net.minecraft.text.LiteralText;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.text.MutableText;
|
import net.minecraft.text.MutableText;
|
||||||
import net.minecraft.text.Style;
|
import net.minecraft.text.Style;
|
||||||
import net.minecraft.text.Text;
|
|
||||||
import net.minecraft.util.Formatting;
|
import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
@ -15,12 +15,10 @@ import com.google.common.collect.Maps;
|
|||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.brigadier.Command;
|
import com.mojang.brigadier.Command;
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.arguments.ArgumentType;
|
|
||||||
import com.mojang.brigadier.arguments.BoolArgumentType;
|
import com.mojang.brigadier.arguments.BoolArgumentType;
|
||||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
import com.mojang.brigadier.builder.ArgumentBuilder;
|
import com.mojang.brigadier.builder.ArgumentBuilder;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import com.mojang.brigadier.suggestion.Suggestions;
|
import com.mojang.brigadier.suggestion.Suggestions;
|
||||||
@ -40,7 +38,6 @@ import net.minecraft.world.World;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@ -55,7 +52,7 @@ public class CommandClaim {
|
|||||||
CommandManager.literal("deleteAll").executes(CommandClaim::deleteAllClaim),
|
CommandManager.literal("deleteAll").executes(CommandClaim::deleteAllClaim),
|
||||||
CommandManager.literal("deleteSubClaim").executes(CommandClaim::deleteSubClaim),
|
CommandManager.literal("deleteSubClaim").executes(CommandClaim::deleteSubClaim),
|
||||||
CommandManager.literal("deleteAllSubClaims").executes(CommandClaim::deleteAllSubClaim),
|
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)).executes(cmd->listClaims(cmd, GameProfileArgumentType.getProfileArgument(cmd, "player")))),
|
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")))),
|
||||||
CommandManager.literal("switchMode").executes(CommandClaim::switchClaimMode),
|
CommandManager.literal("switchMode").executes(CommandClaim::switchClaimMode),
|
||||||
CommandManager.literal("adminMode").requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel)).executes(CommandClaim::switchAdminMode),
|
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),
|
CommandManager.literal("readGriefPrevention").requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel)).executes(CommandClaim::readGriefPreventionData),
|
||||||
@ -89,9 +86,9 @@ public class CommandClaim {
|
|||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <S, T extends ArgumentBuilder<S,T>> T addToMainCommand(T main, ArgumentBuilder<S,T>... other) {
|
private static <S, T extends ArgumentBuilder<S, T>> T addToMainCommand(T main, ArgumentBuilder<S, T>... other) {
|
||||||
if (other != null)
|
if (other != null)
|
||||||
for (ArgumentBuilder<S,T> o : other)
|
for (ArgumentBuilder<S, T> o : other)
|
||||||
main.then(o);
|
main.then(o);
|
||||||
return main;
|
return main;
|
||||||
}
|
}
|
||||||
@ -224,30 +221,29 @@ public class CommandClaim {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static int listClaims(CommandContext<ServerCommandSource> context, Collection<GameProfile> profs) throws CommandSyntaxException {
|
private static int listClaims(CommandContext<ServerCommandSource> context, Collection<GameProfile> profs) throws CommandSyntaxException {
|
||||||
if(profs.size()!=1) {
|
if (profs.size() != 1) {
|
||||||
context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.onlyOnePlayer, Formatting.RED), false);
|
context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.onlyOnePlayer, Formatting.RED), false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
GameProfile prof = profs.iterator().next();
|
GameProfile prof = profs.iterator().next();
|
||||||
if(prof == null || prof.getId()==null)
|
if (prof == null || prof.getId() == null)
|
||||||
return 0;
|
return 0;
|
||||||
return listClaimsFromUUID(context, prof.getId());
|
return listClaimsFromUUID(context, prof.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int listClaimsFromUUID(CommandContext<ServerCommandSource> context, UUID of) throws CommandSyntaxException {
|
private static int listClaimsFromUUID(CommandContext<ServerCommandSource> context, UUID of) throws CommandSyntaxException {
|
||||||
MinecraftServer server = context.getSource().getMinecraftServer();
|
MinecraftServer server = context.getSource().getMinecraftServer();
|
||||||
ServerPlayerEntity player = of==null?context.getSource().getPlayer():server.getPlayerManager().getPlayer(of);
|
ServerPlayerEntity player = of == null ? context.getSource().getPlayer() : server.getPlayerManager().getPlayer(of);
|
||||||
Map<World, Collection<Claim>> claims = Maps.newHashMap();
|
Map<World, Collection<Claim>> claims = Maps.newHashMap();
|
||||||
for (ServerWorld world : server.getWorlds()) {
|
for (ServerWorld world : server.getWorlds()) {
|
||||||
ClaimStorage storage = ClaimStorage.get(world);
|
ClaimStorage storage = ClaimStorage.get(world);
|
||||||
claims.put(world, storage.allClaimsFromPlayer(player!=null?player.getUuid():of));
|
claims.put(world, storage.allClaimsFromPlayer(player != null ? player.getUuid() : of));
|
||||||
}
|
}
|
||||||
if(player!=null) {
|
if (player != null) {
|
||||||
PlayerClaimData data = PlayerClaimData.get(player);
|
PlayerClaimData data = PlayerClaimData.get(player);
|
||||||
context.getSource().sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBlocksFormat,
|
context.getSource().sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBlocksFormat,
|
||||||
data.getClaimBlocks(), data.getAdditionalClaims(), data.usedClaimBlocks()), Formatting.GOLD), false);
|
data.getClaimBlocks(), data.getAdditionalClaims(), data.usedClaimBlocks()), Formatting.GOLD), false);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
OfflinePlayerData data = new OfflinePlayerData(server, of);
|
OfflinePlayerData data = new OfflinePlayerData(server, of);
|
||||||
context.getSource().sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBlocksFormat,
|
context.getSource().sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBlocksFormat,
|
||||||
data.claimBlocks, data.additionalClaimBlocks, data.getUsedClaimBlocks(server)), Formatting.GOLD), false);
|
data.claimBlocks, data.additionalClaimBlocks, data.getUsedClaimBlocks(server)), Formatting.GOLD), false);
|
||||||
|
@ -66,7 +66,7 @@ public class Config {
|
|||||||
this.claimingItem = Registry.ITEM.get(new Identifier((obj.get("claimingItem").getAsString())));
|
this.claimingItem = Registry.ITEM.get(new Identifier((obj.get("claimingItem").getAsString())));
|
||||||
this.inspectionItem = Registry.ITEM.get(new Identifier((obj.get("inspectionItem").getAsString())));
|
this.inspectionItem = Registry.ITEM.get(new Identifier((obj.get("inspectionItem").getAsString())));
|
||||||
this.claimDisplayTime = obj.get("claimDisplayTime").getAsInt();
|
this.claimDisplayTime = obj.get("claimDisplayTime").getAsInt();
|
||||||
if(obj.has("permissionLevel"))
|
if (obj.has("permissionLevel"))
|
||||||
this.permissionLevel = obj.get("permissionLevel").getAsInt();
|
this.permissionLevel = obj.get("permissionLevel").getAsInt();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -32,7 +32,6 @@ import net.minecraft.util.hit.HitResult;
|
|||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import java.security.Permission;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class ItemInteractEvents {
|
public class ItemInteractEvents {
|
||||||
@ -77,28 +76,27 @@ public class ItemInteractEvents {
|
|||||||
return ActionResult.PASS;
|
return ActionResult.PASS;
|
||||||
ClaimStorage storage = ClaimStorage.get((ServerWorld) context.getWorld());
|
ClaimStorage storage = ClaimStorage.get((ServerWorld) context.getWorld());
|
||||||
BlockPos placePos = new ItemPlacementContext(context).getBlockPos();
|
BlockPos placePos = new ItemPlacementContext(context).getBlockPos();
|
||||||
Claim claim = storage.getClaimAt(placePos.add(0,255,0));
|
Claim claim = storage.getClaimAt(placePos.add(0, 255, 0));
|
||||||
if (claim == null)
|
if (claim == null)
|
||||||
return ActionResult.PASS;
|
return ActionResult.PASS;
|
||||||
if (blackListedItems.contains(context.getStack().getItem()))
|
if (blackListedItems.contains(context.getStack().getItem()))
|
||||||
return ActionResult.PASS;
|
return ActionResult.PASS;
|
||||||
boolean actualInClaim = placePos.getY()>=claim.getDimensions()[4];
|
boolean actualInClaim = placePos.getY() >= claim.getDimensions()[4];
|
||||||
ServerPlayerEntity player = (ServerPlayerEntity) context.getPlayer();
|
ServerPlayerEntity player = (ServerPlayerEntity) context.getPlayer();
|
||||||
if (context.getStack().getItem() == Items.END_CRYSTAL) {
|
if (context.getStack().getItem() == Items.END_CRYSTAL) {
|
||||||
if (claim.canInteract(player, EnumPermission.ENDCRYSTALPLACE, placePos, false))
|
if (claim.canInteract(player, EnumPermission.ENDCRYSTALPLACE, placePos, false))
|
||||||
return ActionResult.PASS;
|
return ActionResult.PASS;
|
||||||
else if(actualInClaim) {
|
else if (actualInClaim) {
|
||||||
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, Formatting.DARK_RED), true);
|
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, Formatting.DARK_RED), true);
|
||||||
return ActionResult.FAIL;
|
return ActionResult.FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (claim.canInteract(player, EnumPermission.PLACE, placePos, false)) {
|
if (claim.canInteract(player, EnumPermission.PLACE, placePos, false)) {
|
||||||
if(!actualInClaim && context.getStack().getItem() instanceof BlockItem){
|
if (!actualInClaim && context.getStack().getItem() instanceof BlockItem) {
|
||||||
claim.extendDownwards(placePos);
|
claim.extendDownwards(placePos);
|
||||||
}
|
}
|
||||||
return ActionResult.PASS;
|
return ActionResult.PASS;
|
||||||
}
|
} else if (actualInClaim) {
|
||||||
else if(actualInClaim) {
|
|
||||||
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, Formatting.DARK_RED), true);
|
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, Formatting.DARK_RED), true);
|
||||||
BlockState other = context.getWorld().getBlockState(placePos.up());
|
BlockState other = context.getWorld().getBlockState(placePos.up());
|
||||||
player.networkHandler.sendPacket(new BlockUpdateS2CPacket(placePos.up(), other));
|
player.networkHandler.sendPacket(new BlockUpdateS2CPacket(placePos.up(), other));
|
||||||
@ -128,9 +126,9 @@ public class ItemInteractEvents {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ClaimStorage storage = ClaimStorage.get(player.getServerWorld());
|
ClaimStorage storage = ClaimStorage.get(player.getServerWorld());
|
||||||
Claim claim = storage.getClaimAt(target.add(0,255,0));
|
Claim claim = storage.getClaimAt(target.add(0, 255, 0));
|
||||||
PlayerClaimData data = PlayerClaimData.get(player);
|
PlayerClaimData data = PlayerClaimData.get(player);
|
||||||
if(data.claimCooldown())
|
if (data.claimCooldown())
|
||||||
return;
|
return;
|
||||||
data.setClaimActionCooldown();
|
data.setClaimActionCooldown();
|
||||||
if (claim != null) {
|
if (claim != null) {
|
||||||
@ -148,7 +146,7 @@ public class ItemInteractEvents {
|
|||||||
data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY());
|
data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY());
|
||||||
} else {
|
} else {
|
||||||
if (data.currentEdit() != null) {
|
if (data.currentEdit() != null) {
|
||||||
if(!data.editingCorner().equals(target)) {
|
if (!data.editingCorner().equals(target)) {
|
||||||
Set<Claim> fl = claim.resizeSubclaim(data.currentEdit(), data.editingCorner(), target);
|
Set<Claim> fl = claim.resizeSubclaim(data.currentEdit(), data.editingCorner(), target);
|
||||||
if (!fl.isEmpty()) {
|
if (!fl.isEmpty()) {
|
||||||
fl.forEach(confl -> data.addDisplayClaim(confl, EnumDisplayType.MAIN, player.getBlockPos().getY()));
|
fl.forEach(confl -> data.addDisplayClaim(confl, EnumDisplayType.MAIN, player.getBlockPos().getY()));
|
||||||
@ -158,7 +156,7 @@ public class ItemInteractEvents {
|
|||||||
data.setEditingCorner(null);
|
data.setEditingCorner(null);
|
||||||
}
|
}
|
||||||
} else if (data.editingCorner() != null) {
|
} else if (data.editingCorner() != null) {
|
||||||
if(!data.editingCorner().equals(target)) {
|
if (!data.editingCorner().equals(target)) {
|
||||||
Set<Claim> fl = claim.tryCreateSubClaim(data.editingCorner(), target);
|
Set<Claim> fl = claim.tryCreateSubClaim(data.editingCorner(), target);
|
||||||
data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY());
|
data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY());
|
||||||
if (!fl.isEmpty()) {
|
if (!fl.isEmpty()) {
|
||||||
|
@ -62,16 +62,16 @@ public class WorldEvents {
|
|||||||
return fl;
|
return fl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canStartRaid(ServerPlayerEntity player){
|
public static boolean canStartRaid(ServerPlayerEntity player) {
|
||||||
Claim claim = ClaimStorage.get(player.getServerWorld()).getClaimAt(player.getBlockPos());
|
Claim claim = ClaimStorage.get(player.getServerWorld()).getClaimAt(player.getBlockPos());
|
||||||
if(claim!=null && !claim.canInteract(player, EnumPermission.RAID, player.getBlockPos()))
|
if (claim != null && !claim.canInteract(player, EnumPermission.RAID, player.getBlockPos()))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canFireSpread(ServerWorld world, BlockPos pos){
|
public static boolean canFireSpread(ServerWorld world, BlockPos pos) {
|
||||||
Claim claim = ClaimStorage.get(world).getClaimAt(pos);
|
Claim claim = ClaimStorage.get(world).getClaimAt(pos);
|
||||||
if(claim!=null && !claim.canInteract(null, EnumPermission.FIRESPREAD, pos))
|
if (claim != null && !claim.canInteract(null, EnumPermission.FIRESPREAD, pos))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -83,8 +83,8 @@ 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 (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,12 +117,11 @@ 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 (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));
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
this.slots.get(i).setStack(ItemStack.EMPTY);
|
this.slots.get(i).setStack(ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,16 +26,16 @@ public abstract class FireBlockMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "getBurnChance(Lnet/minecraft/world/WorldView;Lnet/minecraft/util/math/BlockPos;)I", at = @At(value = "HEAD"), cancellable = true)
|
@Inject(method = "getBurnChance(Lnet/minecraft/world/WorldView;Lnet/minecraft/util/math/BlockPos;)I", at = @At(value = "HEAD"), cancellable = true)
|
||||||
public void burn(WorldView worldView, BlockPos pos, CallbackInfoReturnable<Integer> info){
|
public void burn(WorldView worldView, BlockPos pos, CallbackInfoReturnable<Integer> info) {
|
||||||
if(worldView instanceof ServerWorld && !WorldEvents.canFireSpread((ServerWorld) worldView, pos)){
|
if (worldView instanceof ServerWorld && !WorldEvents.canFireSpread((ServerWorld) worldView, pos)) {
|
||||||
info.setReturnValue(0);
|
info.setReturnValue(0);
|
||||||
info.cancel();
|
info.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "trySpreadingFire", at = @At(value = "HEAD"), cancellable = true)
|
@Inject(method = "trySpreadingFire", at = @At(value = "HEAD"), cancellable = true)
|
||||||
public void spread(World world, BlockPos pos, int spreadFactor, Random rand, int currentAge, CallbackInfo info){
|
public void spread(World world, BlockPos pos, int spreadFactor, Random rand, int currentAge, CallbackInfo info) {
|
||||||
if(!world.isClient && !WorldEvents.canFireSpread((ServerWorld) world, pos)){
|
if (!world.isClient && !WorldEvents.canFireSpread((ServerWorld) world, pos)) {
|
||||||
info.cancel();
|
info.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||||||
public class RaidManagerMixin {
|
public class RaidManagerMixin {
|
||||||
|
|
||||||
@Inject(method = "startRaid", at = @At(value = "HEAD"), cancellable = true)
|
@Inject(method = "startRaid", at = @At(value = "HEAD"), cancellable = true)
|
||||||
public void checkRaid(ServerPlayerEntity player, CallbackInfoReturnable<Raid> info){
|
public void checkRaid(ServerPlayerEntity player, CallbackInfoReturnable<Raid> info) {
|
||||||
if(!WorldEvents.canStartRaid(player)){
|
if (!WorldEvents.canStartRaid(player)) {
|
||||||
info.setReturnValue(null);
|
info.setReturnValue(null);
|
||||||
info.cancel();
|
info.cancel();
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,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 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)) {
|
||||||
@ -69,13 +69,13 @@ public class ClaimDisplay {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
for (int[] pos : this.poss) {
|
for (int[] pos : this.poss) {
|
||||||
if(pos[1]!=pos[2])
|
if (pos[1] != pos[2])
|
||||||
player.networkHandler.sendPacket(new ParticleS2CPacket(this.corner, true, pos[0] + 0.5, pos[2] + 0.25, pos[3] + 0.5, 0, 0.5f, 0, 0, 1));
|
player.networkHandler.sendPacket(new ParticleS2CPacket(this.corner, true, pos[0] + 0.5, pos[2] + 0.25, pos[3] + 0.5, 0, 0.5f, 0, 0, 1));
|
||||||
player.networkHandler.sendPacket(new ParticleS2CPacket(this.corner, 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.corner, true, pos[0] + 0.5, pos[1] + 0.25, pos[3] + 0.5, 0, 0.5f, 0, 0, 1));
|
||||||
}
|
}
|
||||||
if (this.middlePoss != null)
|
if (this.middlePoss != null)
|
||||||
for (int[] pos : this.middlePoss) {
|
for (int[] pos : this.middlePoss) {
|
||||||
if(pos[1]!=pos[2])
|
if (pos[1] != pos[2])
|
||||||
player.networkHandler.sendPacket(new ParticleS2CPacket(this.middle, true, pos[0] + 0.5, pos[2] + 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[2] + 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));
|
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));
|
||||||
}
|
}
|
||||||
@ -156,14 +156,14 @@ public class ClaimDisplay {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
int[] yRet = new int[]{pos.getY(), pos.getY()};
|
int[] yRet = new int[]{pos.getY(), pos.getY()};
|
||||||
if(state.getMaterial().isLiquid()){
|
if (state.getMaterial().isLiquid()) {
|
||||||
pos = pos.up();
|
pos = pos.up();
|
||||||
state = world.getBlockState(pos);
|
state = world.getBlockState(pos);
|
||||||
while (state.getMaterial().isLiquid()) {
|
while (state.getMaterial().isLiquid()) {
|
||||||
pos = pos.up();
|
pos = pos.up();
|
||||||
state = world.getBlockState(pos);
|
state = world.getBlockState(pos);
|
||||||
}
|
}
|
||||||
if(state.getMaterial().isReplaceable())
|
if (state.getMaterial().isReplaceable())
|
||||||
yRet[1] = pos.getY();
|
yRet[1] = pos.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,8 @@ public class OfflinePlayerData {
|
|||||||
|
|
||||||
public final int claimBlocks, additionalClaimBlocks;
|
public final int claimBlocks, additionalClaimBlocks;
|
||||||
public final UUID owner;
|
public final UUID owner;
|
||||||
public OfflinePlayerData(MinecraftServer server, UUID uuid){
|
|
||||||
|
public OfflinePlayerData(MinecraftServer server, UUID uuid) {
|
||||||
File dir = new File(server.getSavePath(WorldSavePath.PLAYERDATA).toFile(), "/claimData/");
|
File dir = new File(server.getSavePath(WorldSavePath.PLAYERDATA).toFile(), "/claimData/");
|
||||||
int claim = ConfigHandler.config.startingBlocks;
|
int claim = ConfigHandler.config.startingBlocks;
|
||||||
int add = 0;
|
int add = 0;
|
||||||
@ -41,12 +42,12 @@ public class OfflinePlayerData {
|
|||||||
this.additionalClaimBlocks = add;
|
this.additionalClaimBlocks = add;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getUsedClaimBlocks(MinecraftServer server){
|
public int getUsedClaimBlocks(MinecraftServer server) {
|
||||||
int usedClaimsBlocks = 0;
|
int usedClaimsBlocks = 0;
|
||||||
for (ServerWorld world : server.getWorlds()) {
|
for (ServerWorld world : server.getWorlds()) {
|
||||||
Collection<Claim> claims = ClaimStorage.get(world).allClaimsFromPlayer(this.owner);
|
Collection<Claim> claims = ClaimStorage.get(world).allClaimsFromPlayer(this.owner);
|
||||||
if (claims != null)
|
if (claims != null)
|
||||||
usedClaimsBlocks += claims.stream().filter(claim->!claim.isAdminClaim()).mapToInt(Claim::getPlane).sum();
|
usedClaimsBlocks += claims.stream().filter(claim -> !claim.isAdminClaim()).mapToInt(Claim::getPlane).sum();
|
||||||
}
|
}
|
||||||
return usedClaimsBlocks;
|
return usedClaimsBlocks;
|
||||||
}
|
}
|
||||||
|
@ -97,12 +97,12 @@ public class PlayerClaimData {
|
|||||||
* block onUse -> item use. Might be a better way but for now this. But also handles having
|
* block onUse -> item use. Might be a better way but for now this. But also handles having
|
||||||
* same items on both hands triggering
|
* same items on both hands triggering
|
||||||
*/
|
*/
|
||||||
public void setClaimActionCooldown(){
|
public void setClaimActionCooldown() {
|
||||||
this.actionCooldown = 10;
|
this.actionCooldown = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean claimCooldown(){
|
public boolean claimCooldown() {
|
||||||
return this.actionCooldown>0;
|
return this.actionCooldown > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Claim currentEdit() {
|
public Claim currentEdit() {
|
||||||
@ -146,8 +146,7 @@ public class PlayerClaimData {
|
|||||||
state = this.player.world.getBlockState(pos);
|
state = this.player.world.getBlockState(pos);
|
||||||
}
|
}
|
||||||
this.cornerRenderPos = ClaimDisplay.getPosFrom(this.player.getServerWorld(), pos.getX(), pos.getZ(), pos.getY());
|
this.cornerRenderPos = ClaimDisplay.getPosFrom(this.player.getServerWorld(), pos.getX(), pos.getZ(), pos.getY());
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
this.cornerRenderPos = null;
|
this.cornerRenderPos = null;
|
||||||
this.firstCorner = pos;
|
this.firstCorner = pos;
|
||||||
}
|
}
|
||||||
@ -183,7 +182,7 @@ public class PlayerClaimData {
|
|||||||
this.lastBlockTick = 0;
|
this.lastBlockTick = 0;
|
||||||
}
|
}
|
||||||
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));
|
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));
|
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));
|
||||||
}
|
}
|
||||||
@ -265,7 +264,7 @@ public class PlayerClaimData {
|
|||||||
for (ServerWorld world : this.player.getServer().getWorlds()) {
|
for (ServerWorld world : this.player.getServer().getWorlds()) {
|
||||||
Collection<Claim> claims = ClaimStorage.get(world).allClaimsFromPlayer(this.player.getUuid());
|
Collection<Claim> claims = ClaimStorage.get(world).allClaimsFromPlayer(this.player.getUuid());
|
||||||
if (claims != null)
|
if (claims != null)
|
||||||
usedClaimsBlocks += claims.stream().filter(claim->!claim.isAdminClaim()).mapToInt(Claim::getPlane).sum();
|
usedClaimsBlocks += claims.stream().filter(claim -> !claim.isAdminClaim()).mapToInt(Claim::getPlane).sum();
|
||||||
}
|
}
|
||||||
return usedClaimsBlocks;
|
return usedClaimsBlocks;
|
||||||
}
|
}
|
||||||
@ -305,8 +304,7 @@ public class PlayerClaimData {
|
|||||||
}
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e){
|
|
||||||
src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.errorFile, f.getName(), Formatting.RED)), false);
|
src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.errorFile, f.getName(), Formatting.RED)), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user