use of biz.princeps.landlord.manager.LangManager in project LandLord by SpatiumPrinceps.
the class LandMap method displayMap.
/**
* core method for actually displaying the Map
*
* @param p the player, who asked for a map
* @return a reference to the scoreboard
*/
private SimpleScoreboard displayMap(Player p) {
Scoreboard board = ScoreboardLib.createScoreboard(p).setHandler(new ScoreboardHandler() {
LangManager messages = plugin.getLangManager();
@Override
public String getTitle(Player p) {
return messages.getRawString("Commands.LandMap.header");
}
@Override
public List<Entry> getEntries(Player player) {
if (!currDir.equals(getPlayerDirection(mapViewer)) || !currChunk.equals(mapViewer.getLocation().getChunk())) {
currDir = getPlayerDirection(mapViewer);
}
EntryBuilder eb = new EntryBuilder();
String[] mapData = buildMap(p);
for (String aMapData : mapData) {
// Not sure what this part does. It works without lol
/*if (mapData[i].length() < 21) {
for (int f = 0; f < (21 - mapData[i].length()); f++) {
mapData[i] += ChatColor.RESET;
}
}*/
eb.next(aMapData);
}
return eb.build();
}
}).setUpdateInterval(plugin.getConfig().getLong("Map.refreshRate", 10));
SimpleScoreboard simpleScoreboard = (SimpleScoreboard) board;
simpleScoreboard.activate();
this.scoreboard = simpleScoreboard;
return simpleScoreboard;
}
use of biz.princeps.landlord.manager.LangManager in project LandLord by SpatiumPrinceps.
the class Landlord method onEnable.
@Override
public void onEnable() {
// Dependency stuff
if (getWorldGuard() == null) {
getLogger().warning("WorldGuard not found! Please ensure you have the correct version of WorldGuard in order to use LandLord");
getPluginLoader().disablePlugin(this);
return;
} else
wgHandler = new WorldGuardHandler(getWorldGuard());
if (getVault() == null) {
getLogger().warning("Vault not found! Not all features of landlord are working.");
} else
vaultHandler = new VaultHandler(getVault());
if (!getServer().getPluginManager().isPluginEnabled("ProtocolLib")) {
getLogger().warning("ProtocolLib not found! Please ensure you have the correct version of ProtocolLib in order to use LandLord");
getPluginLoader().disablePlugin(this);
return;
}
instance = this;
PrincepsLib.setPluginInstance(this);
checkWorldNames();
saveDefaultConfig();
ConfigUtil.handleConfigUpdate(this.getDataFolder() + "/config.yml", "/config.yml");
saveDefaultConfig();
langManager = new LangManager(this, getConfig().getString("Language", "en"));
databaseAPI = new DatabaseAPI(DatabaseType.valueOf(getConfig().getString("DatabaseType")), getConfig(), new Requests(), "biz.princeps.landlord.persistent");
handleDatabase();
manageCommands();
manageListeners();
managePlaceholders();
manageItems();
lPlayerManager = new LPlayerManager(databaseAPI);
lPlayerManager.onStartup();
mapManager = new MapManager();
ScoreboardLib.setPluginInstance(this);
costManager = new CostManager();
executorService = Executors.newCachedThreadPool();
// Retrieve the LPlayer objects for all online players (in case of reload)
Bukkit.getOnlinePlayers().forEach(p -> {
List<Object> lPlayer = this.getDatabaseAPI().retrieveObjects(LPlayer.class, new Conditions.Builder().addCondition("uuid", p.getUniqueId().toString()).create());
LPlayer lp;
if (lPlayer.size() > 0)
lp = (LPlayer) lPlayer.get(0);
else
lp = new LPlayer(p.getUniqueId());
this.getPlayerManager().add(p.getUniqueId(), lp);
});
if (getConfig().getBoolean("EnableMetrics")) {
Metrics metrics = new Metrics(this);
// TODO maybe add some interesting statistics
}
}
use of biz.princeps.landlord.manager.LangManager in project LandLord by SpatiumPrinceps.
the class Landlordbase method onCommand.
@Override
public void onCommand(Properties properties, Arguments arguments) {
if (properties.isConsole())
return;
LangManager lm = Landlord.getInstance().getLangManager();
List<String> playersList = lm.getStringList("Commands.Help.players");
List<String> adminList = lm.getStringList("Commands.Help.admins");
int perSite = Landlord.getInstance().getConfig().getInt("HelpCommandPerSite");
String[] argsN = new String[1];
if (arguments.get().length == 1) {
argsN[0] = (arguments.get()[0] == null ? "0" : arguments.get()[0]);
}
List<String> toDisplay = new ArrayList<>();
if (properties.getPlayer().hasPermission("landlord.admin.help"))
toDisplay.addAll(adminList);
toDisplay.addAll(playersList);
// System.out.println(toDisplay.size());
MultiPagedMessage msg = new MultiPagedMessage.Builder().setElements(toDisplay).setPerSite(perSite).setHeaderString(lm.getRawString("Commands.Help.header")).setNextString(lm.getRawString("Commands.Help.next")).setPreviousString(lm.getRawString("Commands.Help.previous")).setCommand("ll help", argsN).build();
properties.getPlayer().spigot().sendMessage(msg.create());
}
use of biz.princeps.landlord.manager.LangManager in project LandLord by SpatiumPrinceps.
the class LandMap method buildMap.
private String[] buildMap(Player p) {
final int radius = 3;
String[][] mapBoard = getMapDir(getPlayerDirection(p));
String[] mapRows = new String[mapBoard.length + 3];
if (!currChunk.equals(mapViewer.getLocation().getChunk())) {
updateMap();
}
Map<Chunk, OwnedLand> nearby = plugin.getWgHandler().getNearbyLands(p.getLocation(), radius, radius);
for (int z = 0; z < mapBoard.length; z++) {
StringBuilder row = new StringBuilder();
for (int x = 0; x < mapBoard[z].length; x++) {
int xx = x - radius;
int zz = z - radius;
OwnedLand land = nearby.get(p.getWorld().getChunkAt(xx + p.getLocation().getChunk().getX(), zz + p.getLocation().getChunk().getZ()));
String currSpot = mapBoard[z][x];
if (land != null) {
if (land.getWGLand().getOwners().getUniqueIds().contains(p.getUniqueId())) {
currSpot = ChatColor.GREEN + currSpot;
} else if (land.getWGLand().getMembers().getUniqueIds().contains(p.getUniqueId())) {
currSpot = ChatColor.YELLOW + currSpot;
} else {
currSpot = ChatColor.RED + currSpot;
}
} else {
if (currSpot.equals("∞") || currSpot.equals("\u2062")) {
currSpot = ChatColor.RESET + currSpot;
} else {
currSpot = ChatColor.GRAY + currSpot;
}
}
row.append(currSpot);
}
mapRows[z] = row.toString();
}
LangManager messages = plugin.getLangManager();
final String yours = messages.getRawString("Commands.LandMap.yours");
final String friends = messages.getRawString("Commands.LandMap.friends");
final String others = messages.getRawString("Commands.LandMap.others");
if (yours.length() <= 25) {
mapRows[mapRows.length - 3] = ChatColor.GREEN + "█- " + yours;
} else {
mapRows[mapRows.length - 3] = ChatColor.GREEN + "█- " + yours.substring(0, 25);
}
if (friends.length() <= 25) {
mapRows[mapRows.length - 2] = ChatColor.YELLOW + "█- " + friends;
} else {
mapRows[mapRows.length - 2] = ChatColor.YELLOW + "█- " + friends.substring(0, 25);
}
if (others.length() <= 25) {
mapRows[mapRows.length - 1] = ChatColor.RED + "█- " + others;
} else {
mapRows[mapRows.length - 1] = ChatColor.RED + "█- " + others.substring(0, 25);
}
return mapRows;
}
Aggregations