initial commit
This commit is contained in:
commit
4885aa1adf
9 changed files with 196 additions and 0 deletions
26
.classpath
Normal file
26
.classpath
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/target/
|
23
.project
Normal file
23
.project
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>giants</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
16
.settings/org.eclipse.jdt.core.prefs
Normal file
16
.settings/org.eclipse.jdt.core.prefs
Normal file
|
@ -0,0 +1,16 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
4
.settings/org.eclipse.m2e.core.prefs
Normal file
4
.settings/org.eclipse.m2e.core.prefs
Normal file
|
@ -0,0 +1,4 @@
|
|||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
27
pom.xml
Normal file
27
pom.xml
Normal file
|
@ -0,0 +1,27 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>giants</groupId>
|
||||
<artifactId>giants</artifactId>
|
||||
<version>1.0-b1</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.18.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
86
src/main/java/pl/minecon724/giants/Main.java
Normal file
86
src/main/java/pl/minecon724/giants/Main.java
Normal file
|
@ -0,0 +1,86 @@
|
|||
package pl.minecon724.giants;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class Main extends JavaPlugin implements Listener {
|
||||
File configFile = new File(getDataFolder(), "config.yml");
|
||||
FileConfiguration config;
|
||||
|
||||
Random rnd = new Random();
|
||||
|
||||
boolean ai;
|
||||
double chance;
|
||||
Map<PotionEffectType, Integer> effects;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (!(configFile.exists())) {
|
||||
saveResource("config.yml", false);
|
||||
}
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
ai = config.getBoolean("ai");
|
||||
chance = config.getDouble("chance");
|
||||
for (Object s : config.getList("effects")) {
|
||||
try {
|
||||
String[] parts = ((String) s).split(":");
|
||||
if (!(StringUtils.isNumeric(parts[1]))) {
|
||||
throw new IllegalArgumentException(parts[1] + " is not a number");
|
||||
}
|
||||
PotionEffectType effectType = PotionEffectType.getByName(parts[0]);
|
||||
if (effectType == null) {
|
||||
throw new IllegalArgumentException(parts[0] + " is not a PotionEffectType");
|
||||
}
|
||||
Integer duration = Integer.valueOf(parts[1]);
|
||||
effects.put(effectType, duration);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Bukkit.getLogger().severe("Unable to parse potion effects!");
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
getServer().getPluginManager().registerEvents(this, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void entitySpawn(EntitySpawnEvent e) {
|
||||
if (e.getEntityType() == EntityType.ZOMBIE) {
|
||||
if (rnd.nextDouble() <= chance) {
|
||||
e.setCancelled(true);
|
||||
spawnGiant(ai, e.getLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Entity spawnGiant(boolean ai, Location pos) {
|
||||
LivingEntity entity = (LivingEntity) pos.getWorld().spawnEntity(pos, EntityType.GIANT);
|
||||
if (ai) {
|
||||
//entity.addPassenger(pos.getWorld().spawnEntity(pos, EntityType.HUSK));
|
||||
entity.setAI(true);
|
||||
}
|
||||
for (Entry<PotionEffectType, Integer> t : effects.entrySet()) {
|
||||
PotionEffect effect = new PotionEffect(t.getKey(), Integer.MAX_VALUE, t.getValue());
|
||||
effect.apply(entity);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
8
src/main/resources/config.yml
Normal file
8
src/main/resources/config.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
ai: true
|
||||
# Spawning chance, from 0 to 1
|
||||
chance: 0.02
|
||||
# Additional potion effects
|
||||
# type:amplifier
|
||||
# See https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html
|
||||
effects:
|
||||
- "JUMP:2"
|
5
src/main/resources/plugin.yml
Normal file
5
src/main/resources/plugin.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
name: Giants
|
||||
version: 1.0
|
||||
api-version: 1.18
|
||||
main: pl.minecon724.giants.Main
|
||||
author: Minecon724
|
Loading…
Reference in a new issue