AlttdGriefPrevention/src/me/ryanhamshire/GriefPrevention/PlayerKickBanTask.java

62 lines
1.6 KiB
Java
Raw Normal View History

2013-01-25 03:45:39 +00:00
/*
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;
//message to send player.
private String reason;
2013-01-25 03:45:39 +00:00
2015-07-15 01:13:33 +00:00
//source of ban
private String source;
//whether to ban
private boolean ban;
2015-07-15 01:13:33 +00:00
public PlayerKickBanTask(Player player, String reason, String source, boolean ban)
2013-01-25 03:45:39 +00:00
{
this.player = player;
this.reason = reason;
2015-07-15 01:13:33 +00:00
this.source = source;
this.ban = ban;
2013-01-25 03:45:39 +00:00
}
@Override
public void run()
{
if(this.ban)
2013-01-25 03:45:39 +00:00
{
//ban
GriefPrevention.banPlayer(this.player, this.reason, this.source);
2013-01-25 03:45:39 +00:00
}
else if(this.player.isOnline())
{
this.player.kickPlayer(this.reason);
2013-01-25 03:45:39 +00:00
}
}
}