Fixed all cross version material issues.

This commit is contained in:
ProSavage 2018-08-13 00:33:40 -05:00
parent b58410e8ab
commit 8fc9ed7395
9 changed files with 74 additions and 31 deletions

View File

@ -69,6 +69,7 @@ public class P extends MPlugin {
public P() { public P() {
p = this; p = this;
} }
@ -207,6 +208,59 @@ public class P extends MPlugin {
this.loadSuccessful = true; this.loadSuccessful = true;
} }
//multiversion material fields
public Material SUGAR_CANE_BLOCK;
public Material BANNER;
public Material CROPS;
public Material REDSTONE_LAMP_ON;
public Material STAINED_GLASS;
public Material STATIONARY_WATER;
public Material STAINED_CLAY;
public Material WOOD_BUTTON;
public Material SOIL;
public Material MOB_SPANWER;
public Material THIN_GLASS;
public Material IRON_FENCE;
public Material NETHER_FENCE;
public Material FENCE;
private void setupMultiversionMaterials() {
if (!mc113) {
BANNER = Material.valueOf("BANNER");
CROPS = Material.valueOf("LEGACY_CROPS");
SUGAR_CANE_BLOCK = Material.valueOf("LEGACY_SUGAR_CANE_BLOCK");
REDSTONE_LAMP_ON = Material.valueOf("LEGACY_REDSTONE_LAMP_ON");
STAINED_GLASS = Material.valueOf("LEGACY_STAINED_GLASS");
STATIONARY_WATER = Material.valueOf("LEGACY_STATIONARY_WATER");
STAINED_CLAY = Material.valueOf("LEGACY_STAINED_CLAY");
WOOD_BUTTON = Material.valueOf("LEGACY_WOOD_BUTTON");
SOIL = Material.valueOf("LEGACY_SOIL");
MOB_SPANWER = Material.valueOf("LEGACY_MOB_SPAWNER");
THIN_GLASS = Material.valueOf("LEGACY_THIN_GLASS");
IRON_FENCE = Material.valueOf("LEGACY_IRON_FENCE");
NETHER_FENCE = Material.valueOf("LEGACY_NETHER_FENCE");
FENCE = Material.valueOf("LEGACY_FENCE");
} else {
BANNER = Material.valueOf("LEGACY_BANNER");
CROPS = Material.valueOf("CROPS");
SUGAR_CANE_BLOCK = Material.valueOf("SUGAR_CANE_BLOCK");
REDSTONE_LAMP_ON = Material.valueOf("REDSTONE_LAMP_ON");
STAINED_GLASS = Material.valueOf("STAINED_GLASS");
STATIONARY_WATER = Material.valueOf("STATIONARY_WATER");
STAINED_CLAY = Material.valueOf("STAINED_CLAY");
WOOD_BUTTON = Material.valueOf("WOOD_BUTTON");
SOIL = Material.valueOf("SOIL");
MOB_SPANWER = Material.valueOf("MOB_SPAWNER");
THIN_GLASS = Material.valueOf("THIN_GLASS");
IRON_FENCE = Material.valueOf("IRON_FENCE");
NETHER_FENCE = Material.valueOf("NETHER_FENCE");
FENCE = Material.valueOf("FENCE");
}
}
private void setupPlaceholderAPI() { private void setupPlaceholderAPI() {
Plugin clip = getServer().getPluginManager().getPlugin("PlaceholderAPI"); Plugin clip = getServer().getPluginManager().getPlugin("PlaceholderAPI");
if (clip != null && clip.isEnabled()) { if (clip != null && clip.isEnabled()) {

View File

@ -52,15 +52,10 @@ public class CmdBanner extends FCommand {
} else { } else {
Material banner;
if (!P.p.mc113) {
banner = Material.valueOf("BANNER");
} else {
banner = Material.valueOf("LEGACY_BANNER");
}
warBanner = P.p.createItem(banner, 1, (short) 1, P.p.getConfig().getString("fbanners.Item.Name"), P.p.getConfig().getStringList("fbanners.Item.Lore"));
warBanner = P.p.createItem(P.p.BANNER, 1, (short) 1, P.p.getConfig().getString("fbanners.Item.Name"), P.p.getConfig().getStringList("fbanners.Item.Lore"));
} }
fme.msg(TL.COMMAND_BANNER_SUCCESS); fme.msg(TL.COMMAND_BANNER_SUCCESS);
warBanner.setAmount(1); warBanner.setAmount(1);

View File

@ -131,7 +131,7 @@ public class CmdSeeChunk extends FCommand {
} else { } else {
Material type = blockY % 5 == 0 ? Material.LEGACY_REDSTONE_LAMP_ON : Material.LEGACY_STAINED_GLASS; Material type = blockY % 5 == 0 ? P.p.REDSTONE_LAMP_ON : P.p.STAINED_GLASS;
VisualizeUtil.addLocation(player, loc, type); VisualizeUtil.addLocation(player, loc, type);
} }
} }

