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 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",
|
||||
ColorConfig.HIGHLIGHT + "Rechtsklick" + ColorConfig.OTHER + " - " + ColorConfig.BASE + "Setzt die 2. Position"),
|
||||
false, clickType -> {
|
||||
@ -83,8 +83,7 @@ public class Countingwand {
|
||||
+ point.getZ()
|
||||
+ ColorConfig.OTHER
|
||||
+ "] ("
|
||||
+ ColorConfig.HIGHLIGHT
|
||||
+ Countingwand.getAmount(selection.getKey(), selection.getValue())
|
||||
+ Countingwand.getDimensions(selection.getKey(), selection.getValue())
|
||||
+ ColorConfig.OTHER
|
||||
+ ")");
|
||||
}
|
||||
@ -94,11 +93,15 @@ public class Countingwand {
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@ import org.bukkit.entity.Player;
|
||||
public class CountingwandCommand extends SWCommand {
|
||||
|
||||
public CountingwandCommand() {
|
||||
super("countingwand", "/countingwand", "cwand", "/cwand");
|
||||
super("countingwand", "/countingwand", "cwand", "/cwand", "zollstock", "/zollstock");
|
||||
}
|
||||
|
||||
@Register
|
||||
|
@ -43,7 +43,7 @@ public class CountingwandGuiItem extends BauGuiItem {
|
||||
@Override
|
||||
public ItemStack getItem(Player player) {
|
||||
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",
|
||||
ColorConfig.HIGHLIGHT + "Rechtsklick" + ColorConfig.OTHER + " - " + ColorConfig.BASE + "Setzt die 2. Position"),
|
||||
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),
|
||||
TNT("FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB),
|
||||
FIRE("FLAG_FIRE", FireMode.class, FireMode.ALLOW),
|
||||
DAMAGE("FLAG_DAMAGE", DamageMode.class, DamageMode.ALLOW),
|
||||
FREEZE("FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE),
|
||||
PROTECT("FLAG_PROTECT", ProtectMode.class, ProtectMode.INACTIVE);
|
||||
|
||||
|
@ -65,7 +65,7 @@ public enum ColorMode implements Flag.Value<ColorMode> {
|
||||
@Override
|
||||
public ColorMode getValueOf(final String name) {
|
||||
try {
|
||||
return ColorMode.valueOf(name);
|
||||
return ColorMode.valueOf(name.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
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
|
||||
public FireMode getValueOf(final String name) {
|
||||
try {
|
||||
return FireMode.valueOf(name);
|
||||
return FireMode.valueOf(name.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
if (name.equalsIgnoreCase("false")) {
|
||||
return FireMode.DENY;
|
||||
|
@ -50,7 +50,7 @@ public enum FreezeMode implements Flag.Value<FreezeMode> {
|
||||
@Override
|
||||
public FreezeMode getValueOf(final String name) {
|
||||
try {
|
||||
return FreezeMode.valueOf(name);
|
||||
return FreezeMode.valueOf(name.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
if (name.equalsIgnoreCase("false")) {
|
||||
return FreezeMode.INACTIVE;
|
||||
|
@ -49,7 +49,7 @@ public enum ProtectMode implements Flag.Value<ProtectMode> {
|
||||
@Override
|
||||
public ProtectMode getValueOf(final String name) {
|
||||
try {
|
||||
return ProtectMode.valueOf(name);
|
||||
return ProtectMode.valueOf(name.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
if (name.equalsIgnoreCase("false")) {
|
||||
return ProtectMode.INACTIVE;
|
||||
|
@ -50,7 +50,7 @@ public enum TNTMode implements Flag.Value<TNTMode> {
|
||||
@Override
|
||||
public TNTMode getValueOf(final String name) {
|
||||
try {
|
||||
return TNTMode.valueOf(name);
|
||||
return TNTMode.valueOf(name.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return TNTMode.ALLOW;
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren