7.2.2
This commit is contained in:
parent
6fa1b7340c
commit
2734ba1ae9
|
|
@ -2,7 +2,7 @@ name: GriefPrevention
|
|||
main: me.ryanhamshire.GriefPrevention.GriefPrevention
|
||||
softdepend: [Vault, Multiverse-Core, My Worlds, MystCraft, Transporter]
|
||||
dev-url: http://dev.bukkit.org/server-mods/grief-prevention
|
||||
version: 7.2
|
||||
version: 7.2.2
|
||||
commands:
|
||||
abandonclaim:
|
||||
description: Deletes a claim.
|
||||
|
|
|
|||
|
|
@ -597,6 +597,32 @@ public class BlockEventHandler implements Listener
|
|||
if(!GriefPrevention.instance.config_fireDestroys)
|
||||
{
|
||||
burnEvent.setCancelled(true);
|
||||
Block block = burnEvent.getBlock();
|
||||
Block [] adjacentBlocks = new Block []
|
||||
{
|
||||
block.getRelative(BlockFace.UP),
|
||||
block.getRelative(BlockFace.DOWN),
|
||||
block.getRelative(BlockFace.NORTH),
|
||||
block.getRelative(BlockFace.SOUTH),
|
||||
block.getRelative(BlockFace.EAST),
|
||||
block.getRelative(BlockFace.WEST)
|
||||
};
|
||||
|
||||
//pro-actively put out any fires adjacent the burning block, to reduce future processing here
|
||||
for(int i = 0; i < adjacentBlocks.length; i++)
|
||||
{
|
||||
Block adjacentBlock = adjacentBlocks[i];
|
||||
if(adjacentBlock.getType() == Material.FIRE && adjacentBlock.getRelative(BlockFace.DOWN).getType() != Material.NETHERRACK)
|
||||
{
|
||||
adjacentBlock.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
Block aboveBlock = block.getRelative(BlockFace.UP);
|
||||
if(aboveBlock.getType() == Material.FIRE)
|
||||
{
|
||||
aboveBlock.setType(Material.AIR);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package me.ryanhamshire.GriefPrevention;
|
|||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
|
@ -31,10 +32,10 @@ import org.bukkit.inventory.ItemStack;
|
|||
public abstract class DataStore
|
||||
{
|
||||
//in-memory cache for player data
|
||||
protected HashMap<String, PlayerData> playerNameToPlayerDataMap = new HashMap<String, PlayerData>();
|
||||
protected ConcurrentHashMap<String, PlayerData> playerNameToPlayerDataMap = new ConcurrentHashMap<String, PlayerData>();
|
||||
|
||||
//in-memory cache for group (permission-based) data
|
||||
protected HashMap<String, Integer> permissionToBonusBlocksMap = new HashMap<String, Integer>();
|
||||
protected ConcurrentHashMap<String, Integer> permissionToBonusBlocksMap = new ConcurrentHashMap<String, Integer>();
|
||||
|
||||
//in-memory cache for claim data
|
||||
ArrayList<Claim> claims = new ArrayList<Claim>();
|
||||
|
|
|
|||
|
|
@ -62,13 +62,7 @@ public class DatabaseDataStore extends DataStore
|
|||
|
||||
try
|
||||
{
|
||||
//set username/pass properties
|
||||
Properties connectionProps = new Properties();
|
||||
connectionProps.put("user", this.userName);
|
||||
connectionProps.put("password", this.password);
|
||||
|
||||
//establish connection
|
||||
this.databaseConnection = DriverManager.getConnection(this.databaseUrl, connectionProps);
|
||||
this.refreshDataConnection();
|
||||
}
|
||||
catch(Exception e2)
|
||||
{
|
||||
|
|
@ -240,6 +234,8 @@ public class DatabaseDataStore extends DataStore
|
|||
{
|
||||
try
|
||||
{
|
||||
this.refreshDataConnection();
|
||||
|
||||
//wipe out any existing data about this claim
|
||||
this.deleteClaimFromSecondaryStorage(claim);
|
||||
|
||||
|
|
@ -320,6 +316,8 @@ public class DatabaseDataStore extends DataStore
|
|||
|
||||
try
|
||||
{
|
||||
this.refreshDataConnection();
|
||||
|
||||
Statement statement = databaseConnection.createStatement();
|
||||
statement.execute("INSERT INTO griefprevention_claimdata VALUES(" +
|
||||
id + ", '" +
|
||||
|
|
@ -346,6 +344,8 @@ public class DatabaseDataStore extends DataStore
|
|||
{
|
||||
try
|
||||
{
|
||||
this.refreshDataConnection();
|
||||
|
||||
Statement statement = this.databaseConnection.createStatement();
|
||||
statement.execute("DELETE FROM griefprevention_claimdata WHERE id=" + claim.id + ";");
|
||||
statement.execute("DELETE FROM griefprevention_claimdata WHERE parentid=" + claim.id + ";");
|
||||
|
|
@ -365,6 +365,8 @@ public class DatabaseDataStore extends DataStore
|
|||
|
||||
try
|
||||
{
|
||||
this.refreshDataConnection();
|
||||
|
||||
Statement statement = this.databaseConnection.createStatement();
|
||||
ResultSet results = statement.executeQuery("SELECT * FROM griefprevention_playerdata WHERE name='" + playerName + "';");
|
||||
|
||||
|
|
@ -400,6 +402,8 @@ public class DatabaseDataStore extends DataStore
|
|||
|
||||
try
|
||||
{
|
||||
this.refreshDataConnection();
|
||||
|
||||
SimpleDateFormat sqlFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String dateString = sqlFormat.format(playerData.lastLogin);
|
||||
|
||||
|
|
@ -427,6 +431,8 @@ public class DatabaseDataStore extends DataStore
|
|||
|
||||
try
|
||||
{
|
||||
this.refreshDataConnection();
|
||||
|
||||
Statement statement = databaseConnection.createStatement();
|
||||
statement.execute("DELETE FROM griefprevention_nextclaimid;");
|
||||
statement.execute("INSERT INTO griefprevention_nextclaimid VALUES (" + nextID + ");");
|
||||
|
|
@ -457,11 +463,28 @@ public class DatabaseDataStore extends DataStore
|
|||
{
|
||||
try
|
||||
{
|
||||
this.databaseConnection.close();
|
||||
if(!this.databaseConnection.isClosed())
|
||||
{
|
||||
this.databaseConnection.close();
|
||||
}
|
||||
}
|
||||
catch(SQLException e){};
|
||||
}
|
||||
|
||||
this.databaseConnection = null;
|
||||
this.databaseConnection = null;
|
||||
}
|
||||
|
||||
private void refreshDataConnection() throws SQLException
|
||||
{
|
||||
if(this.databaseConnection == null || this.databaseConnection.isClosed())
|
||||
{
|
||||
//set username/pass properties
|
||||
Properties connectionProps = new Properties();
|
||||
connectionProps.put("user", this.userName);
|
||||
connectionProps.put("password", this.password);
|
||||
|
||||
//establish connection
|
||||
this.databaseConnection = DriverManager.getConnection(this.databaseUrl, connectionProps);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2254,7 +2254,7 @@ public class GriefPrevention extends JavaPlugin
|
|||
if(hasLeaves)
|
||||
{
|
||||
//schedule a cleanup task for later, in case the player leaves part of this tree hanging in the air
|
||||
TreeCleanupTask cleanupTask = new TreeCleanupTask(block, rootBlock, treeBlocks);
|
||||
TreeCleanupTask cleanupTask = new TreeCleanupTask(block, rootBlock, treeBlocks, rootBlock.getData());
|
||||
|
||||
//20L ~ 1 second, so 2 mins = 120 seconds ~ 2400L
|
||||
GriefPrevention.instance.getServer().getScheduler().scheduleSyncDelayedTask(GriefPrevention.instance, cleanupTask, 2400L);
|
||||
|
|
|
|||
|
|
@ -235,15 +235,18 @@ class PlayerEventHandler implements Listener
|
|||
//log entry
|
||||
GriefPrevention.AddLogEntry("Banning " + player.getName() + " for spam.");
|
||||
|
||||
//ban
|
||||
GriefPrevention.instance.getServer().getOfflinePlayer(player.getName()).setBanned(true);
|
||||
|
||||
//kick
|
||||
player.kickPlayer(GriefPrevention.instance.config_spam_banMessage);
|
||||
//kick and ban
|
||||
PlayerKickBanTask task = new PlayerKickBanTask(player, GriefPrevention.instance.config_spam_banMessage);
|
||||
GriefPrevention.instance.getServer().getScheduler().scheduleSyncDelayedTask(GriefPrevention.instance, task, 1L);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.kickPlayer("");
|
||||
//log entry
|
||||
GriefPrevention.AddLogEntry("Banning " + player.getName() + " for spam.");
|
||||
|
||||
//just kick
|
||||
PlayerKickBanTask task = new PlayerKickBanTask(player, null);
|
||||
GriefPrevention.instance.getServer().getScheduler().scheduleSyncDelayedTask(GriefPrevention.instance, task, 1L);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
59
src/me/ryanhamshire/GriefPrevention/PlayerKickBanTask.java
Normal file
59
src/me/ryanhamshire/GriefPrevention/PlayerKickBanTask.java
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
GriefPrevention Server Plugin for Minecraft
|
||||
Copyright (C) 2012 Ryan Hamshire
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.ryanhamshire.GriefPrevention;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
//kicks or bans a player
|
||||
//need a task for this because async threads (like the chat event handlers) can't kick or ban.
|
||||
//but they CAN schedule a task to run in the main thread to do that job
|
||||
class PlayerKickBanTask implements Runnable
|
||||
{
|
||||
//player to kick or ban
|
||||
private Player player;
|
||||
|
||||
//ban message. if null, don't ban
|
||||
private String banReason;
|
||||
|
||||
public PlayerKickBanTask(Player player, String banReason)
|
||||
{
|
||||
this.player = player;
|
||||
this.banReason = banReason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if(this.banReason != null)
|
||||
{
|
||||
//ban
|
||||
GriefPrevention.instance.getServer().getOfflinePlayer(this.player.getName()).setBanned(true);
|
||||
|
||||
//kick
|
||||
if(this.player.isOnline())
|
||||
{
|
||||
this.player.kickPlayer(this.banReason);
|
||||
}
|
||||
}
|
||||
else if(this.player.isOnline())
|
||||
{
|
||||
this.player.kickPlayer("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -54,6 +54,7 @@ class RestoreNatureProcessingTask implements Runnable
|
|||
{
|
||||
this.snapshots = snapshots;
|
||||
this.miny = miny;
|
||||
if(this.miny < 0) this.miny = 0;
|
||||
this.environment = environment;
|
||||
this.lesserBoundaryCorner = lesserBoundaryCorner;
|
||||
this.greaterBoundaryCorner = greaterBoundaryCorner;
|
||||
|
|
|
|||
|
|
@ -34,13 +34,15 @@ class TreeCleanupTask implements Runnable
|
|||
{
|
||||
private Block originalChoppedBlock; //first block chopped in the tree
|
||||
private Block originalRootBlock; //where the root of the tree used to be
|
||||
private byte originalRootBlockData; //data value of that root block (TYPE of log)
|
||||
private ArrayList<Block> originalTreeBlocks; //a list of other log blocks determined to be part of this tree
|
||||
|
||||
public TreeCleanupTask(Block originalChoppedBlock, Block originalRootBlock, ArrayList<Block> originalTreeBlocks)
|
||||
public TreeCleanupTask(Block originalChoppedBlock, Block originalRootBlock, ArrayList<Block> originalTreeBlocks, byte originalRootBlockData)
|
||||
{
|
||||
this.originalChoppedBlock = originalChoppedBlock;
|
||||
this.originalRootBlock = originalRootBlock;
|
||||
this.originalTreeBlocks = originalTreeBlocks;
|
||||
this.originalRootBlockData = originalRootBlockData;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -93,7 +95,7 @@ class TreeCleanupTask implements Runnable
|
|||
if(currentBlock.getType() == Material.AIR && (currentBlock.getRelative(BlockFace.DOWN).getType() == Material.DIRT || currentBlock.getRelative(BlockFace.DOWN).getType() == Material.GRASS))
|
||||
{
|
||||
currentBlock.setType(Material.SAPLING);
|
||||
currentBlock.setData(this.originalRootBlock.getData()); //makes the sapling type match the original tree type
|
||||
currentBlock.setData(this.originalRootBlockData); //makes the sapling type match the original tree type
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user