Warn when not using Java 8 or greater.

Note: this warning is not in the shared WorldEdit class because it
doesn't get loaded as early as the individual plugin/mod
implementations for some reason.
This commit is contained in:
Kenzie Togami 2016-05-05 17:38:57 -07:00
parent ecc4948668
commit 301d02c9c5
3 changed files with 56 additions and 2 deletions

View File

@ -48,6 +48,8 @@ import com.sk89q.worldedit.regions.CylinderRegion;
import com.sk89q.worldedit.regions.Polygonal2DRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.util.Java8Detector;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -117,6 +119,9 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent());
loadAdapter(); // Need an adapter to work with special blocks with NBT data
// Check Java version
Java8Detector.notifyIfNot8();
}
private void loadConfig() {

View File

@ -0,0 +1,46 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.util;
import com.google.common.base.Joiner;
import com.sk89q.worldedit.WorldEdit;
public final class Java8Detector {
public static void notifyIfNot8() {
String[] ver = System.getProperty("java.version").split("\\.");
int major = Integer.parseInt(ver[1]);
if (major <= 7) {
// Implicitly java 7 because we compile against 7, so this won't
// even launch on 6.
WorldEdit.logger
.warning("WorldEdit has detected you are using Java 7"
+ " (based on detected version "
+ Joiner.on('.').join(ver) + ").");
WorldEdit.logger.warning(
"WorldEdit will stop supporting Java less than version 8 in the future,"
+ " due to Java 7 being EOL since April 2015."
+ " Please update your server to Java 8.");
}
}
private Java8Detector() {
}
}

View File

@ -19,8 +19,6 @@
package com.sk89q.worldedit.forge;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.common.FMLCommonHandler;
import org.apache.logging.log4j.Logger;
import com.google.common.base.Joiner;
@ -31,6 +29,7 @@ import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.internal.LocalWorldAdapter;
import com.sk89q.worldedit.util.Java8Detector;
import java.io.File;
import java.util.Map;
@ -62,6 +61,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/
@Mod(modid = ForgeWorldEdit.MOD_ID, name = "WorldEdit", version = "%VERSION%", acceptableRemoteVersions = "*")
public class ForgeWorldEdit {
static {
Java8Detector.notifyIfNot8();
}
public static Logger logger;
public static final String MOD_ID = "worldedit";