General cleanup
Removing outdated comments Removing outdated annotations Adding new annotations Removing deprecation
This commit is contained in:
@@ -24,7 +24,7 @@ import com.redstoner.utils.CommandException;
|
||||
import com.redstoner.utils.CommandMap;
|
||||
|
||||
@AutoRegisterListener
|
||||
@Version(major = 3, minor = 2, revision = 4, compatible = 3)
|
||||
@Version(major = 3, minor = 2, revision = 5, compatible = 3)
|
||||
public final class BlockPlaceMods implements Module, Listener
|
||||
{
|
||||
public static String PREFIX = ChatColor.GRAY + "[" + ChatColor.DARK_GREEN + "BPM" + ChatColor.GRAY + "]"
|
||||
@@ -38,8 +38,6 @@ public final class BlockPlaceMods implements Module, Listener
|
||||
{
|
||||
mod.registerListeners();
|
||||
}
|
||||
// CommandManager.registerCommand(getCommandString(), this, Main.plugin);
|
||||
// Sorry but this stuff isn't working for me. Not gonna spend more time on it.
|
||||
try
|
||||
{
|
||||
Map<String, org.bukkit.command.Command> commandMap = CommandMap.getCommandMap();
|
||||
@@ -82,19 +80,6 @@ public final class BlockPlaceMods implements Module, Listener
|
||||
{}
|
||||
}
|
||||
|
||||
/* @Override
|
||||
* public String getCommandString() {
|
||||
* return "command mod {\n" +
|
||||
* "perm utils.blockplacemods.command;\n" +
|
||||
* "type player;\n" +
|
||||
* "[empty] {\n" +
|
||||
* "run mod_empty;\n" +
|
||||
* "}\n" +
|
||||
* "[string:args...] {\n" +
|
||||
* "run mod args;\n" +
|
||||
* "}\n" +
|
||||
* "}\n";
|
||||
* } */
|
||||
@Command(hook = "mod_empty")
|
||||
public void onModEmptyCommand(CommandSender sender)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.redstoner.modules.blockplacemods.mods;
|
||||
|
||||
import com.redstoner.modules.datamanager.DataManager;
|
||||
import com.redstoner.utils.CommandException;
|
||||
import com.redstoner.utils.ItemProperties;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
@@ -17,13 +15,16 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.util.Arrays;
|
||||
import com.redstoner.modules.datamanager.DataManager;
|
||||
import com.redstoner.utils.CommandException;
|
||||
import com.redstoner.utils.ItemProperties;
|
||||
|
||||
public class ModInventory extends ModAbstract
|
||||
{
|
||||
protected InventoryType inventoryType;
|
||||
|
||||
public ModInventory(String name, InventoryType inventoryType) {
|
||||
public ModInventory(String name, InventoryType inventoryType)
|
||||
{
|
||||
super(name);
|
||||
this.inventoryType = inventoryType;
|
||||
}
|
||||
@@ -69,7 +70,7 @@ public class ModInventory extends ModAbstract
|
||||
throw new CommandException("Slot number " + slot + " is negative");
|
||||
}
|
||||
// Set the stored item to the item in the sender's hand
|
||||
ItemStack item = sender.getItemInHand();
|
||||
ItemStack item = sender.getInventory().getItemInMainHand();
|
||||
if (item == null || item.getType() == Material.AIR || item.getAmount() == 0)
|
||||
{
|
||||
// Remove the item.
|
||||
@@ -125,33 +126,38 @@ public class ModInventory extends ModAbstract
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected ItemStack[] get(Player player)
|
||||
{
|
||||
Object obj = DataManager.getData(player.getUniqueId().toString(), "BlockPlaceMods", getName());
|
||||
if (obj == null)
|
||||
return getDefault();
|
||||
JSONArray array = (JSONArray) obj;
|
||||
|
||||
ItemStack[] items = new ItemStack[Math.min(inventoryType.getDefaultSize(), array.size())];
|
||||
for (int i = 0, n = items.length; i < n; i++) {
|
||||
for (int i = 0, n = items.length; i < n; i++)
|
||||
{
|
||||
Object obj2 = array.get(i);
|
||||
if (obj2 instanceof JSONObject) { // if null, items[i] remains null
|
||||
if (obj2 instanceof JSONObject)
|
||||
{ // if null, items[i] remains null
|
||||
items[i] = new ItemProperties().loadFrom((JSONObject) obj2).toItemStack();
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
protected void set(Player player, int index, ItemStack item) {
|
||||
protected void set(Player player, int index, ItemStack item)
|
||||
{
|
||||
ItemStack[] data = get(player);
|
||||
if (item == null) {
|
||||
if (index < data.length) {
|
||||
if (item == null)
|
||||
{
|
||||
if (index < data.length)
|
||||
{
|
||||
data[index] = null;
|
||||
}
|
||||
} else {
|
||||
if (index >= data.length) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (index >= data.length)
|
||||
{
|
||||
data = Arrays.copyOf(data, index + 1);
|
||||
}
|
||||
data[index] = item;
|
||||
@@ -159,6 +165,7 @@ public class ModInventory extends ModAbstract
|
||||
set(player, data);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void set(Player player, ItemStack[] data)
|
||||
{
|
||||
if (highestUsedIndex(data) == -1)
|
||||
@@ -166,7 +173,8 @@ public class ModInventory extends ModAbstract
|
||||
else
|
||||
{
|
||||
JSONArray array = new JSONArray();
|
||||
for (int i = 0, n = highestUsedIndex(data); i < n; i++) {
|
||||
for (int i = 0, n = highestUsedIndex(data); i < n; i++)
|
||||
{
|
||||
ItemStack item = data[i];
|
||||
array.add(item == null ? null : new ItemProperties(item).toJSONObject());
|
||||
}
|
||||
@@ -180,8 +188,8 @@ public class ModInventory extends ModAbstract
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getDefault() {
|
||||
public ItemStack[] getDefault()
|
||||
{
|
||||
return new ItemStack[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class ModToggledCauldron extends ModToggledAbstract
|
||||
{
|
||||
|
||||
public ModToggledCauldron() {
|
||||
public ModToggledCauldron()
|
||||
{
|
||||
super("cauldron", false);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ public class ModToggledCauldron extends ModToggledAbstract
|
||||
return "If active, placed cauldrons are filled, and they cycle on right click";
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
@@ -32,6 +33,7 @@ public class ModToggledCauldron extends ModToggledAbstract
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
@@ -41,5 +43,4 @@ public class ModToggledCauldron extends ModToggledAbstract
|
||||
event.getBlock().setData((byte) 3);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
public class ModToggledPiston extends ModToggledAbstract
|
||||
{
|
||||
|
||||
public ModToggledPiston() {
|
||||
public ModToggledPiston()
|
||||
{
|
||||
super("piston", false);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ public class ModToggledPiston extends ModToggledAbstract
|
||||
return "If active, pistons face the block you place them against";
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
@@ -59,5 +60,4 @@ public class ModToggledPiston extends ModToggledAbstract
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
public class ModToggledStep extends ModToggledAbstract
|
||||
{
|
||||
|
||||
public ModToggledStep() {
|
||||
public ModToggledStep()
|
||||
{
|
||||
super("step", true);
|
||||
getAliases().add("slab");
|
||||
}
|
||||
@@ -19,6 +19,7 @@ public class ModToggledStep extends ModToggledAbstract
|
||||
return "If active, placed steps will always turn upside-down";
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
@@ -36,5 +37,4 @@ public class ModToggledStep extends ModToggledAbstract
|
||||
{
|
||||
return block == Material.STEP || block == Material.STONE_SLAB2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.redstoner.modules.blockplacemods.mods;
|
||||
|
||||
import com.redstoner.misc.Main;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
@@ -11,15 +14,14 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import com.redstoner.misc.Main;
|
||||
|
||||
public class ModToggledTorch extends ModToggledAbstract
|
||||
{
|
||||
private final Set<Block> torchesPlaced = new HashSet<>();
|
||||
|
||||
public ModToggledTorch() {
|
||||
public ModToggledTorch()
|
||||
{
|
||||
super("torch", true);
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.plugin, this::updateTorches, 2, 2);
|
||||
}
|
||||
@@ -44,6 +46,7 @@ public class ModToggledTorch extends ModToggledAbstract
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private boolean isAttachedToRedstoneBlock(Block block)
|
||||
{
|
||||
BlockFace towardsAgainst = getFaceTowardsBlockAgainst(block.getData());
|
||||
@@ -85,5 +88,4 @@ public class ModToggledTorch extends ModToggledAbstract
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,23 +1,29 @@
|
||||
package com.redstoner.utils;
|
||||
|
||||
public class CommandException extends Exception {
|
||||
|
||||
public CommandException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public CommandException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public CommandException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
|
||||
public CommandException() {
|
||||
}
|
||||
|
||||
public CommandException(String message) {
|
||||
super(message);
|
||||
}
|
||||
public class CommandException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = -7176634557736106754L;
|
||||
|
||||
public CommandException(String message, Throwable cause)
|
||||
{
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public CommandException(Throwable cause)
|
||||
{
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public CommandException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace)
|
||||
{
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
|
||||
public CommandException()
|
||||
{}
|
||||
|
||||
public CommandException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
package com.redstoner.utils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.SimpleCommandMap;
|
||||
import org.bukkit.plugin.SimplePluginManager;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
|
||||
public class CommandMap {
|
||||
|
||||
public static Map<String, Command> getCommandMap() throws ReflectiveOperationException, ClassCastException {
|
||||
public class CommandMap
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Map<String, Command> getCommandMap() throws ReflectiveOperationException, ClassCastException
|
||||
{
|
||||
Field field = SimplePluginManager.class.getDeclaredField("commandMap");
|
||||
field.setAccessible(true);
|
||||
Object map = field.get(Bukkit.getPluginManager());
|
||||
@@ -18,5 +20,4 @@ public class CommandMap {
|
||||
field.setAccessible(true);
|
||||
return (Map<String, Command>) field.get(map);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ public class ItemProperties
|
||||
public ItemProperties()
|
||||
{}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ItemProperties(ItemStack item)
|
||||
{
|
||||
if (item == null)
|
||||
@@ -55,6 +56,7 @@ public class ItemProperties
|
||||
unbreakable = meta.isUnbreakable();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ItemStack toItemStack()
|
||||
{
|
||||
ItemStack result = new ItemStack(id, amount, data);
|
||||
|
||||
Reference in New Issue
Block a user