SteamWar/BauSystem2.0
Archiviert
12
0

Merge branch 'master' into English

Dieser Commit ist enthalten in:
yoyosource 2022-04-20 15:25:20 +02:00
Commit 8adc83a379
40 geänderte Dateien mit 99 neuen und 881 gelöschten Zeilen

Datei anzeigen

@ -24,7 +24,7 @@ import de.steamwar.bausystem.entities.DetonatorEntity15;
import de.steamwar.bausystem.entities.SimulatorEntity15; import de.steamwar.bausystem.entities.SimulatorEntity15;
import de.steamwar.bausystem.entities.TraceEntity15; import de.steamwar.bausystem.entities.TraceEntity15;
import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity; import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity;
import de.steamwar.bausystem.features.other.NoClipCommand; import de.steamwar.bausystem.features.util.NoClipCommand;
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity; import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
import de.steamwar.bausystem.features.tracer.AbstractTraceEntity; import de.steamwar.bausystem.features.tracer.AbstractTraceEntity;
import de.steamwar.bausystem.features.warp.AbstractWarpEntity; import de.steamwar.bausystem.features.warp.AbstractWarpEntity;

Datei anzeigen

@ -26,7 +26,7 @@ import de.steamwar.bausystem.entities.SimulatorEntity18;
import de.steamwar.bausystem.entities.TraceEntity18; import de.steamwar.bausystem.entities.TraceEntity18;
import de.steamwar.bausystem.entities.WarpEntity18; import de.steamwar.bausystem.entities.WarpEntity18;
import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity; import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity;
import de.steamwar.bausystem.features.other.NoClipCommand; import de.steamwar.bausystem.features.util.NoClipCommand;
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity; import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
import de.steamwar.bausystem.features.tracer.AbstractTraceEntity; import de.steamwar.bausystem.features.tracer.AbstractTraceEntity;
import de.steamwar.bausystem.features.warp.AbstractWarpEntity; import de.steamwar.bausystem.features.warp.AbstractWarpEntity;

Datei anzeigen

@ -647,8 +647,8 @@ SMART_PLACE_DISABLE = §cSmartPlace deaktiviert
BLOCK_COUNTER_HELP_TOGGLE = §8/§eblockcounter §8- §7Wechsel zwischen an und aus BLOCK_COUNTER_HELP_TOGGLE = §8/§eblockcounter §8- §7Wechsel zwischen an und aus
BLOCK_COUNTER_HELP_ENABLE = §8/§eblockcounter enable §8- §7Schalte den BlockCounter an BLOCK_COUNTER_HELP_ENABLE = §8/§eblockcounter enable §8- §7Schalte den BlockCounter an
BLOCK_COUNTER_HELP_DISABLE = §8/§eblockcounter disable §8- §7Schalte den BlockCounter aus BLOCK_COUNTER_HELP_DISABLE = §8/§eblockcounter disable §8- §7Schalte den BlockCounter aus
BLOCK_COUNTER_MESSAGE = §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/tick BLOCK_COUNTER_MESSAGE = §7Tiefe §8> §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/tick
BLOCK_COUNTER_MESSAGE_SECOND = §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/s BLOCK_COUNTER_MESSAGE_SECOND = §7Tiefe §8> §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/s
BLOCK_COUNTER_ENABLE = §7BlockCounter angemacht BLOCK_COUNTER_ENABLE = §7BlockCounter angemacht
BLOCK_COUNTER_DISABLE = §7BlockCounter ausgemacht BLOCK_COUNTER_DISABLE = §7BlockCounter ausgemacht

Datei anzeigen

@ -19,18 +19,11 @@
package de.steamwar.bausystem.features.gui; package de.steamwar.bausystem.features.gui;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.gui.editor.BauGuiEditor; import de.steamwar.bausystem.features.gui.editor.BauGuiEditor;
import de.steamwar.bausystem.features.gui.editor.BauGuiImportExport;
import de.steamwar.bausystem.features.gui.editor.BauGuiMapping;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@Linked(LinkageType.COMMAND) @Linked(LinkageType.COMMAND)
@ -54,29 +47,4 @@ public class BauGUICommand extends SWCommand {
public void openEditor(Player p) { public void openEditor(Player p) {
BauGuiEditor.openGuiEditor(p, new SWItem().getItemStack()); BauGuiEditor.openGuiEditor(p, new SWItem().getItemStack());
} }
@Register("export")
public void exportGui(Player p) {
String export = BauGuiImportExport.exportGui(BauGuiMapping.getGuiMapping(p));
TextComponent component = new TextComponent();
component.setColor(ChatColor.YELLOW);
component.setBold(true);
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse("GUI_EXPORT_CODE_HOVER", p))));
component.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, export));
component.setText(export);
BauSystem.MESSAGE.send("GUI_EXPORT_CODE", p);
p.spigot().sendMessage(component);
}
@Register("import")
public void importGui(Player p, String code) {
try {
if (BauGuiImportExport.importGui(code, p)) {
BauSystem.MESSAGE.send("GUI_IMPORT_CODE_SUCCESSFUL", p);
}
} catch (Exception e) {
e.printStackTrace();
BauSystem.MESSAGE.send("GUI_IMPORT_INVALID_CODE", p);
}
}
} }

