Skip to content
This repository was archived by the owner on Jan 21, 2019. It is now read-only.

Commit a9926a2

Browse files
Initial commit
0 parents  commit a9926a2

File tree

4 files changed

+303
-0
lines changed

4 files changed

+303
-0
lines changed

pom.xml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>me.ShakeforProtein</groupId>
8+
<artifactId>BSBMechanics</artifactId>
9+
<version>1.0.0</version>
10+
<packaging>jar</packaging>
11+
12+
<name>BSBMechanics</name>
13+
14+
<description>Custm game mechanics for Bentbox Skyblock and Acid Islands.</description>
15+
<properties>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
</properties>
18+
<url>http://treebomc.com</url>
19+
20+
<build>
21+
<defaultGoal>clean package</defaultGoal>
22+
<plugins>
23+
<plugin>
24+
<groupId>org.apache.maven.plugins</groupId>
25+
<artifactId>maven-compiler-plugin</artifactId>
26+
<version>3.7.0</version>
27+
<configuration>
28+
<source>1.8</source>
29+
<target>1.8</target>
30+
</configuration>
31+
</plugin>
32+
<plugin>
33+
<groupId>org.apache.maven.plugins</groupId>
34+
<artifactId>maven-shade-plugin</artifactId>
35+
<version>3.1.0</version>
36+
<executions>
37+
<execution>
38+
<phase>package</phase>
39+
<goals>
40+
<goal>shade</goal>
41+
</goals>
42+
<configuration>
43+
<minimizeJar>true</minimizeJar>
44+
</configuration>
45+
</execution>
46+
</executions>
47+
</plugin>
48+
</plugins>
49+
<resources>
50+
<resource>
51+
<directory>src/main/resources</directory>
52+
<filtering>true</filtering>
53+
</resource>
54+
</resources>
55+
</build>
56+
57+
<repositories>
58+
<repository>
59+
<id>spigotmc-repo</id>
60+
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
61+
</repository>
62+
<repository>
63+
<id>sonatype</id>
64+
<url>https://oss.sonatype.org/content/groups/public/</url>
65+
</repository>
66+
</repositories>
67+
68+
<dependencies>
69+
<dependency>
70+
<groupId>org.spigotmc</groupId>
71+
<artifactId>spigot-api</artifactId>
72+
<version>1.13.2-R0.1-SNAPSHOT</version>
73+
<scope>provided</scope>
74+
</dependency>
75+
</dependencies>
76+
</project>
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
package me.shakeforprotein.bsbmechanics;
2+
3+
import org.bukkit.*;
4+
import org.bukkit.entity.*;
5+
import org.bukkit.event.EventHandler;
6+
import org.bukkit.event.Listener;
7+
import org.bukkit.event.block.Action;
8+
import org.bukkit.event.player.PlayerInteractEvent;
9+
import org.bukkit.inventory.ItemStack;
10+
import org.bukkit.inventory.meta.BookMeta;
11+
import org.bukkit.material.Cauldron;
12+
import org.bukkit.material.Mushroom;
13+
import org.bukkit.plugin.java.JavaPlugin;
14+
15+
import java.util.ArrayList;
16+
import java.util.List;
17+
18+
19+
public final class BSBMechanics extends JavaPlugin implements Listener {
20+
21+
@Override
22+
public void onEnable() {
23+
Boolean debug = false;
24+
System.out.println("BSBMechanics is starting");
25+
getServer().getPluginManager().registerEvents(this, this);
26+
getConfig().options().copyDefaults(true);
27+
getConfig().set("version", this.getDescription().getVersion());
28+
saveConfig();
29+
System.out.println("BSBMechanics startup complete");
30+
}
31+
32+
@Override
33+
public void onDisable() {
34+
System.out.println("BSBMechanics has shut down");
35+
}
36+
37+
int cost = 0;
38+
@EventHandler
39+
private void onStickCauldron (PlayerInteractEvent e) {
40+
if (e.getAction() == Action.RIGHT_CLICK_BLOCK && e.getClickedBlock().getType() == Material.CAULDRON && e.getPlayer().getInventory().getItemInMainHand().getType() == Material.STICK) {
41+
Player p = e.getPlayer();
42+
String world = p.getWorld().getName();
43+
if ((world.equalsIgnoreCase("BSkyblock_world")) || (world.equalsIgnoreCase("AcidIsland_world"))) {
44+
45+
Cauldron cauldron = (Cauldron) e.getClickedBlock().getState().getData();
46+
Location target = e.getClickedBlock().getLocation();
47+
if (cauldron.isFull()) {
48+
e.setCancelled(true);
49+
if (p.getInventory().getItemInOffHand().getType() == Material.WHITE_WOOL) {
50+
spawnMob(p, target, "SHEEP");
51+
}
52+
if (p.getInventory().getItemInOffHand().getType() == Material.LEATHER) {
53+
spawnMob(p, target, "COW");
54+
}
55+
if (p.getInventory().getItemInOffHand().getType() == Material.BONE) {
56+
spawnMob(p, target,"WOLF");
57+
}
58+
if (p.getInventory().getItemInOffHand().getType() == Material.CARROT_ON_A_STICK) {
59+
spawnMob(p, target,"PIG");
60+
}
61+
if (p.getInventory().getItemInOffHand().getType() == Material.CARROT) {
62+
spawnMob(p, target,"RABBIT");
63+
}
64+
if (p.getInventory().getItemInOffHand().getType() == Material.FEATHER) {
65+
spawnMob(p, target,"CHICKEN");
66+
}
67+
if (p.getInventory().getItemInOffHand().getType() == Material.SEAGRASS) {
68+
spawnMob(p, target,"TURTLE");
69+
}
70+
if (p.getInventory().getItemInOffHand().getType() == Material.WHEAT_SEEDS) {
71+
spawnMob(p, target,"PARROT");
72+
}
73+
if (p.getInventory().getItemInOffHand().getType() == Material.COD) {
74+
spawnMob(p, target,"OCELOT");
75+
}
76+
if (p.getInventory().getItemInOffHand().getType() == Material.MUSHROOM_STEW) {
77+
spawnMob(p, target,"MUSHROOM_COW");
78+
}
79+
if (p.getInventory().getItemInOffHand().getType() == Material.HAY_BLOCK) {
80+
spawnMob(p, target,"HORSE");
81+
}
82+
if (p.getInventory().getItemInOffHand().getType() == Material.BOOK) {
83+
createKnowledgeTome(p);
84+
}
85+
}
86+
else{p.sendMessage(ChatColor.RED + "Your cauldron must be full if you want to avoid accidents like this.");
87+
p.getWorld().strikeLightning(p.getLocation());
88+
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
89+
public void run() {
90+
p.getWorld().strikeLightning(target);
91+
}
92+
}, 20L);
93+
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
94+
public void run() {
95+
p.getWorld().strikeLightning(target);
96+
}
97+
}, 40L);
98+
}
99+
}
100+
101+
}
102+
}
103+
104+
private void spawnMob(Player p, Location target, String mobName) {
105+
cost = getConfig().getInt(mobName + ".LEVELS");
106+
if(getConfig().getString(mobName + ".ENABLED").equalsIgnoreCase("true")){
107+
if (p.getLevel() >= cost) {
108+
p.getWorld().strikeLightning(target);
109+
p.setLevel(p.getLevel() - cost);
110+
p.getInventory().getItemInOffHand().setType(Material.AIR);
111+
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
112+
public void run() {
113+
p.getWorld().strikeLightning(target);
114+
}
115+
}, 20L);
116+
117+
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
118+
public void run() {
119+
p.getWorld().strikeLightning(target);
120+
}
121+
}, 30L);
122+
123+
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
124+
public void run() {
125+
p.getWorld().strikeLightning(target);
126+
}
127+
}, 40L);
128+
129+
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
130+
public void run() {
131+
p.getWorld().strikeLightning(target);
132+
}
133+
}, 45L);
134+
135+
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
136+
public void run() {
137+
p.getWorld().strikeLightning(target);
138+
}
139+
}, 50L);
140+
141+
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
142+
public void run() {
143+
p.getWorld().spawnEntity(target.add(0,2,0), (EntityType.valueOf(mobName)));
144+
}
145+
}, 70L);
146+
147+
}
148+
else {p.sendMessage(getConfig().getString("insufficientLEVELS"));}
149+
150+
}
151+
152+
}
153+
154+
155+
private void createKnowledgeTome(Player p) {
156+
157+
ItemStack pOff = p.getInventory().getItemInOffHand();
158+
pOff.setType(Material.WRITTEN_BOOK);
159+
BookMeta pBook = (BookMeta) pOff.getItemMeta();
160+
pBook.setTitle("The effects of Five billion Volts on various cadavers");
161+
pBook.setAuthor("Dr. V. Frankenstein");
162+
163+
List<String> pages = new ArrayList<String>();
164+
pages.add("Foreword: Dear reader this book is intended to pass on my knowledge, so noone need repeat my accursed experiments"); // Page 1
165+
pages.add("Warnings:\n Do not stand too close to the experiment as electricity is known to arc.\n\bThe experiments are hungry, care should be taken to ensure extra materials do not come into contact"); // Page 2
166+
pages.add("In my early experiments I found that I needed a combination of parts from multiple cadavers, carefully stitched together. I have since learned that the more electricity you use, the less cadaver you need"); // Page 3
167+
pages.add("Parrot:\nSeveral loose Seeds\n3 parts saline\n" + getConfig().getInt("PARROT.LEVELS") + " parts Knowledge");
168+
pages.add("Rabbit:\n1 part Carrot (nibbled)\n3 parts saline\n" + getConfig().getInt("RABBIT.LEVELS") + " parts Knowledge");
169+
pages.add("Chicken:\n1 part feather (pluckewd)\n3 parts saline\n" + getConfig().getInt("CHICKEN.LEVELS") + " parts Knowledge");
170+
pages.add("Ocelot:\n1 part cod (raw)\n3 parts saline\n" + getConfig().getInt("OCELOT.LEVELS") + " parts Knowledge");
171+
pages.add("Pigs:\n1 part Seagrass (slimy)\n3 parts saline\n" + getConfig().getInt("TURTLE.LEVELS") + " parts Knowledge");
172+
pages.add("Wolf:\n1 part Bone (chewed)\n3 parts saline\n" + getConfig().getInt("WOLF.LEVELS") + " parts Knowledge");
173+
pages.add("Pigs:\n1 part Carrot on a stick (bitten)\n3 parts saline\n" + getConfig().getInt("PIG.LEVELS") + " parts Knowledge");
174+
pages.add("Sheep:\n1 part white wool(sheared)\n3 parts saline\n" + getConfig().getInt("SHEEP.LEVELS") + " parts Knowledge");
175+
pages.add("Cows:\n1 part leather (skinned)\n3 parts saline\n" + getConfig().getInt("COW.LEVELS") + " parts Knowledge");
176+
pages.add("Mushroom Cow:\n1 part Mushroom Stew (salty)\n3 parts saline\n" + getConfig().getInt("MUSHROOM_COW.LEVELS") + " parts Knowledge");
177+
pages.add("Horse:\n9 part Hay (Baled)\n3 parts saline\n" + getConfig().getInt("HORSE.LEVELS") + " parts Knowledge");
178+
179+
180+
181+
pBook.setPages(pages);
182+
pOff.setItemMeta(pBook);
183+
184+
}
185+
}
186+

