Merge remote-tracking branch 'origin/master'
Dieser Commit ist enthalten in:
Commit
1e68437e0c
@ -21,6 +21,7 @@ package de.steamwar.bausystem.region;
|
|||||||
|
|
||||||
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ -33,11 +34,15 @@ public class Point {
|
|||||||
private final int y;
|
private final int y;
|
||||||
private final int z;
|
private final int z;
|
||||||
|
|
||||||
|
public static Point fromLocation(final Location location) {
|
||||||
|
return new Point(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||||
|
}
|
||||||
|
|
||||||
public Point add(int x, int y, int z) {
|
public Point add(int x, int y, int z) {
|
||||||
return new Point(this.x + x, this.y + y, this.z + z);
|
return new Point(this.x + x, this.y + y, this.z + z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point substract(int x, int y, int z) {
|
public Point subtract(int x, int y, int z) {
|
||||||
return new Point(this.x - x, this.y - y, this.z - z);
|
return new Point(this.x - x, this.y - y, this.z - z);
|
||||||
}
|
}
|
||||||
}
|
}
|
56
BauSystem_API/src/de/steamwar/bausystem/shared/Pair.java
Normale Datei
56
BauSystem_API/src/de/steamwar/bausystem/shared/Pair.java
Normale Datei
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* 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.shared;
|
||||||
|
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class Pair<K, V> {
|
||||||
|
|
||||||
|
private K key;
|
||||||
|
|
||||||
|
private V value;
|
||||||
|
|
||||||
|
|
||||||
|
public Pair(final K key, final V value) {
|
||||||
|
this.key = key;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public K setKey(final K key) {
|
||||||
|
final K currentKey = this.key;
|
||||||
|
this.key = key;
|
||||||
|
return currentKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public V setValue(final V value) {
|
||||||
|
final V currentValue = this.value;
|
||||||
|
this.value = value;
|
||||||
|
return currentValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.key + "=" + this.value;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* 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.autostart;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
|
import de.steamwar.bausystem.linkage.GuiItem;
|
||||||
|
import de.steamwar.bausystem.linkage.LinkageType;
|
||||||
|
import de.steamwar.bausystem.linkage.Linked;
|
||||||
|
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 java.util.Arrays;
|
||||||
|
|
||||||
|
@Linked(LinkageType.GUI_ITEM)
|
||||||
|
public class AutoStartGuiItem extends GuiItem {
|
||||||
|
|
||||||
|
public AutoStartGuiItem() {
|
||||||
|
super(24);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getItem(Player player) {
|
||||||
|
return new SWItem(Material.FIREWORK_STAR, "§eAutostartTimer", Arrays.asList("§eRechtsklick Block §8- §7Starte den Timer"), false, null).getItemStack();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean click(ClickType click, Player p) {
|
||||||
|
p.closeInventory();
|
||||||
|
p.performCommand("timer");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Permission permission() {
|
||||||
|
return Permission.MEMBER;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,104 @@
|
|||||||
|
/*
|
||||||
|
* 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.countingwand;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.config.ColorConfig;
|
||||||
|
import de.steamwar.bausystem.region.Point;
|
||||||
|
import de.steamwar.bausystem.shared.Pair;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
|
import java.util.*;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
|
||||||
|
@UtilityClass
|
||||||
|
public class Countingwand {
|
||||||
|
|
||||||
|
public final ItemStack WAND_ITEM = new SWItem(Material.STICK,
|
||||||
|
ColorConfig.HIGHLIGHT + "Counting Wand",
|
||||||
|
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 -> {
|
||||||
|
}).getItemStack();
|
||||||
|
|
||||||
|
private final Map<String, Pair<Point, Point>> selections = new HashMap<>();
|
||||||
|
|
||||||
|
public boolean isCountingwand(final ItemStack item) {
|
||||||
|
return WAND_ITEM.isSimilar(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkSelection(final Point point, final boolean pos1, final Player p) {
|
||||||
|
Pair<Point, Point> selection = selections.get(p.getUniqueId().toString());
|
||||||
|
final boolean newPos;
|
||||||
|
if (selection != null) {
|
||||||
|
if (pos1) {
|
||||||
|
newPos = !point.equals(selection.setKey(point));
|
||||||
|
} else {
|
||||||
|
newPos = !point.equals(selection.setValue(point));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (pos1) {
|
||||||
|
selection = new Pair<>(point, null);
|
||||||
|
} else {
|
||||||
|
selection = new Pair<>(null, point);
|
||||||
|
}
|
||||||
|
selections.put(p.getUniqueId().toString(), selection);
|
||||||
|
newPos = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newPos) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX
|
||||||
|
+ (pos1 ? "Erste Position bei: " : "Zweite Position bei: ")
|
||||||
|
+ ColorConfig.OTHER
|
||||||
|
+ "["
|
||||||
|
+ ColorConfig.BASE
|
||||||
|
+ point.getX()
|
||||||
|
+ ColorConfig.OTHER
|
||||||
|
+ ", "
|
||||||
|
+ ColorConfig.BASE
|
||||||
|
+ point.getY()
|
||||||
|
+ ColorConfig.OTHER
|
||||||
|
+ ", "
|
||||||
|
+ ColorConfig.BASE
|
||||||
|
+ point.getZ()
|
||||||
|
+ ColorConfig.OTHER
|
||||||
|
+ "] ("
|
||||||
|
+ ColorConfig.HIGHLIGHT
|
||||||
|
+ Countingwand.getAmount(selection.getKey(), selection.getValue())
|
||||||
|
+ ColorConfig.OTHER
|
||||||
|
+ ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePlayer(Player p) {
|
||||||
|
selections.remove(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAmount(final Point point1, final Point point2) {
|
||||||
|
if (point1 == null || point2 == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (Math.abs(point1.getX() - point2.getX()) + 1) * (Math.abs(point1.getY() - point2.getY()) + 1) * (Math.abs(point1.getZ() - point2.getZ()) + 1);
|
||||||
|
}
|
||||||
|
}
|
@ -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.countingwand;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.SWUtils;
|
||||||
|
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 CountingwandCommand extends SWCommand {
|
||||||
|
|
||||||
|
public CountingwandCommand() {
|
||||||
|
super("countingwand", "/countingwand", "cwand", "/cwand");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void genericCommand(final Player p) {
|
||||||
|
SWUtils.giveItemToPlayer(p, Countingwand.WAND_ITEM);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* 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.countingwand;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
|
import de.steamwar.bausystem.config.ColorConfig;
|
||||||
|
import de.steamwar.bausystem.features.gui.BauGUI;
|
||||||
|
import de.steamwar.bausystem.linkage.GuiItem;
|
||||||
|
import de.steamwar.bausystem.linkage.LinkageType;
|
||||||
|
import de.steamwar.bausystem.linkage.Linked;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
|
||||||
|
@Linked(LinkageType.GUI_ITEM)
|
||||||
|
public class CountingwandGuiItem extends GuiItem {
|
||||||
|
|
||||||
|
public CountingwandGuiItem() {
|
||||||
|
super(22);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getItem(Player player) {
|
||||||
|
return new SWItem(Material.STICK,
|
||||||
|
ColorConfig.HIGHLIGHT + "Counting Wand",
|
||||||
|
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 -> {
|
||||||
|
}).getItemStack();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean click(ClickType click, Player p) {
|
||||||
|
p.closeInventory();
|
||||||
|
p.performCommand("countingwand");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Permission permission() {
|
||||||
|
return Permission.WORLDEDIT;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* 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.countingwand;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.linkage.LinkageType;
|
||||||
|
import de.steamwar.bausystem.linkage.Linked;
|
||||||
|
import de.steamwar.bausystem.region.Point;
|
||||||
|
import java.util.Objects;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
|
|
||||||
|
@Linked(LinkageType.LISTENER)
|
||||||
|
public class CountingwandListener implements Listener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockBreak(final BlockBreakEvent event) {
|
||||||
|
if (!Countingwand.isCountingwand(event.getPlayer().getInventory().getItemInMainHand())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
Countingwand.checkSelection(Point.fromLocation(event.getBlock().getLocation()), true, event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerInteract(final PlayerInteractEvent event) {
|
||||||
|
if (!Countingwand.isCountingwand(event.getItem())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
Countingwand.checkSelection(Point.fromLocation(Objects.requireNonNull(event.getClickedBlock()).getLocation()), false, event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onLeave(PlayerQuitEvent event) {
|
||||||
|
Countingwand.removePlayer(event.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* 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.redstonetester;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
|
import de.steamwar.bausystem.config.ColorConfig;
|
||||||
|
import de.steamwar.bausystem.linkage.GuiItem;
|
||||||
|
import de.steamwar.bausystem.linkage.LinkageType;
|
||||||
|
import de.steamwar.bausystem.linkage.Linked;
|
||||||
|
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 java.util.Arrays;
|
||||||
|
|
||||||
|
@Linked(LinkageType.GUI_ITEM)
|
||||||
|
public class RedstoneTesterGuiItem extends GuiItem {
|
||||||
|
|
||||||
|
public RedstoneTesterGuiItem() {
|
||||||
|
super(23);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getItem(Player player) {
|
||||||
|
return new SWItem(Material.REPEATER, ColorConfig.HIGHLIGHT + "Redstonetester", Arrays.asList(ColorConfig.HIGHLIGHT + "Linksklick Block " + ColorConfig.OTHER + "-" + ColorConfig.BASE + " Setzt die 1. Position", ColorConfig.HIGHLIGHT + "Rechtsklick Block " + ColorConfig.OTHER + "-" + ColorConfig.BASE + " Setzt die 2. Position", ColorConfig.HIGHLIGHT + "Shift-Rechtsklick Luft " + ColorConfig.OTHER + "-" + ColorConfig.BASE + " Zurücksetzten"), false, null).getItemStack();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean click(ClickType click, Player p) {
|
||||||
|
p.closeInventory();
|
||||||
|
p.performCommand("redstonetester");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Permission permission() {
|
||||||
|
return Permission.MEMBER;
|
||||||
|
}
|
||||||
|
}
|
@ -25,7 +25,6 @@ import de.steamwar.bausystem.config.ColorConfig;
|
|||||||
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.core.VersionedRunnable;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@Linked(LinkageType.COMMAND)
|
@Linked(LinkageType.COMMAND)
|
||||||
@ -42,9 +41,7 @@ public class RedstonetesterCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void genericCommand(Player p) {
|
public void genericCommand(Player p) {
|
||||||
VersionedRunnable.call(new VersionedRunnable(() -> p.sendMessage(BauSystem.PREFIX + "Der RedstoneTester ist nicht in der 1.12 verfügbar"), 8), new VersionedRunnable(() -> {
|
|
||||||
p.sendMessage(BauSystem.PREFIX + "Messe die Zeit zwischen der Aktivierung zweier Redstone Komponenten");
|
p.sendMessage(BauSystem.PREFIX + "Messe die Zeit zwischen der Aktivierung zweier Redstone Komponenten");
|
||||||
SWUtils.giveItemToPlayer(p, RedstonetesterUtils.WAND);
|
SWUtils.giveItemToPlayer(p, RedstonetesterUtils.WAND);
|
||||||
}, 15));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -68,10 +68,6 @@ public class AutoShutdownListener implements Listener {
|
|||||||
Bukkit.shutdown();
|
Bukkit.shutdown();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
count++;
|
|
||||||
if (count <= 120) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
if (RamUsage.getUsage() > 0.8) {
|
if (RamUsage.getUsage() > 0.8) {
|
||||||
Bukkit.shutdown();
|
Bukkit.shutdown();
|
||||||
|
@ -19,43 +19,14 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.world;
|
package de.steamwar.bausystem.features.world;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import lombok.experimental.UtilityClass;
|
||||||
import de.steamwar.bausystem.linkage.LinkageType;
|
|
||||||
import de.steamwar.bausystem.linkage.Linked;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.boss.BarColor;
|
|
||||||
import org.bukkit.boss.BarStyle;
|
|
||||||
import org.bukkit.boss.BossBar;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@Linked(LinkageType.PLAIN)
|
@UtilityClass
|
||||||
public class RamUsage implements Listener {
|
public class RamUsage {
|
||||||
|
|
||||||
private boolean mode = false;
|
|
||||||
private BossBar bossBar;
|
|
||||||
|
|
||||||
public RamUsage() {
|
|
||||||
bossBar = Bukkit.createBossBar("§eRAM", BarColor.YELLOW, BarStyle.SEGMENTED_10);
|
|
||||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
|
|
||||||
long allocatedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
|
|
||||||
long presumableFreeMemory = Runtime.getRuntime().maxMemory() - allocatedMemory;
|
|
||||||
double percentageFree = presumableFreeMemory / (double) Runtime.getRuntime().maxMemory();
|
|
||||||
bossBar.setProgress(1 - percentageFree);
|
|
||||||
if (mode && percentageFree > 0.5) {
|
|
||||||
mode = false;
|
|
||||||
} else if (!mode && percentageFree < 0.3) {
|
|
||||||
mode = true;
|
|
||||||
}
|
|
||||||
if (mode) {
|
|
||||||
Bukkit.getOnlinePlayers().forEach(bossBar::addPlayer);
|
|
||||||
} else {
|
|
||||||
bossBar.removeAll();
|
|
||||||
}
|
|
||||||
}, 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double getUsage() {
|
public static double getUsage() {
|
||||||
try {
|
try {
|
||||||
|
@ -139,7 +139,7 @@ public class Region {
|
|||||||
this.minPointTestblock = point.add(prototype.getTestblock().getOffsetX(), prototype.getTestblock().getOffsetY(), prototype.getTestblock().getOffsetZ());
|
this.minPointTestblock = point.add(prototype.getTestblock().getOffsetX(), prototype.getTestblock().getOffsetY(), prototype.getTestblock().getOffsetZ());
|
||||||
this.maxPointTestblock = this.minPointTestblock.add(prototype.getTestblock().getSizeX() - 1, prototype.getTestblock().getSizeY() - 1, prototype.getTestblock().getSizeZ() - 1);
|
this.maxPointTestblock = this.minPointTestblock.add(prototype.getTestblock().getSizeX() - 1, prototype.getTestblock().getSizeY() - 1, prototype.getTestblock().getSizeZ() - 1);
|
||||||
|
|
||||||
this.minPointTestblockExtension = this.minPointTestblock.substract(prototype.getTestblock().getExtensionNegativeX(), prototype.getTestblock().getExtensionNegativeY(), prototype.getTestblock().getExtensionNegativeZ());
|
this.minPointTestblockExtension = this.minPointTestblock.subtract(prototype.getTestblock().getExtensionNegativeX(), prototype.getTestblock().getExtensionNegativeY(), prototype.getTestblock().getExtensionNegativeZ());
|
||||||
this.maxPointTestblockExtension = this.maxPointTestblock.add(prototype.getTestblock().getExtensionPositiveX(), prototype.getTestblock().getExtensionPositiveY(), prototype.getTestblock().getExtensionPositiveZ());
|
this.maxPointTestblockExtension = this.maxPointTestblock.add(prototype.getTestblock().getExtensionPositiveX(), prototype.getTestblock().getExtensionPositiveY(), prototype.getTestblock().getExtensionPositiveZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ public class Region {
|
|||||||
this.minPointBuild = point.add(prototype.getBuild().getOffsetX(), prototype.getBuild().getOffsetY(), prototype.getBuild().getOffsetZ());
|
this.minPointBuild = point.add(prototype.getBuild().getOffsetX(), prototype.getBuild().getOffsetY(), prototype.getBuild().getOffsetZ());
|
||||||
this.maxPointBuild = this.minPointBuild.add(prototype.getBuild().getSizeX() - 1, prototype.getBuild().getSizeY() - 1, prototype.getBuild().getSizeZ() - 1);
|
this.maxPointBuild = this.minPointBuild.add(prototype.getBuild().getSizeX() - 1, prototype.getBuild().getSizeY() - 1, prototype.getBuild().getSizeZ() - 1);
|
||||||
|
|
||||||
this.minPointBuildExtension = this.minPointBuild.substract(prototype.getBuild().getExtensionNegativeX(), prototype.getBuild().getExtensionNegativeY(), prototype.getBuild().getExtensionNegativeZ());
|
this.minPointBuildExtension = this.minPointBuild.subtract(prototype.getBuild().getExtensionNegativeX(), prototype.getBuild().getExtensionNegativeY(), prototype.getBuild().getExtensionNegativeZ());
|
||||||
this.maxPointBuildExtension = this.maxPointBuild.add(prototype.getBuild().getExtensionPositiveX(), prototype.getBuild().getExtensionPositiveY(), prototype.getBuild().getExtensionPositiveZ());
|
this.maxPointBuildExtension = this.maxPointBuild.add(prototype.getBuild().getExtensionPositiveX(), prototype.getBuild().getExtensionPositiveY(), prototype.getBuild().getExtensionPositiveZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren