Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin #2

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 38 additions & 41 deletions src/main/java/me/onebone/actaeon/Actaeon.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,55 +13,52 @@
import me.onebone.actaeon.entity.animal.Pig;
import me.onebone.actaeon.entity.animal.Sheep;
import me.onebone.actaeon.entity.monster.Zombie;
import me.onebone.actaeon.entity.monster.evoker.GraveEvokerBoss;

public class Actaeon extends PluginBase implements Listener{
public class Actaeon extends PluginBase implements Listener {

private static Actaeon instance;
private static Actaeon instance;

public static Actaeon getInstance() {
return instance;
}
public static Actaeon getInstance() {
return instance;
}

@Override
public void onLoad() {
if (instance == null) instance = this;
}
@Override
public void onLoad() {
if (instance == null) instance = this;
}

public void onEnable(){
this.saveDefaultConfig();
public void onEnable() {
this.saveDefaultConfig();

//this.registerEntity("Sheep", Sheep.class);
//this.registerEntity("Cow", Cow.class);
//this.registerEntity("Chicken", Chicken.class);
//this.registerEntity("Pig", Pig.class);
this.registerEntity("Zombie", Zombie.class);
this.registerEntity("Evoker", GraveEvokerBoss.class);
this.registerEntity("Sheep", Sheep.class);
this.registerEntity("Cow", Cow.class);
this.registerEntity("Chicken", Chicken.class);
this.registerEntity("Pig", Pig.class);
this.registerEntity("Zombie", Zombie.class);

Item.addCreativeItem(Item.get(Item.SPAWN_EGG, Zombie.NETWORK_ID));
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, Zombie.NETWORK_ID));

Item.addCreativeItem(Item.get(Item.SPAWN_EGG, 10));
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, 11));
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, 12));
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, 13));
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, 14));
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, 18));
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, 22));
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, 23));
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, 24));
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, 25));
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, 28));
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, GraveEvokerBoss.NETWORK_ID));
//this.getServer().getPluginManager().registerEvents(this, this);
}
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, 10));
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, 11));
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, 12));
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, 13));
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, 14));
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, 18));
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, 22));
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, 23));
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, 24));
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, 25));
Item.addCreativeItem(Item.get(Item.SPAWN_EGG, 28));
//this.getServer().getPluginManager().registerEvents(this, this);
}

private void registerEntity(String name, Class<? extends MovingEntity> clazz){
Entity.registerEntity(name, clazz, true);
}
private void registerEntity(String name, Class<? extends MovingEntity> clazz) {
Entity.registerEntity(name, clazz, true);
}

@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Block block = event.getBlock();
event.getPlayer().sendMessage("XYZ=" + block.getX() + "," + block.getY() + "," + block.getZ() + " ID=" + block.getId() + " META=" + block.getDamage());
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Block block = event.getBlock();
//event.getPlayer().sendMessage("XYZ=" + block.getX() + "," + block.getY() + "," + block.getZ() + " ID=" + block.getId() + " META=" + block.getDamage());
}
}
54 changes: 54 additions & 0 deletions src/main/java/me/onebone/actaeon/Utils/Utils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package me.onebone.actaeon.Utils;

import cn.nukkit.math.NukkitRandom;
import cn.nukkit.math.Vector3;

import java.util.Random;

/**
* Copyright © 2016 WetABQ&DreamCityAdminGroup All right reserved.
* Welcome to DreamCity Server Address:dreamcity.top:19132
* Created by WetABQ(Administrator) on 2018/2/11.
* ||| || |||| || |||||||| |||||||
* ||| ||| ||| || || | ||| || ||| |||
* ||| ||| || |||||| |||||||| || || || |||| ||| ||
* || ||||| || ||| || |||| ||| ||||| |||||||| | ||
* || || || || || || | |||||||| || || ||| || ||
* |||| |||| || || || || ||| ||| |||| ||| ||||||||
* || ||| ||||||| ||||| ||| |||| |||||||| ||||| |
* ||||
*/
public class Utils {
private static final Random random = new Random(System.currentTimeMillis());

/**
* Returns a random number between min (inkl.) and max (excl.) If you want a
* number between 1 and 4 (inkl) you need to call rand (1, 5)
*
* @param min min inklusive value
* @param max max exclusive value
* @ a random number
*/
public static int rand(int min, int max) {
if (min == max) {
return max;
}
return min + random.nextInt(max - min);
}

/**
* Returns random boolean
*
* @return a boolean random value either <code>true</code> or
* <code>false</code>
*/
public static boolean rand() {
return random.nextBoolean();
}

public static Vector3 randomVector(Vector3 from, int xRadius, int yRadius, int zRadius) {
NukkitRandom random = new NukkitRandom();

return from.add(random.nextRange(-xRadius, xRadius), random.nextRange(-yRadius, yRadius), random.nextRange(-zRadius, zRadius));
}
}
2 changes: 1 addition & 1 deletion src/main/java/me/onebone/actaeon/entity/Climbable.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.onebone.actaeon.entity;

public interface Climbable{
public interface Climbable {
}
2 changes: 1 addition & 1 deletion src/main/java/me/onebone/actaeon/entity/Fallable.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.onebone.actaeon.entity;

public interface Fallable{
public interface Fallable {
}
2 changes: 1 addition & 1 deletion src/main/java/me/onebone/actaeon/entity/Hostile.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.onebone.actaeon.entity;

public interface Hostile{
public interface Hostile {
}
Loading