Skip to content

Commit

Permalink
Update for new text API in WE
Browse files Browse the repository at this point in the history
  • Loading branch information
me4502 committed Apr 25, 2019
1 parent 445d2ad commit f855664
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.util.formatting.component.Label;
import com.sk89q.worldedit.util.formatting.component.LabelFormat;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.WorldGuard;
Expand Down Expand Up @@ -59,8 +59,8 @@ public void stopFire(CommandContext args, Actor sender) throws CommandException

if (!wcfg.fireSpreadDisableToggle) {
worldGuard.getPlatform().broadcastNotification(
new Label("Fire spread has been globally disabled for '" + world.getName() + "' by "
+ sender.getDisplayName() + ".").create());
LabelFormat.wrap("Fire spread has been globally disabled for '" + world.getName() + "' by "
+ sender.getDisplayName() + "."));
} else {
sender.print("Fire spread was already globally disabled.");
}
Expand All @@ -84,8 +84,8 @@ public void allowFire(CommandContext args, Actor sender) throws CommandException
WorldConfiguration wcfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(world);

if (wcfg.fireSpreadDisableToggle) {
worldGuard.getPlatform().broadcastNotification(new Label("Fire spread has been globally for '" + world.getName() + "' re-enabled by "
+ sender.getDisplayName() + ".").create());
worldGuard.getPlatform().broadcastNotification(LabelFormat.wrap("Fire spread has been globally for '" + world.getName() + "' re-enabled by "
+ sender.getDisplayName() + "."));
} else {
sender.print("Fire spread was already globally enabled.");
}
Expand Down Expand Up @@ -115,8 +115,7 @@ public void stopLag(CommandContext args, Actor sender) throws CommandException {
}

