2017-12-28 05:50:39 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.blocking;
|
|
|
|
|
|
|
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
|
|
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
|
|
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventPriority;
|
|
|
|
import org.bukkit.event.block.BlockBreakEvent;
|
|
|
|
import org.bukkit.event.block.BlockPlaceEvent;
|
|
|
|
|
|
|
|
public class EditBlocker extends FreedomService
|
|
|
|
{
|
|
|
|
@Override
|
2020-07-01 01:51:06 +00:00
|
|
|
public void onStart()
|
2017-12-28 05:50:39 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-07-01 01:51:06 +00:00
|
|
|
public void onStop()
|
2017-12-28 05:50:39 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
|
|
public void onBlockPlace(BlockPlaceEvent event)
|
|
|
|
{
|
|
|
|
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
|
|
|
|
if (!fPlayer.isEditBlocked())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-08-15 22:42:46 +00:00
|
|
|
if (plugin.sl.isStaffSync(event.getPlayer()))
|
2017-12-28 05:50:39 +00:00
|
|
|
{
|
|
|
|
fPlayer.setEditBlocked(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to place blocks has been disabled!");
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
|
|
public void onBlockBreak(BlockBreakEvent event)
|
|
|
|
{
|
|
|
|
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
|
|
|
|
if (!fPlayer.isEditBlocked())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-08-15 22:42:46 +00:00
|
|
|
if (plugin.sl.isStaffSync(event.getPlayer()))
|
2017-12-28 05:50:39 +00:00
|
|
|
{
|
|
|
|
fPlayer.setEditBlocked(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to destroy blocks has been disabled!");
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|