src/main/resources/config.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
SHEEP:
2+
LEVELS: 3
3+
ENABLED: 'true'
4+
COW:
5+
LEVELS: 3
6+
ENABLED: 'true'
7+
WOLF:
8+
LEVELS: 3
9+
ENABLED: 'true'
10+
PIG:
11+
LEVELS: 3
12+
ENABLED: 'true'
13+
RABBIT:
14+
LEVELS: 3
15+
ENABLED: 'true'
16+
CHICKEN:
17+
LEVELS: 3
18+
ENABLED: 'true'
19+
TURTLE:
20+
LEVELS: 15
21+
ENABLED: 'true'
22+
PARROT:
23+
LEVELS: 3
24+
ENABLED: 'true'
25+
OCELOT:
26+
LEVELS: 3
27+
ENABLED: 'true'
28+
MUSHROOM_COW:
29+
LEVELS: 15
30+
ENABLED: 'true'
31+
HORSE:
32+
LEVELS: 3
33+
ENABLED: 'true'
34+
35+
insufficientLEVELS: 'You lack sufficient understanding to perform this ritual.'

src/main/resources/plugin.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: BSBMechanics
2+
version: ${project.version}
3+
main: me.shakeforprotein.bsbmechanics.BSBMechanics
4+
authors: [ShakeforProtein]
5+
description: Custm game mechanics for Bentbox Skyblock and Acid Islands.
6+
website: http://treebomc.com

0 commit comments

Comments
 (0)