Skip to content

Commit 5b9891f

Browse files
committed
Initial commit
1 parent 3fc0d26 commit 5b9891f

File tree

9 files changed

+364
-1
lines changed

9 files changed

+364
-1
lines changed

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
# ClientWorlds-API
2-
The API for the ClientWorlds library used in my (future) projects
2+
The API for the ClientWorlds library used in my (future) projects.
3+
4+
# Javadoc
5+
Coming soon
6+
7+
# Copyright
8+
Copyright 2016 Wout Ceulemans. All Rights Reserved.

pom.xml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>ClientWorlds</artifactId>
7+
<groupId>be.woutdev</groupId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>ClientWorlds-API</artifactId>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>org.bukkit</groupId>
17+
<artifactId>bukkit</artifactId>
18+
<version>1.9.2-R0.1-SNAPSHOT</version>
19+
</dependency>
20+
</dependencies>
21+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package be.woutdev.clientworlds.api;
2+
3+
import be.woutdev.clientworlds.api.framework.API;
4+
5+
/**
6+
* Created by Wout on 24/08/2016.
7+
*/
8+
public class ClientWorldsAPI
9+
{
10+
private static API API;
11+
12+
public static API getAPI()
13+
{
14+
return API;
15+
}
16+
17+
public static void setAPI(API api)
18+
{
19+
if (ClientWorldsAPI.API != null)
20+
{
21+
throw new RuntimeException("Cannot set API twice.");
22+
}
23+
24+
ClientWorldsAPI.API = api;
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package be.woutdev.clientworlds.api.block;
2+
3+
import be.woutdev.clientworlds.api.location.ClientLocation;
4+
import org.bukkit.Material;
5+
import org.bukkit.material.MaterialData;
6+
7+
/**
8+
* Created by Wout on 24/08/2016.
9+
*/
10+
public interface ClientBlock
11+
{
12+
/**
13+
* Get the type of the block.
14+
* @return The Material of the block.
15+
*/
16+
Material getType();
17+
18+
/**
19+
* Set the type of the block.
20+
* @param type The Material of the block.
21+
*/
22+
void setType(Material type);
23+
24+
/**
25+
* Get the MaterialData of this block.
26+
* @return The MaterialData of this block.
27+
*/
28+
MaterialData getData();
29+
30+
/**
31+
* Set the MaterialData for this block.
32+
* @param data The MaterialData to set.
33+
*/
34+
void setData(MaterialData data);
35+
36+
/**
37+
* Get the ClientLocation where this block is at.
38+
* @return The ClientLocation
39+
*/
40+
ClientLocation getLocation();
41+
42+
/**
43+
* Check if this block is a block in the actual world or not.
44+
* @return If this block is real, and therefor the same in the normal world.
45+
*/
46+
boolean isReal();
47+
48+
/**
49+
* Update this block to all players in the ClientWorld.
50+
* @return If the update was successful.
51+
*/
52+
boolean update();
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package be.woutdev.clientworlds.api.event;
2+
3+
import be.woutdev.clientworlds.api.block.ClientBlock;
4+
import org.bukkit.entity.Player;
5+
import org.bukkit.event.Cancellable;
6+
import org.bukkit.event.Event;
7+
import org.bukkit.event.HandlerList;
8+
9+
/**
10+
* Created by Wout on 24/08/2016.
11+
*/
12+
public class ClientWorldBlockBreakEvent extends Event implements Cancellable
13+
{
14+
private static final HandlerList handlers = new HandlerList();
15+
private final Player player;
16+
private final ClientBlock block;
17+
private boolean cancelled;
18+
private String cancelMessage;
19+
20+
public ClientWorldBlockBreakEvent(Player player, ClientBlock block)
21+
{
22+
this.player = player;
23+
this.block = block;
24+
this.cancelled = false;
25+
this.cancelMessage = "";
26+
}
27+
28+
@Override
29+
public boolean isCancelled()
30+
{
31+
return cancelled;
32+
}
33+
34+
@Override
35+
public void setCancelled(boolean b)
36+
{
37+
cancelled = b;
38+
}
39+
40+
public String getCancelMessage()
41+
{
42+
return cancelMessage;
43+
}
44+
45+
public void setCancelMessage(String cancelMessage)
46+
{
47+
this.cancelMessage = cancelMessage;
48+
}
49+
50+
public Player getPlayer()
51+
{
52+
return player;
53+
}
54+
55+
public ClientBlock getBlock()
56+
{
57+
return block;
58+
}
59+
60+
@Override
61+
public HandlerList getHandlers() {
62+
return handlers;
63+
}
64+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package be.woutdev.clientworlds.api.event;
2+
3+
import be.woutdev.clientworlds.api.block.ClientBlock;
4+
import org.bukkit.entity.Player;
5+
import org.bukkit.event.Cancellable;
6+
import org.bukkit.event.Event;
7+
import org.bukkit.event.HandlerList;
8+
9+
/**
10+
* Created by Wout on 24/08/2016.
11+
*/
12+
public class ClientWorldBlockPlaceEvent extends Event implements Cancellable
13+
{
14+
private static final HandlerList handlers = new HandlerList();
15+
private final Player player;
16+
private final ClientBlock block;
17+
private boolean cancelled;
18+
private String cancelMessage;
19+
20+
public ClientWorldBlockPlaceEvent(Player player, ClientBlock block)
21+
{
22+
this.player = player;
23+
this.block = block;
24+
this.cancelled = false;
25+
this.cancelMessage = "";
26+
}
27+
28+
@Override
29+
public boolean isCancelled()
30+
{
31+
return cancelled;
32+
}
33+
34+
@Override
35+
public void setCancelled(boolean b)
36+
{
37+
cancelled = b;
38+
}
39+
40+
public String getCancelMessage()
41+
{
42+
return cancelMessage;
43+
}
44+
45+
public void setCancelMessage(String cancelMessage)
46+
{
47+
this.cancelMessage = cancelMessage;
48+
}
49+
50+
public Player getPlayer()
51+
{
52+
return player;
53+
}
54+
55+
public ClientBlock getBlock()
56+
{
57+
return block;
58+
}
59+
60+
@Override
61+
public HandlerList getHandlers() {
62+
return handlers;
63+
}
64+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package be.woutdev.clientworlds.api.framework;
2+
3+
import be.woutdev.clientworlds.api.world.ClientWorld;
4+
5+
/**
6+
* Created by Wout on 24/08/2016.
7+
*/
8+
public interface API
9+
{
10+
/**
11+
* Create a new ClientWorld instance if the current server version is supported.
12+
* @return A new ClientWorld instance.
13+
*/
14+
ClientWorld createWorld();
15+
16+
/**
17+
* Check if the current server version is supported by ClientWorlds.
18+
* @return If the current server version is supported by ClientWorlds.
19+
*/
20+
boolean isSupported();
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package be.woutdev.clientworlds.api.location;
2+
3+
import be.woutdev.clientworlds.api.world.ClientWorld;
4+
5+
/**
6+
* Created by Wout on 24/08/2016.
7+
*/
8+
public interface ClientLocation
9+
{
10+
/**
11+
* Get the ClientWorld for this location.
12+
* @return The ClientWorld for this location.
13+
*/
14+
ClientWorld getWorld();
15+
16+
/**
17+
* Get the x-coordinate for this location.
18+
* @return The x-coordinate for this location.
19+
*/
20+
int getX();
21+
22+
/**
23+
* Get the y-coordinate for this location.
24+
* @return The y-coordinate for this location.
25+
*/
26+
int getY();
27+
28+
/**
29+
* Get the z-coordinate for this location.
30+
* @return The z-coordinate for this location.
31+
*/
32+
int getZ();
33+
34+
/**
35+
* Set the x-coordinate for this location.
36+
* @param x The x-coordinate
37+
*/
38+
void setX(int x);
39+
40+
/**
41+
* Set the y-coordinate for this location.
42+
* @param y The y-coordinate
43+
*/
44+
void setY(int y);
45+
46+
/**
47+
* Set the z-coordinate for this location.
48+
* @param z The z-coordinate
49+
*/
50+
void setZ(int z);
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package be.woutdev.clientworlds.api.world;
2+
3+
import be.woutdev.clientworlds.api.block.ClientBlock;
4+
import org.bukkit.Location;
5+
import org.bukkit.entity.Player;
6+
7+
/**
8+
* Created by Wout on 24/08/2016.
9+
*/
10+
public interface ClientWorld
11+
{
12+
/**
13+
* Add a player to the ClientWorld. This will directly send updates to the player.
14+
* @param player The player to add.
15+
* @return If adding the player was successful or not.
16+
*/
17+
boolean addPlayer(Player player);
18+
19+
/**
20+
* Remove a player from the ClientWorld. This will directly update the world to its normal state. Be careful with the players location when using this.
21+
* @param player The player to remove.
22+
* @return If removing the player was successful or not.
23+
*/
24+
boolean removePlayer(Player player);
25+
26+
/**
27+
* Get a ClientBlock by location.
28+
* @param location The location.
29+
* @return The ClientBlock at that location.
30+
*/
31+
ClientBlock getBlockAt(Location location);
32+
33+
/**
34+
* Get a ClientBlock by coordinates.
35+
* @param x The x-coordinate.
36+
* @param y The y-coordinate.
37+
* @param z The z-coordinate.
38+
* @return The ClientBlock at the given coordinates.
39+
*/
40+
ClientBlock getBlockAt(int x, int y, int z);
41+
42+
/**
43+
* Hide the player from the observer.
44+
* @param observer The observer where the player should be hidden from.
45+
* @param player The player that should be hidden for the observer.
46+
* @return If this action went successful.
47+
*/
48+
boolean hide(Player observer, Player player);
49+
50+
/**
51+
* Show the player to the observer.
52+
* @param observer The observer where the player should be shown for.
53+
* @param player The player that should be shown for the observer.
54+
* @return If this action went successful.
55+
*/
56+
boolean show(Player observer, Player player);
57+
}

0 commit comments

Comments
 (0)