Add files via upload

This commit is contained in:
Lemon 2017-11-07 14:11:18 +05:00 committed by GitHub
parent 212b367c3c
commit e1ac92b784
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 287 additions and 0 deletions

View File

@ -0,0 +1,55 @@
package me.totalfreedom.totalfreedommod;
import org.bukkit.event.EventPriority;
import org.bukkit.Location;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import java.text.DecimalFormat;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.entity.Player;
public class DropMonitor extends FreedomService
{
DecimalFormat df;
public DropMonitor(TotalFreedomMod plugin)
{
super(plugin);
this.df = new DecimalFormat("#");
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
public String GetMaterial(final int id)
{
return String.valueOf(Material.getMaterial(id));
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerItemDrop(final PlayerDropItemEvent event)
{
if (plugin.al.isAdmin(event.getPlayer()))
{
return;
}
final int dropeditem = event.getItemDrop().getItemStack().getTypeId();
final Location loc = event.getPlayer().getLocation();
for (Player player : server.getOnlinePlayers())
{
if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).DropMonitorEnabled())
{
FUtil.playerMsg(player, event.getPlayer().getName() + " dropped " + event.getItemDrop().getItemStack().getAmount() + " " + this.GetMaterial(dropeditem) + " at [" + this.df.format(loc.getX()) + ", " + this.df.format(loc.getY()) + ", " + this.df.format(loc.getZ()) + "] at the world '" + loc.getWorld().getName() + "'.");
}
}
}
}

View File

@ -0,0 +1,67 @@
package me.totalfreedom.totalfreedommod;
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
{
public EditBlocker(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.LOW)
public void BlockPlaceEvent(BlockPlaceEvent event)
{
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
if (!fPlayer.isEditBlock())
{
return;
}
if (plugin.al.isAdminSync(event.getPlayer()))
{
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 BlockBreakEvent(BlockBreakEvent event)
{
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
if (!fPlayer.isEditBlock())
{
return;
}
if (plugin.al.isAdminSync(event.getPlayer()))
{
fPlayer.setEditBlocked(false);
return;
}
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to destroy blocks has been disabled!");
event.setCancelled(true);
}
}

View File

@ -0,0 +1,98 @@
package me.totalfreedom.totalfreedommod;
import java.text.DecimalFormat;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.event.entity.LingeringPotionSplashEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.PotionSplashEvent;
import org.bukkit.projectiles.ProjectileSource;
public class PotionMonitorer extends FreedomService
{
DecimalFormat df;
public PotionMonitorer(TotalFreedomMod plugin)
{
super(plugin);
this.df = new DecimalFormat("#");
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
public String GetMaterial(final int id)
{
return String.valueOf(Material.getMaterial(id));
}
@EventHandler(priority = EventPriority.LOW)
public void LingeringPotionSplashEvent(LingeringPotionSplashEvent event)
{
ProjectileSource source = event.getEntity().getShooter();
if (!(source instanceof Player))
{
return;
}
Player player = (Player) source;
if (plugin.al.isAdmin((Player) event.getEntity().getShooter()))
{
return;
}
final int dropeditem = event.getEntity().getItem().getTypeId();
final Location loc = player.getLocation();
for (Player player2 : server.getOnlinePlayers())
{
if (plugin.al.isAdmin(player2) && plugin.pl.getPlayer(player2).PotionMonitorEnabled())
{
FUtil.playerMsg(player2, player.getName() + " Splashed " + event.getEntity().getItem().getAmount() + " " + this.GetMaterial(dropeditem) + " at [" + this.df.format(loc.getX()) + ", " + this.df.format(loc.getY()) + ", " + this.df.format(loc.getZ()) + "] at the world '" + loc.getWorld().getName() + "'.");
}
}
}
@EventHandler(priority = EventPriority.LOW)
public void PotionSplashEvent(PotionSplashEvent event)
{
ProjectileSource source = event.getEntity().getShooter();
if (!(source instanceof Player))
{
return;
}
Player player = (Player) source;
if (plugin.al.isAdmin((Player) event.getEntity().getShooter()))
{
return;
}
final int dropeditem = event.getPotion().getItem().getTypeId();
final Location loc = player.getLocation();
for (Player player2 : server.getOnlinePlayers())
{
if (plugin.al.isAdmin(player2) && plugin.pl.getPlayer(player2).PotionMonitorEnabled())
{
FUtil.playerMsg(player2, player.getName() + " Splashed " + event.getPotion().getItem().getAmount() + " " + this.GetMaterial(dropeditem) + " at [" + this.df.format(loc.getX()) + ", " + this.df.format(loc.getY()) + ", " + this.df.format(loc.getZ()) + "] at the world '" + loc.getWorld().getName() + "'.");
}
}
}
}

View File

@ -0,0 +1,67 @@
package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FSync;
import org.bukkit.ChatColor;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.projectiles.ProjectileSource;
public class PvPBlocker extends FreedomService
{
public PvPBlocker(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.LOW)
public void EntityDamageByEntityEvent(EntityDamageByEntityEvent event)
{
Entity damager = event.getDamager();
FPlayer fPlayer = null;
if (damager instanceof Player)
{
fPlayer = plugin.pl.getPlayerSync((Player) damager);
}
if (damager instanceof Projectile)
{
ProjectileSource ps = ((Projectile) damager).getShooter();
if (ps instanceof Player)
{
fPlayer = plugin.pl.getPlayerSync((Player) ps);
}
}
if (fPlayer == null || !fPlayer.isPVPBlock())
{
return;
}
if (plugin.al.isAdminSync(event.getDamager()))
{
fPlayer.setPVPBlock(false);
return;
}
Player player = (Player) damager;
event.setCancelled(true);
FSync.playerMsg(player, ChatColor.RED + "You have been disallowed from PvPing!");
}
}