mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-03-12 22:59:24 +01:00
Upgrade command Handler, start implementing mvinfo
This commit is contained in:
parent
9acc46f9d1
commit
c5108c3463
1
.gitmodules
vendored
1
.gitmodules
vendored
@ -4,3 +4,4 @@
|
||||
[submodule "lib/commandhandler"]
|
||||
path = lib/commandhandler
|
||||
url = git://github.com/PneumatiCraft/CommandHandler.git
|
||||
branch = notrie
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit f91fbc6dd1030d2576cae84b46d41bd0ff9f5694
|
||||
Subproject commit d5752319a3c66a2eafa63672da1bf78bdf4d6a20
|
@ -53,7 +53,7 @@ public class MVPermissions implements PermissionsInterface {
|
||||
}
|
||||
|
||||
public boolean canTravelFromLocation(Player teleporter, Location location) {
|
||||
if(!this.plugin.isMVWorld(location.getWorld().getName())){
|
||||
if (!this.plugin.isMVWorld(location.getWorld().getName())) {
|
||||
return false;
|
||||
}
|
||||
return canTravelFromWorld(teleporter, this.plugin.getMVWorld(location.getWorld().getName()));
|
||||
@ -69,13 +69,13 @@ public class MVPermissions implements PermissionsInterface {
|
||||
public Boolean canEnterWorld(Player p, MVWorld w) {
|
||||
return this.hasPermission(p, "multiverse.access." + w.getName(), false);
|
||||
}
|
||||
|
||||
|
||||
public Boolean canEnterLocation(Player p, Location l) {
|
||||
if(l == null) {
|
||||
if (l == null) {
|
||||
return false;
|
||||
}
|
||||
String worldName = l.getWorld().getName();
|
||||
if(!this.plugin.isMVWorld(worldName)) {
|
||||
if (!this.plugin.isMVWorld(worldName)) {
|
||||
return false;
|
||||
}
|
||||
return this.hasPermission(p, "multiverse.access." + worldName, false);
|
||||
@ -94,16 +94,21 @@ public class MVPermissions implements PermissionsInterface {
|
||||
Player player = (Player) sender;
|
||||
|
||||
boolean opFallback = this.plugin.getConfig().getBoolean("opfallback", true);
|
||||
this.plugin.log(Level.WARNING, "Checking to see if person has " + node);
|
||||
if (this.permissions != null && this.permissions.has(player, node)) {
|
||||
// If Permissions is enabled we check against them.
|
||||
this.plugin.log(Level.WARNING, "Allowed by P3/P2 ");
|
||||
return true;
|
||||
} else if (sender.hasPermission(node)) {
|
||||
// If Now check the bukkit permissions
|
||||
this.plugin.log(Level.WARNING, "Allowed by BukkitPerms");
|
||||
return true;
|
||||
} else if (player.isOp() && opFallback) {
|
||||
// If Player is Op we always let them use it if they have the fallback enabled!
|
||||
this.plugin.log(Level.WARNING, "Allowed by OP");
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the Player doesn't have Permissions and isn't an Op then
|
||||
// we return true if OP is not required, otherwise we return false
|
||||
// This allows us to act as a default permission guidance
|
||||
@ -120,4 +125,23 @@ public class MVPermissions implements PermissionsInterface {
|
||||
return "Bukkit Permissions/OPs.txt";
|
||||
}
|
||||
|
||||
public boolean hasAnyPermission(CommandSender sender, List<String> nodes, boolean isOpRequired) {
|
||||
for (String node : nodes) {
|
||||
if (this.hasPermission(sender, node, isOpRequired)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAllPermission(CommandSender sender, List<String> nodes, boolean isOpRequired) {
|
||||
for (String node : nodes) {
|
||||
if (!this.hasPermission(sender, node, isOpRequired)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ public class MVTeleport {
|
||||
public boolean safelyTeleport(Entity e, Location l) {
|
||||
if (this.bs.playerCanSpawnHereSafely(l)) {
|
||||
e.teleport(l);
|
||||
//this.plugin.log(Level.WARNING, "The first location you gave me was safe.");
|
||||
this.plugin.log(Level.WARNING, "The first location you gave me was safe.");
|
||||
return true;
|
||||
}
|
||||
if(e instanceof Minecart) {
|
||||
@ -198,7 +198,7 @@ public class MVTeleport {
|
||||
safeLocation.setY(safeLocation.getBlockY() + .5);
|
||||
}
|
||||
e.teleport(safeLocation);
|
||||
//this.plugin.log(Level.WARNING, "Had to look for a bit, but I found a safe place for ya!");
|
||||
this.plugin.log(Level.WARNING, "Had to look for a bit, but I found a safe place for ya!");
|
||||
return true;
|
||||
}
|
||||
if (e instanceof Player) {
|
||||
|
@ -142,10 +142,6 @@ public class MVWorld {
|
||||
addToUpperLists(this.permission);
|
||||
} catch (IllegalArgumentException e) {
|
||||
}
|
||||
// The following 3 lines will add some sample data to new worlds created.
|
||||
// if (config.getIntList("worlds." + name + ".blockBlacklist", new ArrayList<Integer>()).size() == 0) {
|
||||
// addSampleData();
|
||||
// }
|
||||
}
|
||||
|
||||
private void addToUpperLists(Permission permission) {
|
||||
|
@ -75,6 +75,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
|
||||
// Useless stuff to keep us going.
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private static DebugLog debugLog;
|
||||
public static boolean MobsDisabledInDefaultWorld = false;
|
||||
|
||||
// Debug Mode
|
||||
private boolean debug;
|
||||
@ -229,6 +230,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
|
||||
*/
|
||||
private void registerCommands() {
|
||||
// Intro Commands
|
||||
this.commandHandler.registerCommand(new HelpCommand(this));
|
||||
this.commandHandler.registerCommand(new VersionCommand(this));
|
||||
this.commandHandler.registerCommand(new ListCommand(this));
|
||||
this.commandHandler.registerCommand(new InfoCommand(this));
|
||||
@ -246,17 +248,17 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
|
||||
this.commandHandler.registerCommand(new DeleteCommand(this));
|
||||
this.commandHandler.registerCommand(new ConfirmCommand(this));
|
||||
// Modification commands
|
||||
this.commandHandler.registerCommand(new ModifyCommand(this));
|
||||
this.commandHandler.registerCommand(new PurgeCommand(this));
|
||||
this.commandHandler.registerCommand(new ModifyAddCommand(this));
|
||||
this.commandHandler.registerCommand(new ModifySetCommand(this));
|
||||
this.commandHandler.registerCommand(new ModifyRemoveCommand(this));
|
||||
this.commandHandler.registerCommand(new ModifyClearCommand(this));
|
||||
// This modify MUST go last.
|
||||
this.commandHandler.registerCommand(new ModifyCommand(this));
|
||||
|
||||
// Misc Commands
|
||||
this.commandHandler.registerCommand(new EnvironmentCommand(this));
|
||||
this.commandHandler.registerCommand(new SleepCommand(this));
|
||||
this.commandHandler.registerCommand(new HelpCommand(this));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -750,6 +752,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
|
||||
this.log(Level.SEVERE, "Monster spawning has been DISABLED.");
|
||||
this.log(Level.SEVERE, "In order to let Multiverse fully control your worlds:");
|
||||
this.log(Level.SEVERE, "Please set 'spawn-monsters=true' in your server.properties file!");
|
||||
MultiverseCore.MobsDisabledInDefaultWorld = true;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
@ -41,7 +41,9 @@ public class CoordCommand extends MultiverseCommand {
|
||||
}
|
||||
|
||||
MVWorld mvworld = this.plugin.getMVWorld(world.getName());
|
||||
p.sendMessage(ChatColor.AQUA + "--- World Information ---");
|
||||
// TODO: Convert to fancy stuff
|
||||
|
||||
p.sendMessage(ChatColor.AQUA + "--- Location Information ---");
|
||||
p.sendMessage(ChatColor.AQUA + "World: " + ChatColor.WHITE + world.getName());
|
||||
p.sendMessage(ChatColor.AQUA + "Alias: " + mvworld.getColoredWorldString());
|
||||
p.sendMessage(ChatColor.AQUA + "World Scale: " + ChatColor.WHITE + mvworld.getScaling());
|
||||
|
@ -10,18 +10,45 @@ import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.FancyColorScheme;
|
||||
import com.onarandombox.utils.FancyHeader;
|
||||
import com.onarandombox.utils.FancyMessage;
|
||||
import com.onarandombox.utils.FancyText;
|
||||
|
||||
public class InfoCommand extends MultiverseCommand {
|
||||
|
||||
private static final int CMDS_PER_PAGE = 9;
|
||||
private List<String> monsterNames = new ArrayList<String>();
|
||||
private List<String> animalNames = new ArrayList<String>();
|
||||
|
||||
public InfoCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("World Information");
|
||||
this.setCommandUsage("/mv info" + ChatColor.GOLD + " [WORLD]");
|
||||
this.setCommandUsage("/mv info" + ChatColor.GOLD + "[PAGE] [WORLD]");
|
||||
this.setArgRange(0, 1);
|
||||
this.addKey("mvinfo");
|
||||
this.addKey("mvi");
|
||||
this.addKey("mv info");
|
||||
this.setPermission("multiverse.core.info", "Returns detailed information on the world.", PermissionDefault.OP);
|
||||
this.generateNames();
|
||||
}
|
||||
|
||||
private void generateNames() {
|
||||
monsterNames.add("Wolf");
|
||||
monsterNames.add("Creeper");
|
||||
monsterNames.add("Skeleton");
|
||||
monsterNames.add("Spider");
|
||||
monsterNames.add("Slime");
|
||||
monsterNames.add("Spider Jockey");
|
||||
monsterNames.add("Ghast");
|
||||
monsterNames.add("Zombie");
|
||||
monsterNames.add("Zombie Pigman");
|
||||
|
||||
animalNames.add("Pig");
|
||||
animalNames.add("Sheep");
|
||||
animalNames.add("Cow");
|
||||
animalNames.add("Chicken");
|
||||
animalNames.add("Squid");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -37,16 +64,14 @@ public class InfoCommand extends MultiverseCommand {
|
||||
worldName = args.get(0);
|
||||
}
|
||||
if (this.plugin.isMVWorld(worldName)) {
|
||||
for (String s : buildEntireCommand(this.plugin.getMVWorld(worldName))) {
|
||||
sender.sendMessage(s);
|
||||
}
|
||||
showPage(1, sender, this.buildEntireCommand(this.plugin.getMVWorld(worldName)));
|
||||
} else if (this.plugin.getServer().getWorld(worldName) != null) {
|
||||
sender.sendMessage("That world exists, but multiverse does not know about it!");
|
||||
sender.sendMessage("You can import it with" + ChatColor.AQUA + "/mv import " + ChatColor.GREEN + worldName + ChatColor.LIGHT_PURPLE + "{ENV}");
|
||||
sender.sendMessage("For available environments type " + ChatColor.GREEN + "/mv env");
|
||||
}
|
||||
// Leaving this in so we can have a laugh about it.
|
||||
|
||||
|
||||
// else {
|
||||
// sender.sendMessage("That world does not exist!");
|
||||
// sender.sendMessage("You can create it with" + ChatColor.AQUA + "/mv create " + ChatColor.GREEN + worldName + ChatColor.LIGHT_PURPLE + "{ENV}");
|
||||
@ -54,68 +79,80 @@ public class InfoCommand extends MultiverseCommand {
|
||||
// }
|
||||
}
|
||||
|
||||
private List<String> buildEntireCommand(MVWorld world) {
|
||||
List<String> page = new ArrayList<String>();
|
||||
private List<FancyText> buildEntireCommand(MVWorld world) {
|
||||
List<FancyText> message = new ArrayList<FancyText>();
|
||||
// World Name: 1
|
||||
page.add("World: " + world.getName());
|
||||
FancyColorScheme colors = new FancyColorScheme(ChatColor.AQUA, ChatColor.AQUA, ChatColor.GOLD, ChatColor.WHITE);
|
||||
message.add(new FancyHeader("General Info", colors));
|
||||
message.add(new FancyMessage("World Name: ", world.getName(), colors));
|
||||
message.add(new FancyMessage("World Alias: ", world.getColoredWorldString(), colors));
|
||||
message.add(new FancyMessage("World Scale: ", world.getScaling().toString(), colors));
|
||||
message.add(new FancyHeader("PVP Settings", colors));
|
||||
message.add(new FancyMessage("Multiverse Setting: ", world.getPvp().toString(), colors));
|
||||
message.add(new FancyMessage("Bukkit Setting: ", world.getCBWorld().getPVP() + "", colors));
|
||||
message.add(new FancyMessage("Fake PVP Enabled: ", world.getFakePVP() + "", colors));
|
||||
// Next is a blank
|
||||
message.add(new FancyMessage(" ", "", colors));
|
||||
message.add(new FancyMessage(ChatColor.DARK_PURPLE + "X more pages", "", colors));
|
||||
|
||||
// World Scale: 1
|
||||
page.add("World Scale: " + world.getScaling());
|
||||
message.add(new FancyHeader("Monster Settings", colors));
|
||||
message.add(new FancyMessage("Multiverse Setting: ", world.allowMonsterSpawning().toString(), colors));
|
||||
message.add(new FancyMessage("Bukkit Setting: ", world.getCBWorld().getAllowMonsters() + "", colors));
|
||||
boolean warnings = false;
|
||||
if (MultiverseCore.MobsDisabledInDefaultWorld) {
|
||||
message.add(new FancyMessage(ChatColor.RED + "WARNING: ", "Monsters WILL NOT SPAWN IN THIS WORLD.", colors));
|
||||
message.add(new FancyMessage(ChatColor.RED + "WARNING: ", "Check your server log for more details.", colors));
|
||||
}
|
||||
if (world.getMonsterList().size() > 0) {
|
||||
if (world.allowMonsterSpawning()) {
|
||||
message.add(new FancyMessage("Monsters That" + ChatColor.RED + " CAN NOT " + ChatColor.GREEN + "spawn: ", toCommaSeperated(world.getMonsterList()), colors));
|
||||
} else {
|
||||
message.add(new FancyMessage("Monsters That" + ChatColor.GREEN + " CAN SPAWN: ", toCommaSeperated(world.getMonsterList()), colors));
|
||||
}
|
||||
} else {
|
||||
message.add(new FancyMessage("Monsters That CAN spawn: ", world.allowMonsterSpawning() ? "ALL" : "NONE", colors));
|
||||
}
|
||||
|
||||
// PVP: 1
|
||||
page.add("PVP (MV): " + world.getPvp());
|
||||
page.add("PVP: " + world.getCBWorld().getPVP());
|
||||
page.add("Fake PVP: " + world.getFakePVP());
|
||||
page.add("Animals (MV): " + world.allowAnimalSpawning());
|
||||
page.add("Animals: " + world.getCBWorld().getAllowAnimals());
|
||||
page.add("Monsters (MV): " + world.allowMonsterSpawning());
|
||||
page.add("Monsters: " + world.getCBWorld().getAllowMonsters());
|
||||
page.add("Respawn to: " + world.getRespawnToWorld());
|
||||
return message;
|
||||
}
|
||||
|
||||
// This feature is not mission critical and I am spending too much time on it...
|
||||
// Stopping work on it for now --FF 20110623
|
||||
// // Animal Spawning: X
|
||||
// sb.append("Animals can spawn: ");
|
||||
// sb.append(world.animals?"Yes":"No");
|
||||
// sb.append("\n");
|
||||
// if (!world.animalList.isEmpty()) {
|
||||
// sb.append("Except: \n");
|
||||
// for (String s : world.animalList) {
|
||||
// sb.append(" - " + s + "\n");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Monster Spawning
|
||||
// sb.append("Monsters can spawn: ");
|
||||
// sb.append(world.monsters?"Yes":"No");
|
||||
// sb.append("\n");
|
||||
// if (!world.monsterList.isEmpty()) {
|
||||
// sb.append("Except: \n");
|
||||
// for (String s : world.monsterList) {
|
||||
// sb.append(" - " + s + "\n");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Whitelist
|
||||
// if (!world.playerWhitelist.isEmpty()) {
|
||||
// sb.append("Whitelisted Players: \n");
|
||||
// for (String s : world.playerWhitelist) {
|
||||
// if (!s.matches("[gG]:.+")) {
|
||||
// sb.append(" - " + s + "\n");
|
||||
// }
|
||||
// }
|
||||
// sb.append("Whitelisted Groups: \n");
|
||||
// for (String s : world.playerWhitelist) {
|
||||
// if (s.matches("[gG]:")) {
|
||||
// sb.append(" - " + s.split("[g]:")[1] + "\n");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return page;
|
||||
private String toCommaSeperated(List<String> list) {
|
||||
String result = list.get(0);
|
||||
|
||||
for (int i = 1; i < list.size() - 1; i++) {
|
||||
result += ", " + list.get(i);
|
||||
}
|
||||
result += " and " + list.get(list.size() - 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
protected ChatColor getChatColor(boolean positive) {
|
||||
return positive ? ChatColor.GREEN : ChatColor.RED;
|
||||
}
|
||||
|
||||
private void showPage(int page, CommandSender sender, List<FancyText> messages) {
|
||||
int start = (sender instanceof Player) ? (page - 1) * CMDS_PER_PAGE : 0;
|
||||
int end = (sender instanceof Player) ? start + CMDS_PER_PAGE : messages.size();
|
||||
boolean altColor = false;
|
||||
for (int i = start; i < end; i++) {
|
||||
// For consistancy, print some extra lines if it's a player:
|
||||
if (i < messages.size()) {
|
||||
|
||||
if (messages.get(i) instanceof FancyMessage) {
|
||||
FancyMessage text = (FancyMessage) messages.get(i);
|
||||
text.setAltColor(altColor);
|
||||
altColor = !altColor;
|
||||
sender.sendMessage(text.getFancyText());
|
||||
} else {
|
||||
FancyText text = messages.get(i);
|
||||
sender.sendMessage(text.getFancyText());
|
||||
altColor = false;
|
||||
}
|
||||
|
||||
} else if (sender instanceof Player) {
|
||||
sender.sendMessage(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -25,10 +26,6 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
super(plugin);
|
||||
Permission self = new Permission("multiverse.core.tp.self", "Allows you to teleport yourself to other worlds.", PermissionDefault.OP);
|
||||
Permission other = new Permission("multiverse.core.tp.other", "Allows you to teleport others to other worlds.", PermissionDefault.OP);
|
||||
Map<String, Boolean> children = new HashMap<String, Boolean>();
|
||||
children.put(self.getName(), true);
|
||||
children.put(other.getName(), true);
|
||||
Permission tp = new Permission("multiverse.core.tp", "Allows teleportation to other worlds.", PermissionDefault.OP, children);
|
||||
|
||||
this.setName("Teleport");
|
||||
this.setCommandUsage("/mv tp " + ChatColor.GOLD + "[PLAYER]" + ChatColor.GREEN + " {WORLD}");
|
||||
@ -37,13 +34,13 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
this.addKey("mv tp");
|
||||
this.playerTeleporter = new MVTeleport(this.plugin);
|
||||
// setPermission in some for is REQUIRED
|
||||
this.addAdditonalPermission(self);
|
||||
this.setPermission(self);
|
||||
this.addAdditonalPermission(other);
|
||||
this.setPermission(tp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
this.plugin.log(Level.WARNING, "running MVTP");
|
||||
// Check if the command was sent from a Player.
|
||||
Player teleporter = null;
|
||||
Player teleportee = null;
|
||||
@ -119,5 +116,6 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
String message = ChatColor.GREEN + "Multiverse" + ChatColor.WHITE + " did not teleport " + ChatColor.AQUA + player + ChatColor.WHITE + " to " + ChatColor.DARK_AQUA + d.getName() + ChatColor.WHITE + " because it was unsafe.";
|
||||
this.plugin.getCommandHandler().queueCommand(sender, "mvteleport", "teleportPlayer", items, paramTypes, message, "Would you like to try anyway?", "", "", 15);
|
||||
}
|
||||
this.plugin.log(Level.WARNING, "Done with MVTP");
|
||||
}
|
||||
}
|
||||
|
37
src/main/java/com/onarandombox/utils/FancyColorScheme.java
Normal file
37
src/main/java/com/onarandombox/utils/FancyColorScheme.java
Normal file
@ -0,0 +1,37 @@
|
||||
package com.onarandombox.utils;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class FancyColorScheme {
|
||||
private ChatColor headerColor;
|
||||
private ChatColor mainColor;
|
||||
private ChatColor altColor;
|
||||
private ChatColor defContentColor;
|
||||
|
||||
public FancyColorScheme(ChatColor header, ChatColor main, ChatColor alt, ChatColor defaultColor) {
|
||||
this.headerColor = header;
|
||||
this.mainColor = main;
|
||||
this.altColor = alt;
|
||||
this.defContentColor = defaultColor;
|
||||
}
|
||||
|
||||
public ChatColor getHeader() {
|
||||
return this.headerColor;
|
||||
}
|
||||
|
||||
public ChatColor getMain() {
|
||||
return this.mainColor;
|
||||
}
|
||||
|
||||
public ChatColor getAlt() {
|
||||
return this.altColor;
|
||||
}
|
||||
|
||||
public ChatColor getDefault() {
|
||||
return this.defContentColor;
|
||||
}
|
||||
|
||||
public ChatColor getMain(boolean main) {
|
||||
return main ? this.getMain() : this.getAlt();
|
||||
}
|
||||
}
|
18
src/main/java/com/onarandombox/utils/FancyHeader.java
Normal file
18
src/main/java/com/onarandombox/utils/FancyHeader.java
Normal file
@ -0,0 +1,18 @@
|
||||
package com.onarandombox.utils;
|
||||
|
||||
public class FancyHeader implements FancyText {
|
||||
|
||||
private FancyColorScheme colors;
|
||||
private String text;
|
||||
|
||||
public FancyHeader(String text, FancyColorScheme scheme) {
|
||||
this.colors = scheme;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFancyText() {
|
||||
return colors.getHeader() + "--- " + text + " ---";
|
||||
}
|
||||
|
||||
}
|
34
src/main/java/com/onarandombox/utils/FancyMessage.java
Normal file
34
src/main/java/com/onarandombox/utils/FancyMessage.java
Normal file
@ -0,0 +1,34 @@
|
||||
package com.onarandombox.utils;
|
||||
|
||||
public class FancyMessage implements FancyText {
|
||||
private String title;
|
||||
private String message;
|
||||
private boolean main = true;
|
||||
private FancyColorScheme colors;
|
||||
/**
|
||||
* Allows easy creation of an alternating colored list
|
||||
* @param title
|
||||
* @param message
|
||||
*/
|
||||
public FancyMessage(String title, String message, FancyColorScheme scheme) {
|
||||
this.title = title;
|
||||
this.message = message;
|
||||
this.colors = scheme;
|
||||
}
|
||||
public void setColorMain() {
|
||||
this.main = true;
|
||||
}
|
||||
public void setColorAlt() {
|
||||
this.main = false;
|
||||
}
|
||||
@Override
|
||||
public String getFancyText() {
|
||||
return this.colors.getMain(this.main) + this.title + this.colors.getDefault() + message;
|
||||
}
|
||||
public void setAltColor(boolean altColor) {
|
||||
this.main = !altColor;
|
||||
}
|
||||
public void setMainColor(boolean mainColor) {
|
||||
this.main = mainColor;
|
||||
}
|
||||
}
|
5
src/main/java/com/onarandombox/utils/FancyText.java
Normal file
5
src/main/java/com/onarandombox/utils/FancyText.java
Normal file
@ -0,0 +1,5 @@
|
||||
package com.onarandombox.utils;
|
||||
|
||||
public interface FancyText {
|
||||
public String getFancyText();
|
||||
}
|
Loading…
Reference in New Issue
Block a user