Skip to content

Commit

Permalink
Add support for Spigot 1.13+ and some refactoring #25
Browse files Browse the repository at this point in the history
  • Loading branch information
ceskyDJ committed Dec 21, 2021
1 parent ed38533 commit 1e1a13e
Show file tree
Hide file tree
Showing 17 changed files with 20 additions and 70 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version>
<version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

Expand All @@ -92,7 +92,7 @@
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId>
<version>7.0.2</version>
<version>7.0.0</version>
<scope>provided</scope>
</dependency>

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package cz.ceskydj.netherwater.exceptions;

import java.security.PrivilegedActionException;

@SuppressWarnings("unused")
public class MissingPermissionException extends Exception {
public MissingPermissionException() {
}
public MissingPermissionException() {}

public MissingPermissionException(String message) {
super(message);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cz.ceskydj.netherwater.exceptions;

@SuppressWarnings("unused")
public class PluginNotFoundException extends Exception {
public PluginNotFoundException() {
super();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@
import java.util.Objects;

public class BlockBreakListener implements Listener {
private final NetherWater plugin;
private final MessageManager messageManager;
private final DB db;
private final PermissionManager permissionManager;

public BlockBreakListener(NetherWater plugin) {
this.plugin = plugin;

this.messageManager = plugin.getMessageManager();
this.db = plugin.getDatabaseWrapper();
this.permissionManager = plugin.getPermissionManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,18 @@
import cz.ceskydj.netherwater.database.EntityStorage;
import cz.ceskydj.netherwater.managers.ConfigManager;
import cz.ceskydj.netherwater.managers.MessageManager;
import org.bouncycastle.util.Arrays;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.data.Levelled;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fish;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityEnterBlockEvent;
import org.bukkit.event.entity.EntityToggleSwimEvent;
import org.bukkit.event.player.PlayerMoveEvent;

import java.util.Objects;

public class MobMoveListener implements Listener {
private final MessageManager messageManager;
private final ConfigManager configManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@
import org.bukkit.event.block.FluidLevelChangeEvent;

public class WaterCreateListener implements Listener {
private final NetherWater plugin;
private final ConfigManager configManager;
private final MessageManager messageManager;

public WaterCreateListener(NetherWater plugin) {
this.plugin = plugin;

this.configManager = plugin.getConfigManager();
this.messageManager = plugin.getMessageManager();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void onBlockDispense(BlockDispenseEvent event) {
this.messageManager.dump("- Block: " + block.getType().name());
this.messageManager.dump("- Block's metadata: " + block.getBlockData().getAsString(true));
this.messageManager.dump("- Item: " + item.getType().name());
this.messageManager.dump("- Item's metadata: " + item.getItemMeta().toString());
this.messageManager.dump("- Item's metadata: " + item.getItemMeta());

if (block.getType() != Material.DISPENSER) {
return;
Expand Down Expand Up @@ -75,12 +75,9 @@ public void onBlockDispense(BlockDispenseEvent event) {
Dispenser dispenser = (Dispenser) block.getState();
Inventory inventory = dispenser.getInventory();

Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() {
@Override
public void run() {
int bucketPosition = inventory.first(Material.WATER_BUCKET);
inventory.setItem(bucketPosition, new ItemStack(Material.BUCKET));
}
Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, () -> {
int bucketPosition = inventory.first(Material.WATER_BUCKET);
inventory.setItem(bucketPosition, new ItemStack(Material.BUCKET));
});

// If the player has bypass permission, the water block won't disappear
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.bukkit.potion.PotionType;

import java.util.Objects;
import java.util.logging.Level;

public class WaterPlaceListener implements Listener {
private final MessageManager messageManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;

public class WaterReplaceListener implements Listener {
private final NetherWater plugin;
private final DB db;
private final PermissionManager permissionManager;

public WaterReplaceListener(NetherWater plugin) {
this.plugin = plugin;

this.db = plugin.getDatabaseWrapper();
this.permissionManager = plugin.getPermissionManager();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@
import org.bukkit.event.player.PlayerInteractEvent;

public class WaterScoopListener implements Listener {
private final NetherWater plugin;
private final ConfigManager configManager;
private final MessageManager messageManager;
private final DB db;
private final PermissionManager permissionManager;

public WaterScoopListener(NetherWater plugin) {
this.plugin = plugin;

this.configManager = plugin.getConfigManager();
this.messageManager = plugin.getMessageManager();
this.db = plugin.getDatabaseWrapper();
Expand All @@ -42,7 +39,12 @@ public void onPlayerInteract(PlayerInteractEvent event) {
}

Player player = event.getPlayer();
Block selectedBlock = event.getClickedBlock().getRelative(event.getBlockFace());
Block selectedBlock;
if (event.getClickedBlock() != null) {
selectedBlock = event.getClickedBlock().getRelative(event.getBlockFace());
} else {
return;
}

if (selectedBlock.getType() != Material.WATER) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.List;

public class ConfigManager {
private ConfigManipulator configManipulator;
private final ConfigManipulator configManipulator;

public ConfigManager(ConfigManipulator configManipulator) {
this.configManipulator = configManipulator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import de.leonhard.storage.Config;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.ItemStack;
Expand All @@ -18,6 +17,7 @@
import java.util.Map;
import java.util.Objects;

@SuppressWarnings("unused")
public class ConfigManipulator {
private final NetherWater plugin;
private final MessageManager messageManager;
Expand Down Expand Up @@ -164,12 +164,6 @@ public ItemStack getItemStack(String key) {
return this.configData.getOrDefault(key, defaultValue);
}

public Location getLocation(String key) {
Location defaultValue = this.defaultConfig.getLocation(key);

return this.configData.getOrDefault(key, defaultValue);
}

public OfflinePlayer getOfflinePlayer(String key) {
OfflinePlayer defaultValue = this.defaultConfig.getOfflinePlayer(key);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void sendMessage(ConsoleCommandSender console, String messageName) {
this.sendMessage(console, messageName, null);
}

public void sendMessage(ConsoleCommandSender console, String messageName, Map<String, String> variables) {
public void sendMessage(ConsoleCommandSender ignoredConsole, String messageName, Map<String, String> variables) {
this.consoleMessage(this.prepareMessage(messageName, variables));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.Levelled;
import org.bukkit.material.Cauldron;

import java.util.LinkedHashSet;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public void run() {

if (blockType.contains("CAULDRON") && block.getBlockData() instanceof Levelled) {
Levelled water_level = (Levelled) block.getBlockData();

if (water_level.getLevel() == 1) {
// There is the last bit of water --> empty cauldron completely
block.setType(Material.CAULDRON);
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ author: ceskyDJ

main: cz.ceskydj.netherwater.NetherWater
database: true
api-version: "1.15"
api-version: "1.13"
softdepend:
- WorldEdit
- WorldGuard
Expand Down Expand Up @@ -44,6 +44,7 @@ permissions:
netherwater.spread.bypass: true
netherwater.scooping.bypass: true
netherwater.disappearing.bypass: true
netherwater.drying.bypass: true
netherwater.world.bypass:
description: Allows players to bypass the disabled worlds and place water
default: op
Expand Down

0 comments on commit 1e1a13e

Please sign in to comment.