### World Creation Examples Source: https://wiki.traincarts.net/p/MyWorlds/Commands Examples of creating worlds with different environments, seeds, and generators. ```text /world create world1:BananaSpace:12,grass,wood,dirt -1856378464 ``` ```text /world create world2 -527332672 ``` ```text /world create world2_nether ``` ```text /world create mynether/nether ``` ```text /world create itssobig/largebiomes ``` ```text /world create world3_skylands ``` ```text /world create skylandsworld ``` -------------------------------- ### Create and start a Task with a delay Source: https://wiki.traincarts.net/p/BKCommonLib/Task Shows how to create a Task subclass and start it with a 10-tick delay. The run() method broadcasts a message after the delay. The start() method returns the Task instance for chaining. ```java Task myTask = new Task(MyPlugin.plugin) { @Override public void run() { Bukkit.broadcastMessage("Test after 10 ticks!"); } }.start(10); ``` -------------------------------- ### World creation command examples Source: https://wiki.traincarts.net/p/MyWorlds/ManagingWorlds/zh-cn Examples of /world create commands with their results, including overworld, nether, flat, and generator plugin worlds. ```command /world create world1 ``` ```command /world create world1_nether ``` ```command /world create mynether/nether ``` ```command /world create HippoCraft/flat 251 ``` ```command /world create waterworld/flat::2;7,5x1,5x3,5x12,90x9;1;biome_1,village ``` ```command /world create Space:bSpace:awesome ``` -------------------------------- ### Run Paper server (java -jar) Source: https://wiki.traincarts.net/p/Light-Cleaner Starts the Paper server for the first time. It will fail and ask you to agree to the EULA; after editing eula.txt to set eula=true, run the same command again to start the server for real. ```bash java -jar paper-1.12.2-1620.jar ``` -------------------------------- ### Example existing collision configuration Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TrainCarts/MobEntering An example of a collision configuration that already has some options set, showing the format used in DefaultTrainProperties.yml. ```yaml collision: players: DEFAULT misc: PUSH train: LINK block: DEFAULT ``` -------------------------------- ### /map give [player] command example Source: https://wiki.traincarts.net/p/Maplands/Commands Example of the give subcommand to give the map to another player. Requires the maplands.command.give permission. If no player is provided, the map is given to the executor. ```text /map give Bergerkiller ``` -------------------------------- ### values.yml configuration example Source: https://wiki.traincarts.net/p/SignLink/en Example configuration for values.yml. It sets default values for the plugin, including ticker direction and interval, and the value to display. Comments explain the properties. ```yaml # In here you can set default values for this plugin. # The ticker property can be LEFT, RIGHT or NONE and sets the direction message is 'ticked'. # tickerInterval sets the amount of ticks (1/20 of a second) are between the ticker update. # The value is the thing to display or tick. # To use colors in your text, use the § sign followed up by a value from 0 - F. # Example: §cRed to display a red colored 'Red' message. # You can find all color codes on the internet (they may use & there, ignore that!) sign: ticker: NONE value: This is a regular message you can set and is updated only once. test: tickerInterval: 3 ticker: LEFT value: 'This is a test message being ticked from right to left.' ``` -------------------------------- ### MyWorlds world enter localization example Source: https://wiki.traincarts.net/p/MyWorlds/Localization Example from MyWorlds showing how to set enter messages for worlds, with special messages for world1 and lowgrass. Note the lowercase key 'lowgrass'. ```yaml world: enter: default: §aYou teleported to world '%0%'! world1: §aYou teleported to world 1, have a nice stay! lowgrass: §aYou teleported to the nicely built Lowgrass, have fun there! ``` -------------------------------- ### SignActionWelcome.java - Custom Sign Action Example Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TrainCarts/API/SignAction Full example of a custom SignAction that sends a welcome message to all players in the train. It matches signs with 'welcome' on the second line, handles both train and cart signs, and uses SignBuildOptions for build handling. ```java import org.bukkit.entity.Player; import com.bergerkiller.bukkit.tc.controller.MinecartMember; import com.bergerkiller.bukkit.tc.events.SignActionEvent; import com.bergerkiller.bukkit.tc.events.SignChangeActionEvent; import com.bergerkiller.bukkit.tc.signactions.SignAction; import com.bergerkiller.bukkit.tc.signactions.SignActionType; import com.bergerkiller.bukkit.tc.utils.SignBuildOptions; /** * Displays a welcome message to the players in the train */ public class SignActionWelcome extends SignAction { @Override public boolean match(SignActionEvent info) { // Checks that the second line starts with 'welcome' (case-insensitive) return info.isType("welcome"); } @Override public void execute(SignActionEvent info) { // When a [train] sign is placed, activate when powered by redstone when the train // goes over the sign, or when redstone is activated. if (info.isTrainSign() && info.isAction(SignActionType.GROUP_ENTER, SignActionType.REDSTONE_ON) && info.isPowered() && info.hasGroup() ) { for (MinecartMember member : info.getGroup()) { sendGreetingForCart(info, member); } return; } // When a [cart] sign is placed, activate when powered by redstone when each cart // goes over the sign, or when redstone is activated. if (info.isCartSign() && info.isAction(SignActionType.MEMBER_ENTER, SignActionType.REDSTONE_ON) && info.isPowered() && info.hasMember() ) { sendGreetingForCart(info, info.getMember()); return; } } public void sendGreetingForCart(SignActionEvent info, MinecartMember member) { // Lines 3 and 4 configure the message to send String message = info.getLine(2) + info.getLine(3); // Send to all player passengers of the cart (could be multiple seats!) for (Player passenger : member.getEntity().getPlayerPassengers()) { passenger.sendMessage(message); } } @Override public boolean build(SignChangeActionEvent event) { // This is executed when a player places down a sign matching this sign action // Permissions are checked and then a message is displayed to the player // For simplicity you can use the SignBuildOptions API for this. // You are free to use your own code here that checks permissions/etc. return SignBuildOptions.create() .setName(event.isCartSign() ? "cart welcome greeter" : "train welcome greeter") .setDescription("sends a welcome message to all players in the train") .handle(event.getPlayer()); } } ``` -------------------------------- ### Quick Command Examples for TrainCarts Selectors Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TrainCarts/Commands/Selectors Examples of using @ptrain and @train selectors in commands to target passengers or trains based on conditions like distance, name, destination, cuboid range, and tag. ```text /say hello @ptrain[distance=..5] ``` ```text /kick @ptrain[name=train23] ``` ```text /train destroy --train @train[destination=InterState5] ``` ```text /train eject --train @train[dx=-2..2,dy=-3..3,dz=-2..2] ``` ```text /train launch 0.5 --options 2 --train @train[tag=express] ``` -------------------------------- ### Create and configure a scoreboard team Source: https://wiki.traincarts.net/p/BKCommonLib/Scoreboards Creates or retrieves a team named 'example', sets it visible to all, shows it, sets display name, prefix, and suffix, then adds a player. Note the typo 'nul' in the source. ```java CommonTeam team = CommonScoreboard.getTeam("example"); if(team == nul) { team = CommonScoreboard.createTeam("example"); team.setSendToAll(true); //set if team is visible for everyone team.show(); //Create team team.setDisplayName("Example"); //Not sure where this is used for team.setPrefix(ChatColor.RED.toString()); //Prefix (in front of name) team.setSuffix(" - Example"); } team.addPlayer(player); ``` -------------------------------- ### Portal sign example Source: https://wiki.traincarts.net/p/MyWorlds/Portals Example portal sign that teleports players to a portal named 'Portal1' in world 'HubWorld'. ```text [portal] Portal1 HubWorld ``` -------------------------------- ### Example YAML output with headers Source: https://wiki.traincarts.net/p/BKCommonLib/ConfigurationAPI Shows the YAML output produced by the Configuration API when headers are set. The main header uses a different syntax to avoid conflict with the first node header. ```yaml # This is the configuration of MyAwesomePlugin # Sets the awesomeness of this plugin awesomeness: 85 # Controls what levels of awesomeness are enabled enabledLevels: # Whether awesome looks are enabled looks: true # Whether awesome usage is enabled usage: false ``` -------------------------------- ### Create and load or save a new FileConfiguration Source: https://wiki.traincarts.net/p/BKCommonLib/ConfigurationAPI Initializes a FileConfiguration for 'config.yml', loads it if it exists, otherwise sets default values and saves. Demonstrates the basic load/save pattern and getting values with explicit class types. ```java FileConfiguration config = new FileConfiguration(this, "config.yml"); if (config.exists()) { config.load(); // Load the configuration from the file } else { config.set("config1", 12); config.set("config2", 14); config.save(); // Saves the new data to file } System.out.println(config.get("config1", Integer.class)); System.out.println(config.get("config2", Integer.class)); ``` -------------------------------- ### Example variable permission nodes in PermissionDefaults.yml Source: https://wiki.traincarts.net/p/BKCommonLib/PermissionDefaults Defines a variable permission node with a wildcard and specific sub-permissions for tools. Shows default values and descriptions for each node. ```yaml myplugin: use: '*': default: op description: Can use all tools hammer: default: true description: Can use the hammer tool drill: default: false description: Can use the drill tool ``` -------------------------------- ### /map render [uuid] command example Source: https://wiki.traincarts.net/p/Maplands/Commands Example of the render subcommand to manually render a map using a UUID. Requires the maplands.command.render permission. Useful when automatic rendering is disabled. The command with UUID can be obtained from the Map Menu Settings > Render command option. ```text /map render e152900a-f3a0-46e3-98ad-d58322854126 ``` -------------------------------- ### Variable permission node example in PermissionDefaults.yml Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/BKCommonLib/PermissionDefaults Example of a variable permission node structure in PermissionDefaults.yml. The '*' node sets the default for all sub-permissions, while specific sub-nodes (hammer, drill) can override it. In this example, OP players can use all tools, all players can use the hammer, and no one can use the drill by default. ```yaml myplugin: use: '*': default: op description: Can use all tools hammer: default: true description: Can use the hammer tool drill: default: false description: Can use the drill tool ``` -------------------------------- ### Get a configuration node with getNode(path) Source: https://wiki.traincarts.net/p/BKCommonLib/ConfigurationAPI Retrieves a ConfigurationNode by path, creating it if it does not exist. The method never returns null. Use the node's get method with a default value to read values. ```java ConfigurationNode entities = config.getNode("entities"); maxCount = entities.get("maxCount", 225); message = entities.get("message", "You have reached the maximum amount of entities"); EntityLogic.initialize(entities); ``` -------------------------------- ### Sort and Limit Selector Examples Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TrainCarts/Commands/Selectors Use sort (nearest, furthest, random) and limit (natural integer) to pick a limited set of trains based on distance. ```text @train[distance=..100,sort=random,limit=1] ``` ```text @train[distance=..100,sort=nearest,limit=2] ``` ```text @train[distance=1000..,sort=furthest,limit=10] ``` -------------------------------- ### Scene selection example: animate doors[open] Source: https://wiki.traincarts.net/p/TrainCarts/Signs/Animate Plays a specific scene 'open' of the animation 'doors' on the sign. Use animation[scenestart:sceneend] for ranges, animation[:scene] for up to a scene, or animation[scene:] for from a scene to the end. ```plaintext [train] animate doors[open] 1.0 ``` -------------------------------- ### Task in a plugin with start and stop Source: https://wiki.traincarts.net/p/BKCommonLib/Task Shows a typical usage in a plugin: starting a repeating task in onEnable and stopping it in onDisable. Uses Task.stop(myTask) for null safety. ```java public class MyPlugin extends JavaPlugin { private Task myTask; @Override public void onEnable() { myTask = new Task(this) { @Override public void run() { Bukkit.broadcastMessage("This message is displayed about every second"); } }.start(20, 20); } @Override public void onDisable() { Task.stop(myTask); myTask = null; } } ``` -------------------------------- ### Load configuration and get values with automatic defaults Source: https://wiki.traincarts.net/p/BKCommonLib/ConfigurationAPI Loads the configuration (even if the file does not exist) and retrieves values with default values. The defaults are automatically set if the node is missing, and saving updates the file. ```java FileConfiguration config = new FileConfiguration(this, "config.yml"); config.load(); System.out.println(config.get("config1", 12)); System.out.println(config.get("config2", 14)); config.save(); ``` -------------------------------- ### Position Cuboid Selector Examples Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TrainCarts/Commands/Selectors Select trains within a cuboid defined by x/y/z and optional dx/dy/dz. The world condition can target other worlds. All examples use @train and can be substituted with @ptrain. ```text @train[x=10..12,y=23..56,z=-100..-80] ``` ```text @train[x=10,y=23,z=-100,dx=2,dy=33,dz=20] ``` ```text @train[x=10,y=10,z=10,dx=-2..2,dy=-10..10,dz=-2..2] ``` ```text @train[dx=-10..10,dy=-5..5,dz=-10..10] ``` ```text @train[world=world_the_end,x=10,y=89,z=-20,dx=-10..10,dy=-10..10,dz=-10..10] ``` -------------------------------- ### Targeting flag --train examples Source: https://wiki.traincarts.net/p/TrainCarts/Commands/en Targets a train by name. The first example selects a train named 'train12'. The second uses the @train selector to target multiple trains matching a pattern. ```text /train maxspeed 0.0 --train train12 ``` ```text /train maxspeed --train @train[name=intercity*] ``` -------------------------------- ### TCWelcomeSign.java - Plugin Registration Example Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TrainCarts/API/SignAction Example of a JavaPlugin main class that registers and unregisters the custom SignAction. Registration is done in onLoad to ensure availability during train loading, and unregistration in onDisable to prevent issues on reload. ```java import org.bukkit.plugin.java.JavaPlugin; import com.bergerkiller.bukkit.tc.signactions.SignAction; public class TCWelcomeSign extends JavaPlugin { public final SignActionWelcome signActionWelcome = new SignActionWelcome(); @Override public void onLoad() { // Register the signs SignAction.register(signActionWelcome); } @Override public void onEnable() { } @Override public void onDisable() { // Unregister the signs to prevent problems during /reload SignAction.unregister(signActionWelcome); } } ``` -------------------------------- ### World inventory command syntax Source: https://wiki.traincarts.net/p/MyWorlds/SeperateInventories These are the syntax examples for the /world inventory command, showing merge, split, enable, and disable subcommands. The merge command saves shared data in the first world argument, while split detaches worlds from shared state. ```text /world inventory merge [world1] [world2] [world3] ``` ```text /world inventory split [world1] [world2] [world3] ``` ```text /world inventory enable [world] ``` ```text /world inventory disable [world] ``` -------------------------------- ### Targeting flag --world example Source: https://wiki.traincarts.net/p/TrainCarts/Commands/en Targets trains in a different world. Required when running commands from the server terminal. ```text /train destroy --world world_nether --near 2 66 -134 1.5 ``` -------------------------------- ### Run Light Cleaner on the current world Source: https://wiki.traincarts.net/p/Light-Cleaner/en Execute this command in-game or from the terminal to start cleaning the world you are in. Requires operator permissions (use 'op my_name' first). ```minecraft-command /cleanlight world ``` -------------------------------- ### Speed Selector Example Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TrainCarts/Commands/Selectors Select trains by actual movement speed (at most the speed limit). Alias: velocity. ```text @train[speed=0] ``` -------------------------------- ### Train Name Selector Examples Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TrainCarts/Commands/Selectors Select trains by exact name or wildcard pattern (same rules as remote control syntax). ```text @train[name=train12] ``` ```text @train[name=Intercity*Express] ``` ```text @train[name=*] ``` -------------------------------- ### Load localization lines one by one with loadLocale Source: https://wiki.traincarts.net/p/BKCommonLib/PluginBase Override localization() and use loadLocale to load single localization lines. This example loads two lines: 'noperm' and 'nobuild'. ```java @Override public void localization() { loadLocale("noperm", ChatColor.RED + "You do not have permission!"); loadLocale("nobuild", ChatColor.RED + "You can not build here!"); } ``` -------------------------------- ### Manually initialize Metrics instance Source: https://wiki.traincarts.net/p/BKCommonLib/Metrics Creates a Metrics instance using Metrics.initialize(this) and checks for null before adding graphs. The initialize method handles calling start() automatically. ```java Metrics metrics = Metrics.initialize(this); if (metrics != null) { // Add your graphs here } ``` -------------------------------- ### Creating CommonTag, CommonTagList, and CommonTagCompound Source: https://wiki.traincarts.net/p/BKCommonLib/NBTTagAPI Shows the various ways to construct CommonTag, CommonTagList, and CommonTagCompound objects. A tag name is optional, but a value is always required. The last two examples use a name and a collection or map of values. ```java CommonTag tag1 = CommonTag.create("myTagName", "text"); CommonTag tag2 = new CommonTag("myIntData", 12); CommonTagList tagList = new CommonTagList(); CommonTagList tagList = new CommonTagList("MyName", someListOfValues); CommonTagCompound compound = new CommonTagCompound("SomeMap", someMapOfValues); ``` -------------------------------- ### Get a list of integers from configuration Source: https://wiki.traincarts.net/p/BKCommonLib/ConfigurationAPI Retrieves a list of integers from the configuration node 'blockIds'. If the node is not set, an empty list is created automatically. Non-integer values are filtered out. ```java List ints = config.getList("blockIds", Integer.class); ``` -------------------------------- ### Skip sign with station filter Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TrainCarts/Signs/Skip Example of a skip sign with a filter on the second line. The filter 'station' makes the skip mechanism only ignore signs whose second line starts with 'station', skipping the very next station sign while ignoring non-station signs. The filter is case-insensitive. ```plaintext [+train] skip station 0 1 ``` -------------------------------- ### Targeting flag --cart example Source: https://wiki.traincarts.net/p/TrainCarts/Commands/en Selects a single cart from the front. Index 0 is the front, 1 second from front, etc. The words 'head' and 'tail' can also be used to select the first or last cart. ```text /cart destroy --nearest --cart 0 ``` -------------------------------- ### Basic animate sign configurations Source: https://wiki.traincarts.net/p/TrainCarts/Signs/Animate Basic animate sign configuration examples. The first block plays a rotating animation without optionsinate, the second loops a roll animation at speed 0.5, and the third uses flags 'lr' (looped and reset) with a speed of 0.5 and delay of 0.4. All use [train] on the first line. ```plaintext [train] animate rotate ``` ```plaintext [train] animate looped roll 0.5 ``` ```plaintext [train] animate lr rotate 0.5 0.4 ``` -------------------------------- ### Show create usage with /world create Source: https://wiki.traincarts.net/p/MyWorlds/ManagingWorlds/en Lists the usage of /world create in combination with all available environments. ```text /world create ``` -------------------------------- ### Switcher sign examples Source: https://wiki.traincarts.net/p/TC-Coasters/zh Switcher sign syntax for TrainCarts. The first example switches junction 1 to direction 2 for empty trains and to direction 3 otherwise. The second example uses counter syntax to alternate trains between directions 2 and 3. ```plaintext [+train] switcher 1-2:empty 1-3:default ``` ```plaintext [+train] switcher 1-2:1 1-3:1 ``` -------------------------------- ### Ejector sign absolute coordinates example Source: https://wiki.traincarts.net/p/TrainCarts/Signs/Ejector/en Example of the third line when using 'eject at': exact world coordinates to teleport players to. ```plaintext 154/67/-2442 ``` -------------------------------- ### Ejector sign offset example Source: https://wiki.traincarts.net/p/TrainCarts/Signs/Ejector/en Example of the third line offset when using 'eject': 0/0/4 ejects players to the left of the train. ```plaintext 0/0/4 ``` -------------------------------- ### Basic spawner sign syntax Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TrainCarts/Signs/Spawner The basic syntax for a spawner sign. The first line is [train], the second line is 'spawn', and the third/fourth lines define the spawn pattern. The example shows spawning two minecarts. ```plaintext [train] spawn 2 psmmmmmsp ``` -------------------------------- ### Remote control ejector sign example Source: https://wiki.traincarts.net/p/TrainCarts/Signs/Ejector/en Example of remotely ejecting a train named 'train01' using [train train01] on the first line. ```plaintext [train train01] eject 0/2/0 ``` -------------------------------- ### World Creation Command Syntax Source: https://wiki.traincarts.net/p/MyWorlds/Commands Basic syntax for creating worlds with MyWorlds, including optional generator, arguments, and seed. Use /world, /myworlds, or /mw aliases. ```text /world create [worldname]:[generator]:[arguments] [seed] ``` ```text /world create [worldname] [seed] ``` ```text /world create [worldname]/[environment] [seed] ``` -------------------------------- ### Example graph implementation for total server memory Source: https://wiki.traincarts.net/p/BKCommonLib/Metrics Adds a graph named 'Total server memory' using Metrics.addGraph. The onUpdate method clears existing plotters, calculates total memory in MB, and toggles a plotter for the appropriate memory range. This method is called on the main thread, so it is thread-safe to access Bukkit or plugin resources. ```java // Total server memory getMetrics().addGraph(new Graph("Total server memory") { @Override public void onUpdate(Plugin plugin) { clearPlotters(); // Get server total memory in MB (>> 20 = / (1024 * 1024)) final long mem = Runtime.getRuntime().totalMemory() >> 20; final String key; if (mem <= 512) { key = "0-512 MB"; } else if (mem <= 1024) { key = "512-1024 MB"; } else if (mem <= 2048) { key = "1024-2048 MB"; } else if (mem <= 4096) { key = "2048-4096 MB"; } else if (mem <= 8192) { key = "4096-8192 MB"; } else if (mem <= 16384) { key = "8-16 GB"; } else { key = "16+ GB"; } togglePlotter(key, true); } }); ``` -------------------------------- ### Basic player.enter localization node Source: https://wiki.traincarts.net/p/MyWorlds/Localization Shows the default structure for a player.enter localization node with a single message using the %0% argument placeholder. ```yaml someplugin: player: enter: §ePlayer %0% joined the server! Say hello! ``` -------------------------------- ### Ejector sign syntax example Source: https://wiki.traincarts.net/p/TrainCarts/Signs/Ejector/en Example of the ejector sign syntax with [train] to eject all minecarts, 'eject' to teleport relative to the minecarts, offset 0/12/12, and angle 90/0. ```plaintext [train] eject 0/12/12 90/0 ``` -------------------------------- ### Run Light Cleaner on current world (/cleanlight world) Source: https://wiki.traincarts.net/p/Light-Cleaner Runs Light Cleaner on the world you are currently in. You can also run it from the terminal window without logging on, but it's a good idea to check the world was loaded correctly first. ```text /cleanlight world ``` -------------------------------- ### Get and show a sidebar scoreboard Source: https://wiki.traincarts.net/p/BKCommonLib/Scoreboards Retrieves the scoreboard for an online player, gets the SIDEBAR objective, shows it, and creates a score named 'kills' with value 17. Use sidebar.hide() to hide the sidebar. ```java Player player = Bukkit.getOnlinePlayers()[0]; //just get an online player as example CommonScoreboard board = CommonScoreboard.get(player); //Get the scoreboard form the player CommonObjective sidebar = board.getObjective(Display.SIDEBAR); //Get the sidebar scoreboard sidebar.show(); //Shwo the sidebar (use siderbar.hide() to hide) sidebar.createScore("kills", 17); //Create a new score called 'kills' and make the value 17 ``` -------------------------------- ### Clone TabView and display to a specific player Source: https://wiki.traincarts.net/p/BKCommonLib/TabView Shows how to clone the startup TabView instance and set a cell's text and ping before displaying it to a specific player. Use this for per-player custom views. ```java TabView myView = this.tabView.clone(); myView.set(0, 0, player.getName(), TabView.PING_NONE); myView.displayTo(player); ``` -------------------------------- ### Run Light Cleaner on world from terminal (/cleanlight world world) Source: https://wiki.traincarts.net/p/Light-Cleaner Runs Light Cleaner on the world named 'world' from the terminal window without logging on. Use this after confirming the world loaded correctly. ```text /cleanlight world world ``` -------------------------------- ### List Generator Plugins Command Source: https://wiki.traincarts.net/p/MyWorlds/Commands Lists plugins on the server that offer a world generator. ```text /world listgenerators ``` -------------------------------- ### Set default properties via command Source: https://wiki.traincarts.net/p/TrainCarts/TrainProperties/en Select a train by punching it, then run this command to set its default property list to default, admin, or spawner. ```text /train setdefault default|admin|spawner ``` -------------------------------- ### Get values with automatic type conversion Source: https://wiki.traincarts.net/p/BKCommonLib/NBTTagAPI Shows how to retrieve values from a CommonTagCompound using overloads that convert between types, such as getting a String from an int tag or a Difficulty enum from an int identifier. Specify the Class type or a non-null default to obtain the value. ```java CommonTagCompound data = new CommonTagCompound("data"); data.putValue("x", 12); data.putValue("y", 15); data.putValue("difficulty", -1); String textX = data.getValue("x", String.class); double doubleY= data.getValue("y", 0.0); Difficulty diffculty = data.getValue("difficulty", Difficulty.class, null); if (difficulty != null) { System.out.println(difficulty); } ``` -------------------------------- ### Void World Creation for 1.12.2 and before Source: https://wiki.traincarts.net/p/MyWorlds/Commands Creates a void world using flat world options with air and nostructures override for older versions. ```text /world create my_void_world/flat::3;minecraft:air;127;nostructures; ``` -------------------------------- ### ulslocalization Source: https://wiki.traincarts.net/p/Special%3AApiSandbox Internal. Get the localization of ULS in the given language. ```APIDOC ## ulslocalization ### Description Internal. Get the localization of ULS in the given language. ### Method GET ### Endpoint /api.php?action=ulslocalization ### Parameters #### Query Parameters - **language** (string) - Required - The language for which to get the localization. ### Response #### Success Response (200) - **localization** (object) - The localization data for the specified language. #### Response Example { "localization": {} } ``` -------------------------------- ### Load or save world configuration commands Source: https://wiki.traincarts.net/p/MyWorlds/Commands Use /world config load to load world configuration from worlds.yml and /world config save to save it. Requires the myworlds.world.config permission. ```text /world config load ``` ```text /world config save ``` -------------------------------- ### Void World Creation for 1.13+ Source: https://wiki.traincarts.net/p/MyWorlds/Commands Creates a void world using flat world options with air and the_void biome, and nostructures override. ```text /world create my_void_world/flat::minecraft:air;minecraft:the_void;nostructures ``` -------------------------------- ### Derailed Selector Examples Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TrainCarts/Commands/Selectors Select trains that have derailed. Accepts 1 or true. ```text @train[derailed=1] ``` ```text @train[derailed=true] ``` -------------------------------- ### Import CSV file from URL Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TC-Coasters/NoLimits Use this command in-game to import a CSV file from a URL, such as a pastebin link. Replace with the actual URL. ```text /tcc import ``` -------------------------------- ### Crafter sign syntax example Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TrainCarts/Signs/Crafter Example of the crafter sign syntax. The first line sets whether to craft in the entire train or only the minecart above the sign. The second line uses 'craft' with an optional radius. The third and fourth lines define items to craft; items are crafted from left to right, and an extra empty slot may be needed. ```plaintext [train] craft wood;stick torch ``` -------------------------------- ### Targeting flag --nearest example Source: https://wiki.traincarts.net/p/TrainCarts/Commands/en Selects the nearest train to the sender, at most 128 blocks away. ```text /train maxspeed 0.0 --nearest ``` -------------------------------- ### Create TabView instance in plugin class Source: https://wiki.traincarts.net/p/BKCommonLib/TabView Initialize a TabView with maximum dimensions (3 columns, 20 rows) in a plugin class. This must be done during plugin startup because new tabs cannot be created while the server is running. ```java public class MyPlugin extends JavaPlugin { private TabView tabView = TabView.createTab(3, 20); public void onEnable() { } public void onDisable() { } } ``` -------------------------------- ### Distance Selector Examples Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TrainCarts/Commands/Selectors Filter trains by spherical distance from the sender or a specified coordinate/cuboid. Supports range syntax. ```text @train[distance=..10] ``` ```text @train[distance=1000..] ``` ```text @train[x=100,y=50,z=-100,distance=..5] ``` ```text @train[x=10,y=10,z=10,dx=50,dz=50,distance=..10] ``` -------------------------------- ### Basic launcher sign syntax Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TrainCarts/Signs/Launcher Basic launcher sign with launch distance 10, target speed 0.4, and continue direction. The speed is not locked after launching. ```plaintext [train] launch 10 0.4 continue ``` -------------------------------- ### /cleanlight command usage Source: https://wiki.traincarts.net/p/Light-Cleaner Lists all /cleanlight command variants for regenerating lighting, aborting operations, checking status, and remote execution from command blocks. ```plaintext /cleanlight - regenerate lighting for all chunks you can see /cleanlight 12 - regenerate lighting 25x25 chunks around you /cleanlight world - regenerate lighting in the current world /cleanlight world world1 - regenerate lighting for world1 /cleanlight abort - cancels any ongoing lighting operations /cleanlight status - checks up on the status of the repairs /cleanlight at [chunk_x] [chunk_z] [chunk_radius] (world) - regenerate lighting remotely (can be run from command blocks) ``` -------------------------------- ### Restructure world folder on Windows (Step 8) Source: https://wiki.traincarts.net/p/Light-Cleaner/en Move the DIM-1 and DIM1 folders from the nether and end dimensions into the main world folder, then remove the old dimension folders. Run these commands in the server root folder. ```batch move ./world_nether/DIM-1 ./world/DIM-1 move ./world_the_end/DIM1 ./world/DIM1 rmdir /s /q ./world_nether rmdir /s /q ./world_the_end ``` -------------------------------- ### Targeting flag --near example Source: https://wiki.traincarts.net/p/TrainCarts/Commands/en Selects the nearest train near the specified coordinates, at most the given distance away. ```text /train maxspeed 0.0 --near ~ ~ ~ 5 ``` -------------------------------- ### Debug all destinations with /train debug destination Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TrainCarts/PathFinding Get a stick that displays all destinations reachable from a clicked track, with distance and particles. ```plaintext /train debug destination ``` -------------------------------- ### Set configuration headers with setHeader Source: https://wiki.traincarts.net/p/BKCommonLib/ConfigurationAPI Sets the main header and node headers. Use '\n' for multiple lines or empty lines. The main header is set without a path, while node headers use dot-separated paths. ```java // Set the top-level header config.setHeader("This is the configuration of MyAwesomePlugin"); // Set the header of an option config.setHeader("awesomeness", "\nSets the awesomeness of this plugin"); config.setHeader("enabledLevels", "\nControls what levels of awesomeness are enabled"); config.setHeader("enabledLevels.looks", "Whether awesome looks are enabled"); config.setHeader("enabledLevels.usage", "Whether awesome usage is enabled"); ``` -------------------------------- ### Set train destination command Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TrainCarts/PathFinding Use the /train destination command to set a destination for a minecart. The example sets the destination to 'output'. ```text /train destination [name] /train destination output ``` -------------------------------- ### Template usage: {{License Mojang}} Source: https://wiki.traincarts.net/p/Template%3ALicense_Mojang Add this template to the file page to mark it as containing Mojang intellectual property. The template displays a license notice with the header 'License'. ```wikitext {{License Mojang}} ``` -------------------------------- ### Unloaded Selector Examples Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TrainCarts/Commands/Selectors Select trains inside unloaded chunks (no longer simulated). Trains that keep chunks loaded do not unload. ```text @train[unloaded=1] ``` ```text @train[unloaded=true] ``` -------------------------------- ### Create Map Item with MapDisplayProperties Source: https://wiki.traincarts.net/p/Map_Display/API/en Build a map item with additional metadata using MapDisplayProperties. Set properties like creator and background, then obtain the ItemStack with getMapItem(). ```java MapDisplayProperties prop = MapDisplayProperties.createNew(MyCustomDisplay.class); prop.set("creator", player.getName()); prop.set("background", "https://url/to/some/image.png"); ItemStack item = prop.getMapItem(); // Rest is the same ``` -------------------------------- ### Extend PluginBase with enable, disable, command, and getMinimumLibVersion Source: https://wiki.traincarts.net/p/BKCommonLib/PluginBase Basic usage of PluginBase: extend it and override enable(), disable(), command(), and getMinimumLibVersion(). The getMinimumLibVersion() method must be overridden to return the minimum BKCommonLib version supported, enabling a proper message if BKCommonLib is outdated. ```java public class MyPlugin extends PluginBase { @Override public void enable() { // Enable logic } @Override public void disable() { // Disable logic } @Override public boolean command(CommandSender sender, String command, String[] args) { return false; } @Override public int getMinimumLibVersion() { return Common.VERSION; } } ``` -------------------------------- ### Debug single destination with /train debug destination Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TrainCarts/PathFinding Get a stick that displays the precise route to a specific destination when clicking on track. ```plaintext /train debug destination [destination] ``` -------------------------------- ### Create nodes command Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TC-Coasters Command to emulate the right-click create behavior without being in the menu. Requires the train.coasters.use permission. ```text /tcc create ``` -------------------------------- ### Edit a score value Source: https://wiki.traincarts.net/p/BKCommonLib/Scoreboards Edits an existing score by getting it from the sidebar, setting a new value, and calling update() to apply the change. ```java CommonScore kills = siderbar.getScore("kills"); kills.setValue(18); //Change the value to 18 kills kills.update(); //Don't forget ot update the score after changing it! ``` -------------------------------- ### Property sign to set destination Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TrainCarts/PathFinding Use a property sign with the 'destination' property to set a destination for a train. The example sets the destination to 'outpost'. ```text [+train] property destination outpost ``` -------------------------------- ### List worlds with /world list Source: https://wiki.traincarts.net/p/MyWorlds/Commands Shows loaded worlds and worlds in the server directory that can be loaded. Useful for verifying a world is present before loading it. Requires permission myworlds.world.list. ```text /world list ``` -------------------------------- ### Passenger Count Selector Example Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TrainCarts/Commands/Selectors Select trains by number of (player) passengers. Supports range syntax, e.g., 'at least' a number. ```text @train[passengers=5..] ``` -------------------------------- ### Create vanilla world command Source: https://wiki.traincarts.net/p/MyWorlds/ManagingWorlds/zh-cn Command to create a vanilla world. The environment and options are optional; if no seed is specified, a random seed is used. The environment type is appended to the world name when using underscore notation. Not specifying an environment uses NORMAL. ```command /world create worldname_environment(::options) (seed) ``` -------------------------------- ### Display player stats in a TabView table Source: https://wiki.traincarts.net/p/BKCommonLib/TabView Initializes a TabView with headers and fills rows with player name, experience, and time alive. Supports up to 17 players. Place in a command handler or enable logic, but be aware of conflicts with other plugins that modify the player list. Best to allow users to toggle this view off. ```java // Show header at line 1, 2 and 3 tabView.fillRow(0, "==============", TabView.PING_1); tabView.fillRow(1, TabView.TEXT_NONE, TabView.PING_NONE); tabView.setRowText(1, "Players", "Experience", "Time Alive"); tabView.fillRow(2, "==============", TabView.PING_1); // Show scores int line = 3; for (Player player : Bukkit.getOnlinePlayers()) { tabView.set(0, line, player.getPlayerListName(), TabView.PING_FULL); tabView.set(1, line, "" + player.getTotalExperience(), TabView.PING_FULL); tabView.set(2, line, "" + (player.getTicksLived() / 20) + "s", TabView.PING_FULL); line++; // Out of bounds! if (line >= tabView.getHeight()) { break; } } // Display to everyone tabView.displayToAll(); ``` -------------------------------- ### Obtaining CommonEntity from existing Entity Source: https://wiki.traincarts.net/p/BKCommonLib/CommonEntity Shows how to get a CommonEntity instance from an existing Bukkit Entity, including specialized extensions for players and items. ```java CommonEntity entity = CommonEntity.get(entity); CommonPlayer player = CommonEntity.get(playerEntity); CommonItem item = CommonEntity.get(itemEntity); ``` -------------------------------- ### Craft 64 wood items using RecipeUtil.getCraftingRequirements and CraftRecipe.craftItems Source: https://wiki.traincarts.net/p/BKCommonLib/Recipes Attempts to craft 64 wood items using the first available crafting recipe. The craft method does not account for the number of items produced per operation, so craftItems is used instead. Only the first recipe found is used, ignoring other possible crafting methods. ```java Inventory inventory = player.getInventory(); CraftRecipe[] recipes = RecipeUtil.getCraftingRequirements(Material.WOOD, null); if (recipes.length > 0) { recipes[0].craftItems(inventory, 64); } ``` -------------------------------- ### Enable Metrics in plugin.yml Source: https://wiki.traincarts.net/p/BKCommonLib/PluginBase Add 'metrics: true' to plugin.yml to enable Metrics. By default it is disabled. PluginBase automatically starts the Metrics instance when enabling. ```yaml metrics: true ``` -------------------------------- ### Train Tag Selector Examples Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TrainCarts/Commands/Selectors Filter by tags assigned to trains. Supports wildcard patterns and can be specified multiple times. Checks presence/absence, not exclusivity. ```text @train[tag=mytag] ``` ```text @train[tag=*fast,tag=!express] ``` -------------------------------- ### Restructure world folder on Linux (Step 8) Source: https://wiki.traincarts.net/p/Light-Cleaner/en Move the DIM-1 and DIM1 folders from the nether and end dimensions into the main world folder, then remove the old dimension folders. Run these commands in the server root folder. ```bash mv ./world_nether/DIM-1 ./world/DIM-1 mv ./world_the_end/DIM1 ./world/DIM1 rm -rf ./world_nether rm -rf ./world_the_end ``` -------------------------------- ### Create Map Item with MapDisplay.createMapItem Source: https://wiki.traincarts.net/p/Map_Display/API/en Create an ItemStack that loads the custom display when given to a player. Optionally set a display name and add the item to the player's inventory. ```java ItemStack item = MapDisplay.createMapItem(MyCustomDisplay.class); ItemUtil.setDisplayName(item, "My Custom Display"); // Optional player.getInventory().addItem(item); seplayerder.sendMessage(ChatColor.GREEN + "Given My Custom Display map!"); ``` -------------------------------- ### /world allowspawn and denyspawn command syntax Source: https://wiki.traincarts.net/p/MyWorlds/Commands Allows or denies certain mobs from spawning on a world. Custom-spawned mobs are ignored. Use mob types or keywords 'animal', 'monster', 'all', or 'mob'. Requires permission myworlds.world.spawning. ```text /world allowspawn [mobname] [worldname] ``` ```text /world allowspawn [mobname] ``` ```text /world denyspawn [mobname] [worldname] ``` ```text /world denyspawn [mobname] ``` ```text /world denyspawn creeper ``` ```text /world denyspawn animal world1 ``` -------------------------------- ### Configure default portal destinations for nether_world Source: https://wiki.traincarts.net/p/MyWorlds/Portals Commands to set nether portal destination and mode for the nether world, teleporting players back to the overworld. ```text /mw netherportal destination overworld /mw netherportal mode nether_link ``` -------------------------------- ### Station Sign with Launch Speed Source: https://wiki.traincarts.net/p/TrainCarts/Signs/Station Station sign with a launch speed of 0.4 on the fourth line. The second example also includes a 5-second delay and continue mode. ```text [train] station 0.4 ``` ```text [train] station 5 continue 0.4 ``` -------------------------------- ### Invalid CommonTag construction with null data Source: https://wiki.traincarts.net/p/BKCommonLib/NBTTagAPI This example will NOT work because a CommonTag cannot be constructed with null data. The internal handle cannot change after creation, so setting data later is impossible. ```java CommonTag myData = new CommonTag("Data", null); myData.setData(12); ``` -------------------------------- ### Give a train chest with a pre-configured train Source: https://wiki.traincarts.net/p/Special%3AMyLanguage/TrainCarts/Train_Spawn_Chest Use this command to give a train chest item with a pre-configured train inside, using the same pattern as the spawn sign. Requires the train.command.chest.create permission. ```text /train chest mytrain ``` -------------------------------- ### Replacing All Entities with a Controller using EntityAddEvent Source: https://wiki.traincarts.net/p/BKCommonLib/Controller Listens for the EntityAddEvent to set a custom controller on every newly added Item entity. Uses EventPriority.LOWEST to run early. Ignores non-Item entities and assigns a CustomItemController to items. ```java @EventHandler(priority = EventPriority.LOWEST) public void onEntityAdd(EntityAddEvent event) { if (!(event.getEntity() instanceof Item)) { return; } CommonEntity.get((Item) event.getEntity()).setController(new CustomItemController()); } ``` -------------------------------- ### Flat World Options Syntax Source: https://wiki.traincarts.net/p/MyWorlds/Commands Syntax for specifying flat world options using the options String. ```text /world create the_world_name/flat::[options] ``` ```text /world create the_world_name/flat::3;1*minecraft:bedrock,7*minecraft:dirt,1*minecraft:stone,1*minecraft:sandstone;2;village ```