mirror of
https://github.com/CivMC/Civ.git
synced 2026-07-15 23:20:44 +00:00
enhanced solution to dynamite bug
This commit is contained in:
@@ -111,7 +111,7 @@ public class BlockListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Coordinate> reinforcedBlocks = new ArrayList<Coordinate>();
|
||||
List<Coordinate> reinforcedBlocksCoords = new ArrayList<Coordinate>();
|
||||
HashMap<Coordinate, Block> affectedBlocks = new HashMap<Coordinate, Block>();
|
||||
|
||||
//Initialize min & max X,Y,Z coordinates
|
||||
@@ -165,18 +165,19 @@ public class BlockListener implements Listener {
|
||||
|
||||
//Query database for any reinforced blocks that may be in the blast radius
|
||||
//Reinforced blocks should have a durability > 0 (aka >= 1)
|
||||
reinforcedBlocks = dao.selectReinforcements(worldName, smallestX, largestX, smallestY, largestY, smallestZ, largestZ);
|
||||
System.out.println(reinforcedBlocks.get(0));
|
||||
reinforcedBlocksCoords = dao.selectReinforcements(worldName, smallestX, largestX, smallestY, largestY, smallestZ, largestZ);
|
||||
|
||||
if(reinforcedBlocks.size() < 1){
|
||||
if(reinforcedBlocksCoords.size() < 1){
|
||||
return;
|
||||
}
|
||||
|
||||
//If there was some found, loop through each one
|
||||
for(int i = 0; i < reinforcedBlocks.size(); i++){
|
||||
Coordinate reinforcedBlock = reinforcedBlocks.get(i);
|
||||
for(int i = 0; i < reinforcedBlocksCoords.size(); i++){
|
||||
Coordinate rbCoords = reinforcedBlocksCoords.get(i);
|
||||
Block reinforcedBlock = affectedBlocks.get(rbCoords);
|
||||
|
||||
//Then remove it from explosion
|
||||
event.blockList().remove(affectedBlocks.get(reinforcedBlock));
|
||||
event.blockList().remove(reinforcedBlock);
|
||||
}
|
||||
|
||||
//Update reinforcements to set durability of blocks that are within blast radius
|
||||
|
||||
@@ -9,6 +9,9 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
@@ -19,6 +22,7 @@ public class Citadel extends JavaPlugin {
|
||||
public HashMap<Player, Integer> playerPlacementState;
|
||||
public CitadelDao dao;
|
||||
public Logger log;
|
||||
public Connection connection;
|
||||
|
||||
public void onEnable() {
|
||||
log = this.getLogger();
|
||||
@@ -46,14 +50,41 @@ public class Citadel extends JavaPlugin {
|
||||
materialRequirements.put(Material.getMaterial(keys[i]), requirements[i]);
|
||||
}
|
||||
|
||||
try {
|
||||
dao = new CitadelDao();
|
||||
try
|
||||
{
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
|
||||
this.connection = DriverManager.getConnection("jdbc:sqlite:plugins/Citadel/Citadel.db");
|
||||
this.connection.createStatement().execute(
|
||||
"CREATE TABLE IF NOT EXISTS REINFORCEMENTS (x INTEGER,y INTEGER,z INTEGER,world TEXT,durability INTEGER);");
|
||||
|
||||
this.connection.createStatement().execute(
|
||||
"CREATE TABLE IF NOT EXISTS GROUPS (grpName TEXT,member TEXT);");
|
||||
|
||||
this.connection.createStatement().execute(
|
||||
"CREATE TABLE IF NOT EXISTS REGISTRY (x INTEGER,y INTEGER,z INTEGER,world TEXT,grp TEXT);");
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new BlockListener(this), this);
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
System.err.println("sorry there was some sort of sql exception:");
|
||||
System.err.println(e.toString());
|
||||
System.err.println(e.getSQLState());
|
||||
return;
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
System.err.println("sorry we couldn't find the sqlite driver:");
|
||||
System.err.println(e.toString());
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("Other weird error when enabling Citadel: ");
|
||||
System.err.println(e.toString());
|
||||
}
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new BlockListener(this), this);
|
||||
log.info("Citadel - Hi folks, Citadel is now on :D.");
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
|
||||
Reference in New Issue
Block a user