Add BlockShowMode
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
86036455ec
Commit
d64fcf8b3b
@ -27,12 +27,15 @@ import de.steamwar.bausystem.features.tracer.show.ShowModeParameter;
|
||||
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.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;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -141,13 +144,37 @@ public class TraceCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register({"show"})
|
||||
public void showCommand(Player p, ShowModeParameterType... showModeParameterTypes) {
|
||||
@Register({"show", "entity"})
|
||||
public void showEntityCommand(Player p, ShowModeParameterType... showModeParameterTypes) {
|
||||
internalShow(p, ShowModeType.ENTITY, showModeParameterTypes);
|
||||
}
|
||||
|
||||
@Register({"show", "block"})
|
||||
public void showBlockCommand(Player p, ShowModeParameterType... showModeParameterTypes) {
|
||||
internalShow(p, ShowModeType.BLOCK, showModeParameterTypes);
|
||||
}
|
||||
|
||||
private enum ShowModeType {
|
||||
ENTITY,
|
||||
BLOCK
|
||||
}
|
||||
|
||||
private void internalShow(Player p, @NonNull ShowModeType showModeType, ShowModeParameterType... showModeParameterTypes) {
|
||||
if (!permissionCheck(p)) return;
|
||||
ShowModeParameter showModeParameter = new ShowModeParameter();
|
||||
for (ShowModeParameterType showModeParameterType : showModeParameterTypes) {
|
||||
showModeParameterType.getShowModeParameterConsumer().accept(showModeParameter);
|
||||
}
|
||||
TraceShowManager.show(p, new TraceEntityShowMode(p, showModeParameter));
|
||||
switch (showModeType) {
|
||||
case BLOCK:
|
||||
TraceShowManager.show(p, new BlockShowMode(p, showModeParameter));
|
||||
break;
|
||||
case ENTITY:
|
||||
TraceShowManager.show(p, new TraceEntityShowMode(p, showModeParameter));
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_SHOW", p);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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.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;
|
||||
|
||||
public class BlockShowMode implements ShowMode<TNTPosition> {
|
||||
|
||||
protected final Player player;
|
||||
protected final ShowModeParameter showModeParameter;
|
||||
|
||||
private Set<Point> positionSet = new HashSet<>();
|
||||
|
||||
public BlockShowMode(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);
|
||||
player.sendBlockChange(location, Material.RED_STAINED_GLASS.createBlockData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
positionSet.forEach(point -> {
|
||||
Location location = point.toLocation(player.getWorld());
|
||||
player.sendBlockChange(location, location.getBlock().getBlockData());
|
||||
});
|
||||
positionSet.clear();
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren