Merge remote-tracking branch 'origin/master'
Dieser Commit ist enthalten in:
Commit
d24e1f2c4d
@ -35,7 +35,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
public class Countingwand {
|
public class Countingwand {
|
||||||
|
|
||||||
public final ItemStack WAND_ITEM = new SWItem(Material.STICK,
|
public final ItemStack WAND_ITEM = new SWItem(Material.STICK,
|
||||||
ColorConfig.HIGHLIGHT + "Counting Wand",
|
ColorConfig.HIGHLIGHT + "Zollstock",
|
||||||
Arrays.asList(ColorConfig.HIGHLIGHT + "Linksklick" + ColorConfig.OTHER + " - " + ColorConfig.BASE + "Setzt die 1. Position",
|
Arrays.asList(ColorConfig.HIGHLIGHT + "Linksklick" + ColorConfig.OTHER + " - " + ColorConfig.BASE + "Setzt die 1. Position",
|
||||||
ColorConfig.HIGHLIGHT + "Rechtsklick" + ColorConfig.OTHER + " - " + ColorConfig.BASE + "Setzt die 2. Position"),
|
ColorConfig.HIGHLIGHT + "Rechtsklick" + ColorConfig.OTHER + " - " + ColorConfig.BASE + "Setzt die 2. Position"),
|
||||||
false, clickType -> {
|
false, clickType -> {
|
||||||
@ -83,8 +83,7 @@ public class Countingwand {
|
|||||||
+ point.getZ()
|
+ point.getZ()
|
||||||
+ ColorConfig.OTHER
|
+ ColorConfig.OTHER
|
||||||
+ "] ("
|
+ "] ("
|
||||||
+ ColorConfig.HIGHLIGHT
|
+ Countingwand.getDimensions(selection.getKey(), selection.getValue())
|
||||||
+ Countingwand.getAmount(selection.getKey(), selection.getValue())
|
|
||||||
+ ColorConfig.OTHER
|
+ ColorConfig.OTHER
|
||||||
+ ")");
|
+ ")");
|
||||||
}
|
}
|
||||||
@ -94,11 +93,15 @@ public class Countingwand {
|
|||||||
selections.remove(p);
|
selections.remove(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAmount(final Point point1, final Point point2) {
|
public String getDimensions(final Point point1, final Point point2) {
|
||||||
if (point1 == null || point2 == null) {
|
if (point1 == null || point2 == null) {
|
||||||
return 0;
|
return ColorConfig.HIGHLIGHT + "0" + ColorConfig.OTHER + "," + ColorConfig.HIGHLIGHT + "0" + ColorConfig.OTHER + "," + ColorConfig.HIGHLIGHT + "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ColorConfig.HIGHLIGHT + "" + (Math.abs(point1.getX() - point2.getX()) + 1) + ColorConfig.OTHER + ", " + ColorConfig.HIGHLIGHT + "" + (Math.abs(point1.getY() - point2.getY()) + 1) + ColorConfig.OTHER + ", " +ColorConfig.HIGHLIGHT + "" + (Math.abs(point1.getZ() - point2.getZ()) + 1) + ColorConfig.OTHER;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAmount(final Point point1, final Point point2) {
|
||||||
return (Math.abs(point1.getX() - point2.getX()) + 1) * (Math.abs(point1.getY() - point2.getY()) + 1) * (Math.abs(point1.getZ() - point2.getZ()) + 1);
|
return (Math.abs(point1.getX() - point2.getX()) + 1) * (Math.abs(point1.getY() - point2.getY()) + 1) * (Math.abs(point1.getZ() - point2.getZ()) + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -30,7 +30,7 @@ import org.bukkit.entity.Player;
|
|||||||
public class CountingwandCommand extends SWCommand {
|
public class CountingwandCommand extends SWCommand {
|
||||||
|
|
||||||
public CountingwandCommand() {
|
public CountingwandCommand() {
|
||||||
super("countingwand", "/countingwand", "cwand", "/cwand");
|
super("countingwand", "/countingwand", "cwand", "/cwand", "zollstock", "/zollstock");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
|
@ -43,7 +43,7 @@ public class CountingwandGuiItem extends BauGuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(Player player) {
|
public ItemStack getItem(Player player) {
|
||||||
return new SWItem(Material.STICK,
|
return new SWItem(Material.STICK,
|
||||||
ColorConfig.HIGHLIGHT + "Counting Wand",
|
ColorConfig.HIGHLIGHT + "Zollstock",
|
||||||
Arrays.asList(ColorConfig.HIGHLIGHT + "Linksklick" + ColorConfig.OTHER + " - " + ColorConfig.BASE + "Setzt die 1. Position",
|
Arrays.asList(ColorConfig.HIGHLIGHT + "Linksklick" + ColorConfig.OTHER + " - " + ColorConfig.BASE + "Setzt die 1. Position",
|
||||||
ColorConfig.HIGHLIGHT + "Rechtsklick" + ColorConfig.OTHER + " - " + ColorConfig.BASE + "Setzt die 2. Position"),
|
ColorConfig.HIGHLIGHT + "Rechtsklick" + ColorConfig.OTHER + " - " + ColorConfig.BASE + "Setzt die 2. Position"),
|
||||||
false, clickType -> {
|
false, clickType -> {
|
||||||
|
@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* 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.SWUtils;
|
||||||
|
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.SWCommand;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
|
@Linked(LinkageType.COMMAND)
|
||||||
|
public class DamageCommand extends SWCommand {
|
||||||
|
|
||||||
|
protected DamageCommand() {
|
||||||
|
super("damage", "dmg");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register(help = true)
|
||||||
|
public void genericHelp(Player p, String... args) {
|
||||||
|
p.sendMessage("§8/§edamage §8- §7Toggle Spielerschaden");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void toggleCommand(Player p) {
|
||||||
|
if (!permissionCheck(p)) return;
|
||||||
|
Region region = Region.getRegion(p.getLocation());
|
||||||
|
if (toggle(region)) {
|
||||||
|
RegionUtils.actionBar(region, getEnableMessage());
|
||||||
|
} else {
|
||||||
|
RegionUtils.actionBar(region, getDisableMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getNoPermMessage() {
|
||||||
|
return "§cDu darfst hier nicht Spielerschaden (de-)aktivieren";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getEnableMessage() {
|
||||||
|
return "§cRegions Spielerschaden deaktiviert";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getDisableMessage() {
|
||||||
|
return "§aRegions Spielerschaden aktiviert";
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean permissionCheck(Player player) {
|
||||||
|
if (!Permission.hasPermission(player, Permission.WORLD)) {
|
||||||
|
player.sendMessage(BauSystem.PREFIX + getNoPermMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
}
|
@ -32,6 +32,7 @@ public enum Flag implements EnumDisplay {
|
|||||||
COLOR("FLAG_COLOR", ColorMode.class, ColorMode.YELLOW),
|
COLOR("FLAG_COLOR", ColorMode.class, ColorMode.YELLOW),
|
||||||
TNT("FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB),
|
TNT("FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB),
|
||||||
FIRE("FLAG_FIRE", FireMode.class, FireMode.ALLOW),
|
FIRE("FLAG_FIRE", FireMode.class, FireMode.ALLOW),
|
||||||
|
DAMAGE("FLAG_DAMAGE", DamageMode.class, DamageMode.ALLOW),
|
||||||
FREEZE("FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE),
|
FREEZE("FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE),
|
||||||
PROTECT("FLAG_PROTECT", ProtectMode.class, ProtectMode.INACTIVE);
|
PROTECT("FLAG_PROTECT", ProtectMode.class, ProtectMode.INACTIVE);
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ public enum ColorMode implements Flag.Value<ColorMode> {
|
|||||||
@Override
|
@Override
|
||||||
public ColorMode getValueOf(final String name) {
|
public ColorMode getValueOf(final String name) {
|
||||||
try {
|
try {
|
||||||
return ColorMode.valueOf(name);
|
return ColorMode.valueOf(name.toUpperCase());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
return ColorMode.YELLOW;
|
return ColorMode.YELLOW;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -49,7 +49,7 @@ public enum FireMode implements Flag.Value<FireMode> {
|
|||||||
@Override
|
@Override
|
||||||
public FireMode getValueOf(final String name) {
|
public FireMode getValueOf(final String name) {
|
||||||
try {
|
try {
|
||||||
return FireMode.valueOf(name);
|
return FireMode.valueOf(name.toUpperCase());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
if (name.equalsIgnoreCase("false")) {
|
if (name.equalsIgnoreCase("false")) {
|
||||||
return FireMode.DENY;
|
return FireMode.DENY;
|
||||||
|
@ -50,7 +50,7 @@ public enum FreezeMode implements Flag.Value<FreezeMode> {
|
|||||||
@Override
|
@Override
|
||||||
public FreezeMode getValueOf(final String name) {
|
public FreezeMode getValueOf(final String name) {
|
||||||
try {
|
try {
|
||||||
return FreezeMode.valueOf(name);
|
return FreezeMode.valueOf(name.toUpperCase());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
if (name.equalsIgnoreCase("false")) {
|
if (name.equalsIgnoreCase("false")) {
|
||||||
return FreezeMode.INACTIVE;
|
return FreezeMode.INACTIVE;
|
||||||
|
@ -49,7 +49,7 @@ public enum ProtectMode implements Flag.Value<ProtectMode> {
|
|||||||
@Override
|
@Override
|
||||||
public ProtectMode getValueOf(final String name) {
|
public ProtectMode getValueOf(final String name) {
|
||||||
try {
|
try {
|
||||||
return ProtectMode.valueOf(name);
|
return ProtectMode.valueOf(name.toUpperCase());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
if (name.equalsIgnoreCase("false")) {
|
if (name.equalsIgnoreCase("false")) {
|
||||||
return ProtectMode.INACTIVE;
|
return ProtectMode.INACTIVE;
|
||||||
|
@ -50,7 +50,7 @@ public enum TNTMode implements Flag.Value<TNTMode> {
|
|||||||
@Override
|
@Override
|
||||||
public TNTMode getValueOf(final String name) {
|
public TNTMode getValueOf(final String name) {
|
||||||
try {
|
try {
|
||||||
return TNTMode.valueOf(name);
|
return TNTMode.valueOf(name.toUpperCase());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
return TNTMode.ALLOW;
|
return TNTMode.ALLOW;
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren