Skip to content

loickal/PoloCloud-Entity

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚡ PoloCloud-Entity

What is "PoloCloud-Entity"?

PoloCloud-Entity is a Plugin for the PoloCloud, where you can create Entities. These Entities will then work as a "server-switcher".

ℹ️ Everything will update automaticly when, for example a new Player joins to a Group

Usage

Command: /cloudentity
Aliases: /entity, /entities, /cloudentites
Permission: (default, is changeable in the Config) -> cloud.plugin.entity.command

Create a Entity

To create a entity there are differnt ways:

  1. **Command (or aliases) create < EntityType > < GroupName >

    • Example:
      • /cloudentity create Villager Lobby
  2. **Command (or aliases) create < EntityType > < GroupName > < Title >

    • This is used for creating a CloudEntity with a custom Title
    • Message Placeholders
    • ℹ️ This Command Supports ColorCodes (Use & for displaying a § Color) -> ChatColors
    • Example:
      • /cloudentity create Villager Lobby &7Group &b{GROUP}

Removing a Entity

For removing there is only one Way:

  • **Command (or aliases) create < EntityType > < GroupName >
    • ℹ️ You have to be 0.5 Blocks near the Entity you want to Remove
    • Example:
      • /cloudentity remove

Placeholders

There are different placeholders. You use them with these brackets {} in the bracket you have to write the Name of the Placeholder

Funktion Example
{GROUP} ServiceGroup#getName() Gets the Name of the specific ServiceGroup {GROUP} -> Lobby
{PLAYERS} none Gets all Players of the specific ServiceGroup (Only in Title of the Entity useable) {PLAYERS} -> 95
{SERVER} CloudService#getName() Gets the Name of the specific CloudService (Only in Inventory useable) {SERVER} -> Lobby-1
{ONLINE} CloudService#getOnlineCount() Gets the OnlinePlayers of the specific CloudService Only in Inventory useable) {ONLINE} -> 25
{MAX} CloudService#getMaxPlayers() Gets the Maximum Players of the specific CloudService Only in Inventory useable) {MAX} -> 50
{MOTD} CloudService#getMotd() Gets the MOTD of the specific CloudService Only in Inventory useable) {MOTD} -> "Super tolle Motd"
{{HIGHEST_SERVICE_NAME}} CloudService#getName() Gets the ServiceName of the CloudService with the highest Player-Count {HIGHEST_SERVICE_NAME} -> "Lobby-1"
{HIGHEST_SERVICE_ONLINE} CloudService#getOnlineCount() Gets the PlayerCount of the CloudService with the highest Player-Count {HIGHEST_SERVICE_ONLINE} -> 95
{HIGHEST_SERVICE_MAX} CloudService#getMaxPlayers() Gets the PlayerCount of the CloudService with the highest Player-Count {HIGHEST_SERVICE_MAX} -> 100
{HIGHEST_SERVICE_MOTD} CloudService#getMotd() Gets the Motd of the CloudService with the highest Player-Count {HIGHEST_SERVICE_MOTD} -> "Motd of the Service with the highest Player-Count"

Developer

Download the SourceCode, import it in your IDE and run 'mvn install'.

Then in your Target-Project import the PoloCloud-Entity Dependency in your pom.xml

   <dependency>
      <groupId>de.polocloud</groupId>
      <artifactId>PoloCloud-Entity</artifactId>
      <version>2.1.1-RELEASE</version>
   </dependency>

PoloCloud-Entity offers the possibility to change the to open Inventory when a Player clicks on a CloudEntity

How does it work? You have to register a Listener, from there easly create a new void-Method with the @EventHandler Annonation

    public class Test implements Listener {  
      
      @EventHandler  
      public void handle(CloudEntityInventoryOpenEvent event) {  
      
      }  
      
    }

Used Imports:

    import de.polocloud.plugin.entity.event.CloudEntityInventoryOpenEvent;  
    import org.bukkit.event.EventHandler;  
    import org.bukkit.event.Listener;

From there you can access these Values:

  • The Player, who has clicked on the CloudEntity (example for the example above event.getPlayer()
  • The CloudEntity the Player has clicked on (example for the example above event.getCloudEntity()
  • The ServiceGroup the CloudEntity is from event.getServiceGroup()
  • The Inventory you can change (example for the example above event.getInventory()
  • The List with the displayed CloudServices in it (List<CloudService>) (example for the example above event.getCloudServices()

Now if you want to change the Inventory (add Item, remove Item, change Item) you can easily set the Inventory with event.setInventory(updateInventory);

Example

    public class Test implements Listener {  
      
      @EventHandler  
      public void handle(CloudEntityInventoryOpenEvent event) {  
      	Inventory inventory = event.getInventory();  
      	inventory.addItem(new ItemStack(Material.WOODEN_AXE));  
      	event.setInventory(inventory);  
      }  
      
    }

Used Imports:

    import de.polocloud.plugin.entity.event.CloudEntityInventoryOpenEvent;  
    import org.bukkit.Material;  
    import org.bukkit.event.EventHandler;  
    import org.bukkit.event.Listener;  
    import org.bukkit.inventory.Inventory;  
    import org.bukkit.inventory.ItemStack;

ℹ️ Also you can cancel to opening of the Inventory with event.setCanceled(true);

Get a CloudEntity

Ways to get a CloudEntity:

⚠️ All of these Methods can return a nulled CloudEntity

  1. Of Location (from spawned CloudEntity)
   CloudEntityHandler.getInstance().getCloudEntityOfLocation(yourLocation);
  1. Of Location (from the Config Location)
   CloudEntityHandler.getInstance().getCloudEntityOfLocation0(yourLocation);
  1. Of Entity (the SpawnedEntity)
   CloudEntityHandler.getInstance().getCloudEntityOfEntity(yourEntity);

Get all CloudEntites

Invoke:

    List<CloudEntity> entities = CloudEntityHandler.getInstance().getEntities();

Destroy a CloudEntity

You need a CloudEntity, then invoke:

    CloudEntity cloudEntity; //<- Your CloudEntity (only for placeholder)
    cloudEntity.destroy();

Spawn a CloudEntity

You need a CloudEntity, then invoke:

    CloudEntity cloudEntity; //<- Your CloudEntity (only for placeholder)
    cloudEntity.spawn();

Create a new CloudEntity

You need:

  • Location
  • EntityType
  • ServiceGroup
  • String (used as title) (:information_source: Optional (How to use then? Simple use null as Title)
  • String (used as secondLine) (:information_source: Optional (How to use then? Simple use null as Title)
  • Location (used as title) (:information_source: Optional (How to use then? Simple use null as Title)

ℹ️ This can return you a valid CloudEntity Object

    Location location; //<- Your CloudEntity (only for placeholder)
    EntityType entityType; //<- Your EntityType (only for placeholder)
    ServiceGroup serviceGroup; //<- Your ServiceGroup (only for placeholder)
    String title; //<- Optional (Nullable) (only for placeholder)
    String secondLine; //<- Optional (Nullable) (only for placeholder)
    Location secondLineLocation; //<- Optional (Nullable) (only for placeholder)
    
    CloudEntity cloudEntity = CloudEntityHandler.getInstance().createCloudEntity(location, entityType, serviceGroup, title, secondLine, secondLineLocation);
    
    or when the title should be default:
    
    CloudEntity cloudEntity = CloudEntityHandler.getInstance().createCloudEntity(location, entityType, serviceGroup, null, null, null);
    
    or when the secondTitle should be null:
    
    CloudEntity cloudEntity = CloudEntityHandler.getInstance().createCloudEntity(location, entityType, serviceGroup, title, null, null);
    
    or when the secondTitleLocation should be default:
    
    CloudEntity cloudEntity = CloudEntityHandler.getInstance().createCloudEntity(location, entityType, serviceGroup, title, secondLine, null);

Remove a CloudEntity

You need a CloudEntity, then invoke:

    CloudEntity cloudEntity; //<- Your CloudEntity (only for placeholder)
    CloudEntityHandler.getInstance().removeEntity(yourCloudEntity);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%