Add BasicShowMode
Dieser Commit ist enthalten in:
Ursprung
4824893d79
Commit
de9c79240a
@ -8,11 +8,8 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class TNTEntity_12 extends EntityFallingBlock implements AbstractTNTEntity {
|
public class TNTEntity_12 extends EntityFallingBlock implements AbstractTNTEntity {
|
||||||
|
|
||||||
private TNTPosition position;
|
|
||||||
|
|
||||||
public TNTEntity_12(World world, TNTPosition position, Player player) {
|
public TNTEntity_12(World world, TNTPosition position, Player player) {
|
||||||
super(((CraftWorld) world).getHandle(), position.getLocation().getX(), position.getLocation().getY(), position.getLocation().getZ(), Blocks.TNT.getBlockData());
|
super(((CraftWorld) world).getHandle(), position.getLocation().getX(), position.getLocation().getY(), position.getLocation().getZ(), Blocks.TNT.getBlockData());
|
||||||
this.position = position;
|
|
||||||
|
|
||||||
this.setNoGravity(true);
|
this.setNoGravity(true);
|
||||||
this.ticksLived = -12000;
|
this.ticksLived = -12000;
|
||||||
@ -35,6 +32,9 @@ public class TNTEntity_12 extends EntityFallingBlock implements AbstractTNTEntit
|
|||||||
ReflectionUtils.setValue("h", packetPlayOutSpawnEntity, 0);
|
ReflectionUtils.setValue("h", packetPlayOutSpawnEntity, 0);
|
||||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutSpawnEntity);
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutSpawnEntity);
|
||||||
|
|
||||||
|
PacketPlayOutEntityTeleport packetPlayOutEntityTeleport = new PacketPlayOutEntityTeleport(this);
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityTeleport);
|
||||||
|
|
||||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true);
|
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true);
|
||||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityMetadata);
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityMetadata);
|
||||||
|
|
||||||
|
@ -8,11 +8,8 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class TNTEntity_15 extends EntityFallingBlock implements AbstractTNTEntity {
|
public class TNTEntity_15 extends EntityFallingBlock implements AbstractTNTEntity {
|
||||||
|
|
||||||
private TNTPosition position;
|
|
||||||
|
|
||||||
public TNTEntity_15(World world, TNTPosition position, Player player) {
|
public TNTEntity_15(World world, TNTPosition position, Player player) {
|
||||||
super(((CraftWorld) world).getHandle(), position.getLocation().getX(), position.getLocation().getY(), position.getLocation().getZ(), Blocks.TNT.getBlockData());
|
super(((CraftWorld) world).getHandle(), position.getLocation().getX(), position.getLocation().getY(), position.getLocation().getZ(), Blocks.TNT.getBlockData());
|
||||||
this.position = position;
|
|
||||||
|
|
||||||
this.setNoGravity(true);
|
this.setNoGravity(true);
|
||||||
this.ticksLived = -12000;
|
this.ticksLived = -12000;
|
||||||
@ -29,12 +26,17 @@ public class TNTEntity_15 extends EntityFallingBlock implements AbstractTNTEntit
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbstractTNTEntity display(Player player) {
|
public AbstractTNTEntity display(Player player) {
|
||||||
|
System.out.println("SHOW: " + player + " " + locX() + " " + locY() + " " + locZ());
|
||||||
|
|
||||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(this);
|
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(this);
|
||||||
ReflectionUtils.setValue("f", packetPlayOutSpawnEntity, 0);
|
ReflectionUtils.setValue("f", packetPlayOutSpawnEntity, 0);
|
||||||
ReflectionUtils.setValue("g", packetPlayOutSpawnEntity, 0);
|
ReflectionUtils.setValue("g", packetPlayOutSpawnEntity, 0);
|
||||||
ReflectionUtils.setValue("h", packetPlayOutSpawnEntity, 0);
|
ReflectionUtils.setValue("h", packetPlayOutSpawnEntity, 0);
|
||||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutSpawnEntity);
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutSpawnEntity);
|
||||||
|
|
||||||
|
PacketPlayOutEntityTeleport packetPlayOutEntityTeleport = new PacketPlayOutEntityTeleport(this);
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityTeleport);
|
||||||
|
|
||||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true);
|
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true);
|
||||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityMetadata);
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityMetadata);
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
||||||
import de.steamwar.bausystem.tracer.show.StoredRecords;
|
import de.steamwar.bausystem.tracer.show.StoredRecords;
|
||||||
|
import de.steamwar.bausystem.tracer.show.TraceShowManager;
|
||||||
import de.steamwar.bausystem.world.Welt;
|
import de.steamwar.bausystem.world.Welt;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -83,8 +84,10 @@ public class CommandTrace implements CommandExecutor {
|
|||||||
player.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen gelöscht");
|
player.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen gelöscht");
|
||||||
break;
|
break;
|
||||||
case "show":
|
case "show":
|
||||||
|
TraceShowManager.show(player);
|
||||||
break;
|
break;
|
||||||
case "hide":
|
case "hide":
|
||||||
|
TraceShowManager.hide(player);
|
||||||
break;
|
break;
|
||||||
case "toggleshow":
|
case "toggleshow":
|
||||||
case "interpolate":
|
case "interpolate":
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
package de.steamwar.bausystem.tracer.record;
|
package de.steamwar.bausystem.tracer.record;
|
||||||
|
|
||||||
public class RecordStateMachine {
|
public class RecordStateMachine {
|
||||||
private RecordStateMachine(){}
|
private RecordStateMachine() {
|
||||||
|
}
|
||||||
|
|
||||||
private static final TraceAutoHandler autoHandler = new TraceAutoHandler();
|
private static final TraceAutoHandler autoHandler = new TraceAutoHandler();
|
||||||
|
|
||||||
@ -28,15 +29,15 @@ public class RecordStateMachine {
|
|||||||
private static Recorder recorder = null;
|
private static Recorder recorder = null;
|
||||||
|
|
||||||
public static void commandStart() {
|
public static void commandStart() {
|
||||||
recordStatus = RecordStatus.RECORD;
|
|
||||||
autoHandler.disable();
|
autoHandler.disable();
|
||||||
recordStart();
|
recordStart();
|
||||||
|
recordStatus = RecordStatus.RECORD;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void commandStop() {
|
public static void commandStop() {
|
||||||
recordStatus = RecordStatus.IDLE;
|
|
||||||
autoHandler.disable();
|
autoHandler.disable();
|
||||||
recordStop();
|
recordStop();
|
||||||
|
recordStatus = RecordStatus.IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void commandAuto() {
|
public static void commandAuto() {
|
||||||
@ -52,27 +53,23 @@ public class RecordStateMachine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void autoRecord(){
|
static void autoRecord() {
|
||||||
recordStatus = RecordStatus.RECORD_AUTO;
|
|
||||||
recordStart();
|
recordStart();
|
||||||
|
recordStatus = RecordStatus.RECORD_AUTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void autoIdle(){
|
static void autoIdle() {
|
||||||
recordStatus = RecordStatus.IDLE_AUTO;
|
|
||||||
recordStop();
|
recordStop();
|
||||||
|
recordStatus = RecordStatus.IDLE_AUTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void recordStart() {
|
private static void recordStart() {
|
||||||
if(recordStatus.isTracing())
|
if (recordStatus.isTracing()) return;
|
||||||
return;
|
|
||||||
|
|
||||||
recorder = new Recorder();
|
recorder = new Recorder();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void recordStop() {
|
private static void recordStop() {
|
||||||
if(!recordStatus.isTracing())
|
if (!recordStatus.isTracing()) return;
|
||||||
return;
|
|
||||||
|
|
||||||
recorder.stopRecording();
|
recorder.stopRecording();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,11 +77,13 @@ public class RecordStateMachine {
|
|||||||
return recordStatus;
|
return recordStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int size(){
|
public static int size() {
|
||||||
|
if (recorder == null) return 0;
|
||||||
return recorder.size();
|
return recorder.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long getStartTime(){
|
public static long getStartTime() {
|
||||||
|
if (recorder == null) return 0;
|
||||||
return recorder.getStartTime();
|
return recorder.getStartTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,13 +41,13 @@ public class Recorder implements Listener {
|
|||||||
private final BukkitTask task;
|
private final BukkitTask task;
|
||||||
private final Record record;
|
private final Record record;
|
||||||
|
|
||||||
Recorder(){
|
Recorder() {
|
||||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
||||||
task = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), this::run, 1, 1);
|
task = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), this::run, 1, 1);
|
||||||
record = new Record();
|
record = new Record();
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopRecording(){
|
void stopRecording() {
|
||||||
HandlerList.unregisterAll(this);
|
HandlerList.unregisterAll(this);
|
||||||
task.cancel();
|
task.cancel();
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ public class Recorder implements Listener {
|
|||||||
|
|
||||||
private Record.TNTRecord get(TNTPrimed tntPrimed) {
|
private Record.TNTRecord get(TNTPrimed tntPrimed) {
|
||||||
Record.TNTRecord tntRecord = recordMap.get(tntPrimed);
|
Record.TNTRecord tntRecord = recordMap.get(tntPrimed);
|
||||||
if(tntRecord != null)
|
if (tntRecord != null)
|
||||||
return tntRecord;
|
return tntRecord;
|
||||||
|
|
||||||
tntRecord = this.record.spawn();
|
tntRecord = this.record.spawn();
|
||||||
|
@ -30,26 +30,26 @@ public class Record {
|
|||||||
private final long startTime;
|
private final long startTime;
|
||||||
private final List<TNTRecord> tnt = new ArrayList<>();
|
private final List<TNTRecord> tnt = new ArrayList<>();
|
||||||
|
|
||||||
public int size(){
|
public int size() {
|
||||||
return tnt.size();
|
return tnt.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getStartTime(){
|
public long getStartTime() {
|
||||||
return startTime;
|
return startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showAll(ShowMode mode) {
|
public void showAll(ShowMode mode) {
|
||||||
for(TNTRecord record : tnt)
|
for (TNTRecord record : tnt)
|
||||||
record.showAll(mode);
|
record.showAll(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The following methods should only be called by a recorder */
|
/* The following methods should only be called by a recorder */
|
||||||
public Record(){
|
public Record() {
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
StoredRecords.add(this);
|
StoredRecords.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TNTRecord spawn(){
|
public TNTRecord spawn() {
|
||||||
TNTRecord record = new TNTRecord();
|
TNTRecord record = new TNTRecord();
|
||||||
tnt.add(record);
|
tnt.add(record);
|
||||||
return record;
|
return record;
|
||||||
@ -59,8 +59,8 @@ public class Record {
|
|||||||
private final List<TNTPosition> positions = new ArrayList<>(41);
|
private final List<TNTPosition> positions = new ArrayList<>(41);
|
||||||
private boolean exploded = false;
|
private boolean exploded = false;
|
||||||
|
|
||||||
public void showAll(ShowMode mode){
|
public void showAll(ShowMode mode) {
|
||||||
for(TNTPosition position : positions)
|
for (TNTPosition position : positions)
|
||||||
mode.show(position);
|
mode.show(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,18 +23,20 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class StoredRecords {
|
public class StoredRecords {
|
||||||
|
|
||||||
private static final List<Record> records = new ArrayList<>();
|
private static final List<Record> records = new ArrayList<>();
|
||||||
|
|
||||||
public static void add(Record record){
|
public static void add(Record record) {
|
||||||
records.add(record);
|
records.add(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showAll(ShowMode mode){
|
public static void showAll(ShowMode mode) {
|
||||||
for(Record record : records) record.showAll(mode);
|
for (Record record : records) record.showAll(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clear(){
|
public static void clear() {
|
||||||
records.clear();
|
records.clear();
|
||||||
TraceShowManager.clear();
|
TraceShowManager.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,42 +13,42 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class TraceShowManager implements Listener {
|
public class TraceShowManager implements Listener {
|
||||||
private TraceShowManager(){}
|
private TraceShowManager() {}
|
||||||
|
|
||||||
private static final Map<Player, ShowMode> showModes = new HashMap<>();
|
private static final Map<Player, ShowMode> showModes = new HashMap<>();
|
||||||
|
|
||||||
public static void show(Player player){
|
public static void show(Player player) {
|
||||||
hide(player);
|
hide(player);
|
||||||
ShowMode showMode = new BasicShowMode(player);
|
ShowMode showMode = new BasicShowMode(player);
|
||||||
StoredRecords.showAll(showMode);
|
StoredRecords.showAll(showMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void hide(Player player){
|
public static void hide(Player player) {
|
||||||
ShowMode showMode = showModes.remove(player);
|
ShowMode showMode = showModes.remove(player);
|
||||||
if(showMode == null)
|
if (showMode == null)
|
||||||
return;
|
return;
|
||||||
showMode.hide();
|
showMode.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only to be called by record */
|
/* Only to be called by record */
|
||||||
static void show(TNTPosition tnt){
|
static void show(TNTPosition tnt) {
|
||||||
for(ShowMode mode : showModes.values())
|
for (ShowMode mode : showModes.values())
|
||||||
mode.show(tnt);
|
mode.show(tnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only to be called by StoredRecords */
|
/* Only to be called by StoredRecords */
|
||||||
static void clear(){
|
static void clear() {
|
||||||
for(ShowMode mode : showModes.values())
|
for (ShowMode mode : showModes.values())
|
||||||
mode.hide();
|
mode.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Internal if player leaves*/
|
/* Internal if player leaves*/
|
||||||
static{
|
static {
|
||||||
Bukkit.getPluginManager().registerEvents(new TraceShowManager(), BauSystem.getPlugin());
|
Bukkit.getPluginManager().registerEvents(new TraceShowManager(), BauSystem.getPlugin());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onLeave(PlayerQuitEvent event){
|
public void onLeave(PlayerQuitEvent event) {
|
||||||
showModes.remove(event.getPlayer());
|
showModes.remove(event.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren