Merge pull request #5 from marcocorriero/patch-2

Makes Trail loggeable to coreprotect.
This commit is contained in:
Lemon 2017-11-23 07:25:32 +05:00 committed by GitHub
commit c5e40bcc13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,12 +1,12 @@
package me.totalfreedom.totalfreedommod.fun;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Set;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@ -16,7 +16,6 @@ import org.bukkit.event.player.PlayerMoveEvent;
public class Trailer extends FreedomService
{
private final Random random = new Random();
private final Set<String> trailPlayers = new HashSet<>(); // player name
@ -60,8 +59,22 @@ public class Trailer extends FreedomService
return;
}
final Location location = fromBlock.getLocation();
fromBlock.setType(Material.WOOL);
DepreciationAggregator.setData_Block(fromBlock, (byte) random.nextInt(16));
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)