Reformat code

This commit is contained in:
dordsor21
2018-12-19 23:26:20 +00:00
parent fa2dbb2b89
commit 11ccfe7ac4
27 changed files with 365 additions and 401 deletions

View File

@ -32,8 +32,7 @@ import java.util.HashSet;
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getRefClass;
@SuppressWarnings("unused")
public class ChunkListener implements Listener {
@SuppressWarnings("unused") public class ChunkListener implements Listener {
private RefMethod methodGetHandleChunk;
private RefField mustSave;

View File

@ -18,8 +18,7 @@ import org.bukkit.plugin.Plugin;
import java.util.List;
@SuppressWarnings("unused")
public class EntityPortal_1_7_9 implements Listener {
@SuppressWarnings("unused") public class EntityPortal_1_7_9 implements Listener {
private static boolean ignoreTP = false;
public EntityPortal_1_7_9() {

View File

@ -16,8 +16,7 @@ import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.Plugin;
@SuppressWarnings("unused")
public class EntitySpawnListener implements Listener {
@SuppressWarnings("unused") public class EntitySpawnListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void creatureSpawnEvent(EntitySpawnEvent event) {
Entity entity = event.getEntity();

View File

@ -16,8 +16,7 @@ import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
@SuppressWarnings("unused")
public class ForceFieldListener {
@SuppressWarnings("unused") public class ForceFieldListener {
private static Set<PlotPlayer> getNearbyPlayers(Player player, Plot plot) {
Set<PlotPlayer> players = new HashSet<>();

View File

@ -56,8 +56,7 @@ import java.util.regex.Pattern;
/**
* Player Events involving plots.
*/
@SuppressWarnings("unused")
public class PlayerEvents extends PlotListener implements Listener {
@SuppressWarnings("unused") public class PlayerEvents extends PlotListener implements Listener {
private boolean pistonBlocks = true;
private float lastRadius;
@ -175,7 +174,8 @@ public class PlayerEvents extends PlotListener implements Listener {
case ZOMBIE_HORSE:
case SKELETON_HORSE:
// animal
return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP);
return EntityUtil
.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP);
case BLAZE:
case CAVE_SPIDER:
case CREEPER:
@ -204,14 +204,16 @@ public class PlayerEvents extends PlotListener implements Listener {
case VEX:
case ZOMBIE_VILLAGER:
// monster
return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP);
return EntityUtil
.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP);
default:
if (entity instanceof LivingEntity) {
if (entity instanceof Animals) {
return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP);
return EntityUtil
.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP);
} else if (entity instanceof Monster) {
return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP,
Flags.HOSTILE_CAP);
return EntityUtil
.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP);
} else {
return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP);
}
@ -943,8 +945,9 @@ public class PlayerEvents extends PlotListener implements Listener {
return;
}
if (PlotSquared.get().worldedit != null && pp.getAttribute("worldedit")) {
if (player.getInventory().getItemInMainHand().getType() == LegacyMappings.fromLegacyId(PlotSquared.get().worldedit
.getConfiguration().wandItem).getMaterial()) {
if (player.getInventory().getItemInMainHand().getType() == LegacyMappings
.fromLegacyId(PlotSquared.get().worldedit.getConfiguration().wandItem)
.getMaterial()) {
return;
}
}
@ -1202,8 +1205,8 @@ public class PlayerEvents extends PlotListener implements Listener {
Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK);
Block block = event.getBlock();
if (destroy.isPresent() && destroy.get()
.contains(PlotBlock.get(block.getType().name()))
|| Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
.contains(PlotBlock.get(block.getType().name())) || Permissions
.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
return;
}
event.setCancelled(true);
@ -1679,8 +1682,9 @@ public class PlayerEvents extends PlotListener implements Listener {
return;
}
if (PlotSquared.get().worldedit != null && pp.getAttribute("worldedit")) {
if (player.getInventory().getItemInMainHand().getType() == LegacyMappings.fromLegacyId(PlotSquared.get().worldedit
.getConfiguration().wandItem).getMaterial()) {
if (player.getInventory().getItemInMainHand().getType() == LegacyMappings
.fromLegacyId(PlotSquared.get().worldedit.getConfiguration().wandItem)
.getMaterial()) {
return;
}
}
@ -1991,8 +1995,7 @@ public class PlayerEvents extends PlotListener implements Listener {
} else if (!plot.isAdded(plotPlayer.getUUID())) {
Optional<HashSet<PlotBlock>> use = plot.getFlag(Flags.USE);
Block block = event.getBlockClicked();
if (use.isPresent() && use.get()
.contains(PlotBlock.get(block.getType().name()))) {
if (use.isPresent() && use.get().contains(PlotBlock.get(block.getType().name()))) {
return;
}
if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_OTHER)) {

View File

@ -14,8 +14,7 @@ import org.bukkit.event.block.BlockExplodeEvent;
import java.util.Iterator;
@SuppressWarnings("unused")
public class PlayerEvents183 implements Listener {
@SuppressWarnings("unused") public class PlayerEvents183 implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBigBoom(BlockExplodeEvent event) {

View File

@ -32,8 +32,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.UUID;
@SuppressWarnings("unused")
public class PlayerEvents_1_8 extends PlotListener implements Listener {
@SuppressWarnings("unused") public class PlayerEvents_1_8 extends PlotListener implements Listener {
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)

View File

@ -9,8 +9,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.LingeringPotionSplashEvent;
@SuppressWarnings("unused")
public class PlayerEvents_1_9 implements Listener {
@SuppressWarnings("unused") public class PlayerEvents_1_9 implements Listener {
private final PlayerEvents parent;

View File

@ -28,8 +28,7 @@ import java.util.Iterator;
import java.util.Map.Entry;
import java.util.UUID;
@SuppressWarnings("unused")
public class PlotPlusListener extends PlotListener implements Listener {
@SuppressWarnings("unused") public class PlotPlusListener extends PlotListener implements Listener {
private static final HashMap<String, Interval> feedRunnable = new HashMap<>();
private static final HashMap<String, Interval> healRunnable = new HashMap<>();

View File

@ -12,8 +12,7 @@ import org.bukkit.event.entity.EntityPickupItemEvent;
import java.util.UUID;
@SuppressWarnings("unused")
public class PlotPlusListener_1_12 implements Listener {
@SuppressWarnings("unused") public class PlotPlusListener_1_12 implements Listener {
@EventHandler public void onItemPickup(EntityPickupItemEvent event) {
LivingEntity ent = event.getEntity();

View File

@ -11,9 +11,8 @@ import org.bukkit.event.player.PlayerPickupItemEvent;
import java.util.UUID;
@SuppressWarnings("unused")
public class PlotPlusListener_Legacy implements Listener {
@SuppressWarnings("unused") public class PlotPlusListener_Legacy implements Listener {
@EventHandler public void onItemPickup(PlayerPickupItemEvent event) {
Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player);

View File

@ -19,8 +19,7 @@ import java.lang.reflect.Method;
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getRefClass;
@SuppressWarnings("unused")
public class SingleWorldListener implements Listener {
@SuppressWarnings("unused") public class SingleWorldListener implements Listener {
private Method methodGetHandleChunk;
private Field mustSave, done, lit, s;

View File

@ -7,13 +7,12 @@ import org.bukkit.Material;
public class BukkitBlockRegistry extends BlockRegistry<Material> {
public BukkitBlockRegistry(final Material... preInitializedItems) {
super(Material.class, preInitializedItems);
}
public BukkitBlockRegistry(final Material... preInitializedItems) {
super(Material.class, preInitializedItems);
}
@Override
public PlotBlock getPlotBlock(@NonNull final Material item) {
return PlotBlock.get(item.name());
}
@Override public PlotBlock getPlotBlock(@NonNull final Material item) {
return PlotBlock.get(item.name());
}
}

View File

@ -3,26 +3,9 @@ package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.C;
import com.github.intellectualsites.plotsquared.plot.object.LegacyPlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper;
import com.github.intellectualsites.plotsquared.plot.object.StringPlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.*;
import com.github.intellectualsites.plotsquared.plot.object.schematic.PlotItem;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import javax.annotation.Nullable;
import com.github.intellectualsites.plotsquared.plot.util.*;
import lombok.NonNull;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@ -37,12 +20,10 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import org.bukkit.material.Sandstone;
import org.bukkit.material.Step;
import org.bukkit.material.Tree;
import org.bukkit.material.WoodenStep;
import org.bukkit.material.Wool;
import org.bukkit.material.*;
import javax.annotation.Nullable;
import java.util.*;
@SuppressWarnings({"unused", "WeakerAccess"}) public class BukkitUtil extends WorldUtil {
@ -80,14 +61,6 @@ import org.bukkit.material.Wool;
return getLocation(location).getPlot();
}
@Override public boolean isBlockSame(PlotBlock block1, PlotBlock block2) {
if (block1.equals(block2)) {
return true;
}
Material mat1 = getMaterial(block1), mat2 = getMaterial(block2);
return mat1 == mat2;
}
/**
* Get a plot based on the player location.
*
@ -261,6 +234,30 @@ import org.bukkit.material.Wool;
location.getPitch());
}
public static BukkitLegacyMappings getBukkitLegacyMappings() {
return (BukkitLegacyMappings) PlotSquared.imp().getLegacyMappings();
}
public static Material getMaterial(@NonNull final PlotBlock plotBlock) {
if (plotBlock instanceof StringPlotBlock) {
return Material
.getMaterial(((StringPlotBlock) plotBlock).getItemId().toUpperCase(Locale.ENGLISH));
} else {
final LegacyPlotBlock legacyPlotBlock = (LegacyPlotBlock) plotBlock;
return getBukkitLegacyMappings()
.fromLegacyToString(legacyPlotBlock.getId(), legacyPlotBlock.getData())
.to(Material.class);
}
}
@Override public boolean isBlockSame(PlotBlock block1, PlotBlock block2) {
if (block1.equals(block2)) {
return true;
}
Material mat1 = getMaterial(block1), mat2 = getMaterial(block2);
return mat1 == mat2;
}
@Override public boolean isWorld(@NonNull final String worldName) {
return getWorld(worldName) != null;
}
@ -379,10 +376,6 @@ import org.bukkit.material.Wool;
return list;
}
public static BukkitLegacyMappings getBukkitLegacyMappings() {
return (BukkitLegacyMappings) PlotSquared.imp().getLegacyMappings();
}
@Override
public boolean addItems(@NonNull final String worldName, @NonNull final PlotItem items) {
final World world = getWorld(worldName);
@ -405,15 +398,6 @@ import org.bukkit.material.Wool;
return false;
}
public static Material getMaterial(@NonNull final PlotBlock plotBlock) {
if (plotBlock instanceof StringPlotBlock) {
return Material.getMaterial(((StringPlotBlock) plotBlock).getItemId().toUpperCase(Locale.ENGLISH));
} else {
final LegacyPlotBlock legacyPlotBlock = (LegacyPlotBlock) plotBlock;
return getBukkitLegacyMappings().fromLegacyToString(legacyPlotBlock.getId(), legacyPlotBlock.getData()).to(Material.class);
}
}
@Override public boolean isBlockSolid(@NonNull final PlotBlock block) {
try {
final Material material = getMaterial(block);
@ -450,7 +434,7 @@ import org.bukkit.material.Wool;
public StringComparison<PlotBlock>.ComparisonResult getClosestBlock(String name) {
final PlotBlock plotBlock = BukkitUtil.getBukkitLegacyMappings().fromAny(name);
if (plotBlock != null) {
return new StringComparison<PlotBlock>().new ComparisonResult(1, plotBlock);
return new StringComparison<PlotBlock>().new ComparisonResult(1, plotBlock);
}
return BukkitUtil.getBukkitLegacyMappings().getClosestsMatch(name);
}