Merge remote-tracking branch 'origin/master'
Dieser Commit ist enthalten in:
Commit
20d569e12d
@ -30,7 +30,7 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
@Getter
|
@Getter
|
||||||
private static BauSystem instance;
|
private static BauSystem instance;
|
||||||
|
|
||||||
// public static final String PREFIX = "§eBauSystem§8» §7";
|
public static final String PREFIX = "§eBauSystem§8» §7";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
@ -19,8 +19,35 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem;
|
package de.steamwar.bausystem;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.config.BauServer;
|
||||||
|
import de.steamwar.sql.BauweltMember;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
public enum Permission {
|
public enum Permission {
|
||||||
WORLD,
|
WORLD(BauweltMember::isWorld),
|
||||||
WORLDEDIT,
|
WORLDEDIT(BauweltMember::isWorldEdit),
|
||||||
MEMBER
|
MEMBER(bauweltMember -> true);
|
||||||
|
|
||||||
|
private Predicate<BauweltMember> permissionPredicate;
|
||||||
|
|
||||||
|
public boolean hasPermission(Player member) {
|
||||||
|
if (member.getUniqueId().equals(BauServer.getInstance().getOwner())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
BauweltMember bauMember = BauweltMember.getBauMember(BauServer.getInstance().getOwner(), member.getUniqueId());
|
||||||
|
if (bauMember == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return permissionPredicate.test(bauMember);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasPermission(Player member, Permission permission) {
|
||||||
|
return permission.hasPermission(member);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* 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.BauSystem;
|
||||||
|
import de.steamwar.bausystem.linkage.LinkageType;
|
||||||
|
import de.steamwar.bausystem.linkage.Linked;
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
|
|
||||||
|
@Linked(LinkageType.COMMAND)
|
||||||
|
public class TeleportCommand extends SWCommand {
|
||||||
|
|
||||||
|
public TeleportCommand() {
|
||||||
|
super("teleport", "tp");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register(help = true)
|
||||||
|
public void genericHelp(Player p, String... args) {
|
||||||
|
p.sendMessage("§8/§etp §8[§7Player§8] §8- §7Teleportiere dich zu einem Spieler");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void genericCommand(Player p, Player target) {
|
||||||
|
if (p.getUniqueId().equals(target.getUniqueId())) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cSei eins mit dir selbst!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
p.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND);
|
||||||
|
}
|
||||||
|
}
|
102
BauSystem_Main/src/de/steamwar/bausystem/features/other/TimeCommand.java
Normale Datei
102
BauSystem_Main/src/de/steamwar/bausystem/features/other/TimeCommand.java
Normale Datei
@ -0,0 +1,102 @@
|
|||||||
|
/*
|
||||||
|
* 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.BauSystem;
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
|
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.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Linked(LinkageType.COMMAND)
|
||||||
|
public class TimeCommand extends SWCommand {
|
||||||
|
|
||||||
|
private static List<String> tabCompletions = Arrays.asList("0", "6000", "12000", "18000");
|
||||||
|
|
||||||
|
public TimeCommand() {
|
||||||
|
super("time");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register(help = true)
|
||||||
|
public void genericHelp(Player p, String... args) {
|
||||||
|
p.sendMessage("§8/§etime §8<§7Zeit 0=Morgen§8, §76000=Mittag§8, §718000=Mitternacht§8> §8- §7Setzt die Zeit auf dem Bau");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void genericCommand(Player p, int time) {
|
||||||
|
if (!Permission.hasPermission(p, Permission.WORLD)) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (time < 0 || time > 24000) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Bukkit.getWorlds().get(0).setTime(time);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void genericCommand(Player p, Time time) {
|
||||||
|
if (!Permission.hasPermission(p, Permission.WORLD)) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Bukkit.getWorlds().get(0).setTime(time.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@ClassMapper(value = int.class, local = true)
|
||||||
|
public TypeMapper<Integer> doubleTypeMapper() {
|
||||||
|
return SWCommandUtils.createMapper(s -> {
|
||||||
|
try {
|
||||||
|
return Integer.parseInt(s);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}, s -> tabCompletions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Time {
|
||||||
|
NIGHT(18000),
|
||||||
|
DAY(6000),
|
||||||
|
DAWN(0),
|
||||||
|
SUNSET(12000),
|
||||||
|
NACHT(18000),
|
||||||
|
TAG(6000),
|
||||||
|
MORGEN(0),
|
||||||
|
ABEND(12000);
|
||||||
|
|
||||||
|
private int value;
|
||||||
|
|
||||||
|
private Time(int value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* 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 final World WORLD = Bukkit.getWorlds().get(0);
|
||||||
|
|
||||||
|
public WorldSpawnCommand() {
|
||||||
|
super("worldspawn");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register(help = true)
|
||||||
|
public void genericHelp(Player p, String... args) {
|
||||||
|
p.sendMessage("§8/§eworldspawn §8- §7Teleportiere dich zum Spawn");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void genericCommand(Player p) {
|
||||||
|
p.teleport(WORLD.getSpawnLocation(), PlayerTeleportEvent.TeleportCause.COMMAND);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@Linked(LinkageType.COMMAND)
|
||||||
|
public class SpeedCommand extends SWCommand {
|
||||||
|
|
||||||
|
public SpeedCommand() {
|
||||||
|
super("speed");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register(help = true)
|
||||||
|
public void genericHelp(Player p, String[] args) {
|
||||||
|
p.sendMessage("§8/§espeed §8[§e1§8-§e10§8] §8- §7Setzte deine Flug- und Laufgeschindigkeit.");
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "Aktuelle geschwindigkeit: §e" + p.getFlySpeed() * 10F);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void speedCommand(Player p, float speed) {
|
||||||
|
speed = speed / 10F;
|
||||||
|
if (speed < -1F) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§c" + speed + " ist zu klein");
|
||||||
|
} else if (speed > 1F) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§c" + speed + " ist zu hoch");
|
||||||
|
} else {
|
||||||
|
p.setFlySpeed(speed);
|
||||||
|
p.setWalkSpeed(speed);
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "Aktuelle geschwindigkeit: §e" + p.getFlySpeed() * 10F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren