Code cleaning and Gradle Update

Updated gradle wrapper to 3.0
Updated Gradle files for Nukkit
Added/cleaned minor Nukkit code
Removed duplicate TitleManagement code

Signed-off-by: MattBDev <mattbdev@outlook.com>
This commit is contained in:
MattBDev 2016-09-13 18:10:01 -04:00
parent a95b68b73c
commit b6dac54677
15 changed files with 58 additions and 84 deletions

View File

@ -18,7 +18,7 @@ public class DefaultTitleManager extends TitleManager {
* @param stayTime Stay on screen time
* @param fadeOutTime Fade out time
*/
public DefaultTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
DefaultTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
super(title, subtitle, fadeInTime, stayTime, fadeOutTime);
}
@ -106,9 +106,9 @@ public class DefaultTitleManager extends TitleManager {
}
}
private Method getMethod(Class<?> clazz, String name, Class<?>... args) {
Method getMethod(Class<?> clazz, String name, Class<?>... args) {
for (Method m : clazz.getMethods()) {
if (m.getName().equals(name) && (args.length == 0 || ClassListEqual(args, m.getParameterTypes()))) {
if (m.getName().equals(name) && (args.length == 0 || classListEqual(args, m.getParameterTypes()))) {
m.setAccessible(true);
return m;
}
@ -116,17 +116,4 @@ public class DefaultTitleManager extends TitleManager {
return null;
}
boolean ClassListEqual(Class<?>[] l1, Class<?>[] l2) {
if (l1.length != l2.length) {
return false;
}
boolean equal = true;
for (int i = 0; i < l1.length; i++) {
if (l1[i] != l2[i]) {
equal = false;
break;
}
}
return equal;
}
}

View File

@ -17,7 +17,7 @@ public class DefaultTitleManager_183 extends DefaultTitleManager {
* @param stayTime Stay on screen time
* @param fadeOutTime Fade out time
*/
public DefaultTitleManager_183(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
DefaultTitleManager_183(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
super(title, subtitle, fadeInTime, stayTime, fadeOutTime);
}
@ -67,15 +67,4 @@ public class DefaultTitleManager_183 extends DefaultTitleManager {
}
}
}
private Method getMethod(Class<?> clazz, String name, Class<?>... args) {
for (Method m : clazz.getMethods()) {
if (m.getName().equals(name) && ((args.length == 0) || ClassListEqual(args, m.getParameterTypes()))) {
m.setAccessible(true);
return m;
}
}
return null;
}
}

View File

@ -19,7 +19,7 @@ public class HackTitleManager extends TitleManager {
* @param stayTime Stay on screen time
* @param fadeOutTime Fade out time
*/
public HackTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
HackTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
super(title, subtitle, fadeInTime, stayTime, fadeOutTime);
}
@ -162,18 +162,4 @@ public class HackTitleManager extends TitleManager {
return null;
}
private boolean classListEqual(Class<?>[] l1, Class<?>[] l2) {
if (l1.length != l2.length) {
return false;
}
boolean equal = true;
for (int i = 0; i < l1.length; i++) {
if (l1[i] != l2[i]) {
equal = false;
break;
}
}
return equal;
}
}

View File

@ -241,4 +241,17 @@ public abstract class TitleManager {
return true;
}
boolean classListEqual(Class<?>[] l1, Class<?>[] l2) {
if (l1.length != l2.length) {
return false;
}
boolean equal = true;
for (int i = 0; i < l1.length; i++) {
if (l1[i] != l2[i]) {
equal = false;
break;
}
}
return equal;
}
}

View File

