Funktionierender Tracer
Dieser Commit ist enthalten in:
Ursprung
7b9c1da8ae
Commit
1b9afcd5da
@ -6,14 +6,12 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.TNTPrimed;
|
import org.bukkit.entity.TNTPrimed;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
|
||||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
|
||||||
import org.bukkit.event.world.WorldUnloadEvent;
|
import org.bukkit.event.world.WorldUnloadEvent;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
@ -29,13 +27,11 @@ public class TNTTracer implements Listener, Runnable {
|
|||||||
private final World world;
|
private final World world;
|
||||||
private final BukkitTask task;
|
private final BukkitTask task;
|
||||||
private final Set<Location> locations;
|
private final Set<Location> locations;
|
||||||
private final Set<TNTPrimed> tnts;
|
|
||||||
private boolean printed;
|
private boolean printed;
|
||||||
|
|
||||||
private TNTTracer(World world){
|
private TNTTracer(World world){
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.locations = new HashSet<>();
|
this.locations = new HashSet<>();
|
||||||
this.tnts = new HashSet<>();
|
|
||||||
this.printed = false;
|
this.printed = false;
|
||||||
this.task = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), this, 1, 1);
|
this.task = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), this, 1, 1);
|
||||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance());
|
Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance());
|
||||||
@ -44,7 +40,6 @@ public class TNTTracer implements Listener, Runnable {
|
|||||||
|
|
||||||
private void stop(){
|
private void stop(){
|
||||||
task.cancel();
|
task.cancel();
|
||||||
tnts.clear();
|
|
||||||
HandlerList.unregisterAll(this);
|
HandlerList.unregisterAll(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +66,6 @@ public class TNTTracer implements Listener, Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void hide(){
|
public void hide(){
|
||||||
end();
|
|
||||||
if(!printed)
|
if(!printed)
|
||||||
return;
|
return;
|
||||||
for(Location l : locations){
|
for(Location l : locations){
|
||||||
@ -80,32 +74,7 @@ public class TNTTracer implements Listener, Runnable {
|
|||||||
continue;
|
continue;
|
||||||
b.setType(Material.AIR);
|
b.setType(Material.AIR);
|
||||||
}
|
}
|
||||||
}
|
end();
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onExplode(EntityExplodeEvent e){
|
|
||||||
if(e.getEntityType() != EntityType.PRIMED_TNT)
|
|
||||||
return;
|
|
||||||
|
|
||||||
tnts.remove((TNTPrimed) e.getEntity());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onSpawn(EntitySpawnEvent e){
|
|
||||||
if(e.getEntityType() != EntityType.PRIMED_TNT)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(e.getLocation().getWorld() != world)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(tnts.size() > 150){
|
|
||||||
for(Player p : Bukkit.getOnlinePlayers()){
|
|
||||||
p.sendMessage(BauSystem.PREFIX + "§cEs können nicht mehr als 150 TNT verfolgt werden!");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
tnts.add((TNTPrimed) e.getEntity());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -117,8 +86,15 @@ public class TNTTracer implements Listener, Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for(TNTPrimed tnt : tnts){
|
if(locations.size() < 20000){
|
||||||
locations.add(tnt.getLocation());
|
for(Entity e : world.getEntitiesByClass(TNTPrimed.class)){
|
||||||
|
locations.add(e.getLocation());
|
||||||
|
}
|
||||||
|
if(locations.size() >= 20000){
|
||||||
|
for(Player p : world.getPlayers()){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cEs werden keine weiteren Positionen mehr erfasst (20.000 Block Limit)");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren