Makes Trail loggeable to coreprotect.

This commit is contained in:
marcocorriero 2017-11-16 14:48:54 +01:00 committed by GitHub
parent 9e7c385fef
commit 25ad80be60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,12 +1,12 @@
package me.totalfreedom.totalfreedommod.fun; package me.totalfreedom.totalfreedommod.fun;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.Set; import java.util.Set;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator; import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -14,11 +14,15 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
public class Trailer extends FreedomService public class Trailer extends FreedomService
{ {
public byte data;
private final Random random = new Random(); private final Random random = new Random();
private final Set<String> trailPlayers = new HashSet<>(); // player name public final Set<String> trailPlayers = new HashSet<>(); // player name
public Trailer(TotalFreedomMod plugin) public Trailer(TotalFreedomMod plugin)
{ {
@ -60,8 +64,23 @@ public class Trailer extends FreedomService
return; return;
} }
final Location location = fromBlock.getLocation();
fromBlock.setType(Material.WOOL); fromBlock.setType(Material.WOOL);
DepreciationAggregator.setData_Block(fromBlock, (byte) random.nextInt(16)); DepreciationAggregator.setData_Block(fromBlock, (byte) random.nextInt(16));
final byte data = DepreciationAggregator.getData_Block(fromBlock);
Material material = Material.getMaterial(String.valueOf(fromBlock.getType()));
for (int x = -1; x <= 1; x++)
{
for (int z = -1; z <= 1; z++)
{
final Location trail_pos;
trail_pos = new Location(event.getPlayer().getWorld(), fromBlock.getX() + x, fromBlock.getY(), fromBlock.getZ() + z);
if (trailPlayers.contains(event.getPlayer().getName())) {
plugin.cpb.getCoreProtectAPI().logPlacement(event.getPlayer().getName(), trail_pos, material, data);
}
}
}
} }
public void remove(Player player) public void remove(Player player)