mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-05 09:20:52 +01:00
Various
Fixes #1177 Additional check for left click with milk on adult entity Add setting for enabling persistent meta Only set fly persistent meta if it differs from the current gamemode fly mode.
This commit is contained in:
parent
28ad14500a
commit
480453b716
@ -2102,7 +2102,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
Entity victim = event.getEntity();
|
Entity victim = event.getEntity();
|
||||||
if (!entityDamage(damager, victim)) {
|
if (!entityDamage(damager, victim)) {
|
||||||
event.setCancelled(true);
|
if (event.isCancelled()) {
|
||||||
if (victim instanceof Ageable) {
|
if (victim instanceof Ageable) {
|
||||||
Ageable ageable = (Ageable) victim;
|
Ageable ageable = (Ageable) victim;
|
||||||
if (ageable.getAge() == -24000) {
|
if (ageable.getAge() == -24000) {
|
||||||
@ -2111,6 +2111,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean entityDamage(Entity damager, Entity victim) {
|
public boolean entityDamage(Entity damager, Entity victim) {
|
||||||
|
@ -285,6 +285,8 @@ public class Settings extends Config {
|
|||||||
public static boolean UUID_CACHE = true;
|
public static boolean UUID_CACHE = true;
|
||||||
@Comment("Notify players of updates")
|
@Comment("Notify players of updates")
|
||||||
public static boolean UPDATER = true;
|
public static boolean UPDATER = true;
|
||||||
|
@Comment("Stores user metadata in a database")
|
||||||
|
public static boolean PERSISTENT_META = true;
|
||||||
@Comment("Optimizes permission checks")
|
@Comment("Optimizes permission checks")
|
||||||
public static boolean PERMISSION_CACHE = true;
|
public static boolean PERMISSION_CACHE = true;
|
||||||
@Comment("Optimizes block changing code")
|
@Comment("Optimizes block changing code")
|
||||||
|
@ -415,6 +415,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void populatePersistentMetaMap() {
|
public void populatePersistentMetaMap() {
|
||||||
|
if (Settings.Enabled_Components.PERSISTENT_META) {
|
||||||
DBFunc.getPersistentMeta(getUUID(), new RunnableVal<Map<String, byte[]>>() {
|
DBFunc.getPersistentMeta(getUUID(), new RunnableVal<Map<String, byte[]>>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Map<String, byte[]> value) {
|
public void run(Map<String, byte[]> value) {
|
||||||
@ -422,6 +423,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public byte[] getPersistentMeta(String key) {
|
public byte[] getPersistentMeta(String key) {
|
||||||
return this.metaMap.get(key);
|
return this.metaMap.get(key);
|
||||||
@ -431,14 +433,18 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
if (this.metaMap.containsKey(key)) {
|
if (this.metaMap.containsKey(key)) {
|
||||||
this.metaMap.remove(key);
|
this.metaMap.remove(key);
|
||||||
}
|
}
|
||||||
|
if (Settings.Enabled_Components.PERSISTENT_META) {
|
||||||
DBFunc.removePersistentMeta(getUUID(), key);
|
DBFunc.removePersistentMeta(getUUID(), key);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setPersistentMeta(String key, byte[] value) {
|
public void setPersistentMeta(String key, byte[] value) {
|
||||||
boolean delete = hasPersistentMeta(key);
|
boolean delete = hasPersistentMeta(key);
|
||||||
this.metaMap.put(key, value);
|
this.metaMap.put(key, value);
|
||||||
|
if (Settings.Enabled_Components.PERSISTENT_META) {
|
||||||
DBFunc.addPersistentMeta(getUUID(), key, value, delete);
|
DBFunc.addPersistentMeta(getUUID(), key, value, delete);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasPersistentMeta(String key) {
|
public boolean hasPersistentMeta(String key) {
|
||||||
return this.metaMap.containsKey(key);
|
return this.metaMap.containsKey(key);
|
||||||
|
@ -57,11 +57,15 @@ public class ExpireManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void handleEntry(PlotPlayer pp, Plot plot) {
|
public void handleEntry(PlotPlayer pp, Plot plot) {
|
||||||
if (plotsToDelete != null && !plotsToDelete.isEmpty() && pp.hasPermission("plots.admin.command.autoclear") && plotsToDelete.contains(plot) && !isExpired(new ArrayDeque<>(tasks), plot).isEmpty()) {
|
if (plotsToDelete != null && !plotsToDelete.isEmpty() && pp.hasPermission("plots.admin.command.autoclear") && plotsToDelete.contains(plot)) {
|
||||||
|
if (!isExpired(new ArrayDeque<>(tasks), plot).isEmpty()) {
|
||||||
|
confirmExpiry(pp);
|
||||||
|
} else {
|
||||||
plotsToDelete.remove(plot);
|
plotsToDelete.remove(plot);
|
||||||
confirmExpiry(pp);
|
confirmExpiry(pp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public long getTimestamp(UUID uuid) {
|
public long getTimestamp(UUID uuid) {
|
||||||
Long value = this.dates_cache.get(uuid);
|
Long value = this.dates_cache.get(uuid);
|
||||||
@ -69,29 +73,37 @@ public class ExpireManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void confirmExpiry(final PlotPlayer pp) {
|
public void confirmExpiry(final PlotPlayer pp) {
|
||||||
if (plotsToDelete != null && !plotsToDelete.isEmpty() && pp
|
if (pp.getMeta("ignoreExpireTask") != null) {
|
||||||
.hasPermission("plots.admin.command.autoclear")) {
|
return;
|
||||||
|
}
|
||||||
|
if (plotsToDelete != null && !plotsToDelete.isEmpty() && pp.hasPermission("plots.admin.command.autoclear")) {
|
||||||
final int num = plotsToDelete.size();
|
final int num = plotsToDelete.size();
|
||||||
for (final Plot current : plotsToDelete) {
|
while (!plotsToDelete.isEmpty()) {
|
||||||
|
Iterator<Plot> iter = plotsToDelete.iterator();
|
||||||
|
final Plot current = iter.next();
|
||||||
if (!isExpired(new ArrayDeque<>(tasks), current).isEmpty()) {
|
if (!isExpired(new ArrayDeque<>(tasks), current).isEmpty()) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
pp.setMeta("ignoreExpireTask", true);
|
||||||
pp.teleport(current.getCenter());
|
pp.teleport(current.getCenter());
|
||||||
|
pp.deleteMeta("ignoreExpireTask");
|
||||||
PlotMessage msg = new PlotMessage()
|
PlotMessage msg = new PlotMessage()
|
||||||
.text(num + " " + (num > 1 ? "plots are" : "plot is") + " expired:").color("$1").command("/plot list expired")
|
.text(num + " " + (num > 1 ? "plots are" : "plot is") + " expired: ").color("$1").text(current.toString()).color("$2").suggest("/plot list expired")
|
||||||
.tooltip("/plot list expired")
|
.tooltip("/plot list expired")
|
||||||
//.text("\n - ").color("$3").text("Delete all (/plot delete expired)").color("$2").command("/plot delete expired")
|
//.text("\n - ").color("$3").text("Delete all (/plot delete expired)").color("$2").command("/plot delete expired")
|
||||||
.text("\n - ").color("$3").text("Delete this (/plot delete)").color("$2").command("/plot delete")
|
.text("\n - ").color("$3").text("Delete this (/plot delete)").color("$2").suggest("/plot delete")
|
||||||
.tooltip("/plot delete")
|
.tooltip("/plot delete")
|
||||||
.text("\n - ").color("$3").text("Remind later (/plot set keep 1d)").color("$2").command("/plot set keep 1d")
|
.text("\n - ").color("$3").text("Remind later (/plot set keep 1d)").color("$2").suggest("/plot set keep 1d")
|
||||||
.tooltip("/plot set keep 1d")
|
.tooltip("/plot set keep 1d")
|
||||||
.text("\n - ").color("$3").text("Keep this (/plot set keep true)").color("$2").command("/plot set keep true")
|
.text("\n - ").color("$3").text("Keep this (/plot set keep true)").color("$2").suggest("/plot set keep true")
|
||||||
.tooltip("/plot set keep true");
|
.tooltip("/plot set keep true");
|
||||||
msg.send(pp);
|
msg.send(pp);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
iter.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plotsToDelete.clear();
|
plotsToDelete.clear();
|
||||||
|
@ -72,6 +72,17 @@ public class PlotListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Optional<Boolean> flyFlag = plot.getFlag(Flags.FLY);
|
||||||
|
if (flyFlag.isPresent()) {
|
||||||
|
boolean flight = player.getFlight();
|
||||||
|
if (flyFlag.get() != player.getFlight()) {
|
||||||
|
PlotGameMode gamemode = player.getGameMode();
|
||||||
|
if (flight != (gamemode == PlotGameMode.CREATIVE || gamemode == PlotGameMode.SPECTATOR)) {
|
||||||
|
player.setPersistentMeta("flight", ByteArrayUtilities.booleanToBytes(player.getFlight()));
|
||||||
|
}
|
||||||
|
player.setFlight(flyFlag.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
Optional<PlotGameMode> gamemodeFlag = plot.getFlag(Flags.GAMEMODE);
|
Optional<PlotGameMode> gamemodeFlag = plot.getFlag(Flags.GAMEMODE);
|
||||||
if (gamemodeFlag.isPresent()) {
|
if (gamemodeFlag.isPresent()) {
|
||||||
if (player.getGameMode() != gamemodeFlag.get()) {
|
if (player.getGameMode() != gamemodeFlag.get()) {
|
||||||
@ -83,13 +94,6 @@ public class PlotListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Optional<Boolean> flyFlag = plot.getFlag(Flags.FLY);
|
|
||||||
if (flyFlag.isPresent()) {
|
|
||||||
if (flyFlag.get() != player.getFlight()) {
|
|
||||||
player.setPersistentMeta("flight", ByteArrayUtilities.booleanToBytes(player.getFlight()));
|
|
||||||
player.setFlight(flyFlag.get());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Optional<Long> timeFlag = plot.getFlag(Flags.TIME);
|
Optional<Long> timeFlag = plot.getFlag(Flags.TIME);
|
||||||
if (timeFlag.isPresent()) {
|
if (timeFlag.isPresent()) {
|
||||||
try {
|
try {
|
||||||
@ -200,6 +204,7 @@ public class PlotListener {
|
|||||||
if (plot.getFlag(Flags.FLY).isPresent()) {
|
if (plot.getFlag(Flags.FLY).isPresent()) {
|
||||||
if (player.hasPersistentMeta("flight")) {
|
if (player.hasPersistentMeta("flight")) {
|
||||||
player.setFlight(ByteArrayUtilities.bytesToBoolean(player.getPersistentMeta("flight")));
|
player.setFlight(ByteArrayUtilities.bytesToBoolean(player.getPersistentMeta("flight")));
|
||||||
|
player.removePersistentMeta("flight");
|
||||||
} else {
|
} else {
|
||||||
PlotGameMode gameMode = player.getGameMode();
|
PlotGameMode gameMode = player.getGameMode();
|
||||||
if (gameMode == PlotGameMode.SURVIVAL || gameMode == PlotGameMode.ADVENTURE) {
|
if (gameMode == PlotGameMode.SURVIVAL || gameMode == PlotGameMode.ADVENTURE) {
|
||||||
|
Loading…
Reference in New Issue
Block a user