SteamWar/BauSystem
Archiviert
13
0

Merge pull request 'Initial Commit 1.12 Support' (#80) from TNTTracer into master

Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Lixfel 2020-07-20 05:48:58 +02:00
Commit 8d44e714c7
17 geänderte Dateien mit 88 neuen und 84 gelöschten Zeilen

Datei anzeigen

@ -1,6 +1,6 @@
package de.steamwar.bausystem.tracer; package de.steamwar.bausystem.tracer;
import de.steamwar.bausystem.tracer.showcallback.TNTShowCallback_15; import de.steamwar.bausystem.tracer.showcallback.TNTCallbackShow;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -51,7 +51,7 @@ public class PlayerTraceCache_15 {
return false; return false;
} }
public void show(Player player, TNTShowCallback_15.ShowMode showMode) { public void show(Player player, TNTCallbackShow.ShowMode showMode) {
if (hiding) return; if (hiding) return;
if (positions.length == 0 || positions.length % 3 != 0) return; if (positions.length == 0 || positions.length % 3 != 0) return;
for (int i = 0; i < positions.length; i += 3) { for (int i = 0; i < positions.length; i += 3) {
@ -59,7 +59,7 @@ public class PlayerTraceCache_15 {
float y = positions[i + 1]; float y = positions[i + 1];
float z = positions[i + 2]; float z = positions[i + 2];
if (showMode == TNTShowCallback_15.ShowMode.PARTICLE && positions.length / 3 < 1000) { if (showMode == TNTCallbackShow.ShowMode.PARTICLE && positions.length / 3 < 1000) {
showCorner(player, x - 0.49F, y, z - 0.49F, Particle.FLAME); showCorner(player, x - 0.49F, y, z - 0.49F, Particle.FLAME);
} else { } else {
showBlock(player, x, y + 0.49F, z, Material.RED_STAINED_GLASS, (byte) 14); showBlock(player, x, y + 0.49F, z, Material.RED_STAINED_GLASS, (byte) 14);
@ -78,7 +78,7 @@ public class PlayerTraceCache_15 {
if (hasBlock(positions, x, y, z)) continue; if (hasBlock(positions, x, y, z)) continue;
if (showMode == TNTShowCallback_15.ShowMode.PARTICLE) { if (showMode == TNTCallbackShow.ShowMode.PARTICLE) {
showCorner(player, x - 0.49F, y, z - 0.49F, Particle.VILLAGER_HAPPY); showCorner(player, x - 0.49F, y, z - 0.49F, Particle.VILLAGER_HAPPY);
} else { } else {
showBlock(player, x, y + 0.49F, z, Material.LIME_STAINED_GLASS, (byte) 5); showBlock(player, x, y + 0.49F, z, Material.LIME_STAINED_GLASS, (byte) 5);

Datei anzeigen

@ -1,8 +1,8 @@
package de.steamwar.bausystem.tracer; package de.steamwar.bausystem.tracer;
import de.steamwar.bausystem.tracer.guicallback.RecordingCallback_15; import de.steamwar.bausystem.tracer.guicallback.GuiCallbackRecording;
import de.steamwar.bausystem.tracer.guicallback.TNTFrameCallback_15; import de.steamwar.bausystem.tracer.guicallback.GuiCallbackTNTFrame;
import de.steamwar.bausystem.tracer.guicallback.TNTTraceCallback_15; import de.steamwar.bausystem.tracer.guicallback.GuiCallbackTNTTrace;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
@ -17,9 +17,9 @@ import java.util.List;
public class TNTTracerGUI_15 { public class TNTTracerGUI_15 {
private static TNTFrameCallback_15 tntFrameCallback_15; private static GuiCallbackTNTFrame guiCallbackTNTFrame;
private static TNTTraceCallback_15 tntTraceCallback_15; private static GuiCallbackTNTTrace guiCallbackTNTTrace;
private static RecordingCallback_15 recordingCallback_15; private static GuiCallbackRecording guiCallbackRecording;
private static Inventory getEmpty(String title) { private static Inventory getEmpty(String title) {
Inventory inventory = Bukkit.createInventory(null, 54, title); Inventory inventory = Bukkit.createInventory(null, 54, title);
@ -60,12 +60,12 @@ public class TNTTracerGUI_15 {
inventory.setItem(1, createItem(Material.HONEYCOMB, false, "§eShow§8/§eHide")); inventory.setItem(1, createItem(Material.HONEYCOMB, false, "§eShow§8/§eHide"));
inventory.setItem(4, createItem(Material.BARRIER, false, "§eClear ausgewählte Positionen")); inventory.setItem(4, createItem(Material.BARRIER, false, "§eClear ausgewählte Positionen"));
inventory.setItem(5, createItem(Material.OBSERVER, false, "§eToggle AUTO-Trace")); inventory.setItem(5, createItem(Material.OBSERVER, false, "§eToggle AUTO-Trace"));
inventory.setItem(6, recordingCallback_15.run()); inventory.setItem(6, guiCallbackRecording.run());
inventory.setItem(8, createItem(Material.PAPER, false, "§7PAGE §e§l" + page + "§8/§e§l" + allPages)); inventory.setItem(8, createItem(Material.PAPER, false, "§7PAGE §e§l" + page + "§8/§e§l" + allPages));
} }
private static Inventory getFrameInventory(Player p, int page) { private static Inventory getFrameInventory(Player p, int page) {
ItemStack[] items = tntFrameCallback_15.run(p); ItemStack[] items = guiCallbackTNTFrame.run(p);
Inventory inventory = getEmpty("§7§lTRACE §8- §e§lAufnahmen"); Inventory inventory = getEmpty("§7§lTRACE §8- §e§lAufnahmen");
if (items.length == 0) { if (items.length == 0) {
@ -76,10 +76,10 @@ public class TNTTracerGUI_15 {
return inventory; return inventory;
} }
public static void init(TNTFrameCallback_15 tntFrameCallback_15, TNTTraceCallback_15 tntTraceCallback_15, RecordingCallback_15 recordingCallback_15) { public static void init(GuiCallbackTNTFrame guiCallbackTNTFrame, GuiCallbackTNTTrace guiCallbackTNTTrace, GuiCallbackRecording guiCallbackRecording) {
TNTTracerGUI_15.tntFrameCallback_15 = tntFrameCallback_15; TNTTracerGUI_15.guiCallbackTNTFrame = guiCallbackTNTFrame;
TNTTracerGUI_15.tntTraceCallback_15 = tntTraceCallback_15; TNTTracerGUI_15.guiCallbackTNTTrace = guiCallbackTNTTrace;
TNTTracerGUI_15.recordingCallback_15 = recordingCallback_15; TNTTracerGUI_15.guiCallbackRecording = guiCallbackRecording;
} }
public enum Menu { public enum Menu {

Datei anzeigen

@ -1,6 +1,9 @@
package de.steamwar.bausystem.tracer; package de.steamwar.bausystem.tracer;
import de.steamwar.bausystem.tracer.showcallback.*; import de.steamwar.bausystem.tracer.debugcallback.DebugCallbackActionBar;
import de.steamwar.bausystem.tracer.showcallback.TNTCallbackCacheUpdate;
import de.steamwar.bausystem.tracer.showcallback.TNTCallbackShow;
import de.steamwar.bausystem.tracer.updatecallback.*;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -19,12 +22,12 @@ class TNTTracer_15 {
private TNTTracer_15(){} private TNTTracer_15(){}
private static TracerCallback_15 tracerCallback; private static TracerCallbackPositions tracerCallbackPositions;
private static TracerCallbackUpdatePoints_15 tracerCallbackUpdatePoints; private static TracerCallbackUpdatePoints tracerCallbackUpdatePoints;
private static TracerCallbackTracing_15 tracerCallbackTracing; private static TracerCallbackTracing tracerCallbackTracing;
private static TracerActionBarCallback_15 tracerActionBarCallback; private static DebugCallbackActionBar debugCallbackActionBar;
private static TNTShowCallback_15 tntShowCallback; private static TNTCallbackShow tntCallbackShow;
private static CacheUpdateCallback_15 cacheUpdateCallback; private static TNTCallbackCacheUpdate tntCallbackCacheUpdate;
private static Map<Player, PlayerTraceCache_15> playerMap = new HashMap<>(); private static Map<Player, PlayerTraceCache_15> playerMap = new HashMap<>();
@ -40,7 +43,7 @@ class TNTTracer_15 {
return d * d; return d * d;
} }
static void init(Plugin plugin, TracerCallback_15 tracerCallback, TracerCallbackUpdatePoints_15 tracerCallbackUpdatePoints, TracerActionBarCallback_15 tracerActionBarCallback, TNTShowCallback_15 tntShowCallback, CacheUpdateCallback_15 cacheUpdateCallback, TracerCallbackTracing_15 tracerCallbackTracing) { static void init(Plugin plugin, TracerCallbackPositions tracerCallbackPositions, TracerCallbackUpdatePoints tracerCallbackUpdatePoints, TracerCallbackTracing tracerCallbackTracing, DebugCallbackActionBar debugCallbackActionBar, TNTCallbackShow tntCallbackShow, TNTCallbackCacheUpdate tntCallbackCacheUpdate) {
Bukkit.getScheduler().runTaskTimer(plugin, () -> { Bukkit.getScheduler().runTaskTimer(plugin, () -> {
synchronized (synchronizer) { synchronized (synchronizer) {
synchronizer.notifyAll(); synchronizer.notifyAll();
@ -59,11 +62,11 @@ class TNTTracer_15 {
} }
}); });
TNTTracer_15.tracerCallback = tracerCallback; TNTTracer_15.tracerCallbackPositions = tracerCallbackPositions;
TNTTracer_15.tracerCallbackUpdatePoints = tracerCallbackUpdatePoints; TNTTracer_15.tracerCallbackUpdatePoints = tracerCallbackUpdatePoints;
TNTTracer_15.tracerActionBarCallback = tracerActionBarCallback; TNTTracer_15.debugCallbackActionBar = debugCallbackActionBar;
TNTTracer_15.tntShowCallback = tntShowCallback; TNTTracer_15.tntCallbackShow = tntCallbackShow;
TNTTracer_15.cacheUpdateCallback = cacheUpdateCallback; TNTTracer_15.tntCallbackCacheUpdate = tntCallbackCacheUpdate;
TNTTracer_15.tracerCallbackTracing = tracerCallbackTracing; TNTTracer_15.tracerCallbackTracing = tracerCallbackTracing;
} }
@ -77,7 +80,7 @@ class TNTTracer_15 {
private static void run() { private static void run() {
if (actionBar) { if (actionBar) {
String actionBar = tracerActionBarCallback.run(); String actionBar = debugCallbackActionBar.run();
Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(actionBar))); Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(actionBar)));
} }
for (Player p : Bukkit.getOnlinePlayers()) { for (Player p : Bukkit.getOnlinePlayers()) {
@ -89,13 +92,13 @@ class TNTTracer_15 {
traceCache = playerMap.get(p); traceCache = playerMap.get(p);
} }
if (!traceCache.nearLastLocation(p) && !cacheUpdateCallback.run(p)) { if (!traceCache.nearLastLocation(p) && !tntCallbackCacheUpdate.run(p)) {
traceCache.show(p, tntShowCallback.run(p)); traceCache.show(p, tntCallbackShow.run(p));
continue; continue;
} }
update(p, traceCache); update(p, traceCache);
traceCache.show(p, tntShowCallback.run(p)); traceCache.show(p, tntCallbackShow.run(p));
} }
} }
@ -106,7 +109,7 @@ class TNTTracer_15 {
return; return;
} }
float[] floats = tracerCallback.run(p); float[] floats = tracerCallbackPositions.run(p);
if (floats.length == 0 || floats.length % 3 != 0) { if (floats.length == 0 || floats.length % 3 != 0) {
traceCache.setPositions(noValue); traceCache.setPositions(noValue);
traceCache.setUpdatePoints(noValue); traceCache.setUpdatePoints(noValue);

Datei anzeigen

@ -1,8 +0,0 @@
package de.steamwar.bausystem.tracer.showcallback;
@FunctionalInterface
public interface TracerActionBarCallback_15 {
String run();
}

Datei anzeigen

@ -1,10 +0,0 @@
package de.steamwar.bausystem.tracer.showcallback;
import org.bukkit.entity.Player;
@FunctionalInterface
public interface TracerCallbackTracing_15 {
boolean run(Player p);
}

Datei anzeigen

@ -1,10 +0,0 @@
package de.steamwar.bausystem.tracer.showcallback;
import org.bukkit.entity.Player;
@FunctionalInterface
public interface TracerCallbackUpdatePoints_15 {
float[] run(Player p);
}

Datei anzeigen

@ -1,10 +0,0 @@
package de.steamwar.bausystem.tracer.showcallback;
import org.bukkit.entity.Player;
@FunctionalInterface
public interface TracerCallback_15 {
float[] run(Player p);
}

Datei anzeigen

@ -0,0 +1,8 @@
package de.steamwar.bausystem.tracer.debugcallback;
@FunctionalInterface
public interface DebugCallbackActionBar {
String run();
}

Datei anzeigen

@ -3,7 +3,7 @@ package de.steamwar.bausystem.tracer.guicallback;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@FunctionalInterface @FunctionalInterface
public interface RecordingCallback_15 { public interface GuiCallbackRecording {
ItemStack run(); ItemStack run();

Datei anzeigen

@ -4,7 +4,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@FunctionalInterface @FunctionalInterface
public interface TNTFrameCallback_15 { public interface GuiCallbackTNTFrame {
ItemStack[] run(Player p); ItemStack[] run(Player p);

Datei anzeigen

@ -4,7 +4,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@FunctionalInterface @FunctionalInterface
public interface TNTTraceCallback_15 { public interface GuiCallbackTNTTrace {
ItemStack[] run(Player p); ItemStack[] run(Player p);

Datei anzeigen

@ -3,7 +3,7 @@ package de.steamwar.bausystem.tracer.showcallback;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@FunctionalInterface @FunctionalInterface
public interface CacheUpdateCallback_15 { public interface TNTCallbackCacheUpdate {
boolean run(Player p); boolean run(Player p);

Datei anzeigen

@ -3,7 +3,7 @@ package de.steamwar.bausystem.tracer.showcallback;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@FunctionalInterface @FunctionalInterface
public interface TNTShowCallback_15 { public interface TNTCallbackShow {
public static enum ShowMode { public static enum ShowMode {
BLOCK, BLOCK,

Datei anzeigen

@ -0,0 +1,10 @@
package de.steamwar.bausystem.tracer.updatecallback;
import org.bukkit.entity.Player;
@FunctionalInterface
public interface TracerCallbackPositions {
float[] run(Player p);
}

Datei anzeigen

@ -0,0 +1,10 @@
package de.steamwar.bausystem.tracer.updatecallback;
import org.bukkit.entity.Player;
@FunctionalInterface
public interface TracerCallbackTracing {
boolean run(Player p);
}

Datei anzeigen

@ -0,0 +1,10 @@
package de.steamwar.bausystem.tracer.updatecallback;
import org.bukkit.entity.Player;
@FunctionalInterface
public interface TracerCallbackUpdatePoints {
float[] run(Player p);
}

Datei anzeigen

@ -1,7 +1,7 @@
package de.steamwar.bausystem.tracer; package de.steamwar.bausystem.tracer;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.tracer.showcallback.TNTShowCallback_15; import de.steamwar.bausystem.tracer.showcallback.TNTCallbackShow;
import de.steamwar.bausystem.tracer.trace.ShowManager; import de.steamwar.bausystem.tracer.trace.ShowManager;
import de.steamwar.bausystem.tracer.trace.ShowStatus; import de.steamwar.bausystem.tracer.trace.ShowStatus;
import de.steamwar.bausystem.tracer.trace.TNTFrame; import de.steamwar.bausystem.tracer.trace.TNTFrame;
@ -45,7 +45,7 @@ public class TNTTracer15 {
private static final float[] noValue = new float[0]; private static final float[] noValue = new float[0];
public static void initTNTTracer_15() { public static void initTNTTracer_15() {
TNTTracer_15.init(BauSystem.getPlugin(), TNTTracer15::getTracePoints, TNTTracer15::getTraceUpdatePoints, TNTTracer15::getActionBar, TNTTracer15::showMode, p -> ShowManager.get(p).isDirty(), p -> { TNTTracer_15.init(BauSystem.getPlugin(), TNTTracer15::getTracePoints, TNTTracer15::getTraceUpdatePoints, p -> ShowManager.get(p).isDirty(), TNTTracer15::getActionBar, TNTTracer15::showMode, p -> {
if (System.currentTimeMillis() - lastExplosion < 4500) { if (System.currentTimeMillis() - lastExplosion < 4500) {
ShowManager.get(p).dirty(); ShowManager.get(p).dirty();
} }
@ -202,11 +202,11 @@ public class TNTTracer15 {
return traces; return traces;
} }
private static TNTShowCallback_15.ShowMode showMode(Player player) { private static TNTCallbackShow.ShowMode showMode(Player player) {
if (ShowManager.get(player).getShowMode() == ShowStatus.ShowMode.BLOCK) { if (ShowManager.get(player).getShowMode() == ShowStatus.ShowMode.BLOCK) {
return TNTShowCallback_15.ShowMode.BLOCK; return TNTCallbackShow.ShowMode.BLOCK;
} else { } else {
return TNTShowCallback_15.ShowMode.PARTICLE; return TNTCallbackShow.ShowMode.PARTICLE;
} }
} }
@ -270,6 +270,9 @@ public class TNTTracer15 {
static void explode(TNTPrimed tntPrimed) { static void explode(TNTPrimed tntPrimed) {
if (tntFrames.isEmpty()) return; if (tntFrames.isEmpty()) return;
if (System.currentTimeMillis() - lastExplosion > 4500) {
ShowManager.dirty();
}
lastExplosion = System.currentTimeMillis(); lastExplosion = System.currentTimeMillis();
tntFrames.getLast().explode(tntPrimed); tntFrames.getLast().explode(tntPrimed);
} }
@ -313,10 +316,8 @@ public class TNTTracer15 {
tntFrames.addLast(new TNTFrame()); tntFrames.addLast(new TNTFrame());
task = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), TNTTracer15::run, 1, 1); task = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), TNTTracer15::run, 1, 1);
current = System.currentTimeMillis(); current = System.currentTimeMillis();
if (status == Status.RECORD_AUTO) {
run(); run();
} }
}
if (status == Status.RECORD_AUTO) { if (status == Status.RECORD_AUTO) {
current = System.currentTimeMillis(); current = System.currentTimeMillis();
} }