forked from SteamWar/SteamWar
Fix some more issues
This commit is contained in:
+6
-7
@@ -22,10 +22,9 @@ package de.steamwar.bausystem.features.region.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.linkage.specific.BauGuiItem;
|
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||||
import de.steamwar.bausystem.region.Color;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
|
||||||
import de.steamwar.bausystem.region.flags.ColorMode;
|
import de.steamwar.bausystem.region.flags.ColorMode;
|
||||||
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.inventory.SWListInv;
|
import de.steamwar.inventory.SWListInv;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
@@ -45,7 +44,7 @@ public class ColorBauGuiItem extends BauGuiItem {
|
|||||||
super(2);
|
super(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Material mapColor(Color color) {
|
private static Material mapColor(ColorMode color) {
|
||||||
switch (color) {
|
switch (color) {
|
||||||
case RED:
|
case RED:
|
||||||
return Material.RED_CONCRETE;
|
return Material.RED_CONCRETE;
|
||||||
@@ -85,17 +84,17 @@ public class ColorBauGuiItem extends BauGuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(Player player) {
|
public ItemStack getItem(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
ColorMode mode = region.getPlain(Flag.COLOR, ColorMode.class);
|
ColorMode mode = region.getFlags().get(Flag.COLOR).orElse(ColorMode.PINK);
|
||||||
return new SWItem(mapColor(mode.getColor()), BauSystem.MESSAGE.parse("REGION_ITEM_COLOR", player, BauSystem.MESSAGE.parse(mode.getChatValue(), player))).getItemStack();
|
return new SWItem(mapColor(mode), BauSystem.MESSAGE.parse("REGION_ITEM_COLOR", player, BauSystem.MESSAGE.parse(mode.getChatValue(), player))).getItemStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean click(ClickType click, Player p) {
|
public boolean click(ClickType click, Player p) {
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
ColorMode current = Region.getRegion(p.getLocation()).getPlain(Flag.COLOR, ColorMode.class);
|
ColorMode current = Region.getRegion(p.getLocation()).getFlags().get(Flag.COLOR).orElse(ColorMode.PINK);
|
||||||
List<SWListInv.SWListEntry<ColorMode>> items = new ArrayList<>();
|
List<SWListInv.SWListEntry<ColorMode>> items = new ArrayList<>();
|
||||||
for (ColorMode value : ColorMode.values()) {
|
for (ColorMode value : ColorMode.values()) {
|
||||||
items.add(new SWListInv.SWListEntry<>(new SWItem(mapColor(value.getColor()), (byte) 0, "§f" + BauSystem.MESSAGE.parse(value.getChatValue(), p), Collections.emptyList(), value == current, clickType -> {
|
items.add(new SWListInv.SWListEntry<>(new SWItem(mapColor(value), (byte) 0, "§f" + BauSystem.MESSAGE.parse(value.getChatValue(), p), Collections.emptyList(), value == current, clickType -> {
|
||||||
}), value));
|
}), value));
|
||||||
}
|
}
|
||||||
SWListInv<ColorMode> inv = new SWListInv<>(p, BauSystem.MESSAGE.parse("REGION_ITEM_COLOR_CHOOSE", p), items, (clickType, colorMode) -> {
|
SWListInv<ColorMode> inv = new SWListInv<>(p, BauSystem.MESSAGE.parse("REGION_ITEM_COLOR_CHOOSE", p), items, (clickType, colorMode) -> {
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.SWUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||||
import de.steamwar.bausystem.region.GlobalRegion;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
import de.steamwar.bausystem.utils.TickEndEvent;
|
import de.steamwar.bausystem.utils.TickEndEvent;
|
||||||
@@ -85,14 +84,14 @@ public class TPSSystem implements Listener {
|
|||||||
private void bossbar() {
|
private void bossbar() {
|
||||||
if ((TickManager.impl.isStepping() || TickManager.impl.isSprinting()) && TickManager.impl.getRemainingTicks() > 0) {
|
if ((TickManager.impl.isStepping() || TickManager.impl.isSprinting()) && TickManager.impl.getRemainingTicks() > 0) {
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||||
BauSystemBossbar bossbar = BossBarService.instance.get(player, GlobalRegion.getInstance(), "TickStep");
|
BauSystemBossbar bossbar = BossBarService.instance.get(player, Region.getGlobalRegion(), "TickStep");
|
||||||
bossbar.setColor(BarColor.YELLOW);
|
bossbar.setColor(BarColor.YELLOW);
|
||||||
bossbar.setTitle(BauSystem.MESSAGE.parse("TICK_BOSSBAR", player, TickManager.impl.getDoneTicks(), TickManager.impl.getTotalTicks()));
|
bossbar.setTitle(BauSystem.MESSAGE.parse("TICK_BOSSBAR", player, TickManager.impl.getDoneTicks(), TickManager.impl.getTotalTicks()));
|
||||||
bossbar.setProgress(TickManager.impl.getDoneTicks() / (double) TickManager.impl.getTotalTicks());
|
bossbar.setProgress(TickManager.impl.getDoneTicks() / (double) TickManager.impl.getTotalTicks());
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||||
BossBarService.instance.remove(player, GlobalRegion.getInstance(), "TickStep");
|
BossBarService.instance.remove(player, Region.getGlobalRegion(), "TickStep");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-9
@@ -28,7 +28,7 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
|||||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
import de.steamwar.bausystem.features.world.WorldEditListener;
|
import de.steamwar.bausystem.features.world.WorldEditListener;
|
||||||
import de.steamwar.bausystem.features.worldedit.utils.SpecialReplace;
|
import de.steamwar.bausystem.features.worldedit.utils.SpecialReplace;
|
||||||
import de.steamwar.bausystem.region.Color;
|
import de.steamwar.bausystem.region.flags.ColorMode;
|
||||||
import de.steamwar.bausystem.shared.Pair;
|
import de.steamwar.bausystem.shared.Pair;
|
||||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||||
import de.steamwar.command.PreviousArguments;
|
import de.steamwar.command.PreviousArguments;
|
||||||
@@ -63,7 +63,7 @@ public class ColorReplaceCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register(description = "COLORREPLACE_HELP")
|
@Register(description = "COLORREPLACE_HELP")
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public void genericCommand(@Validator Player player, Pair<Integer, Color> from, Color to) {
|
public void genericCommand(@Validator Player player, Pair<Integer, ColorMode> from, ColorMode to) {
|
||||||
if (from.getValue() == to) {
|
if (from.getValue() == to) {
|
||||||
BukkitAdapter.adapt(player).printInfo(TranslatableComponent.of("worldedit.replace.replaced", new Component[]{TextComponent.of(0)}));
|
BukkitAdapter.adapt(player).printInfo(TranslatableComponent.of("worldedit.replace.replaced", new Component[]{TextComponent.of(0)}));
|
||||||
return;
|
return;
|
||||||
@@ -89,23 +89,23 @@ public class ColorReplaceCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ClassMapper(value = Pair.class, local = true)
|
@ClassMapper(value = Pair.class, local = true)
|
||||||
public TypeMapper<Pair<Integer, Color>> typeMapper() {
|
public TypeMapper<Pair<Integer, ColorMode>> typeMapper() {
|
||||||
return new TypeMapper<Pair<Integer, Color>>() {
|
return new TypeMapper<Pair<Integer, ColorMode>>() {
|
||||||
@Override
|
@Override
|
||||||
public Pair<Integer, Color> map(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
public Pair<Integer, ColorMode> map(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
||||||
if (s.contains("%")) {
|
if (s.contains("%")) {
|
||||||
String[] split = s.split("%");
|
String[] split = s.split("%");
|
||||||
if (split.length != 2) {
|
if (split.length != 2) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Color color = Color.valueOf(split[1].toUpperCase());
|
ColorMode color = ColorMode.valueOf(split[1].toUpperCase());
|
||||||
try {
|
try {
|
||||||
return new Pair<>(Integer.parseInt(split[0]), color);
|
return new Pair<>(Integer.parseInt(split[0]), color);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new Pair<>(100, Color.valueOf(s.toUpperCase()));
|
return new Pair<>(100, ColorMode.valueOf(s.toUpperCase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -113,12 +113,12 @@ public class ColorReplaceCommand extends SWCommand {
|
|||||||
if (s.matches("[0-9].*")) {
|
if (s.matches("[0-9].*")) {
|
||||||
if (s.contains("%")) {
|
if (s.contains("%")) {
|
||||||
String sub = s.substring(0, s.indexOf("%") + 1);
|
String sub = s.substring(0, s.indexOf("%") + 1);
|
||||||
return Arrays.stream(Color.values()).map(Color::name).map(t -> sub + t.toLowerCase()).collect(Collectors.toSet());
|
return Arrays.stream(ColorMode.values()).map(ColorMode::name).map(t -> sub + t.toLowerCase()).collect(Collectors.toSet());
|
||||||
} else {
|
} else {
|
||||||
return Arrays.asList(s);
|
return Arrays.asList(s);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Arrays.stream(Color.values()).map(Color::name).map(String::toLowerCase).collect(Collectors.toSet());
|
return Arrays.stream(ColorMode.values()).map(ColorMode::name).map(String::toLowerCase).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ public interface Region {
|
|||||||
static Region getRegion(Location location) {
|
static Region getRegion(Location location) {
|
||||||
return RegionSystem.INSTANCE.get(location);
|
return RegionSystem.INSTANCE.get(location);
|
||||||
}
|
}
|
||||||
|
static Region getGlobalRegion() {
|
||||||
|
return RegionSystem.INSTANCE.getGlobalRegion();
|
||||||
|
}
|
||||||
|
|
||||||
UUID getID();
|
UUID getID();
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import de.steamwar.bausystem.region.Color;
|
|
||||||
import de.steamwar.bausystem.region.Point;
|
import de.steamwar.bausystem.region.Point;
|
||||||
|
import de.steamwar.bausystem.region.flags.ColorMode;
|
||||||
import de.steamwar.sql.SchematicData;
|
import de.steamwar.sql.SchematicData;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -102,8 +102,8 @@ public class PasteBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PasteBuilder color(Color color) {
|
public PasteBuilder color(ColorMode color) {
|
||||||
if (color == Color.PINK) return this;
|
if (color == ColorMode.PINK) return this;
|
||||||
|
|
||||||
Map<String, BaseBlock> blockCache = new HashMap<>();
|
Map<String, BaseBlock> blockCache = new HashMap<>();
|
||||||
return map((clipboard, blockVector3) -> {
|
return map((clipboard, blockVector3) -> {
|
||||||
@@ -122,7 +122,7 @@ public class PasteBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can only be used before {@link #color(Color)}.
|
* Can only be used before {@link #color(ColorMode)}.
|
||||||
*/
|
*/
|
||||||
public PasteBuilder onlyColors(boolean onlyColors) {
|
public PasteBuilder onlyColors(boolean onlyColors) {
|
||||||
if (!onlyColors) return this;
|
if (!onlyColors) return this;
|
||||||
|
|||||||
Reference in New Issue
Block a user