Automatic visualization reversion.

Set to 60 seconds after visualization appearance.
This commit is contained in:
ryanhamshire 2014-10-16 20:33:48 -07:00
parent f2634fa464
commit b51006a949
2 changed files with 51 additions and 0 deletions

View File

@ -49,5 +49,11 @@ class VisualizationApplicationTask implements Runnable
//remember the visualization applied to this player for later (so it can be inexpensively reverted)
playerData.currentVisualization = visualization;
//schedule automatic visualization reversion in 60 seconds.
GriefPrevention.instance.getServer().getScheduler().scheduleSyncDelayedTask(
GriefPrevention.instance,
new VisualizationReversionTask(player, playerData, visualization),
20L * 60); //60 seconds
}
}

View File

@ -0,0 +1,45 @@
/*
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;
//applies a visualization for a player by sending him block change packets
class VisualizationReversionTask implements Runnable
{
private Visualization visualization;
private Player player;
private PlayerData playerData;
public VisualizationReversionTask(Player player, PlayerData playerData, Visualization visualization)
{
this.visualization = visualization;
this.playerData = playerData;
this.player = player;
}
@Override
public void run()
{
//don't do anything if the player's current visualization is different from the one scheduled to revert
if(playerData.currentVisualization != visualization) return;
Visualization.Revert(player);
}
}