Add ParticleShowMode
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
d64fcf8b3b
Commit
592e3964aa
@ -28,10 +28,10 @@ import de.steamwar.bausystem.features.tracer.show.ShowModeParameterType;
|
||||
import de.steamwar.bausystem.features.tracer.show.StoredRecords;
|
||||
import de.steamwar.bausystem.features.tracer.show.TraceShowManager;
|
||||
import de.steamwar.bausystem.features.tracer.show.mode.BlockShowMode;
|
||||
import de.steamwar.bausystem.features.tracer.show.mode.ParticleShowMode;
|
||||
import de.steamwar.bausystem.features.tracer.show.mode.TraceEntityShowMode;
|
||||
import de.steamwar.bausystem.linkage.LinkageType;
|
||||
import de.steamwar.bausystem.linkage.Linked;
|
||||
import de.steamwar.bausystem.shared.ShowMode;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
@ -150,12 +150,18 @@ public class TraceCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register({"show", "block"})
|
||||
public void showBlockCommand(Player p, ShowModeParameterType... showModeParameterTypes) {
|
||||
internalShow(p, ShowModeType.BLOCK, showModeParameterTypes);
|
||||
public void showBlockCommand(Player p) {
|
||||
internalShow(p, ShowModeType.BLOCK);
|
||||
}
|
||||
|
||||
@Register({"show", "particle"})
|
||||
public void showParticleCommand(Player p) {
|
||||
internalShow(p, ShowModeType.PARTICLE);
|
||||
}
|
||||
|
||||
private enum ShowModeType {
|
||||
ENTITY,
|
||||
PARTICLE,
|
||||
BLOCK
|
||||
}
|
||||
|
||||
@ -169,6 +175,9 @@ public class TraceCommand extends SWCommand {
|
||||
case BLOCK:
|
||||
TraceShowManager.show(p, new BlockShowMode(p, showModeParameter));
|
||||
break;
|
||||
case PARTICLE:
|
||||
TraceShowManager.show(p, new ParticleShowMode(p, showModeParameter));
|
||||
break;
|
||||
case ENTITY:
|
||||
TraceShowManager.show(p, new TraceEntityShowMode(p, showModeParameter));
|
||||
break;
|
||||
|
@ -20,15 +20,12 @@
|
||||
package de.steamwar.bausystem.features.tracer.show.mode;
|
||||
|
||||
import de.steamwar.bausystem.features.tracer.TNTPosition;
|
||||
import de.steamwar.bausystem.features.tracer.TNTTracer_15;
|
||||
import de.steamwar.bausystem.features.tracer.show.ShowModeParameter;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.shared.ShowMode;
|
||||
import de.steamwar.core.VersionedCallable;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.tracer.show.mode;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.tracer.TNTPosition;
|
||||
import de.steamwar.bausystem.features.tracer.show.ShowModeParameter;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.shared.ShowMode;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class ParticleShowMode implements ShowMode<TNTPosition> {
|
||||
|
||||
protected final Player player;
|
||||
protected final ShowModeParameter showModeParameter;
|
||||
|
||||
private Set<Point> positionSet = new HashSet<>();
|
||||
|
||||
private BukkitTask bukkitTask;
|
||||
|
||||
public ParticleShowMode(Player player, ShowModeParameter showModeParameter) {
|
||||
this.player = player;
|
||||
this.showModeParameter = showModeParameter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show(TNTPosition position) {
|
||||
Location location = position.getLocation().toLocation(player.getWorld());
|
||||
Point point = Point.fromLocation(location);
|
||||
if (positionSet.contains(point)) {
|
||||
return;
|
||||
}
|
||||
positionSet.add(point);
|
||||
if (bukkitTask == null) {
|
||||
bukkitTask = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
|
||||
positionSet.forEach(p -> player.spawnParticle(Particle.BARRIER, p.toLocation(player), 1, 0, 0, 0, 0));
|
||||
}, 15L, 15L);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
positionSet.clear();
|
||||
if (bukkitTask != null) {
|
||||
bukkitTask.cancel();
|
||||
}
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren