fix nametag optimization still consuming item when consumption is disabled
fix datahandlers returning wrong values when checking for cooldown millis remove unused dependency
This commit is contained in:
parent
9525a2b3ba
commit
11ef3eedac
12
pom.xml
12
pom.xml
@ -122,25 +122,19 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-text-minimessage</artifactId>
|
<artifactId>adventure-text-minimessage</artifactId>
|
||||||
<version>4.16.0</version>
|
<version>4.17.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Needed to actually display colors in ComponentLogger -->
|
<!-- Needed to actually display colors in ComponentLogger -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-text-serializer-ansi</artifactId>
|
<artifactId>adventure-text-serializer-ansi</artifactId>
|
||||||
<version>4.16.0</version>
|
<version>4.17.0</version>
|
||||||
</dependency>
|
|
||||||
<!-- Adventure plaintext serializer for reading unstyled content of components -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.kyori</groupId>
|
|
||||||
<artifactId>adventure-text-serializer-plain</artifactId>
|
|
||||||
<version>4.16.0</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Adventure ComponentLogger for colorful slf4j logging -->
|
<!-- Adventure ComponentLogger for colorful slf4j logging -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-text-logger-slf4j</artifactId>
|
<artifactId>adventure-text-logger-slf4j</artifactId>
|
||||||
<version>4.16.0</version>
|
<version>4.17.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Bukkit bStats -->
|
<!-- Bukkit bStats -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -111,8 +111,8 @@ public class OptimizeByNametag implements VillagerOptimizerModule, Listener {
|
|||||||
if (!optimizeEvent.callEvent()) return;
|
if (!optimizeEvent.callEvent()) return;
|
||||||
|
|
||||||
if (!consume_nametag) {
|
if (!consume_nametag) {
|
||||||
event.setCancelled(true);
|
player.getInventory().addItem(usedItem.asOne());
|
||||||
villager.customName(meta.displayName());
|
player.updateInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
wVillager.setOptimizationType(optimizeEvent.getOptimizationType());
|
wVillager.setOptimizationType(optimizeEvent.getOptimizationType());
|
||||||
|
@ -92,14 +92,13 @@ public class AVLVillagerDataHandlerImpl implements VillagerDataHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveOptimizeTime() {
|
public void saveOptimizeTime() {
|
||||||
dataContainer.set(Keyring.AntiVillagerLag.NEXT_OPTIMIZATION_SYSTIME_SECONDS.getKey(), PersistentDataType.LONG,
|
// We do nothing here to not break stuff
|
||||||
TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()) + 30);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getOptimizeCooldownMillis(long cooldown_millis) {
|
public long getOptimizeCooldownMillis(long cooldown_millis) {
|
||||||
if (dataContainer.has(Keyring.AntiVillagerLag.NEXT_OPTIMIZATION_SYSTIME_SECONDS.getKey(), PersistentDataType.LONG)) {
|
if (dataContainer.has(Keyring.AntiVillagerLag.NEXT_OPTIMIZATION_SYSTIME_SECONDS.getKey(), PersistentDataType.LONG)) {
|
||||||
return Math.max(cooldown_millis, System.currentTimeMillis() - TimeUnit.SECONDS.toMillis(dataContainer.get(Keyring.AntiVillagerLag.NEXT_OPTIMIZATION_SYSTIME_SECONDS.getKey(), PersistentDataType.LONG)));
|
return TimeUnit.SECONDS.toMillis(dataContainer.get(Keyring.AntiVillagerLag.NEXT_OPTIMIZATION_SYSTIME_SECONDS.getKey(), PersistentDataType.LONG) - System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
return cooldown_millis;
|
return cooldown_millis;
|
||||||
}
|
}
|
||||||
@ -130,7 +129,7 @@ public class AVLVillagerDataHandlerImpl implements VillagerDataHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveLastLevelUp() {
|
public void saveLastLevelUp() {
|
||||||
dataContainer.set(Keyring.AntiVillagerLag.NEXT_LEVELUP_SYSTIME_SECONDS.getKey(), PersistentDataType.LONG, TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()) + 30);
|
// We do nothing here to not break stuff
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -82,7 +82,10 @@ public class MainVillagerDataHandlerImpl implements VillagerDataHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getOptimizeCooldownMillis(long cooldown_millis) {
|
public long getOptimizeCooldownMillis(long cooldown_millis) {
|
||||||
return Math.max(System.currentTimeMillis() - getLastOptimize(), cooldown_millis);
|
if (getLastOptimize() > 0L) {
|
||||||
|
return cooldown_millis - (System.currentTimeMillis() - getLastOptimize());
|
||||||
|
}
|
||||||
|
return cooldown_millis;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -126,7 +126,7 @@ public class WrappedVillager implements VillagerDataHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getOptimizeCooldownMillis(long cooldown_millis) {
|
public long getOptimizeCooldownMillis(long cooldown_millis) {
|
||||||
long cooldown = cooldown_millis;
|
long cooldown = 0L;
|
||||||
for (VillagerDataHandler handler : dataHandlers) {
|
for (VillagerDataHandler handler : dataHandlers) {
|
||||||
cooldown = Math.max(cooldown, handler.getOptimizeCooldownMillis(cooldown_millis));
|
cooldown = Math.max(cooldown, handler.getOptimizeCooldownMillis(cooldown_millis));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user