Begin implementation of CheckStyle style checking

This commit is contained in:
md_5 2019-04-23 14:00:30 +10:00
parent a2d787f6eb
commit 48c4c5ca81
28 changed files with 144 additions and 97 deletions

36
checkstyle.xml Normal file
View File

@ -0,0 +1,36 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<!-- See http://checkstyle.sourceforge.net/config_misc.html#NewlineAtEndOfFile -->
<module name="NewlineAtEndOfFile"/>
<!-- See http://checkstyle.sourceforge.net/config_whitespace.html -->
<module name="FileTabCharacter"/>
<!-- See http://checkstyle.sourceforge.net/config_misc.html -->
<module name="RegexpSingleline">
<property name="format" value="\s+$"/>
<property name="minimum" value="0"/>
<property name="maximum" value="0"/>
<property name="message" value="Line has trailing spaces."/>
</module>
<module name="TreeWalker">
<!-- See http://checkstyle.sourceforge.net/config_import.html -->
<module name="RedundantImport"/>
<!-- See http://checkstyle.sourceforge.net/config_modifiers.html -->
<module name="ModifierOrder"/>
<!-- See http://checkstyle.sourceforge.net/config_design.html -->
<!--<module name="FinalClass"/>-->
<!--<module name="InterfaceIsType"/>-->
<!-- See http://checkstyle.sourceforge.net/config_misc.html -->
<module name="ArrayTypeStyle"/>
<module name="UpperEll"/>
</module>
</module>

View File

@ -1,16 +1,12 @@
--- a/net/minecraft/server/BlockPiston.java
+++ b/net/minecraft/server/BlockPiston.java
@@ -6,6 +6,18 @@
@@ -6,6 +6,14 @@
import java.util.List;
import java.util.Set;
+// CraftBukkit start
+import java.util.AbstractList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.ListIterator;
+
+import com.google.common.collect.ImmutableList;
+import java.util.AbstractList;
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.event.block.BlockPistonRetractEvent;
+import org.bukkit.event.block.BlockPistonExtendEvent;
@ -19,7 +15,7 @@
public class BlockPiston extends BlockDirectional {
public static final BlockStateBoolean EXTENDED = BlockProperties.g;
@@ -112,6 +124,18 @@
@@ -112,6 +120,18 @@
}
}
@ -38,7 +34,7 @@
world.playBlockAction(blockposition, this, b0, enumdirection.a());
}
@@ -281,6 +305,48 @@
@@ -281,6 +301,48 @@
IBlockData[] aiblockdata = new IBlockData[j];
EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.opposite();
Set<BlockPosition> set = Sets.newHashSet(list);

View File

@ -278,12 +278,10 @@
return true;
} else {
return false;
@@ -727,14 +869,40 @@
public boolean cB() {
@@ -728,13 +870,39 @@
return this.getMonsterType() == EnumMonsterType.UNDEAD;
}
-
+
+ // CraftBukkit start
@Nullable
public MobEffect c(@Nullable MobEffectList mobeffectlist) {

View File

@ -279,16 +279,15 @@
this.releaseShoulderEntities();
- if (!this.isSpectator()) {
- this.d(damagesource);
- }
+ // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory.
+ if (!event.getKeepInventory()) {
+ this.inventory.clear();
+ }
+
+ this.setSpectatorTarget(this); // Remove spectated target
+ // CraftBukkit end
}
- this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.DEATH_COUNT, this.getName(), ScoreboardScore::incrementScore);
+ this.setSpectatorTarget(this); // Remove spectated target
+ // CraftBukkit end
+
+ // CraftBukkit - Get our scores instead
+ this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.DEATH_COUNT, this.getName(), ScoreboardScore::incrementScore);
EntityLiving entityliving = this.getKillingEntity();

View File

