Initial commit
This commit is contained in:
3
Plugins/Old/Corona/.idea/.gitignore
generated
vendored
Normal file
3
Plugins/Old/Corona/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
8
Plugins/Old/Corona/.idea/artifacts/Corona.xml
generated
Normal file
8
Plugins/Old/Corona/.idea/artifacts/Corona.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="Corona">
|
||||
<output-path>$PROJECT_DIR$/../../../Plugins</output-path>
|
||||
<root id="archive" name="Corona.jar">
|
||||
<element id="module-output" name="Corona" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
||||
11
Plugins/Old/Corona/.idea/libraries/spigot_1_8_8.xml
generated
Normal file
11
Plugins/Old/Corona/.idea/libraries/spigot_1_8_8.xml
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="spigot 1.8.8">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/../Spigot Versions/spigot 1.8.8.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/../Spigot Versions/spigot 1.8.8.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
6
Plugins/Old/Corona/.idea/misc.xml
generated
Normal file
6
Plugins/Old/Corona/.idea/misc.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
8
Plugins/Old/Corona/.idea/modules.xml
generated
Normal file
8
Plugins/Old/Corona/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Corona.iml" filepath="$PROJECT_DIR$/Corona.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
12
Plugins/Old/Corona/Corona.iml
Normal file
12
Plugins/Old/Corona/Corona.iml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="spigot 1.8.8" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4
Plugins/Old/Corona/out/production/Corona/plugin.yml
Normal file
4
Plugins/Old/Corona/out/production/Corona/plugin.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
name: Corona
|
||||
version: 1.8
|
||||
main: de.craftix.corona.Main
|
||||
author: deiner-Mudda
|
||||
17
Plugins/Old/Corona/src/de/craftix/corona/ActionbarAPI.java
Normal file
17
Plugins/Old/Corona/src/de/craftix/corona/ActionbarAPI.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package de.craftix.corona;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ActionbarAPI {
|
||||
|
||||
public static void show(Player p, String content){
|
||||
IChatBaseComponent base = IChatBaseComponent.ChatSerializer.a("{\"text\": \"\"}").a(content);
|
||||
PacketPlayOutChat chat = new PacketPlayOutChat(base, (byte) 2);
|
||||
CraftPlayer cp = (CraftPlayer)p;
|
||||
cp.getHandle().playerConnection.sendPacket(chat);
|
||||
}
|
||||
|
||||
}
|
||||
82
Plugins/Old/Corona/src/de/craftix/corona/CoronaAPI.java
Normal file
82
Plugins/Old/Corona/src/de/craftix/corona/CoronaAPI.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package de.craftix.corona;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
public class CoronaAPI {
|
||||
public static ArrayList<Player> coronaPlayer = new ArrayList<>();
|
||||
private static ArrayList<PotionEffectType> effects = new ArrayList<>();
|
||||
private static int timerID;
|
||||
private static int infectionTimerID;
|
||||
|
||||
public static void setup(){
|
||||
effects.add(PotionEffectType.BLINDNESS);
|
||||
effects.add(PotionEffectType.SLOW);
|
||||
effects.add(PotionEffectType.WEAKNESS);
|
||||
effects.add(PotionEffectType.CONFUSION);
|
||||
startInfectionTimer();
|
||||
}
|
||||
|
||||
public static void giveCorona(Player p){
|
||||
CoronaAPI.coronaPlayer.add(p);
|
||||
new CoronaPlayer(p);
|
||||
ActionbarAPI.show(p, "§cDu hast nun Corona!");
|
||||
}
|
||||
|
||||
public static void sendEffects(Player p){
|
||||
Random rand = new Random();
|
||||
int value = rand.nextInt(4);
|
||||
PotionEffect effect = new PotionEffect(effects.get(value), 250, 255);
|
||||
p.addPotionEffect(effect);
|
||||
}
|
||||
|
||||
public static void startTimer(){
|
||||
timerID = Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.getInstance(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player p : coronaPlayer){
|
||||
for (PotionEffect pe : p.getActivePotionEffects()){
|
||||
for (PotionEffectType corona : effects){
|
||||
if (pe.getType().equals(corona)) return;
|
||||
}
|
||||
}
|
||||
Random rand = new Random();
|
||||
if (rand.nextInt(5) < 2) continue;
|
||||
ActionbarAPI.show(p, "§cZufällige Corona attacke!");
|
||||
sendEffects(p);
|
||||
}
|
||||
}
|
||||
}, 0, 500);
|
||||
}
|
||||
|
||||
public static void stopTimer(){
|
||||
Bukkit.getScheduler().cancelTask(timerID);
|
||||
}
|
||||
|
||||
private static void startInfectionTimer(){
|
||||
infectionTimerID = Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.getInstance(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player all : Bukkit.getOnlinePlayers()){
|
||||
for (Player corona : coronaPlayer){
|
||||
if (corona == all) continue;
|
||||
if (all.getLocation().distance(corona.getLocation()) <= 2){
|
||||
CoronaAPI.coronaPlayer.add(all);
|
||||
new CoronaPlayer(all);
|
||||
ActionbarAPI.show(all, "§cDu wurdest mit Corona infiziert!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0, 50);
|
||||
}
|
||||
|
||||
public static void stopInfectionTimer(){
|
||||
Bukkit.getScheduler().cancelTask(infectionTimerID);
|
||||
}
|
||||
}
|
||||
24
Plugins/Old/Corona/src/de/craftix/corona/CoronaPlayer.java
Normal file
24
Plugins/Old/Corona/src/de/craftix/corona/CoronaPlayer.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package de.craftix.corona;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CoronaPlayer {
|
||||
public Player p;
|
||||
private int timerID;
|
||||
public CoronaPlayer(Player p){
|
||||
this.p = p;
|
||||
startTimer();
|
||||
}
|
||||
|
||||
private void startTimer(){
|
||||
timerID = Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.getInstance(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CoronaAPI.coronaPlayer.remove(p);
|
||||
ActionbarAPI.show(p, "§aDu hast Corona überstanden!");
|
||||
Bukkit.getScheduler().cancelTask(timerID);
|
||||
}
|
||||
}, 12000, 1);
|
||||
}
|
||||
}
|
||||
24
Plugins/Old/Corona/src/de/craftix/corona/Listener/onEat.java
Normal file
24
Plugins/Old/Corona/src/de/craftix/corona/Listener/onEat.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package de.craftix.corona.Listener;
|
||||
|
||||
import de.craftix.corona.CoronaAPI;
|
||||
import de.craftix.corona.Main;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class onEat implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onEatEvent(PlayerItemConsumeEvent event){
|
||||
if (!Main.coronaFood.contains(event.getItem().getType())) return;
|
||||
Random rand = new Random();
|
||||
if (rand.nextBoolean() && !CoronaAPI.coronaPlayer.contains(event.getPlayer())){
|
||||
Player p = event.getPlayer();
|
||||
CoronaAPI.giveCorona(p);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
46
Plugins/Old/Corona/src/de/craftix/corona/Main.java
Normal file
46
Plugins/Old/Corona/src/de/craftix/corona/Main.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package de.craftix.corona;
|
||||
|
||||
import de.craftix.corona.Listener.onEat;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
private static Main instance;
|
||||
public static ArrayList<Material> coronaFood = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
coronaFood.add(Material.RAW_BEEF);
|
||||
coronaFood.add(Material.RAW_CHICKEN);
|
||||
coronaFood.add(Material.RAW_FISH);
|
||||
coronaFood.add(Material.PORK);
|
||||
coronaFood.add(Material.POTATO);
|
||||
coronaFood.add(Material.POISONOUS_POTATO);
|
||||
coronaFood.add(Material.RABBIT);
|
||||
coronaFood.add(Material.MUTTON);
|
||||
registerListener();
|
||||
CoronaAPI.setup();
|
||||
CoronaAPI.startTimer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
CoronaAPI.stopTimer();
|
||||
CoronaAPI.stopInfectionTimer();
|
||||
}
|
||||
|
||||
private void registerListener(){
|
||||
PluginManager pm = Bukkit.getPluginManager();
|
||||
pm.registerEvents(new onEat(), this);
|
||||
}
|
||||
|
||||
public static Main getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
4
Plugins/Old/Corona/src/plugin.yml
Normal file
4
Plugins/Old/Corona/src/plugin.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
name: Corona
|
||||
version: 1.8
|
||||
main: de.craftix.corona.Main
|
||||
author: deiner-Mudda
|
||||
Reference in New Issue
Block a user