-
-
Notifications
You must be signed in to change notification settings - Fork 882
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge common print functions into abstract class
- Loading branch information
1 parent
a872c37
commit e588d51
Showing
12 changed files
with
120 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractActor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.sk89q.worldedit.extension.platform; | ||
|
||
import com.sk89q.worldedit.util.formatting.WorldEditText; | ||
import com.sk89q.worldedit.util.formatting.text.Component; | ||
import com.sk89q.worldedit.util.formatting.text.TextComponent; | ||
import com.sk89q.worldedit.util.formatting.text.format.NamedTextColor; | ||
|
||
import java.util.function.Consumer; | ||
|
||
/** | ||
* Base class for implementing an actor. Provides reasonable defaults. | ||
*/ | ||
public abstract class AbstractActor implements Actor { | ||
|
||
private final Consumer<Component> sendMessage; | ||
|
||
protected AbstractActor(Consumer<Component> sendMessage) { | ||
this.sendMessage = sendMessage; | ||
} | ||
|
||
@Override | ||
@Deprecated | ||
public void printRaw(String msg) { | ||
for (String part : msg.split("\n")) { | ||
print(TextComponent.of(part)); | ||
} | ||
} | ||
|
||
@Override | ||
@Deprecated | ||
public void print(String msg) { | ||
for (String part : msg.split("\n")) { | ||
print(TextComponent.of(part, NamedTextColor.LIGHT_PURPLE)); | ||
} | ||
} | ||
|
||
@Override | ||
@Deprecated | ||
public void printDebug(String msg) { | ||
for (String part : msg.split("\n")) { | ||
print(TextComponent.of(part, NamedTextColor.GRAY)); | ||
} | ||
} | ||
|
||
@Override | ||
@Deprecated | ||
public void printError(String msg) { | ||
for (String part : msg.split("\n")) { | ||
print(TextComponent.of(part, NamedTextColor.RED)); | ||
} | ||
} | ||
|
||
@Override | ||
public void print(Component component) { | ||
sendMessage.accept(WorldEditText.format(component, getLocale())); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.