mirror of
https://github.com/CivMC/Civ.git
synced 2026-07-15 23:20:44 +00:00
add reinforcement decay close to border
This commit is contained in:
@@ -18,7 +18,7 @@ debug: true
|
||||
|
||||
#Still used in calculating the localized decay. The difference is localized decay uses different last activity timers for each region.
|
||||
global_decay_timer: 6 weeks
|
||||
global_decay_multiplier: 2.0
|
||||
global_decay_multiplier: 2.5
|
||||
|
||||
reinforcements:
|
||||
stone:
|
||||
@@ -349,7 +349,9 @@ world-border-buffers:
|
||||
#'CIRCLE' or 'SQUARE' supported only
|
||||
shape: CIRCLE
|
||||
#Radius from border center you want the no reinforcement zone to kick in
|
||||
starting_radius: 9900
|
||||
starting_radius: 4440
|
||||
# force decay instead of preventing reinforcements
|
||||
decay: true
|
||||
#Center of the border
|
||||
center:
|
||||
x: 0.0
|
||||
@@ -358,7 +360,9 @@ world-border-buffers:
|
||||
#'CIRCLE' or 'SQUARE' supported only
|
||||
shape: CIRCLE
|
||||
#Radius from border center you want the no reinforcement zone to kick in
|
||||
starting_radius: 9900
|
||||
starting_radius: 4440
|
||||
# force decay instead of preventing reinforcements
|
||||
decay: true
|
||||
#Center of the border
|
||||
center:
|
||||
x: 0.0
|
||||
@@ -488,4 +492,4 @@ reinforcementBreakMultipliers:
|
||||
|
||||
# number of times a tool can break a reinforcement before it gets damaged by one durability
|
||||
# set to 0 to disable
|
||||
reinforcementBreaksPerToolDamage: 50
|
||||
reinforcementBreaksPerToolDamage: 45
|
||||
|
||||
@@ -350,6 +350,7 @@ world-border-buffers:
|
||||
shape: CIRCLE
|
||||
#Radius from border center you want the no reinforcement zone to kick in
|
||||
starting_radius: 9900
|
||||
decay: false
|
||||
#Center of the border
|
||||
center:
|
||||
x: 0.0
|
||||
@@ -359,6 +360,7 @@ world-border-buffers:
|
||||
shape: CIRCLE
|
||||
#Radius from border center you want the no reinforcement zone to kick in
|
||||
starting_radius: 9900
|
||||
decay: false
|
||||
#Center of the border
|
||||
center:
|
||||
x: 0.0
|
||||
|
||||
@@ -32,7 +32,7 @@ services:
|
||||
|
||||
CIV_TIMEOUT_TIME: 3000000
|
||||
CIV_PVP_HOSTNAME: 'pvp.localhost'
|
||||
CIV_GAMMA_HOSTNAME: 'gamma.localhost'
|
||||
CIV_GAMMA_HOSTNAME: 'mini.localhost'
|
||||
CIV_HOSTNAME: 'main.localhost'
|
||||
|
||||
CIV_FORWARDING_SECRET: '1234'
|
||||
|
||||
@@ -335,8 +335,9 @@ public class CitadelConfigManager extends ConfigParser {
|
||||
}
|
||||
double centerX = insideCenter.getDouble("x", 0.0);
|
||||
double centerZ = insideCenter.getDouble("z", 0.0);
|
||||
logger.info("Parsed World Border Buffer zone for world " + world.getName() + " with radius " + worldBorderBufferSize + " in shape " + worldBorderShape + " centered at " + centerX + ", " + centerZ);
|
||||
buffers.put(world.getUID(), new WorldBorderBuffers(centerX, centerZ, worldBorderShape, worldBorderBufferSize));
|
||||
boolean decay = insideWorld.getBoolean("decay", false);
|
||||
logger.info("Parsed World Border Buffer zone for world " + world.getName() + " with radius " + worldBorderBufferSize + " in shape " + worldBorderShape + " centered at " + centerX + ", " + centerZ + ", decay: " + decay);
|
||||
buffers.put(world.getUID(), new WorldBorderBuffers(centerX, centerZ, worldBorderShape, worldBorderBufferSize, decay));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package vg.civcraft.mc.citadel;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -20,6 +22,7 @@ import vg.civcraft.mc.citadel.activity.ActivityMap;
|
||||
import vg.civcraft.mc.citadel.events.ReinforcementCreationEvent;
|
||||
import vg.civcraft.mc.citadel.events.ReinforcementDestructionEvent;
|
||||
import vg.civcraft.mc.citadel.model.Reinforcement;
|
||||
import vg.civcraft.mc.citadel.model.WorldBorderBuffers;
|
||||
import vg.civcraft.mc.citadel.reinforcementtypes.ReinforcementType;
|
||||
import vg.civcraft.mc.civmodcore.world.WorldUtils;
|
||||
import vg.civcraft.mc.namelayer.group.Group;
|
||||
@@ -91,18 +94,37 @@ public final class ReinforcementLogic {
|
||||
}
|
||||
|
||||
public static double getDecayDamage(Reinforcement reinforcement) {
|
||||
double inactiveDecay;
|
||||
|
||||
if (reinforcement.getGroup() != null) {
|
||||
//long lastRefresh = reinforcement.getGroup().getActivityTimeStamp();
|
||||
ActivityMap map = Citadel.getInstance().getActivityMap();
|
||||
return map.getLastActivityTime(reinforcement.getGroup(), reinforcement.getLocation())
|
||||
inactiveDecay = map.getLastActivityTime(reinforcement.getGroup(), reinforcement.getLocation())
|
||||
.map(Instant::toEpochMilli)
|
||||
.map(lastRefresh -> reinforcement.getType().getDecayDamageMultipler(lastRefresh))
|
||||
.orElse(1d);
|
||||
} else {
|
||||
return reinforcement.getType().getDeletedGroupMultiplier();
|
||||
inactiveDecay = reinforcement.getType().getDeletedGroupMultiplier();
|
||||
}
|
||||
|
||||
return inactiveDecay * getBufferDecayDamage(reinforcement);
|
||||
}
|
||||
|
||||
private static double getBufferDecayDamage(Reinforcement reinforcement) {
|
||||
Location location = reinforcement.getLocation();
|
||||
WorldBorderBuffers buffer = Citadel.getInstance().getConfigManager().getWorldBorderBuffers()
|
||||
.get(location.getWorld().getUID());
|
||||
if (!buffer.decay()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!buffer.checkIfOutside(location.getX(), location.getZ())) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return reinforcement.getType().getDecayDamageMultipler(reinforcement.getCreationTime());
|
||||
}
|
||||
|
||||
|
||||
public static Reinforcement getReinforcementAt(Location location) {
|
||||
return Citadel.getInstance().getReinforcementManager().getReinforcement(location);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package vg.civcraft.mc.citadel.listener;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
@@ -15,6 +17,7 @@ import vg.civcraft.mc.citadel.model.WorldBorderBuffers;
|
||||
public class WorldBorderListener implements Listener {
|
||||
|
||||
private Map<UUID, WorldBorderBuffers> buffers;
|
||||
private Set<UUID> warned = new HashSet<>();
|
||||
|
||||
public WorldBorderListener() {
|
||||
this.buffers = Citadel.getInstance().getConfigManager().getWorldBorderBuffers();
|
||||
@@ -28,7 +31,15 @@ public class WorldBorderListener implements Listener {
|
||||
}
|
||||
WorldBorderBuffers buffer = buffers.get(world.getUID());
|
||||
Location reinforcementLocation = event.getReinforcement().getLocation();
|
||||
if (buffer.checkIfOutside(reinforcementLocation.getX(), reinforcementLocation.getZ())) {
|
||||
if (!buffer.checkIfOutside(reinforcementLocation.getX(), reinforcementLocation.getZ())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (buffer.decay()) {
|
||||
if (warned.add(event.getPlayer().getUniqueId())) {
|
||||
event.getPlayer().sendMessage(Component.text("Reinforcing this close to the border will cause your reinforcements to instantly start decaying").color(NamedTextColor.RED));
|
||||
}
|
||||
} else {
|
||||
event.getPlayer().sendMessage(Component.text("You cannot reinforce this close to the border!").color(NamedTextColor.RED));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package vg.civcraft.mc.citadel.model;
|
||||
|
||||
public record WorldBorderBuffers(double centerX, double centerZ, Shape borderShape, double bufferSize) {
|
||||
public record WorldBorderBuffers(double centerX, double centerZ, Shape borderShape, double bufferSize, boolean decay) {
|
||||
|
||||
public enum Shape {
|
||||
CIRCLE,
|
||||
|
||||
@@ -15,14 +15,6 @@ commands:
|
||||
/<command> <hackname> enable|disable
|
||||
/<command> <hackname> get|set <config> [value]
|
||||
permission: simpleadmin.hacks
|
||||
invsee:
|
||||
description: See any player inventory, online or not.
|
||||
usage: /<command> [playername|UUID]
|
||||
permission: simpleadmin.invsee
|
||||
invmod:
|
||||
description: Modify any player inventory, online or not.
|
||||
usage: /<command> [playername|UUID]
|
||||
permission: simpleadmin.invmod
|
||||
chunklimits:
|
||||
description: Display block chunk limit in chat
|
||||
usage: /<command>
|
||||
@@ -107,9 +99,7 @@ permissions:
|
||||
default: op
|
||||
children:
|
||||
simpleadmin.hacks: true
|
||||
simpleadmin.invsee: true
|
||||
simpleadmin.chestsee: true
|
||||
simpleadmin.invmod: true
|
||||
simpleadmin.chestmod: true
|
||||
simpleadmin.kit: true
|
||||
simpleadmin.book: true
|
||||
@@ -127,15 +117,9 @@ permissions:
|
||||
simpleadmin.hacks:
|
||||
description: Allows control of the hacks and settings which simpleadminhacks supports
|
||||
default: op
|
||||
simpleadmin.invsee:
|
||||
description: Allows viewing player inventory
|
||||
default: op
|
||||
simpleadmin.chestsee:
|
||||
description: Allows viewing any chests
|
||||
default: op
|
||||
simpleadmin.invmod:
|
||||
description: Allows modifying player inventory
|
||||
default: op
|
||||
simpleadmin.chestmod:
|
||||
description: Allows modifying any chests
|
||||
default: op
|
||||
|
||||
Reference in New Issue
Block a user