@ -1,17 +1,17 @@
--- a/net/minecraft/server/EntityTrackerEntry.java
+++ b/net/minecraft/server/EntityTrackerEntry.java
@@ -8,6 +8,11 @@
import java.util.function.Consumer;
@@ -9,6 +9,11 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+
+// CraftBukkit start
+import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerVelocityEvent;
+// CraftBukkit end
+
public class EntityTrackerEntry {
private static final Logger a = LogManager.getLogger();
@@ -29,8 +34,12 @@
private List<Entity> p;
private boolean q;

View File

@ -1,11 +1,10 @@
--- a/net/minecraft/server/InventorySubcontainer.java
+++ b/net/minecraft/server/InventorySubcontainer.java
@@ -4,13 +4,65 @@
@@ -4,13 +4,64 @@
import java.util.Iterator;
import java.util.List;
+// CraftBukkit start
+import java.util.List;
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;

View File

@ -1,12 +1,11 @@
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -47,6 +47,14 @@
@@ -47,6 +47,13 @@
import org.apache.commons.lang3.Validate;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import jline.console.ConsoleReader;
+import joptsimple.OptionSet;
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.Main;
@ -15,7 +14,7 @@
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements IMojangStatistics, ICommandListener, AutoCloseable, Runnable {
@@ -65,7 +73,7 @@
@@ -65,7 +72,7 @@
public final DataFixer dataConverterManager;
private String serverIp;
private int serverPort = -1;
@ -24,7 +23,7 @@
private PlayerList playerList;
private volatile boolean isRunning = true;
private boolean isStopped;
@@ -104,7 +112,7 @@
@@ -104,7 +111,7 @@
private final GameProfileRepository gameProfileRepository;
private final UserCache userCache;
private long Z;
@ -33,7 +32,7 @@
thread.setUncaughtExceptionHandler((thread1, throwable) -> {
MinecraftServer.LOGGER.error(throwable);
});
@@ -133,7 +141,20 @@
@@ -133,7 +140,20 @@
@Nullable
private String av;
@ -55,7 +54,7 @@
super("Server");
this.ae = new ResourceManager(EnumResourcePackType.SERVER_DATA, this.serverThread);
this.resourcePackRepository = new ResourcePackRepository<>(ResourcePackLoader::new);
@@ -146,15 +167,15 @@
@@ -146,15 +166,15 @@
this.ao = new CustomFunctionData(this);
this.ap = new CircularTimer();
this.proxy = proxy;
@ -75,7 +74,7 @@
this.dataConverterManager = datafixer;
this.ae.a((IReloadListener) this.aj);
this.ae.a((IReloadListener) this.ai);
@@ -163,7 +184,32 @@
@@ -163,7 +183,32 @@
this.ae.a((IReloadListener) this.an);
this.executorService = SystemUtils.e();
this.K = s;
@ -108,7 +107,7 @@
private void initializeScoreboards(WorldPersistentData worldpersistentdata) {
PersistentScoreboard persistentscoreboard = (PersistentScoreboard) worldpersistentdata.a(PersistentScoreboard::new, "scoreboard");
@@ -199,11 +245,11 @@
@@ -199,11 +244,11 @@
}
if (this.forceUpgrade) {
@ -123,7 +122,7 @@
IChatBaseComponent ichatbasecomponent = null;
while (!worldupgrader.b()) {
@@ -242,8 +288,9 @@
@@ -242,8 +287,9 @@
}
protected void a(String s, String s1, long i, WorldType worldtype, JsonElement jsonelement) {
@ -134,7 +133,7 @@
WorldNBTStorage worldnbtstorage = this.getConvertable().a(s, this);
this.a(this.getWorld(), worldnbtstorage);
@@ -268,24 +315,134 @@
@@ -268,24 +314,134 @@
}
this.a(worldnbtstorage.getDirectory(), worlddata);
@ -282,7 +281,7 @@
if (!worlddata.v()) {
try {
@@ -309,23 +466,8 @@
@@ -309,23 +465,8 @@
worlddata.d(true);
}
@ -307,7 +306,7 @@
private void a(WorldData worlddata) {
worlddata.f(false);
@@ -344,6 +486,25 @@
@@ -344,6 +485,25 @@
protected void a(File file, WorldData worlddata) {
this.resourcePackRepository.a((ResourcePackSource) (new ResourcePackSourceVanilla()));
this.resourcePackFolder = new ResourcePackSourceFolder(new File(file, "datapacks"));
@ -333,7 +332,7 @@
this.resourcePackRepository.a((ResourcePackSource) this.resourcePackFolder);
this.resourcePackRepository.a();
List<ResourcePackLoader> list = Lists.newArrayList();
@@ -364,11 +525,13 @@
@@ -364,11 +524,13 @@
this.b(worlddata);
}
@ -350,7 +349,7 @@
BlockPosition blockposition = worldserver.getSpawn();
worldloadlistener.a(new ChunkCoordIntPair(blockposition));
@@ -385,11 +548,13 @@
@@ -385,11 +547,13 @@
this.nextTick += 100L;
this.sleepForTick();
@ -368,7 +367,7 @@
if (forcedchunk != null) {
WorldServer worldserver1 = this.getWorldServer(dimensionmanager);
@@ -408,6 +573,8 @@
@@ -408,6 +572,8 @@
this.sleepForTick();
worldloadlistener.b();
chunkproviderserver.getLightEngine().a(5);
@ -377,7 +376,7 @@
}
protected void a(String s, WorldNBTStorage worldnbtstorage) {
@@ -466,8 +633,29 @@
@@ -466,8 +632,29 @@
this.stop();
}
@ -407,7 +406,7 @@
if (this.getServerConnection() != null) {
this.getServerConnection().b();
}
@@ -476,6 +664,7 @@
@@ -476,6 +663,7 @@
MinecraftServer.LOGGER.info("Saving players");
this.playerList.savePlayers();
this.playerList.shutdown();
@ -415,7 +414,7 @@
}
MinecraftServer.LOGGER.info("Saving worlds");
@@ -548,11 +737,13 @@
@@ -548,11 +736,13 @@
if (i > 2000L && this.nextTick - this.lastOverloadTime >= 15000L) {
long j = i / 50L;
@ -429,7 +428,7 @@
this.nextTick += 50L;
if (this.T) {
this.T = false;
@@ -599,6 +790,12 @@
@@ -599,6 +789,12 @@
} catch (Throwable throwable1) {
MinecraftServer.LOGGER.error("Exception stopping the server", throwable1);
} finally {
@ -442,7 +441,7 @@
this.exit();
}
@@ -709,7 +906,7 @@
@@ -709,7 +905,7 @@
this.serverPing.b().a(agameprofile);
}
@ -451,7 +450,7 @@
MinecraftServer.LOGGER.debug("Autosave started");
this.methodProfiler.enter("save");
this.playerList.savePlayers();
@@ -739,27 +936,43 @@
@@ -739,27 +935,43 @@
}
protected void b(BooleanSupplier booleansupplier) {
@ -501,7 +500,7 @@
this.methodProfiler.enter("tick");
@@ -798,7 +1011,8 @@
@@ -798,7 +1010,8 @@
this.tickables.add(runnable);
}
@ -511,7 +510,7 @@
OptionParser optionparser = new OptionParser();
OptionSpec<Void> optionspec = optionparser.accepts("nogui");
OptionSpec<Void> optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits");
@@ -821,15 +1035,17 @@
@@ -821,15 +1034,17 @@
optionparser.printHelpOn(System.err);
return;
}
@ -531,7 +530,7 @@
MinecraftServer.LOGGER.info("Initialized '" + java_nio_file_path.toAbsolutePath().toString() + "' and '" + java_nio_file_path1.toAbsolutePath().toString() + "'");
return;
}
@@ -841,14 +1057,15 @@
@@ -841,14 +1056,15 @@
DispenserRegistry.init();
DispenserRegistry.c();
@ -550,7 +549,7 @@
dedicatedserver.i((String) optionset.valueOf(optionspec7));
dedicatedserver.setPort((Integer) optionset.valueOf(optionspec10));
dedicatedserver.e(optionset.has(optionspec2));
@@ -871,6 +1088,25 @@
@@ -871,6 +1087,25 @@
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(MinecraftServer.LOGGER));
Runtime.getRuntime().addShutdownHook(thread);
@ -576,7 +575,7 @@
} catch (Exception exception) {
MinecraftServer.LOGGER.fatal("Failed to start the minecraft server", exception);
}
@@ -890,7 +1126,9 @@
@@ -890,7 +1125,9 @@
}
public void startServerThread() {
@ -586,7 +585,7 @@
}
public File d(String s) {
@@ -945,7 +1183,7 @@
@@ -945,7 +1182,7 @@
}
public String getServerModName() {
@ -595,7 +594,7 @@
}
public CrashReport b(CrashReport crashreport) {
@@ -984,7 +1222,7 @@
@@ -984,7 +1221,7 @@
}
public boolean E() {
@ -604,7 +603,7 @@
}
@Override
@@ -1480,4 +1718,16 @@
@@ -1480,4 +1717,16 @@
}
public abstract boolean b(GameProfile gameprofile);

