Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei1058 committed Feb 2, 2021
1 parent 1f4c2c5 commit efa59ff
Show file tree
Hide file tree
Showing 39 changed files with 1,360 additions and 146 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ Please note that I've fully re-coded it and I'm its copyright holder.
![header](.github/images/farmer_orb_wheat.gif)


WIP
WIP


registerOrb(Factory, Category, Identifier)
34 changes: 34 additions & 0 deletions handyorbs-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,39 @@

<artifactId>handyorbs-api</artifactId>

<dependencies>
<dependency>
<groupId>com.andrei1058.handyorbs</groupId>
<artifactId>handyorbs-core</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>


<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</exclusion>
<exclusion>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</exclusion>
<exclusion>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
package com.andrei1058.handyorbs.api;

import com.andrei1058.handyorbs.core.OrbBase;
import org.bukkit.Location;

public interface HandyOrbs {

/**
* Register a new orb.
*
* @param identifier unique identifier.
* @param orb orb class.
* @param category orb category.
*/
boolean registerOrb(String identifier, Class<? extends OrbBase> orb, OrbCategory category);

/**
* Spawn a new orb.
*/
OrbBase spawnOrb(String identifier, OrbCategory category, Location location, int radius);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.andrei1058.handyorbs.api;

public enum OrbCategory {

FARMING,
SPECIAL,
PVP,
OTHER;
}
37 changes: 36 additions & 1 deletion handyorbs-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,49 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>handyorbs-core</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<!--This adds the Spigot API artifact to the build -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<artifactId>spigot</artifactId>
<version>1.16.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</exclusion>
<exclusion>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</exclusion>
<exclusion>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.andrei1058.handyorbs</groupId>
<artifactId>handyorbs-vcommon</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
package com.andrei1058.handyorbs.core;

import com.andrei1058.handyorbs.core.version.OrbEntityFactory;
import org.bukkit.plugin.Plugin;

public class HandyOrbsCore {

private final Plugin owner;
private static HandyOrbsCore instance;

private HandyOrbsCore(Plugin plugin) {
this.owner = plugin;
}

/**
* Initialize orbs core.
*
* @param plugin owner. Used for registering tasks etc.
* @return false if server version is not supported.
*/
public HandyOrbsCore(Plugin plugin) {
this.owner = plugin;
public static boolean init(Plugin plugin) {
if (instance == null) {
if (!OrbEntityFactory.init()){
return false;
}
instance = new HandyOrbsCore(plugin);
}
return true;
}

/**
Expand All @@ -21,4 +34,8 @@ public HandyOrbsCore(Plugin plugin) {
public Plugin getOwner() {
return owner;
}

public static HandyOrbsCore getInstance() {
return instance;
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,56 @@
package com.andrei1058.handyorbs.core;

import org.bukkit.Location;

public class OrbBase {
import com.andrei1058.handyorbs.core.region.IRegion;
import com.andrei1058.handyorbs.core.version.OrbEntity;
import com.andrei1058.handyorbs.core.version.OrbEntityFactory;
import org.bukkit.*;
import org.bukkit.inventory.ItemStack;

import java.util.UUID;

public abstract class OrbBase {

private int orbId = -1;
private String world;
private IRegion region;
private OrbEntity orbEntity;

protected OrbBase(Location location, IRegion region) {
this.world = location.getWorld() == null ? "null" : location.getWorld().getName();
this.region = region;
World world = Bukkit.getWorld(this.world);
if (world == null) throw new IllegalStateException("World is not loaded!");
orbEntity = OrbEntityFactory.getInstance().spawnOrbEntity(new Location(world, location.getX(), location.getY(), location.getZ()), new ItemStack(Material.GOLD_BLOCK));
if (orbEntity == null) throw new IllegalStateException("Could not spawn orb entity!");

orbEntity.setDisplayName("&x&F&E&D&B&F&0My &x&C&B&A&F&C&0Nice &x&5&1&4&6&4&COrb");
orbEntity.setRightClickListener((player -> {
player.sendMessage("right click " + (player.isSneaking() ? "(shifting)" : ""));
return null;
}));
}

private Location location;
public void unLoad() {

protected OrbBase(Location location){
this.location = location;
}

public boolean load(){
return false;
public int getOrbId() {
return orbId;
}

public void unLoad(){

public OrbEntity getOrbEntity() {
return orbEntity;
}

public void changeLocation(Location newLocation){
this.location = newLocation;
// todo teleport orb
public String getWorld() {
return world;
}

protected void tickAnimation(){

public String getDisplayName(){
return orbEntity.getName();
}

public void setOrbId(int orbId) {
this.orbId = orbId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.andrei1058.handyorbs.core.model;

import java.util.UUID;

public interface Ownable {

UUID getOwner();

void setOwner(UUID uuid);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.andrei1058.handyorbs.core.model;

import com.andrei1058.handyorbs.core.OrbBase;
import com.andrei1058.handyorbs.core.region.IRegion;
import org.bukkit.Location;

import java.util.UUID;

public class WheatOrb extends OrbBase implements Ownable {

private UUID owner;

public WheatOrb(Location location, IRegion region) {
super(location, region);
}

public void setOwner(UUID owner) {
this.owner = owner;
}

public UUID getOwner() {
return owner;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.andrei1058.handyorbs.core.region;

import org.bukkit.Location;

public class Cuboid implements IRegion{

private final int minX, maxX;
private final int minY, maxY;
private final int minZ, maxZ;


public Cuboid(int radius, Location center){
Location l1 = center.clone().subtract(radius, radius, radius);
Location l2 = center.clone().add(radius, radius, radius);

minX = Math.min(l1.getBlockX(), l2.getBlockX());
maxX = Math.max(l1.getBlockX(), l2.getBlockX());

minY = Math.min(l1.getBlockY(), l2.getBlockY());
maxY = Math.max(l1.getBlockY(), l2.getBlockY());

minZ = Math.min(l1.getBlockZ(), l2.getBlockZ());
maxZ = Math.max(l1.getBlockZ(), l2.getBlockZ());

}

@Override
public boolean isInRegion(Location l) {
return (l.getBlockX() <= maxX && l.getBlockX() >= minX) && (l.getY() <= maxY && l.getY() >= minY) && (l.getBlockZ() <= maxZ && l.getBlockZ() >= minZ);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.andrei1058.handyorbs.core.region;

import org.bukkit.Location;

public interface IRegion {

boolean isInRegion(Location location);
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit efa59ff

Please sign in to comment.