if (!args.hasFlag('s')) {
worldGuard.getPlatform().broadcastNotification(new Label("ALL intensive server activity halted by "
+ sender.getDisplayName() + ".").create());
worldGuard.getPlatform().broadcastNotification(LabelFormat.wrap("ALL intensive server activity halted by " + sender.getDisplayName() + "."));
} else {
sender.print("(Silent) ALL intensive server activity halted by " + sender.getDisplayName() + ".");
}
Expand All @@ -138,7 +137,7 @@ public void stopLag(CommandContext args, Actor sender) throws CommandException {
}
} else {
if (!args.hasFlag('s')) {
worldGuard.getPlatform().broadcastNotification(new Label("ALL intensive server activity is now allowed.").create());
worldGuard.getPlatform().broadcastNotification(LabelFormat.wrap("ALL intensive server activity is now allowed."));

if (!(sender instanceof LocalPlayer)) {
sender.print("ALL intensive server activity is now allowed.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.component.Error;
import com.sk89q.worldedit.util.formatting.component.Label;
import com.sk89q.worldedit.util.formatting.component.Subtle;
import com.sk89q.worldedit.util.formatting.component.ErrorFormat;
import com.sk89q.worldedit.util.formatting.component.LabelFormat;
import com.sk89q.worldedit.util.formatting.component.SubtleFormat;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.world.World;
Expand Down Expand Up @@ -597,9 +597,9 @@ public void flag(CommandContext args, Actor sender) throws CommandException {

// Print region information
RegionPrintoutBuilder printout = new RegionPrintoutBuilder(existing, null);
printout.append(new Subtle("(Current flags: ").create());
printout.append(SubtleFormat.wrap("(Current flags: "));
printout.appendFlagsList(false);
printout.append(new Subtle(")").create());
printout.append(SubtleFormat.wrap(")"));
printout.send(sender);
}

Expand Down Expand Up @@ -676,22 +676,22 @@ public void setParent(CommandContext args, Actor sender) throws CommandException
// Tell the user what's wrong
RegionPrintoutBuilder printout = new RegionPrintoutBuilder(parent, null);
assert parent != null;
printout.append(new Error("Uh oh! Setting '" + parent.getId() + "' to be the parent " +
"of '" + child.getId() + "' would cause circular inheritance.\n").create());
printout.append(new Subtle("(Current inheritance on '" + parent.getId() + "':\n").create());
printout.append(ErrorFormat.wrap("Uh oh! Setting '", parent.getId(), "' to be the parent of '", child.getId(),
"' would cause circular inheritance.")).newline();
printout.append(SubtleFormat.wrap("(Current inheritance on '", parent.getId(), "':")).newline();
printout.appendParentTree(true);
printout.append(new Subtle(")").create());
printout.append(SubtleFormat.wrap(")"));
printout.send(sender);
return;
}

// Tell the user the current inheritance
RegionPrintoutBuilder printout = new RegionPrintoutBuilder(child, null);
printout.append(new Label("Inheritance set for region '" + child.getId() + "'.\n").create());
printout.append(LabelFormat.wrap("Inheritance set for region '", child.getId(), "'.")).newline();
if (parent != null) {
printout.append(new Subtle("(Current inheritance:\n").create());
printout.append(SubtleFormat.wrap("(Current inheritance:")).newline();
printout.appendParentTree(true);
printout.append(new Subtle(")").create());
printout.append(SubtleFormat.wrap(")"));
}
printout.send(sender);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
import com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector;
import com.sk89q.worldedit.util.formatting.component.Subtle;
import com.sk89q.worldedit.util.formatting.component.SubtleFormat;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.world.World;
Expand Down Expand Up @@ -327,9 +327,9 @@ protected static void warnAboutDimensions(Actor sender, ProtectedRegion region)
*/
protected static void informNewUser(Actor sender, RegionManager manager, ProtectedRegion region) {
if (manager.getRegions().size() <= 2) {
sender.print(new Subtle("(This region is NOW PROTECTED from modification from others. Don't want that? Use ")
sender.print(SubtleFormat.wrap("(This region is NOW PROTECTED from modification from others. Don't want that? Use ")
.append(TextComponent.of("/rg flag " + region.getId() + " passthrough allow", TextColor.AQUA))
.append(TextComponent.of(")", TextColor.GRAY)).create());
.append(TextComponent.of(")", TextColor.GRAY)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import com.sk89q.squirrelid.cache.ProfileCache;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.formatting.component.Error;
import com.sk89q.worldedit.util.formatting.component.Label;
import com.sk89q.worldedit.util.formatting.component.Subtle;
import com.sk89q.worldedit.util.formatting.component.ErrorFormat;
import com.sk89q.worldedit.util.formatting.component.LabelFormat;
import com.sk89q.worldedit.util.formatting.component.SubtleFormat;
import com.sk89q.worldedit.util.formatting.component.TextComponentProducer;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
Expand Down Expand Up @@ -214,9 +214,9 @@ public void appendDomain() {

private void addDomainString(DefaultDomain domain) {
if (domain.size() != 0) {
builder.append(new Label(domain.toUserFriendlyString(cache)).create());
builder.append(LabelFormat.wrap(domain.toUserFriendlyString(cache)));
} else {
builder.append(new Error("(none)").create());
builder.append(ErrorFormat.wrap("(none)"));
}
}

Expand All @@ -234,9 +234,12 @@ public void appendBounds() {
}

private void appendRegionInformation() {
builder.append(new Subtle("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550").create());
builder.append(new Subtle(" Region Info ").create());
builder.append(new Subtle("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550").create());
TextComponent format = SubtleFormat.wrap(
"\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550",
" Region Info ",
"\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550"
);
builder.append(format);
newLine();
appendBasics();
appendFlags();
Expand All @@ -245,7 +248,7 @@ private void appendRegionInformation() {
appendBounds();

if (cache != null) {
builder.append(new Subtle("Any names suffixed by * are 'last seen names' and may not be up to date.").create());
builder.append(SubtleFormat.wrap("Any names suffixed by * are 'last seen names' and may not be up to date."));
newLine();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package com.sk89q.worldguard.util.logging;

import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.formatting.component.Subtle;
import com.sk89q.worldedit.util.formatting.component.SubtleFormat;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;

Expand Down Expand Up @@ -72,6 +72,6 @@ public void flush() {
*/
@Override
public void publish(LogRecord record) {
player.print(new Subtle(record.getLevel().getName() + ": ").append(TextComponent.of(formatter.format(record), TextColor.WHITE)).create());
player.print(SubtleFormat.wrap(record.getLevel().getName() + ": ").append(TextComponent.of(formatter.format(record), TextColor.WHITE)));
}
}

0 comments on commit f855664

Please sign in to comment.