Datei anzeigen

@ -1,168 +0,0 @@
/*
* 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.gui.editor;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.gui.BauGUI;
import lombok.experimental.UtilityClass;
import org.bukkit.entity.Player;
import java.util.*;
import java.util.stream.Collectors;
@UtilityClass
public class BauGuiImportExport {
private static final String VERSION = "00000";
public String exportGui(BauGuiMapping mapping) {
StringBuilder st = new StringBuilder();
st.append(VERSION); // Version in Binary (0 - 32)
append(st, Integer.toBinaryString(mapping.getSize() / 9), 3); // Menu Size
Map<Integer, Integer> map = new HashMap<>();
mapping.getMapping().forEach((integer, integer2) -> map.put(integer2, integer));
List<Integer> integerList = map.keySet().stream().sorted().collect(Collectors.toList());
for (int i = 0; i < integerList.size(); i++) {
int current = integerList.get(i);
int last = i == 0 ? -1 : integerList.get(i - 1);
if (current - last > 1) {
binaryConvert(st, Integer.toBinaryString(current - last - 1), '0');
}
binaryConvert(st, Integer.toBinaryString(map.get(current)), '1');
}
byte[] bytes = new byte[st.length() / 8 + 1];
if (st.length() / 8 == (int) Math.ceil(st.length() / 8.0)) {
bytes = new byte[st.length() / 8];
}
int index = 0;
while (st.length() > 0) {
byte result = 0;
for (int i = 0; i < Math.min(8, st.length()); i++) {
result |= (st.charAt(i) - '0') << (7 - i);
}
bytes[index] = result;
index++;
st.delete(0, Math.min(8, st.length()));
}
return Base64.getEncoder().encodeToString(bytes);
}
private static void append(StringBuilder st, String s, int length) {
for (int i = 0; i < length - s.length(); i++) {
st.append("0");
}
st.append(s);
}
private static void binaryConvert(StringBuilder st, String s, char identifier) {
StringBuilder current = new StringBuilder().append(identifier).append(s);
char reverseIdentifier = identifier == '0' ? '1' : '0';
boolean added = false;
while (current.length() % 4 != 0) {
current.insert(0, reverseIdentifier);
added = true;
}
if (!added) {
current.insert(0, reverseIdentifier);
current.insert(0, reverseIdentifier);
current.insert(0, reverseIdentifier);
current.insert(0, reverseIdentifier);
}
while (current.length() > 4) {
st.append('1').append(current.substring(0, 4));
current.delete(0, 4);
}
st.append('0').append(current);
}
public static boolean importGui(String str, Player p) {
byte[] bytes = Base64.getDecoder().decode(str);
StringBuilder st = new StringBuilder();
for (byte b : bytes) {
append(st, Integer.toBinaryString(b & 0xFF), 8);
}
if (!st.substring(0, 5).equals(VERSION)) {
BauSystem.MESSAGE.send("GUI_IMPORT_INVALID_CODE", p);
return false;
}
int size = Integer.parseInt(st.substring(5, 8), 2);
if (size <= 0 || size > 5) {
BauSystem.MESSAGE.send("GUI_IMPORT_INVALID_CODE", p);
return false;
}
size *= 9;
st.delete(0, 8);
List<String> blobs = new ArrayList<>();
if (st.length() > 0) {
blobs.add("");
}
while (st.length() > 4) {
String current = st.substring(0, 5);
int last = blobs.size() - 1;
blobs.set(last, blobs.get(last) + current.substring(1));
if (current.startsWith("0")) {
blobs.add("");
}
st.delete(0, 5);
}
blobs.removeIf(String::isEmpty);
blobs.replaceAll(s -> {
char start = s.charAt(0);
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) != start) {
return s.substring(i);
}
}
return s;
});
int currentIndex = 0;
Map<Integer, Integer> map = new HashMap<>();
boolean initial = true;
for (String s : blobs) {
if (s.startsWith("0")) {
currentIndex += Integer.parseInt(s.substring(1), 2);
} else {
if (!initial) {
currentIndex++;
}
initial = false;
s = s.substring(1);
int itemID = Integer.parseInt(s, 2);
if (!BauGUI.getITEMS().containsKey(itemID)) {
BauSystem.MESSAGE.send("GUI_IMPORT_INVALID_CODE", p);
return false;
}
map.put(itemID, currentIndex);
}
}
BauGuiMapping mapping = BauGuiMapping.getGuiMapping(p);
mapping.setMapping(map);
mapping.setSize(size);
return true;
}
}

Datei anzeigen

@ -1,43 +0,0 @@
/*
* 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.other;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.command.SWCommand;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;
@Linked(LinkageType.COMMAND)
public class WorldSpawnCommand extends SWCommand {
private static final World WORLD = Bukkit.getWorlds().get(0);
public WorldSpawnCommand() {
super("worldspawn");
}
@Register(description = "OTHER_WORLDSPAWN_HELP")
public void genericCommand(Player p) {
p.teleport(WORLD.getSpawnLocation().add(0.5, 0, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND);
}
}

Datei anzeigen

@ -1,61 +0,0 @@
/*
* 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.other.items;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.features.other.WorldSpawnCommand;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.linkage.LinkedInstance;
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
import de.steamwar.inventory.SWItem;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
@Linked(LinkageType.BAU_GUI_ITEM)
public class WorldSpawnBauGuiItem extends BauGuiItem {
@LinkedInstance
private WorldSpawnCommand worldSpawnCommand;
public WorldSpawnBauGuiItem() {
super(33);
}
@Override
public ItemStack getItem(Player player) {
return new SWItem(Material.ENDER_EYE, BauSystem.MESSAGE.parse("OTHER_ITEMS_WORLDSPAWN_NAME", player)).getItemStack();
}
@Override
public boolean click(ClickType click, Player p) {
p.closeInventory();
worldSpawnCommand.genericCommand(p);
return false;
}
@Override
public Permission permission() {
return Permission.MEMBER;
}
}

Datei anzeigen

@ -1,91 +0,0 @@
/*
* 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.region;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.DamageMode;
import de.steamwar.command.GuardCheckType;
import de.steamwar.command.GuardChecker;
import de.steamwar.command.GuardResult;
import de.steamwar.command.SWCommand;
import org.bukkit.entity.Player;
@Linked(LinkageType.COMMAND)
public class DamageCommand extends SWCommand {
protected DamageCommand() {
super("damage", "dmg");
}
@Register(description = "REGION_DAMAGE_HELP")
public void toggleCommand(@Guard Player p) {
Region region = Region.getRegion(p.getLocation());
if (toggle(region)) {
RegionUtils.actionBar(region, getEnableMessage());
} else {
RegionUtils.actionBar(region, getDisableMessage());
}
}
private String getNoPermMessage() {
return "REGION_DAMAGE_NO_PERMS";
}
private String getEnableMessage() {
return "REGION_DAMAGE_ENABLED";
}
private String getDisableMessage() {
return "REGION_DAMAGE_DISABLED";
}
private boolean toggle(Region region) {
switch (region.getPlain(Flag.DAMAGE, DamageMode.class)) {
case ALLOW:
region.set(Flag.DAMAGE, DamageMode.DENY);
return true;
default:
case DENY:
region.set(Flag.DAMAGE, DamageMode.ALLOW);
return false;
}
}
@ClassGuard(value = Player.class, local = true)
public GuardChecker guard() {
return (commandSender, guardCheckType, strings, s) -> {
Player player = (Player) commandSender;
if (!Permission.hasPermission(player, Permission.WORLD)) {
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
BauSystem.MESSAGE.send(getNoPermMessage(), player);
}
return GuardResult.DENIED;
}
return GuardResult.ALLOWED;
};
}
}

Datei anzeigen

@ -1,40 +0,0 @@
/*
* 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.region;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.DamageMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
@Linked(LinkageType.LISTENER)
public class DamageListener implements Listener {
@EventHandler
public void onPlayerDamage(EntityDamageEvent e) {
if (e.getEntity() instanceof Player && Region.getRegion(e.getEntity().getLocation()).get(Flag.DAMAGE) == DamageMode.DENY) e.setCancelled(true);
}
}

Datei anzeigen

@ -28,7 +28,6 @@ import de.steamwar.bausystem.linkage.LinkedInstance;
import de.steamwar.bausystem.region.Prototype; import de.steamwar.bausystem.region.Prototype;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.command.*; import de.steamwar.command.*;
@ -40,7 +39,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@ -126,21 +124,6 @@ public class RegionCommand extends SWCommand {
} }
} }
@Register(description = "REGION_REGION_HELP_SELECT")
public void baurahmenCommand(Player p, RegionType regionType) {
selectCommand.baurahmenCommand(p, regionType, RegionExtensionType.NORMAL);
}
@Register(description = "REGION_REGION_HELP_SELECT_EXTENSION")
public void baurahmenCommand(Player p, RegionType regionType, RegionExtensionType regionExtensionType) {
selectCommand.baurahmenCommand(p, regionType, regionExtensionType);
}
@Register(value = "color", description = "REGION_REGION_HELP_COLOR")
public void colorCommand(Player p, ColorMode color) {
colorCommand.genericColor(p, color);
}
@Register(value = "copypoint", description = "REGION_REGION_HELP_COPYPOINT") @Register(value = "copypoint", description = "REGION_REGION_HELP_COPYPOINT")
public void copyPointCommand(Player p) { public void copyPointCommand(Player p) {
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());

Datei anzeigen

@ -1,147 +0,0 @@
/*
* 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.script;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.variables.Context;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@Linked(LinkageType.COMMAND)
public class ScriptVarsCommand extends SWCommand {
public ScriptVarsCommand() {
super("scriptvars");
}
@Register(description = "SCRIPT_COMMAND_VARS_HELP")
public void genericCommand(Player p) {
Context context = ScriptListener.getGlobalContext(p);
if (context.allVariables().isEmpty()) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_NO_VARS", p);
return;
}
int i = 0;
if (context.allVariables().size() == 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_ONE_VAR", p);
} else {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_MANY_VARS", p, context.allVariables().size());
}
for (Map.Entry<String, Value> var : context.entrySet()) {
if (i++ >= 40) break;
BauSystem.MESSAGE.sendPrefixless("SCRIPT_COMMAND_VARS_ELEMENT_WITH_DASH", p, var.getKey(), var.getValue().asString());
}
}
@Register(description = "SCRIPT_COMMAND_VARS_HELP_VAR")
public void getCommand(Player p, String varName) {
Context context = ScriptListener.getGlobalContext(p);
if (context.allVariables().isEmpty()) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_NO_VARS", p);
return;
}
if (!context.hasValue(varName)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_UNKNOWN_VARS", p);
return;
}
BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_ELEMENT", p, varName, context.getValue(varName).asString());
}
@Register(description = "SCRIPT_COMMAND_VARS_HELP_SET")
public void setValueCommand(Player p, String varName, int value) {
Context context = ScriptListener.getGlobalContext(p);
context.putValue(varName, new Value.LongValue(value));
BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_SET_VALUE", p, varName, value);
}
@Register(description = "SCRIPT_COMMAND_VARS_HELP_SET")
public void setValueCommand(Player p, String varName, double value) {
Context context = ScriptListener.getGlobalContext(p);
context.putValue(varName, new Value.DoubleValue(value));
BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_SET_VALUE", p, varName, value);
}
@Register
public void setValueCommand(Player p, String varName, boolean value) {
Context context = ScriptListener.getGlobalContext(p);
context.putValue(varName, new Value.BooleanValue(value));
BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_SET_VALUE", p, varName, value);
}
@Register
public void setValueCommand(Player p, String varName, String... value) {
Context context = ScriptListener.getGlobalContext(p);
String s = String.join(" ", value);
context.putValue(varName, new Value.StringValue(s));
BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_SET_VALUE", p, varName, s);
}
@Register(description = "SCRIPT_COMMAND_VARS_HELP_DELETE")
public void removeCommand(Player p, String varName, @Mapper(value = "Delete") String remove) {
Context context = ScriptListener.getGlobalContext(p);
if (context.allVariables().isEmpty()) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_NO_VARS", p);
return;
}
context.removeValue(varName);
BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_REMOVE_VALUE", p, varName);
}
@ClassMapper(value = String.class, local = true)
public TypeMapper<String> stringTypeMapper() {
return SWCommandUtils.createMapper(s -> s, (commandSender, s) -> {
if (commandSender instanceof Player) {
Player player = (Player) commandSender;
return new ArrayList<>(ScriptListener.getGlobalContext(player).allVariables());
}
return null;
});
}
@Mapper(value = "Delete", local = true)
public TypeMapper<String> clearStringTypeMapper() {
List<String> tabCompletes = Arrays.asList("delete", "clear", "remove");
return SWCommandUtils.createMapper(s -> {
if (s.equalsIgnoreCase("delete") || s.equalsIgnoreCase("clear") || s.equalsIgnoreCase("remove")) {
return s;
}
return null;
}, s -> tabCompletes);
}
@ClassMapper(value = boolean.class, local = true)
public TypeMapper<Boolean> integerTypeMapper() {
List<String> tabCompletes = Arrays.asList("true", "false");
return SWCommandUtils.createMapper(s -> {
if (s.equalsIgnoreCase("remove") || s.equalsIgnoreCase("clear") || s.equalsIgnoreCase("delete")) return null;
return s.equalsIgnoreCase("true");
}, s -> tabCompletes);
}
}

Datei anzeigen

@ -312,9 +312,9 @@ public class TNTSimulator {
} }
private void updatePosition(Set<TNTSpawn> tntSpawns, Consumer<Vector> positionChanger) { private void updatePosition(Set<TNTSpawn> tntSpawns, Consumer<Vector> positionChanger) {
Set<Vector> vectors = new HashSet<>(); Map<Vector, Boolean> vectors = new IdentityHashMap<>();
for (TNTSpawn tntSpawn : tntSpawns) { for (TNTSpawn tntSpawn : tntSpawns) {
if (vectors.add(tntSpawn.position)) { if (vectors.put(tntSpawn.position, true) == null) {
positionChanger.accept(tntSpawn.position); positionChanger.accept(tntSpawn.position);
} }
} }

Datei anzeigen

@ -63,7 +63,7 @@ public class ProcessingTracesState implements LaufbauState {
} else { } else {
Vector movement = location.clone().subtract(previousLocation); Vector movement = location.clone().subtract(previousLocation);
cuboidList.add(new Cuboid(previousLocation.getX() - 0.49, Math.min(previousLocation.getY(), location.getY()), previousLocation.getZ() - 0.49, 0.98, Math.abs(movement.getY()) + 0.98, 0.98)); cuboidList.add(new Cuboid(previousLocation.getX() - 0.49, Math.min(previousLocation.getY(), location.getY()), previousLocation.getZ() - 0.49, 0.98, Math.abs(movement.getY()) + 0.98, 0.98));
if (Math.abs(movement.getX()) > Math.abs(movement.getZ())) { if (Math.abs(tntPosition.getUpdateVelocity().getX()) >= Math.abs(tntPosition.getUpdateVelocity().getZ())) {
cuboidList.add(new Cuboid(Math.min(previousLocation.getX(), location.getX()) - 0.49, location.getY(), previousLocation.getZ() - 0.49, Math.abs(movement.getX()) + 0.98, 0.98, 0.98)); cuboidList.add(new Cuboid(Math.min(previousLocation.getX(), location.getX()) - 0.49, location.getY(), previousLocation.getZ() - 0.49, Math.abs(movement.getX()) + 0.98, 0.98, 0.98));
cuboidList.add(new Cuboid(location.getX() - 0.49, location.getY(), Math.min(previousLocation.getZ(), location.getZ()) - 0.49, 0.98, 0.98, Math.abs(movement.getZ()) + 0.98)); cuboidList.add(new Cuboid(location.getX() - 0.49, location.getY(), Math.min(previousLocation.getZ(), location.getZ()) - 0.49, 0.98, 0.98, Math.abs(movement.getZ()) + 0.98));
} else { } else {

Datei anzeigen

@ -119,20 +119,20 @@ public class Panzern {
return; return;
case SLAB: case SLAB:
currentBlock.setType(slabMaterial); currentBlock.setType(slabMaterial);
editSession.getChangeSet().add(new BlockChange(BukkitAdapter.asBlockVector(currentBlock.getLocation()), airType, slabType)); editSession.setBlock(BukkitAdapter.asBlockVector(currentBlock.getLocation()), slabType);
break; break;
case BLOCK: case BLOCK:
case DEFAULT: case DEFAULT:
currentBlock.setType(blockMaterial); currentBlock.setType(blockMaterial);
editSession.getChangeSet().add(new BlockChange(BukkitAdapter.asBlockVector(currentBlock.getLocation()), airType, blockType)); editSession.setBlock(BukkitAdapter.asBlockVector(currentBlock.getLocation()), blockType);
break; break;
case UNMOVABLE: case UNMOVABLE:
currentBlock.setType(Material.JUKEBOX); currentBlock.setType(Material.JUKEBOX);
editSession.getChangeSet().add(new BlockChange(BukkitAdapter.asBlockVector(currentBlock.getLocation()), airType, jukeboxType)); editSession.setBlock(BukkitAdapter.asBlockVector(currentBlock.getLocation()), jukeboxType);
break; break;
case UNMOVABLE_SLAB: case UNMOVABLE_SLAB:
currentBlock.setType(Material.COBWEB); currentBlock.setType(Material.COBWEB);
editSession.getChangeSet().add(new BlockChange(BukkitAdapter.asBlockVector(currentBlock.getLocation()), airType, cobwebType)); editSession.setBlock(BukkitAdapter.asBlockVector(currentBlock.getLocation()), cobwebType);
break; break;
default: default:
emptyBlocks.add(currentBlock.getLocation().toVector()); emptyBlocks.add(currentBlock.getLocation().toVector());

Datei anzeigen

@ -53,9 +53,9 @@ public class BlockCounter {
double countPerTick = (double) count / Math.max((lastTick - tick), 1); double countPerTick = (double) count / Math.max((lastTick - tick), 1);
if (isActive(player)) { if (isActive(player)) {
if (countPerTick < 100) { if (countPerTick < 100) {
return BauSystem.MESSAGE.parsePrefixed("BLOCK_COUNTER_MESSAGE_SECOND", player, count, tntCount, (int) (countPerTNT * 10) / 10.0, (int) (countPerTick * 100) / 100.0 * 20); return BauSystem.MESSAGE.parse("BLOCK_COUNTER_MESSAGE_SECOND", player, count, tntCount, (int) (countPerTNT * 10) / 10.0, (int) (countPerTick * 100) / 100.0 * 20);
} else { } else {
return BauSystem.MESSAGE.parsePrefixed("BLOCK_COUNTER_MESSAGE", player, count, tntCount, (int) (countPerTNT * 10) / 10.0, (int) (countPerTick * 100) / 100.0); return BauSystem.MESSAGE.parse("BLOCK_COUNTER_MESSAGE", player, count, tntCount, (int) (countPerTNT * 10) / 10.0, (int) (countPerTick * 100) / 100.0);
} }
} }
return null; return null;

Datei anzeigen

@ -22,25 +22,53 @@ package de.steamwar.bausystem.features.tracer;
import de.steamwar.bausystem.features.tracer.show.Record; import de.steamwar.bausystem.features.tracer.show.Record;
import de.steamwar.bausystem.shared.Position; import de.steamwar.bausystem.shared.Position;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.function.Supplier;
@Getter @Getter
public class TNTPosition extends Position { public class TNTPosition extends Position {
@RequiredArgsConstructor
public static class CachingSupplier<T> implements Supplier<T> {
private final Supplier<T> supplier;
private boolean initialized;
private T value;
@Override
public T get() {
if (!initialized) {
value = supplier.get();
initialized = true;
}
return value;
}
}
private final Record.TNTRecord record; private final Record.TNTRecord record;
private final int fuseTicks; private final int fuseTicks;
private final Vector previousLocation; private final Vector previousLocation;
private final Vector velocity;
private final CachingSupplier<Vector> updateVelocity;
private final boolean exploded; private final boolean exploded;
public TNTPosition(Record.TNTRecord record, TNTPrimed entity, Vector previousLocation, boolean exploded) { public TNTPosition(Record.TNTRecord record, TNTPrimed entity, Vector previousLocation, Vector velocity, CachingSupplier<Vector> updateVelocity, boolean exploded) {
super(entity.getLocation().toVector()); super(entity.getLocation().toVector());
this.record = record; this.record = record;
this.fuseTicks = entity.getFuseTicks(); this.fuseTicks = entity.getFuseTicks();
this.previousLocation = previousLocation; this.previousLocation = previousLocation;
this.velocity = velocity;
this.updateVelocity = updateVelocity;
this.exploded = exploded; this.exploded = exploded;
} }
public Vector getUpdateVelocity() {
return updateVelocity.get();
}
@Override @Override
public String toString() { public String toString() {
return "Position{" + return "Position{" +

Datei anzeigen

@ -24,6 +24,7 @@ import de.steamwar.bausystem.features.tracer.TNTPosition;
import de.steamwar.bausystem.shared.ShowMode; import de.steamwar.bausystem.shared.ShowMode;
import lombok.Getter; import lombok.Getter;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
import org.bukkit.util.Vector;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -98,9 +99,21 @@ public class Record {
private void add(TNTPrimed tntPrimed, boolean exploded) { private void add(TNTPrimed tntPrimed, boolean exploded) {
TNTPosition position; TNTPosition position;
if (positions.isEmpty()) { if (positions.isEmpty()) {
position = new TNTPosition(this, tntPrimed, null, exploded); position = new TNTPosition(this, tntPrimed, null, tntPrimed.getVelocity(), new TNTPosition.CachingSupplier<>(() -> null), exploded);
} else { } else {
position = new TNTPosition(this, tntPrimed, positions.get(positions.size() - 1).getLocation(), exploded); int currentSize = positions.size() + 1;
TNTPosition.CachingSupplier<Vector> velocitySupplier = new TNTPosition.CachingSupplier<>(() -> {
Vector current = null;
for (int i = currentSize - 1; i >= 0; i--) {
TNTPosition currentTNT = positions.get(i);
if ((currentTNT.getVelocity().getX() == 0 || currentTNT.getVelocity().getZ() == 0) && current != null) {
break;
}
current = currentTNT.getVelocity();
}
return current;
});
position = new TNTPosition(this, tntPrimed, positions.get(positions.size() - 1).getLocation(), tntPrimed.getVelocity(), velocitySupplier, exploded);
} }
positions.add(position); positions.add(position);
TraceShowManager.show(position); TraceShowManager.show(position);

Datei anzeigen

@ -109,8 +109,7 @@ public abstract class FactoredEntityShowMode implements ShowMode<TNTPosition> {
} }
if (showModeParameter.isInterpolate_XZ()) { if (showModeParameter.isInterpolate_XZ()) {
Vector movement = position.getLocation().clone().subtract(position.getPreviousLocation()); Vector updatePointXZ = Math.abs(position.getUpdateVelocity().getX()) >= Math.abs(position.getUpdateVelocity().getZ())
Vector updatePointXZ = Math.abs(movement.getX()) > Math.abs(movement.getZ())
? position.getLocation().clone().setZ(position.getPreviousLocation().getZ()) ? position.getLocation().clone().setZ(position.getPreviousLocation().getZ())
: position.getLocation().clone().setX(position.getPreviousLocation().getX()); : position.getLocation().clone().setX(position.getPreviousLocation().getX());
if (!position.getLocation().equals(updatePointXZ)) { if (!position.getLocation().equals(updatePointXZ)) {

Datei anzeigen

@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2021 SteamWar.de-Serverteam * Copyright (C) 2022 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.other; package de.steamwar.bausystem.features.util;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;

Datei anzeigen

@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2021 SteamWar.de-Serverteam * Copyright (C) 2022 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.other; package de.steamwar.bausystem.features.util;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;

Datei anzeigen

@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2021 SteamWar.de-Serverteam * Copyright (C) 2022 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.other; package de.steamwar.bausystem.features.util;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;

Datei anzeigen

@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2021 SteamWar.de-Serverteam * Copyright (C) 2022 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.other; package de.steamwar.bausystem.features.util;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.SWUtils;

Datei anzeigen

@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2021 SteamWar.de-Serverteam * Copyright (C) 2022 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.other; package de.steamwar.bausystem.features.util;
import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol; import com.comphenix.tinyprotocol.TinyProtocol;

Datei anzeigen

@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2021 SteamWar.de-Serverteam * Copyright (C) 2022 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.other; package de.steamwar.bausystem.features.util;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.SWUtils;

Datei anzeigen

@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2021 SteamWar.de-Serverteam * Copyright (C) 2022 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.other; package de.steamwar.bausystem.features.util;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;

Datei anzeigen

@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2021 SteamWar.de-Serverteam * Copyright (C) 2022 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.other; package de.steamwar.bausystem.features.util;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;

Datei anzeigen

@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2021 SteamWar.de-Serverteam * Copyright (C) 2022 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.other; package de.steamwar.bausystem.features.util;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.tpslimit.TPSWarpUtils; import de.steamwar.bausystem.features.tpslimit.TPSWarpUtils;

Datei anzeigen

@ -1,48 +0,0 @@
/*
* 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.util;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
@Linked(LinkageType.COMMAND)
public class WaterVisionCommand extends SWCommand {
public WaterVisionCommand() {
super("watervision", "wv");
}
@Register(description = "WATER_VISION_HELP")
public void genericCommand(Player p) {
if (p.hasPotionEffect(PotionEffectType.WATER_BREATHING)) {
p.removePotionEffect(PotionEffectType.WATER_BREATHING);
BauSystem.MESSAGE.sendPrefixless("WATER_VISION_DISABLE", p, ChatMessageType.ACTION_BAR);
return;
}
p.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 1000000, 255, false, false));
BauSystem.MESSAGE.sendPrefixless("WATER_VISION_ENABLE", p, ChatMessageType.ACTION_BAR);
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2021 SteamWar.de-Serverteam * Copyright (C) 2022 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.other.items; package de.steamwar.bausystem.features.util.items;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;

Datei anzeigen

@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2021 SteamWar.de-Serverteam * Copyright (C) 2022 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@ -17,11 +17,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.other.items; package de.steamwar.bausystem.features.util.items;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.features.other.DeclutterCommand; import de.steamwar.bausystem.features.util.DeclutterCommand;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.bausystem.linkage.LinkedInstance;

Datei anzeigen

@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2021 SteamWar.de-Serverteam * Copyright (C) 2022 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.other.items; package de.steamwar.bausystem.features.util.items;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;

Datei anzeigen

@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2021 SteamWar.de-Serverteam * Copyright (C) 2022 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@ -17,11 +17,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.other.items; package de.steamwar.bausystem.features.util.items;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.features.other.KillAllCommand; import de.steamwar.bausystem.features.util.KillAllCommand;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.bausystem.linkage.LinkedInstance;

Datei anzeigen

@ -1,7 +1,7 @@
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
* Copyright (C) 2021 SteamWar.de-Serverteam * Copyright (C) 2022 SteamWar.de-Serverteam
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Affero General Public License as published by
@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.bausystem.features.other.items; package de.steamwar.bausystem.features.util.items;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;

Datei anzeigen

@ -1,60 +0,0 @@
/*
* 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.util.items;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
import de.steamwar.inventory.SWItem;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType;
@Linked(LinkageType.BAU_GUI_ITEM)
public class WaterVisionBauGuiItem extends BauGuiItem {
public WaterVisionBauGuiItem() {
super(18);
}
@Override
public ItemStack getItem(Player player) {
if (player.hasPotionEffect(PotionEffectType.WATER_BREATHING)) {
return new SWItem(Material.WATER_BUCKET, BauSystem.MESSAGE.parse("WATER_VISION_ITEM_ENABLE", player)).getItemStack();
} else {
return new SWItem(Material.BUCKET, BauSystem.MESSAGE.parse("WATER_VISION_ITEM_DISABLE", player)).getItemStack();
}
}
@Override
public boolean click(ClickType click, Player p) {
p.performCommand("wv");
return true;
}
@Override
public Permission permission() {
return Permission.MEMBER;
}
}

Datei anzeigen

@ -1,59 +0,0 @@
/*
* 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.warp;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.inventory.SWItem;
import lombok.experimental.UtilityClass;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import java.util.concurrent.atomic.AtomicInteger;
@UtilityClass
public class Moon {
public static void startMoon(Player player) {
player.getInventory().setHelmet(new SWItem(Material.GLASS, BauSystem.MESSAGE.parse("WARP_MOON_ITEM_NAME", player)).getItemStack());
AtomicInteger countDown = new AtomicInteger(5);
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), bukkitTask -> {
if (countDown.get() == 0) {
AtomicInteger iter = new AtomicInteger(1000);
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), bukkitTask1 -> {
if (player.getLocation().getY() > 300 || iter.getAndDecrement() <= 0) {
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 60 * 5 * 20, 1, false, false));
bukkitTask1.cancel();
} else {
player.setVelocity(player.getVelocity().add(new Vector(0, 0.2, 0)));
player.getWorld().spawnParticle(Particle.FLAME, player.getLocation(), 5);
}
}, 0, 1);
bukkitTask.cancel();
} else {
BauSystem.MESSAGE.sendPrefixless("WARP_MOON_COUNTDOOWN", player, countDown.getAndDecrement());
}
}, 0, 20);
}
}

Datei anzeigen

@ -33,10 +33,21 @@ public class Warp {
private static Map<String, Warp> warpMap = new HashMap<>(); private static Map<String, Warp> warpMap = new HashMap<>();
static {
Warp worldSpawn = new Warp("WorldSpawn");
worldSpawn.setLocation(Bukkit.getWorlds().get(0).getSpawnLocation());
worldSpawn.setMat(Material.NETHER_STAR);
warpMap.put("WorldSpawn", worldSpawn);
}
private String name; private String name;
private Location location; private Location location;
private Material mat; private Material mat;
private Warp(String name) {
this.name = name;
}
public Warp(String name, Player player) { public Warp(String name, Player player) {
this.name = name; this.name = name;
this.location = player.getLocation(); this.location = player.getLocation();

Datei anzeigen

@ -56,11 +56,6 @@ public class WarpCommand extends SWCommand implements Disable, Enable {
return SWCommandUtils.createMapper(Warp::getWarp, (commandSender, s) -> new ArrayList<>(Warp.getWarpNames())); return SWCommandUtils.createMapper(Warp::getWarp, (commandSender, s) -> new ArrayList<>(Warp.getWarpNames()));
} }
@Register(value = "moon", noTabComplete = true)
public void tpMoon(Player p) {
Moon.startMoon(p);
}
@Register(value = "add", description = "WARP_HELP_ADD") @Register(value = "add", description = "WARP_HELP_ADD")
@Register("create") @Register("create")
public void addWarp(@Guard Player player, String name) { public void addWarp(@Guard Player player, String name) {

Datei anzeigen

@ -34,7 +34,6 @@ public enum Flag implements EnumDisplay {
COLOR("FLAG_COLOR", ColorMode.class, ColorMode.YELLOW, region -> false), COLOR("FLAG_COLOR", ColorMode.class, ColorMode.YELLOW, region -> false),
TNT("FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB, region -> true), TNT("FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB, region -> true),
FIRE("FLAG_FIRE", FireMode.class, FireMode.ALLOW, region -> true), FIRE("FLAG_FIRE", FireMode.class, FireMode.ALLOW, region -> true),
DAMAGE("FLAG_DAMAGE", DamageMode.class, DamageMode.ALLOW, region -> false),
FREEZE("FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE, region -> true), FREEZE("FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE, region -> true),
PROTECT("FLAG_PROTECT", ProtectMode.class, ProtectMode.ACTIVE, region -> region.getFloorLevel() != 0); PROTECT("FLAG_PROTECT", ProtectMode.class, ProtectMode.ACTIVE, region -> region.getFloorLevel() != 0);

Datei anzeigen

@ -1,60 +0,0 @@
/*
* 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.region.flags.flagvalues;
import de.steamwar.bausystem.region.flags.Flag;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum DamageMode implements Flag.Value<DamageMode> {
ALLOW("FLAG_DAMAGE_ALLOW"),
DENY("FLAG_DAMAGE_DENY");
private static DamageMode[] values;
private final String chatValue;
@Override
public DamageMode[] getValues() {
if (DamageMode.values == null) {
DamageMode.values = DamageMode.values(); //NOSONAR
}
return DamageMode.values;
}
@Override
public DamageMode getValue() {
return this;
}
@Override
public DamageMode getValueOf(final String name) {
try {
return DamageMode.valueOf(name.toUpperCase());
} catch (IllegalArgumentException e) {
if (name.equalsIgnoreCase("false")) {
return DamageMode.DENY;
}
return DamageMode.ALLOW;
}
}
}

Datei anzeigen

@ -1,7 +1,6 @@
build: build:
- "ln -s /home/gitea/lib" - "ln -s /home/gitea/lib"
- "cp ~/gradle.properties ." - "cp ~/gradle.properties ."
- "chmod u+x build.gradle"
- "./gradlew buildProject" - "./gradlew buildProject"
artifacts: artifacts: