Replaced Material IDs in many cases to fix deprecation warnings

This commit is contained in:
Daniel Saukel 2015-07-15 23:47:42 +02:00
parent 2256c13265
commit f3c1c6791a
24 changed files with 86 additions and 56 deletions

View File

@ -4,6 +4,7 @@ import java.io.File;
import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
@ -117,10 +118,10 @@ public class DGSign {
for (yy = y; yy > y - verticalSigns; yy--) {
for (xx = x; xx > x - maxGroups; xx--) {
Block block = world.getBlockAt(xx, yy, zz);
if (block.getTypeId() != 0 && block.getTypeId() != 68) {
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
return null;
}
if (block.getRelative(0, 0, 1).getTypeId() == 0) {
if (block.getRelative(0, 0, 1).getType() == Material.AIR) {
return null;
}
changeBlocks.add(block);
@ -133,10 +134,10 @@ public class DGSign {
for (xx = x; xx < x + maxGroups; xx++) {
Block block = world.getBlockAt(xx, yy, zz);
if (block.getTypeId() != 0 && block.getTypeId() != 68) {
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
return null;
}
if (block.getRelative(0, 0, -1).getTypeId() == 0) {
if (block.getRelative(0, 0, -1).getType() == Material.AIR) {
return null;
}
changeBlocks.add(block);
@ -148,10 +149,10 @@ public class DGSign {
for (yy = y; yy > y - verticalSigns; yy--) {
for (zz = z; zz < z + maxGroups; zz++) {
Block block = world.getBlockAt(xx, yy, zz);
if (block.getTypeId() != 0 && block.getTypeId() != 68) {
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
return null;
}
if (block.getRelative(1, 0, 0).getTypeId() == 0) {
if (block.getRelative(1, 0, 0).getType() == Material.AIR) {
return null;
}
changeBlocks.add(block);
@ -163,10 +164,10 @@ public class DGSign {
for (yy = y; yy > y - verticalSigns; yy--) {
for (zz = z; zz > z - maxGroups; zz--) {
Block block = world.getBlockAt(xx, yy, zz);
if (block.getTypeId() != 0 && block.getTypeId() != 68) {
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
return null;
}
if (block.getRelative(-1, 0, 0).getTypeId() == 0) {
if (block.getRelative(-1, 0, 0).getType() == Material.AIR) {
return null;
}
changeBlocks.add(block);
@ -200,7 +201,7 @@ public class DGSign {
}
public static DGSign getSign(Block block) {
if (block.getTypeId() == 68) {
if (block.getType() == Material.WALL_SIGN) {
int x = block.getX(), y = block.getY(), z = block.getZ();
for (DGSign dgsign : dgsigns) {
int sx1 = dgsign.startSign.getX(), sy1 = dgsign.startSign.getY(), sz1 = dgsign.startSign.getZ();

View File

@ -156,7 +156,7 @@ public class DPlayer {
if (gworld.isTutorial) {
p.permission.playerAddGroup(this.player, p.mainConfig.tutorialEndGroup);
p.permission.playerRemoveGroup(this.player, p.mainConfig.tutorialStartGroup);
p.getServer().dispatchCommand(p.getServer().getConsoleSender(), "pex user "+player.getName()+" group set "+p.mainConfig.tutorialEndGroup);
p.getServer().dispatchCommand(p.getServer().getConsoleSender(), "pex user "+player.getName()+" group set "+p.mainConfig.tutorialEndGroup);//TODO: Use Vault for this!
}
}
}
@ -291,7 +291,7 @@ public class DPlayer {
p.msg(player, p.language.get("Player_SignCopied"));
}
} else {
String info = "" + block.getTypeId();
String info = "" + block.getType();
if (block.getData() != 0) {
info = info + "," + block.getData();
}
@ -327,7 +327,7 @@ public class DPlayer {
/* Delete Inventory */
this.player.getInventory().clear();
this.player.getInventory().setArmorContents(null);
player.getInventory().setItemInHand(new ItemStack(0));
player.getInventory().setItemInHand(new ItemStack(Material.AIR));
// Remove Potion Effects
for (PotionEffect effect : this.player.getActivePotionEffects()) {
@ -342,19 +342,23 @@ public class DPlayer {
for (ItemStack istack : dclass.items) {
// Leggings
if (istack.getTypeId() == 300 || istack.getTypeId() == 304 || istack.getTypeId() == 308 || istack.getTypeId() == 312 || istack.getTypeId() == 316) {
if (istack.getType() == Material.LEATHER_LEGGINGS || istack.getType() == Material.CHAINMAIL_LEGGINGS || istack.getType() == Material.IRON_LEGGINGS
|| istack.getType() == Material.DIAMOND_LEGGINGS || istack.getType() == Material.GOLD_LEGGINGS) {
this.player.getInventory().setLeggings(istack);
}
// Helmet
else if (istack.getTypeId() == 298 || istack.getTypeId() == 302 || istack.getTypeId() == 306 || istack.getTypeId() == 310 || istack.getTypeId() == 314) {
else if (istack.getType() == Material.LEATHER_HELMET || istack.getType() == Material.CHAINMAIL_HELMET || istack.getType() == Material.IRON_HELMET
|| istack.getType() == Material.DIAMOND_HELMET || istack.getType() == Material.GOLD_HELMET) {
this.player.getInventory().setHelmet(istack);
}
// Chestplate
else if (istack.getTypeId() == 299 || istack.getTypeId() == 303 || istack.getTypeId() == 307 || istack.getTypeId() == 311 || istack.getTypeId() == 315) {
else if (istack.getType() == Material.LEATHER_CHESTPLATE || istack.getType() == Material.CHAINMAIL_CHESTPLATE || istack.getType() == Material.IRON_CHESTPLATE
|| istack.getType() == Material.DIAMOND_CHESTPLATE || istack.getType() == Material.GOLD_CHESTPLATE) {
this.player.getInventory().setChestplate(istack);
}
// Boots
else if (istack.getTypeId() == 301 || istack.getTypeId() == 305 || istack.getTypeId() == 309 || istack.getTypeId() == 313 || istack.getTypeId() == 317) {
else if (istack.getType() == Material.LEATHER_BOOTS || istack.getType() == Material.CHAINMAIL_BOOTS || istack.getType() == Material.IRON_BOOTS
|| istack.getType() == Material.DIAMOND_BOOTS || istack.getType() == Material.GOLD_BOOTS) {
this.player.getInventory().setBoots(istack);
}

View File

@ -2,6 +2,7 @@ package com.dre.dungeonsxl;
import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.Material;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
@ -55,10 +56,12 @@ public class DPortal {
do {
int zz = z1;
do {
int typeId = this.world.getBlockAt(xx, yy, zz).getType().getId();
if (typeId == 0 || typeId == 8 || typeId == 9 || typeId == 10 || typeId == 11 || typeId == 6 || typeId == 30 || typeId == 31 || typeId == 32 || typeId == 34 || typeId == 37
|| typeId == 38 || typeId == 39 || typeId == 40 || typeId == 50 || typeId == 51 || typeId == 59 || typeId == 55 || typeId == 75 || typeId == 78 || typeId == 76) {
this.world.getBlockAt(xx, yy, zz).setTypeId(90);
Material type = this.world.getBlockAt(xx, yy, zz).getType();
if (type == Material.AIR || type == Material.WATER || type == Material.STATIONARY_WATER || type == Material.LAVA || type == Material.STATIONARY_LAVA || type == Material.SAPLING
|| type == Material.WEB || type == Material.LONG_GRASS || type == Material.DEAD_BUSH || type == Material.PISTON_EXTENSION || type == Material.YELLOW_FLOWER
|| type == Material.RED_ROSE || type == Material.BROWN_MUSHROOM || type == Material.RED_MUSHROOM || type == Material.TORCH || type == Material.FIRE
|| type == Material.CROPS || type == Material.REDSTONE_WIRE || type == Material.REDSTONE_TORCH_OFF || type == Material.SNOW || type == Material.REDSTONE_TORCH_ON) {
this.world.getBlockAt(xx, yy, zz).setType(Material.PORTAL);
}
zz = zz + zcount;
@ -117,10 +120,10 @@ public class DPortal {
do {
int zz = z1;
do {
int typeId = this.world.getBlockAt(xx, yy, zz).getType().getId();
Material type = this.world.getBlockAt(xx, yy, zz).getType();
if (typeId == 90) {
this.world.getBlockAt(xx, yy, zz).setTypeId(0);
if (type == Material.PORTAL) {
this.world.getBlockAt(xx, yy, zz).setType(Material.AIR);
}
zz = zz + zcount;

View File

@ -3,6 +3,7 @@ package com.dre.dungeonsxl;
import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
@ -67,7 +68,7 @@ public class LeaveSign {
}
public static LeaveSign getSign(Block block) {
if (block.getTypeId() == 68 || block.getTypeId() == 63) {
if (block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST) {
for (LeaveSign leavesign : lsigns) {
if (block.getWorld() == leavesign.sign.getWorld()) {
if (block.getLocation().distance(leavesign.sign.getBlock().getLocation()) < 1) {

View File

@ -1,5 +1,6 @@
package com.dre.dungeonsxl.commands;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -27,7 +28,7 @@ public class CMDPortal extends DCommand {
dportal = new DPortal(false);
dportal.player = player;
dportal.world = player.getWorld();
player.getInventory().setItemInHand(new ItemStack(268));
player.getInventory().setItemInHand(new ItemStack(Material.WOOD_SWORD));
p.msg(player, p.language.get("Player_PortalIntroduction"));
} else {
DPortal.portals.remove(dportal);

View File

@ -4,6 +4,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@ -29,7 +30,7 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.HIGH)
public void onBlockPhysics(BlockPhysicsEvent event) {
if (event.getBlock().getTypeId() == 90) {
if (event.getBlock().getType() == Material.PORTAL) {
if (DPortal.get(event.getBlock()) != null) {
event.setCancelled(true);
}
@ -41,7 +42,7 @@ public class BlockListener implements Listener {
Block block = event.getBlock();
// Deny DPortal destroying
if (block.getTypeId() == 90) {
if (block.getType() == Material.PORTAL) {
if (DPortal.get(event.getBlock()) != null) {
event.setCancelled(true);
}
@ -172,7 +173,7 @@ public class BlockListener implements Listener {
public void onBlockSpread(BlockSpreadEvent event) {
Block block = event.getBlock();
// Block the Spread off Vines
if (block.getTypeId() == 106) {
if (block.getType() == Material.VINE) {
// Check GameWorlds
GameWorld gworld = GameWorld.get(event.getBlock().getWorld());
if (gworld != null) {

View File

@ -2,6 +2,7 @@ package com.dre.dungeonsxl.listener;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
@ -36,7 +37,7 @@ public class EntityListener implements Listener {
@EventHandler(priority = EventPriority.HIGH)
public void onItemSpawn(ItemSpawnEvent event) {
if (GameWorld.get(event.getLocation().getWorld()) != null) {
if (event.getEntity().getItemStack().getTypeId() == 323) {
if (event.getEntity().getItemStack().getType() == Material.SIGN) {
event.setCancelled(true);
}
}
@ -189,7 +190,7 @@ public class EntityListener implements Listener {
List<Block> blocklist = event.blockList();
for (Block block : blocklist) {
// Portals
if (block.getTypeId() == 90) {
if (block.getType() == Material.PORTAL) {
if (DPortal.get(block) != null) {
event.setCancelled(true);
return;
@ -197,7 +198,7 @@ public class EntityListener implements Listener {
}
// Signs
if (block.getTypeId() == 68 || block.getTypeId() == 63) {
if (block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST) {
if (DGSign.getSign(block) != null) {
event.setCancelled(true);
return;

View File

@ -143,7 +143,7 @@ public class PlayerListener implements Listener {
// Check Signs
if (clickedBlock != null) {
if (clickedBlock.getTypeId() == 68 || clickedBlock.getTypeId() == 63) {
if (clickedBlock.getType() == Material.WALL_SIGN || clickedBlock.getType() == Material.SIGN_POST) {
// Check Group Signs
if (DGSign.playerInteract(event.getClickedBlock(), player)) {
event.setCancelled(true);
@ -386,7 +386,7 @@ public class PlayerListener implements Listener {
dplayer.respawnArmor = event.getEntity().getInventory().getArmorContents();
// Delete all drops
for (ItemStack istack : event.getDrops()) {
istack.setTypeId(0);
istack.setType(Material.AIR);
}
}
}

View File

@ -1,6 +1,8 @@
package com.dre.dungeonsxl.signs;
import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
@ -31,7 +33,7 @@ public class SIGNCheckpoint extends DSign {
@Override
public void onInit() {
sign.getBlock().setTypeId(0);
sign.getBlock().setType(Material.AIR);
initialized = true;
}

View File

@ -1,5 +1,6 @@
package com.dre.dungeonsxl.signs;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import com.dre.dungeonsxl.game.GameChest;
@ -25,18 +26,18 @@ public class SIGNChest extends DSign {
@Override
public void onInit() {
for (int i = -1; i <= 1; i++) {
if (sign.getBlock().getRelative(i, 0, 0).getTypeId() == 54) {
if (sign.getBlock().getRelative(i, 0, 0).getType() == Material.CHEST) {
new GameChest(sign.getBlock().getRelative(i, 0, 0), gworld);
}
if (sign.getBlock().getRelative(0, 0, i).getTypeId() == 54) {
if (sign.getBlock().getRelative(0, 0, i).getType() == Material.CHEST) {
new GameChest(sign.getBlock().getRelative(0, 0, i), gworld);
}
if (sign.getBlock().getRelative(0, i, 0).getTypeId() == 54) {
if (sign.getBlock().getRelative(0, i, 0).getType() == Material.CHEST) {
new GameChest(sign.getBlock().getRelative(0, i, 0), gworld);
}
}
sign.getBlock().setTypeId(0);
sign.getBlock().setType(Material.AIR);
}
@Override

View File

@ -1,7 +1,9 @@
package com.dre.dungeonsxl.signs;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import com.dre.dungeonsxl.game.GameWorld;
public class SIGNChunkUpdater extends DSign {
@ -38,7 +40,7 @@ public class SIGNChunkUpdater extends DSign {
chunk.load();
gworld.loadedChunks.add(chunk);
}
sign.getBlock().setTypeId(0);
sign.getBlock().setType(Material.AIR);
}
@Override

View File

@ -1,6 +1,7 @@
package com.dre.dungeonsxl.signs;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
@ -47,7 +48,7 @@ public class SIGNClasses extends DSign {
if (isContinued) {
Block classBlock = sign.getBlock().getRelative(xx, 0, zz);
if (classBlock.getData() == sign.getData().getData() && classBlock.getTypeId() == 68 && (classBlock.getState() instanceof Sign)) {
if (classBlock.getData() == sign.getData().getData() && classBlock.getType() == Material.WALL_SIGN && (classBlock.getState() instanceof Sign)) {
Sign classSign = (Sign) classBlock.getState();
classSign.setLine(0, ChatColor.DARK_BLUE + "############");
@ -66,7 +67,7 @@ public class SIGNClasses extends DSign {
}
}
} else {
sign.getBlock().setTypeId(0);
sign.getBlock().setType(Material.AIR);
}
}

View File

@ -1,6 +1,7 @@
package com.dre.dungeonsxl.signs;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
@ -39,7 +40,7 @@ public class SIGNEnd extends DSign {
sign.setLine(3, ChatColor.DARK_BLUE + "############");
sign.update();
} else {
sign.getBlock().setTypeId(0);
sign.getBlock().setType(Material.AIR);
}
}

View File

@ -1,6 +1,7 @@
package com.dre.dungeonsxl.signs;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
@ -39,7 +40,7 @@ public class SIGNLeave extends DSign {
sign.setLine(3, ChatColor.DARK_BLUE + "############");
sign.update();
} else {
sign.getBlock().setTypeId(0);
sign.getBlock().setType(Material.AIR);
}
}

View File

@ -1,6 +1,8 @@
package com.dre.dungeonsxl.signs;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import com.dre.dungeonsxl.game.GameWorld;
public class SIGNLobby extends DSign {
@ -23,7 +25,7 @@ public class SIGNLobby extends DSign {
@Override
public void onInit() {
gworld.locLobby = sign.getLocation();
sign.getBlock().setTypeId(0);
sign.getBlock().setType(Material.AIR);
}
@Override

View File

@ -62,7 +62,7 @@ public class SIGNMob extends DSign {
}
}
}
sign.getBlock().setTypeId(0);
sign.getBlock().setType(Material.AIR);
initialized = true;
}

View File

@ -2,8 +2,10 @@ package com.dre.dungeonsxl.signs;
import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import com.dre.dungeonsxl.game.GameWorld;
public class SIGNMsg extends DSign {
@ -38,7 +40,7 @@ public class SIGNMsg extends DSign {
String msg = gworld.config.getMsg(p.parseInt(lines[1]), true);
if (msg != null) {
this.msg = msg;
sign.getBlock().setTypeId(0);
sign.getBlock().setType(Material.AIR);
}
}

View File

@ -1,5 +1,6 @@
package com.dre.dungeonsxl.signs;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import com.dre.dungeonsxl.game.GamePlaceableBlock;
@ -24,7 +25,7 @@ public class SIGNPlace extends DSign {
public void onInit() {
String lines[] = sign.getLines();
gworld.placeableBlocks.add(new GamePlaceableBlock(sign.getBlock(), lines[1], lines[2]));
sign.getBlock().setTypeId(0);
sign.getBlock().setType(Material.AIR);
}
@Override

View File

@ -1,6 +1,7 @@
package com.dre.dungeonsxl.signs;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
@ -40,7 +41,7 @@ public class SIGNReady extends DSign {
sign.setLine(3, ChatColor.DARK_BLUE + "############");
sign.update();
} else {
sign.getBlock().setTypeId(0);
sign.getBlock().setType(Material.AIR);
}
}

View File

@ -1,5 +1,6 @@
package com.dre.dungeonsxl.signs;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
@ -62,7 +63,7 @@ public class SIGNRedstone extends DSign {
}
this.block = sign.getBlock();
this.block.setTypeId(0);
this.block.setType(Material.AIR);
initialized = true;
}
@ -98,11 +99,11 @@ public class SIGNRedstone extends DSign {
}
public void power() {
block.setTypeId(152);
block.setType(Material.REDSTONE_BLOCK);
}
public void unpower() {
block.setTypeId(0);
block.setType(Material.AIR);
}
public void disableTask(int taskId) {

View File

@ -2,10 +2,10 @@ package com.dre.dungeonsxl.signs;
import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import com.dre.dungeonsxl.P;
import com.dre.dungeonsxl.game.GameWorld;
public class SIGNSoundMsg extends DSign {
@ -40,7 +40,7 @@ public class SIGNSoundMsg extends DSign {
String msg = gworld.config.getMsg(p.parseInt(lines[1]), true);
if (msg != null) {
this.msg = msg;
sign.getBlock().setTypeId(0);
sign.getBlock().setType(Material.AIR);
}
}

View File

@ -1,6 +1,8 @@
package com.dre.dungeonsxl.signs;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import com.dre.dungeonsxl.game.GameWorld;
public class SIGNStart extends DSign {
@ -23,7 +25,7 @@ public class SIGNStart extends DSign {
@Override
public void onInit() {
gworld.locStart = sign.getLocation();
sign.getBlock().setTypeId(0);
sign.getBlock().setType(Material.AIR);
}
@Override

View File

@ -3,6 +3,7 @@ package com.dre.dungeonsxl.signs;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import org.bukkit.block.Block;
@ -64,7 +65,7 @@ public class SIGNTrigger extends DSign {
@Override
public void onInit() {
triggerId = p.parseInt(sign.getLine(1));
sign.getBlock().setTypeId(0);
sign.getBlock().setType(Material.AIR);
initialized = true;
}

View File

@ -1,6 +1,6 @@
name: DungeonsXL
main: com.dre.dungeonsxl.P
version: 0.9.1
version: 0.9.2-SNAPSHOT
author: Frank Baumann
authors: [Frank Baumann, Milan Albrecht, Tobias Schmitz, Daniel Saukel]
website: http://www.dre2n.ml