View File

@ -78,7 +78,7 @@ public class FactionsBlockListener implements Listener {
if (!fme.hasFaction()) { if (!fme.hasFaction()) {
return; return;
} }
if (event.getBlock().getType() == Material.LEGACY_MOB_SPAWNER) { if (event.getBlock().getType() == P.p.MOB_SPANWER) {
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER); Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER);
if (access != Access.ALLOW && fme.getRole() != Role.ADMIN) { if (access != Access.ALLOW && fme.getRole() != Role.ADMIN) {

View File

@ -1,6 +1,7 @@
package com.massivecraft.factions.listeners; package com.massivecraft.factions.listeners;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.P;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -47,9 +48,9 @@ public class FactionsExploitListener implements Listener {
// blocks who occupy less than 1 block width or length wise need to be handled differently // blocks who occupy less than 1 block width or length wise need to be handled differently
Material mat = event.getTo().getBlock().getType(); Material mat = event.getTo().getBlock().getType();
if (((mat == Material.LEGACY_THIN_GLASS if (((mat == P.p.THIN_GLASS
|| mat == Material.LEGACY_IRON_FENCE) && clippingThrough(target, from, 0.65)) || mat == P.p.IRON_FENCE) && clippingThrough(target, from, 0.65))
|| ((mat == Material.LEGACY_FENCE || mat == Material.LEGACY_NETHER_FENCE) && clippingThrough(target, from, 0.45))) { || ((mat == P.p.FENCE || mat == P.p.NETHER_FENCE) && clippingThrough(target, from, 0.45))) {
event.setTo(from); event.setTo(from);
return; return;
} }

View File

@ -305,7 +305,7 @@ public class FactionsPlayerListener implements Listener {
// You may use any block unless it is another faction's territory... // You may use any block unless it is another faction's territory...
if (rel.isNeutral() || (rel.isEnemy() && Conf.territoryEnemyProtectMaterials) || (rel.isAlly() && Conf.territoryAllyProtectMaterials) || (rel.isTruce() && Conf.territoryTruceProtectMaterials)) { if (rel.isNeutral() || (rel.isEnemy() && Conf.territoryEnemyProtectMaterials) || (rel.isAlly() && Conf.territoryAllyProtectMaterials) || (rel.isTruce() && Conf.territoryTruceProtectMaterials)) {
if (!justCheck) { if (!justCheck) {
me.msg(TL.PLAYER_USE_TERRITORY, (material == Material.LEGACY_SOIL ? "trample " : "use ") + TextUtil.getMaterialName(material), otherFaction.getTag(myFaction)); me.msg(TL.PLAYER_USE_TERRITORY, (material == P.p.SOIL ? "trample " : "use ") + TextUtil.getMaterialName(material), otherFaction.getTag(myFaction));
} }
return false; return false;
} }
@ -786,7 +786,7 @@ public class FactionsPlayerListener implements Listener {
return; return;
} }
if (e.getItemInHand().getType() == Material.LEGACY_BANNER) { if (e.getItemInHand().getType() == P.p.BANNER) {
ItemStack bannerInHand = e.getItemInHand(); ItemStack bannerInHand = e.getItemInHand();
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer()); FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
ItemStack warBanner = fme.getFaction().getBanner(); ItemStack warBanner = fme.getFaction().getBanner();
@ -796,7 +796,7 @@ public class FactionsPlayerListener implements Listener {
warmeta.setLore(P.p.colorList(P.p.getConfig().getStringList("fbanners.Item.Lore"))); warmeta.setLore(P.p.colorList(P.p.getConfig().getStringList("fbanners.Item.Lore")));
warBanner.setItemMeta(warmeta); warBanner.setItemMeta(warmeta);
} else { } else {
warBanner = P.p.createItem(Material.LEGACY_BANNER, 1, (short) 1, P.p.getConfig().getString("fbanners.Item.Name"), P.p.getConfig().getStringList("fbanners.Item.Lore")); warBanner = P.p.createItem(P.p.BANNER, 1, (short) 1, P.p.getConfig().getString("fbanners.Item.Name"), P.p.getConfig().getStringList("fbanners.Item.Lore"));
} }
if (warBanner.isSimilar(bannerInHand)) { if (warBanner.isSimilar(bannerInHand)) {

View File

@ -1,5 +1,6 @@
package com.massivecraft.factions.util.Particles; package com.massivecraft.factions.util.Particles;
import com.massivecraft.factions.P;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.Location; import org.bukkit.Location;
@ -453,7 +454,7 @@ public enum ParticleEffect {
*/ */
private static boolean isWater(Location location) { private static boolean isWater(Location location) {
Material material = location.getBlock().getType(); Material material = location.getBlock().getType();
return material == Material.WATER || material == Material.LEGACY_STATIONARY_WATER; return material == Material.WATER || material == P.p.STATIONARY_WATER;
} }
/** /**

View File

@ -96,7 +96,7 @@ public enum PermissableAction {
} }
Material material = Material.matchMaterial(section.getString("materials." + name().toLowerCase().replace('_', '-'))); Material material = Material.matchMaterial(section.getString("materials." + name().toLowerCase().replace('_', '-')));
if (material == null) { if (material == null) {
material = Material.LEGACY_STAINED_CLAY; material = P.p.STAINED_CLAY;
} }
Access access = fme.getFaction().getAccess(permissable, this); Access access = fme.getFaction().getAccess(permissable, this);

View File

@ -47,13 +47,9 @@ public class CropUpgrades implements Listener {
private void growCrop(BlockGrowEvent e) { private void growCrop(BlockGrowEvent e) {
Material CROPS; Material CROPS;
if (P.p.mc113) {
CROPS = Material.valueOf("LEGACY_CROPS");
} else {
CROPS = Material.valueOf("CROPS");
}
if (e.getBlock().getType().equals(CROPS)) {
if (e.getBlock().getType().equals(P.p.CROPS)) {
e.setCancelled(true); e.setCancelled(true);
Crops c = new Crops(CropState.RIPE); Crops c = new Crops(CropState.RIPE);
org.bukkit.block.BlockState bs = e.getBlock().getState(); org.bukkit.block.BlockState bs = e.getBlock().getState();
@ -61,19 +57,15 @@ public class CropUpgrades implements Listener {
bs.update(); bs.update();
} }
org.bukkit.block.Block below = e.getBlock().getLocation().subtract(0, 1, 0).getBlock(); org.bukkit.block.Block below = e.getBlock().getLocation().subtract(0, 1, 0).getBlock();
Material SUGARCANEBLOCK;
if (P.p.mc113) {
SUGARCANEBLOCK = Material.valueOf("LEGACY_SUGAR_CANE_BLOCK");
} else {
SUGARCANEBLOCK = Material.valueOf("SUGAR_CANE_BLOCK");
}
if (below.getType() == SUGARCANEBLOCK) {
if (below.getType() == P.p.SUGARCANEBLOCK) {
org.bukkit.block.Block above = e.getBlock().getLocation().add(0, 1, 0).getBlock(); org.bukkit.block.Block above = e.getBlock().getLocation().add(0, 1, 0).getBlock();
if (above.getType() == Material.AIR && above.getLocation().add(0, -2, 0).getBlock().getType() != Material.AIR) { if (above.getType() == Material.AIR && above.getLocation().add(0, -2, 0).getBlock().getType() != Material.AIR) {
above.setType(SUGARCANEBLOCK); above.setType(P.p.SUGARCANEBLOCK);
} }
} }