Add a stupidity fail-safe.

This commit is contained in:
MattBDev 2019-04-29 11:02:47 -04:00
parent 906c1081fa
commit 299fac95fb
3 changed files with 42 additions and 30 deletions

View File

@ -116,10 +116,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
@Override public void onEnable() { @Override public void onEnable() {
this.pluginName = getDescription().getName(); this.pluginName = getDescription().getName();
getServer().getName();
PlotPlayer.registerConverter(Player.class, BukkitUtil::getPlayer); PlotPlayer.registerConverter(Player.class, BukkitUtil::getPlayer);
if (Bukkit.getVersion().contains("git-Spigot")) { if (Bukkit.getVersion().contains("git-Spigot")) {

View File

@ -1,36 +1,44 @@
package com.github.intellectualsites.plotsquared.bukkit.util; package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.LegacyPlotBlock; import com.github.intellectualsites.plotsquared.plot.object.LegacyPlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock; import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.StringPlotBlock; import com.github.intellectualsites.plotsquared.plot.object.StringPlotBlock;
import com.github.intellectualsites.plotsquared.plot.util.LegacyMappings; import com.github.intellectualsites.plotsquared.plot.util.LegacyMappings;
import com.github.intellectualsites.plotsquared.plot.util.StringComparison; import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
import lombok.*; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import java.util.*;
import java.util.stream.Collectors;
/** /**
* Borrowed from https://github.com/Phoenix616/IDConverter/blob/master/mappings/src/main/java/de/themoep/idconverter/IdMappings.java * Borrowed from https://github.com/Phoenix616/IDConverter/blob/master/mappings/src/main/java/de/themoep/idconverter/IdMappings.java
* Original License: * Original License:
* <p> * <p>
* Minecraft ID mappings * Minecraft ID mappings Copyright (C) 2017 Max Lee (https://github.com/Phoenix616)
* Copyright (C) 2017 Max Lee (https://github.com/Phoenix616)
* <p> * <p>
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify it under the terms of the
* it under the terms of the GNU General Public License as published by * GNU General Public License as published by the Free Software Foundation, either version 3 of the
* the Free Software Foundation, either version 3 of the License, or * License, or (at your option) any later version.
* (at your option) any later version.
* <p> * <p>
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* but WITHOUT ANY WARRANTY; without even the implied warranty of * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * General Public License for more details.
* GNU General Public License for more details.
* <p> * <p>
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License along with this program. If
* along with this program. If not, see <http://www.gnu.org/licenses/>. * not, see <http://www.gnu.org/licenses/>.
*/ */
public final class BukkitLegacyMappings extends LegacyMappings { public final class BukkitLegacyMappings extends LegacyMappings {
@ -702,7 +710,15 @@ public final class BukkitLegacyMappings extends LegacyMappings {
try { try {
material = Material.valueOf(legacyBlock.getNewName()); material = Material.valueOf(legacyBlock.getNewName());
} catch (final Exception e) { } catch (final Exception e) {
material = Material.getMaterial(legacyBlock.getLegacyName(), true); try {
material = Material.getMaterial(legacyBlock.getLegacyName(), true);
} catch (NoSuchMethodError error) {
PlotSquared.log(
"You can't use this version of PlotSquared on a server "
+ "less than Minecraft 1.13.2");
Bukkit.shutdown();
break;
}
} }
legacyBlock.material = material; legacyBlock.material = material;
} }
@ -721,13 +737,10 @@ public final class BukkitLegacyMappings extends LegacyMappings {
} }
/** /**
* Try to find a legacy plot block by any means possible. * Try to find a legacy plot block by any means possible. Strategy: - Check if the name contains
* Strategy: * a namespace, if so, strip it - Check if there's a (new) material matching the name - Check if
* - Check if the name contains a namespace, if so, strip it * there's a legacy material matching the name - Check if there's a numerical ID matching the
* - Check if there's a (new) material matching the name * name - Return null if everything else fails
* - Check if there's a legacy material matching the name
* - Check if there's a numerical ID matching the name
* - Return null if everything else fails
* *
* @param string String ID * @param string String ID
* @return LegacyBlock if found, else null * @return LegacyBlock if found, else null

View File

@ -340,9 +340,11 @@ import java.util.*;
} else if (world.getBlockAt(x, y, z - 1).getType().isSolid()) { } else if (world.getBlockAt(x, y, z - 1).getType().isSolid()) {
facing = BlockFace.SOUTH; facing = BlockFace.SOUTH;
} }
block.setType(Material.valueOf( if (PlotSquared.get().IMP.getServerVersion()[1] == 13) {
PlotSquared.get().IMP.getServerVersion()[1] == 13 ? "WALL_SIGN" : "OAK_WALL_SIGN"), block.setType(Material.valueOf("WALL_SIGN"), false);
false); } else {
block.setType(Material.valueOf("OAK_WALL_SIGN"), false);
}
final Directional sign = (Directional) block.getBlockData(); final Directional sign = (Directional) block.getBlockData();
sign.setFacing(facing); sign.setFacing(facing);
block.setBlockData(sign, false); block.setBlockData(sign, false);