mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-09-27 14:22:44 +02:00
Tweak some region info output, fix teleport location.
This commit is contained in:
parent
e4481f9337
commit
df2ae6a666
@ -20,7 +20,6 @@
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.sk89q.bukkit.util.CommandsManagerRegistration;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissionsException;
|
||||
@ -93,9 +92,8 @@
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
/**
|
||||
* The main class for WorldGuard as a Bukkit plugin.
|
||||
@ -488,44 +486,25 @@ public void createDefaultConfiguration(File actual, String defaultName) {
|
||||
return;
|
||||
}
|
||||
|
||||
InputStream input = null;
|
||||
try {
|
||||
JarFile file = new JarFile(getFile());
|
||||
ZipEntry copy = file.getEntry("defaults/" + defaultName);
|
||||
if (copy == null) throw new FileNotFoundException();
|
||||
input = file.getInputStream(copy);
|
||||
try (InputStream stream = getResource("defaults/" + defaultName)){
|
||||
if (stream == null) throw new FileNotFoundException();
|
||||
copyDefaultConfig(stream, actual, defaultName);
|
||||
} catch (IOException e) {
|
||||
WorldGuard.logger.severe("Unable to read default configuration: " + defaultName);
|
||||
getLogger().severe("Unable to read default configuration: " + defaultName);
|
||||
}
|
||||
|
||||
if (input != null) {
|
||||
FileOutputStream output = null;
|
||||
}
|
||||
|
||||
try {
|
||||
output = new FileOutputStream(actual);
|
||||
byte[] buf = new byte[8192];
|
||||
int length = 0;
|
||||
while ((length = input.read(buf)) > 0) {
|
||||
output.write(buf, 0, length);
|
||||
}
|
||||
|
||||
WorldGuard.logger.info("Default configuration file written: "
|
||||
+ actual.getAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException ignore) {
|
||||
}
|
||||
|
||||
try {
|
||||
if (output != null) {
|
||||
output.close();
|
||||
}
|
||||
} catch (IOException ignore) {
|
||||
}
|
||||
private void copyDefaultConfig(InputStream input, File actual, String name) {
|
||||
try (FileOutputStream output = new FileOutputStream(actual)) {
|
||||
byte[] buf = new byte[8192];
|
||||
int length;
|
||||
while ((length = input.read(buf)) > 0) {
|
||||
output.write(buf, 0, length);
|
||||
}
|
||||
getLogger().info("Default configuration file written: " + name);
|
||||
} catch (IOException e) {
|
||||
getLogger().log(Level.WARNING, "Failed to write default config file", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ class FlagHelperBox extends PaginationBox {
|
||||
.collect(Collectors.toList());
|
||||
private static final int SIZE = FLAGS.size() == Flags.INBUILT_FLAGS.size() ? FLAGS.size() : FLAGS.size() + 1;
|
||||
private static final int PAD_PX_SIZE = 180;
|
||||
private static final Set<Flag<?>> DANGER_ZONE = ImmutableSet.of(Flags.BUILD, Flags.PASSTHROUGH, Flags.BLOCK_PLACE, Flags.BLOCK_BREAK);
|
||||
static final Set<Flag<?>> DANGER_ZONE = ImmutableSet.of(Flags.BUILD, Flags.PASSTHROUGH, Flags.BLOCK_PLACE, Flags.BLOCK_BREAK);
|
||||
|
||||
private final World world;
|
||||
private final ProtectedRegion region;
|
||||
|
@ -143,7 +143,17 @@ public void appendFlagsList(boolean useColors) {
|
||||
flagString = flag.getName() + " -g " + group + ": ";
|
||||
}
|
||||
|
||||
TextComponent flagText = TextComponent.of(flagString, useColors ? TextColor.GOLD : TextColor.WHITE)
|
||||
TextColor flagColor = TextColor.WHITE;
|
||||
if (useColors) {
|
||||
// passthrough is ok on global
|
||||
if (FlagHelperBox.DANGER_ZONE.contains(flag)
|
||||
&& !(region.getId().equals(ProtectedRegion.GLOBAL_REGION) && flag == Flags.PASSTHROUGH)) {
|
||||
flagColor = TextColor.DARK_RED;
|
||||
} else {
|
||||
flagColor = TextColor.GOLD;
|
||||
}
|
||||
}
|
||||
TextComponent flagText = TextComponent.of(flagString, flagColor)
|
||||
.append(TextComponent.of(String.valueOf(val), useColors? TextColor.YELLOW : TextColor.WHITE));
|
||||
if (perms != null && perms.maySetFlag(region, flag)) {
|
||||
flagText = flagText.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to set flag")))
|
||||
@ -305,7 +315,7 @@ public void appendBounds() {
|
||||
builder.append(TextComponent.space().append(TextComponent.of("[Teleport]", TextColor.GRAY)
|
||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT,
|
||||
TextComponent.of("Click to teleport").append(TextComponent.newline()).append(
|
||||
TextComponent.of(teleFlag.getBlockY() + ", "
|
||||
TextComponent.of(teleFlag.getBlockX() + ", "
|
||||
+ teleFlag.getBlockY() + ", "
|
||||
+ teleFlag.getBlockZ()))))
|
||||
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND,
|
||||
|
@ -311,7 +311,7 @@ public String toPlayersString(@Nullable ProfileCache cache) {
|
||||
public String toGroupsString() {
|
||||
StringBuilder str = new StringBuilder();
|
||||
for (Iterator<String> it = groupDomain.getGroups().iterator(); it.hasNext(); ) {
|
||||
str.append("*");
|
||||
str.append("g:");
|
||||
str.append(it.next());
|
||||
if (it.hasNext()) {
|
||||
str.append(", ");
|
||||
@ -373,7 +373,8 @@ public Component toUserFriendlyComponent(@Nullable ProfileCache cache) {
|
||||
private Component toGroupsComponent() {
|
||||
final TextComponent.Builder builder = TextComponent.builder("");
|
||||
for (Iterator<String> it = groupDomain.getGroups().iterator(); it.hasNext(); ) {
|
||||
builder.append(TextComponent.of(it.next(), TextColor.GOLD));
|
||||
builder.append(TextComponent.of("g:", TextColor.GRAY))
|
||||
.append(TextComponent.of(it.next(), TextColor.GOLD));
|
||||
if (it.hasNext()) {
|
||||
builder.append(TextComponent.of(", "));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user