@ -610,27 +610,27 @@ public class BukkitChunkManager extends ChunkManager {
public static class ContentMap {
public final Map<BlockLoc, ItemStack[]> chestContents;
public final Map<BlockLoc, ItemStack[]> furnaceContents;
public final Map<BlockLoc, ItemStack[]> dispenserContents;
public final Map<BlockLoc, ItemStack[]> dropperContents;
public final Map<BlockLoc, ItemStack[]> brewingStandContents;
public final Map<BlockLoc, ItemStack[]> beaconContents;
public final Map<BlockLoc, ItemStack[]> hopperContents;
public final Map<BlockLoc, Short[]> furnaceTime;
public final Map<BlockLoc, Object[]> skullData;
public final Map<BlockLoc, Material> jukeboxDisc;
public final Map<BlockLoc, Short> brewTime;
public final Map<BlockLoc, EntityType> spawnerData;
public final Map<BlockLoc, String> cmdData;
public final Map<BlockLoc, String[]> signContents;
public final Map<BlockLoc, Note> noteBlockContents;
public final Map<BlockLoc, List<Pattern>> bannerPatterns;
public final Map<BlockLoc, DyeColor> bannerBase;
public final Set<EntityWrapper> entities;
public final Map<PlotLoc, PlotBlock[]> allBlocks;
final Map<BlockLoc, ItemStack[]> chestContents;
final Map<BlockLoc, ItemStack[]> furnaceContents;
final Map<BlockLoc, ItemStack[]> dispenserContents;
final Map<BlockLoc, ItemStack[]> dropperContents;
final Map<BlockLoc, ItemStack[]> brewingStandContents;
final Map<BlockLoc, ItemStack[]> beaconContents;
final Map<BlockLoc, ItemStack[]> hopperContents;
final Map<BlockLoc, Short[]> furnaceTime;
final Map<BlockLoc, Object[]> skullData;
final Map<BlockLoc, Material> jukeboxDisc;
final Map<BlockLoc, Short> brewTime;
final Map<BlockLoc, EntityType> spawnerData;
final Map<BlockLoc, String> cmdData;
final Map<BlockLoc, String[]> signContents;
final Map<BlockLoc, Note> noteBlockContents;
final Map<BlockLoc, List<Pattern>> bannerPatterns;
final Map<BlockLoc, DyeColor> bannerBase;
final Set<EntityWrapper> entities;
final Map<PlotLoc, PlotBlock[]> allBlocks;
public ContentMap() {
ContentMap() {
this.chestContents = new HashMap<>();
this.furnaceContents = new HashMap<>();
this.dispenserContents = new HashMap<>();

View File

@ -1,5 +1,5 @@
repositories {
maven {url "https://hub.spigotmc.org/nexus/content/groups/public/"}
maven {url "http://ci.regularbox.com/plugin/repository/everything/"}
maven { url = "https://oss.sonatype.org/content/repositories/snapshots/"}
maven {url "http://nexus.hc.to/content/repositories/pub_releases"}
}
@ -16,9 +16,8 @@ configurations.all {
}
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
sourceCompatibility = 1.8
targetCompatibility = 1.8
processResources {
from('src/main/resources') {
include 'plugin.yml'

View File

@ -1,5 +1,5 @@
name: "PlotSquared"
version: "3.4.6-SNAPSHOT-0557671"
version: "3.4.6-SNAPSHOT-a95b68b"
author: Empire92
api: ["1.0.0"]
main: com.plotsquared.nukkit.NukkitMain

View File

@ -12,6 +12,7 @@ import cn.nukkit.entity.item.EntityPotion;
import cn.nukkit.entity.item.EntityVehicle;
import cn.nukkit.entity.mob.EntityMob;
import cn.nukkit.entity.passive.EntityAnimal;
import cn.nukkit.entity.passive.EntityTameable;
import cn.nukkit.entity.passive.EntityWaterAnimal;
import cn.nukkit.entity.projectile.EntityProjectile;
import cn.nukkit.event.Cancellable;
@ -552,7 +553,7 @@ public class PlayerEvents extends PlotListener implements Listener {
PlotPlayer plotPlayer = NukkitUtil.getPlayer(event.getPlayer());
Location location = plotPlayer.getLocation();
PlotArea area = location.getPlotArea();
if (area == null || (!area.PLOT_CHAT != plotPlayer.getAttribute("chat"))) {
if (area == null || (area.PLOT_CHAT == plotPlayer.getAttribute("chat"))) {
return;
}
Plot plot = area.getPlot(location);
@ -1052,9 +1053,7 @@ public void blockDestroy(BlockBreakEvent event) {
@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryClose(InventoryCloseEvent event) {
Player closer = event.getPlayer();
Player player = (Player) closer;
NukkitUtil.getPlayer(player).deleteMeta("inventory");
NukkitUtil.getPlayer(event.getPlayer()).deleteMeta("inventory");
}
@EventHandler(priority = EventPriority.MONITOR)
@ -1224,7 +1223,7 @@ public void blockDestroy(BlockBreakEvent event) {
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
return false;
}
} else if (false) { // TODO victim is tameable
} else if (victim instanceof EntityTameable) {
if (plot != null && (plot.getFlag(Flags.TAMED_ATTACK, false) || plot.getFlag(Flags.PVE, false) || plot.isAdded(plotPlayer.getUUID()))) {
return true;
}

View File

@ -50,7 +50,7 @@ public class NukkitEventUtil extends EventUtil {
public boolean callEvent(Event event) {
plugin.getServer().getPluginManager().callEvent(event);
return !(event instanceof Cancellable) || !((Cancellable) event).isCancelled();
return !(event instanceof Cancellable) || !event.isCancelled();
}
@Override

View File

@ -79,7 +79,7 @@ public class NukkitSchematicHandler extends SchematicHandler {
public void run() {
schematic.put("Blocks", new ByteArrayTag("Blocks", blocks));
schematic.put("Data", new ByteArrayTag("Data", blockData));
schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList<Tag>()));
schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList<>()));
schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, tileEntities));
whenDone.value = new CompoundTag("Schematic", schematic);
TaskManager.runTask(whenDone);

View File

@ -34,7 +34,7 @@ public class NukkitSetupUtils extends SetupUtils {
return;
}
String testWorld = "CheckingPlotSquaredGenerator";
HashMap<String, Object> map = new HashMap<String, Object>();
HashMap<String, Object> map = new HashMap<>();
map.put("world", testWorld);
map.put("plot-generator", new HybridGen());
NukkitPlotGenerator gen = new NukkitPlotGenerator(map);
@ -117,7 +117,7 @@ public class NukkitSetupUtils extends SetupUtils {
e.printStackTrace();
}
if (object.setupGenerator != null) {
HashMap<String, Object> map = new HashMap<String, Object>();
HashMap<String, Object> map = new HashMap<>();
map.put("world", object.world);
map.put("plot-generator", new HybridGen());
plugin.getServer().generateLevel(object.world, object.world.hashCode(), NukkitPlotGenerator.class, map);

View File

@ -8,7 +8,6 @@ import cn.nukkit.level.generator.biome.Biome;
import cn.nukkit.math.Vector3;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.block.BasicLocalBlockQueue;
import com.plotsquared.nukkit.NukkitMain;
@ -112,9 +111,7 @@ public class NukkitLocalQueue<T> extends BasicLocalBlockQueue<T> {
for (int y = 0; y < biomes2.length; y++) {
String biomeStr = biomes2[y];
if (biomeStr != null) {
if (last == null || !StringMan.isEqual(last, biomeStr)) {
biome = Biome.getBiome(biomeStr.toUpperCase()).getId();
}
biome = Biome.getBiome(biomeStr.toUpperCase()).getId();
level.setBiomeId(bx + x, bz + y, biome);
}
}

View File

@ -42,7 +42,6 @@ subprojects {
}
repositories {
mavenCentral()
maven {url "http://ci.regularbox.com/plugin/repository/everything/"}
maven {url "http://empcraft.com/maven2"}
maven {url "http://repo.mcstats.org/content/repositories/public"}
maven {url "http://maven.sk89q.com/repo/"}

View File

@ -1,6 +1,6 @@
#Tue Jun 28 19:14:40 AEST 2016
#Sun Sep 11 16:39:31 EDT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-bin.zip

5
gradlew vendored
View File

@ -161,4 +161,9 @@ function splitJvmOpts() {
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"