View File

@ -1,14 +1,12 @@
--- a/net/minecraft/server/PlayerInventory.java
+++ b/net/minecraft/server/PlayerInventory.java
@@ -5,6 +5,15 @@
@@ -5,6 +5,13 @@
import java.util.List;
import java.util.function.Predicate;
+// CraftBukkit start
+import java.util.ArrayList;
+import java.util.List;
+import org.bukkit.Location;
+
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
@ -16,7 +14,7 @@
public class PlayerInventory implements IInventory, INamableTileEntity {
public final NonNullList<ItemStack> items;
@@ -16,6 +25,54 @@
@@ -16,6 +23,54 @@
private ItemStack carried;
private int h;
@ -71,7 +69,7 @@
public PlayerInventory(EntityHuman entityhuman) {
this.items = NonNullList.a(36, ItemStack.a);
this.armor = NonNullList.a(4, ItemStack.a);
@@ -41,6 +98,22 @@
@@ -41,6 +96,22 @@
return itemstack.getItem() == itemstack1.getItem() && ItemStack.equals(itemstack, itemstack1);
}
@ -94,7 +92,7 @@
public int getFirstEmptySlotIndex() {
for (int i = 0; i < this.items.size(); ++i) {
if (((ItemStack) this.items.get(i)).isEmpty()) {
@@ -513,8 +586,9 @@
@@ -513,8 +584,9 @@
ItemStack itemstack = (ItemStack) this.armor.get(i);
if (itemstack.getItem() instanceof ItemArmor) {
@ -105,7 +103,7 @@
});
}
}
@@ -550,6 +624,11 @@
@@ -550,6 +622,11 @@
}
public ItemStack getCarried() {

View File

@ -1,11 +1,10 @@
--- a/net/minecraft/server/TileEntityFurnace.java
+++ b/net/minecraft/server/TileEntityFurnace.java
@@ -7,6 +7,17 @@
@@ -7,6 +7,16 @@
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.Nullable;
+// CraftBukkit start
+import java.util.List;
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
@ -18,7 +17,7 @@
public abstract class TileEntityFurnace extends TileEntityContainer implements IWorldInventory, RecipeHolder, AutoRecipeOutput, ITickable {
@@ -135,6 +146,36 @@
@@ -135,6 +145,36 @@
return map;
}
@ -55,7 +54,7 @@
private static void a(Map<Item, Integer> map, Tag<Item> tag, int i) {
Iterator iterator = tag.a().iterator();
@@ -211,12 +252,23 @@
@@ -211,12 +251,23 @@
this.cookTime = MathHelper.clamp(this.cookTime - 2, 0, this.cookTimeTotal);
}
} else {
@ -82,7 +81,7 @@
flag1 = true;
if (!itemstack.isEmpty()) {
Item item = itemstack.getItem();
@@ -278,11 +330,38 @@
@@ -278,11 +329,38 @@
ItemStack itemstack1 = irecipe.c();
ItemStack itemstack2 = (ItemStack) this.items.get(2);
@ -121,7 +120,7 @@
if (!this.world.isClientSide) {
this.a(irecipe);
@@ -307,7 +386,7 @@
@@ -307,7 +385,7 @@
}
protected int getRecipeCookingTime() {
@ -130,7 +129,7 @@
}
public static boolean isFuel(ItemStack itemstack) {
@@ -434,7 +513,7 @@
@@ -434,7 +512,7 @@
@Override
public void b(EntityHuman entityhuman) {}
@ -139,7 +138,7 @@
List<IRecipe<?>> list = Lists.newArrayList();
Iterator iterator = this.n.entrySet().iterator();
@@ -443,7 +522,7 @@
@@ -443,7 +521,7 @@
entityhuman.world.getCraftingManager().a((MinecraftKey) entry.getKey()).ifPresent((irecipe) -> {
list.add(irecipe);
@ -148,7 +147,7 @@
});
}
@@ -451,7 +530,7 @@
@@ -451,7 +529,7 @@
this.n.clear();
}
@ -157,7 +156,7 @@
int j;
if (f == 0.0F) {
@@ -465,6 +544,14 @@
@@ -465,6 +543,14 @@
i = j;
}

24
pom.xml
View File

@ -268,6 +268,30 @@
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.19</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>

View File

@ -1,7 +1,6 @@
package org.bukkit.craftbukkit.block.data;
import org.bukkit.block.data.Waterlogged;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftWaterlogged extends CraftBlockData implements Waterlogged {

View File

@ -11,8 +11,8 @@ import org.fusesource.jansi.Ansi;
import org.fusesource.jansi.Ansi.Erase;
public class TerminalConsoleWriterThread extends Thread {
final private ConsoleReader reader;
final private OutputStream output;
private final ConsoleReader reader;
private final OutputStream output;
public TerminalConsoleWriterThread(OutputStream output, ConsoleReader reader) {
this.output = output;

View File

@ -26,7 +26,7 @@ public class ItemStackLoreEnchantmentTest extends ItemStackTest {
return CompoundOperator.compound(
Joiner.on('+'),
NAME_PARAMETER,
~0l,
~0L,
Arrays.asList(
new Object[] {
new Operator() {

View File

@ -36,7 +36,7 @@ import com.google.common.collect.ImmutableList;
@RunWith(Parameterized.class)
public class ItemStackTest extends AbstractTestingBase {
static abstract class StackProvider {
abstract static class StackProvider {
final Material material;
StackProvider(Material material) {