Merge branch 'optional' into breaking

This commit is contained in:
matt
2019-01-09 20:01:32 -05:00
17 changed files with 44 additions and 137 deletions

View File

@ -12,7 +12,6 @@ import com.github.intellectualsites.plotsquared.plot.listener.PlayerBlockEventTy
import com.github.intellectualsites.plotsquared.plot.listener.PlotListener;
import com.github.intellectualsites.plotsquared.plot.object.*;
import com.github.intellectualsites.plotsquared.plot.util.*;
import com.google.common.base.Optional;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -1693,7 +1692,7 @@ import java.util.regex.Pattern;
return;
}
Plot plot = area.getOwnedPlot(location);
if (plot == null || !plot.getFlag(Flags.EXPLOSION).or(false)) {
if (plot == null || !plot.getFlag(Flags.EXPLOSION).orElse(false)) {
event.setCancelled(true);
}
event.blockList().removeIf(
@ -2170,7 +2169,7 @@ import java.util.regex.Pattern;
|| !plotIgnited.equals(plot)) ||
(igniteCause == BlockIgniteEvent.IgniteCause.SPREAD
|| igniteCause == BlockIgniteEvent.IgniteCause.LAVA) && (
!plot.getFlag(Flags.BLOCK_IGNITION).or(false) || plotIgnited == null
!plot.getFlag(Flags.BLOCK_IGNITION).orElse(false) || plotIgnited == null
|| !plotIgnited.equals(plot))) {
event.setCancelled(true);
}

View File

@ -7,7 +7,6 @@ import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.listener.PlotListener;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.google.common.base.Optional;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.block.Block;
@ -28,6 +27,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.UUID;
@SuppressWarnings("unused")
@ -139,15 +139,11 @@ public class PlotPlusListener extends PlotListener implements Listener {
Player player = event.getPlayer();
Plot plot = event.getPlot();
Optional<Integer[]> feed = plot.getFlag(Flags.FEED);
if (feed.isPresent()) {
Integer[] value = feed.get();
feedRunnable.put(player.getUniqueId(), new Interval(value[0], value[1], 20));
}
feed.ifPresent( value -> feedRunnable.put(player.getUniqueId(), new Interval(value[0], value[1], 20))
);
Optional<Integer[]> heal = plot.getFlag(Flags.HEAL);
if (heal.isPresent()) {
Integer[] value = heal.get();
healRunnable.put(player.getUniqueId(), new Interval(value[0], value[1], 20));
}
heal.ifPresent( value -> healRunnable.put(player.getUniqueId(), new Interval(value[0], value[1], 20))
);
}
@EventHandler