测试版
This commit is contained in:
commit
62a67c3869
40
.gitignore
vendored
Normal file
40
.gitignore
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
/.idea/
|
||||
/out/
|
37
pom.xml
Normal file
37
pom.xml
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>DemonWuDeng</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>public-rpg</id>
|
||||
<url>https://repo.aurora-pixels.com/repository/public-rpg/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.Demon.DemonPlugin</groupId>
|
||||
<artifactId>DemonAPI</artifactId>
|
||||
<version>1.2.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
90
src/main/java/me/Demon/DemonWuDeng/GFCJJ/LampAPI.java
Normal file
90
src/main/java/me/Demon/DemonWuDeng/GFCJJ/LampAPI.java
Normal file
|
@ -0,0 +1,90 @@
|
|||
package me.Demon.DemonWuDeng.GFCJJ;
|
||||
|
||||
import me.Demon.DemonPlugin.DemonAPI;
|
||||
import me.Demon.DemonWuDeng.LampData;
|
||||
import me.Demon.DemonWuDeng.Main;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public abstract class LampAPI {
|
||||
|
||||
public static void Start_Event(LampData dataAPI){
|
||||
int lamp_1 = 1;
|
||||
int rand = DemonAPI.getRandomInt(100,1);
|
||||
int probnability = dataAPI.getProbnability(lamp_1);
|
||||
// Bukkit.getConsoleSender().sendMessage("# 灯1 = "+rand+" < "+probnability);
|
||||
if (rand < probnability) {
|
||||
MachineAPI.Spawner_DropItems(dataAPI,lamp_1);
|
||||
MachineAPI.Spawner_RedBlock(dataAPI,lamp_1);
|
||||
dataAPI.setWudeng2(true);
|
||||
}
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
if(dataAPI.isWudeng2()){
|
||||
int lamp_2 = 2;
|
||||
int rand = DemonAPI.getRandomInt(100,1);
|
||||
int probnability = dataAPI.getProbnability(lamp_2);
|
||||
// Bukkit.getConsoleSender().sendMessage("# 灯2 = "+rand+" < "+probnability);
|
||||
if (rand < probnability) {
|
||||
MachineAPI.Spawner_DropItems(dataAPI,lamp_2);
|
||||
MachineAPI.Spawner_RedBlock(dataAPI,lamp_2);
|
||||
dataAPI.setWudeng3(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskLater(Main.plugin, 10L);
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
if(dataAPI.isWudeng3()){
|
||||
int lamp_3 = 3;
|
||||
int rand = DemonAPI.getRandomInt(100,1);
|
||||
int probnability = dataAPI.getProbnability(lamp_3);
|
||||
// Bukkit.getConsoleSender().sendMessage("# 灯3 = "+rand+" < "+probnability);
|
||||
if (rand < probnability) {
|
||||
MachineAPI.Spawner_DropItems(dataAPI,lamp_3);
|
||||
MachineAPI.Spawner_RedBlock(dataAPI,lamp_3);
|
||||
dataAPI.setWudeng4(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskLater(Main.plugin, 20L);
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
if(dataAPI.isWudeng4()){
|
||||
int lamp_4 = 4;
|
||||
int rand = DemonAPI.getRandomInt(100,1);
|
||||
int probnability = dataAPI.getProbnability(lamp_4);
|
||||
// Bukkit.getConsoleSender().sendMessage("# 灯4 = "+rand+" < "+probnability);
|
||||
if (rand < probnability) {
|
||||
MachineAPI.Spawner_DropItems(dataAPI,lamp_4);
|
||||
MachineAPI.Spawner_RedBlock(dataAPI,lamp_4);
|
||||
dataAPI.setWudeng5(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskLater(Main.plugin, 30L);
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
if(dataAPI.isWudeng5()){
|
||||
int lamp_5 = 5;
|
||||
int rand = DemonAPI.getRandomInt(100,1);
|
||||
int probnability = dataAPI.getProbnability(lamp_5);
|
||||
// Bukkit.getConsoleSender().sendMessage("# 灯5 = "+rand+" < "+probnability);
|
||||
if (rand < probnability) {
|
||||
MachineAPI.Spawner_DropItems(dataAPI,lamp_5);
|
||||
MachineAPI.Spawner_RedBlock(dataAPI,lamp_5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskLater(Main.plugin, 40L);
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
dataAPI.setStart(false);
|
||||
dataAPI.setWudeng2(false);
|
||||
dataAPI.setWudeng3(false);
|
||||
dataAPI.setWudeng4(false);
|
||||
dataAPI.setWudeng5(false);
|
||||
}
|
||||
}.runTaskLater(Main.plugin, 60L);
|
||||
}
|
||||
|
||||
}
|
62
src/main/java/me/Demon/DemonWuDeng/GFCJJ/MachineAPI.java
Normal file
62
src/main/java/me/Demon/DemonWuDeng/GFCJJ/MachineAPI.java
Normal file
|
@ -0,0 +1,62 @@
|
|||
package me.Demon.DemonWuDeng.GFCJJ;
|
||||
|
||||
import me.Demon.DemonPlugin.DemonAPI;
|
||||
import me.Demon.DemonWuDeng.LampData;
|
||||
import me.Demon.DemonWuDeng.Main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class MachineAPI implements Listener {
|
||||
|
||||
public static void Spawner_DropItems(LampData dataAPI, int a){
|
||||
if(a == 5){
|
||||
if(DemonAPI.getRandomInt(1000,1) >= 500){
|
||||
a = 6;
|
||||
}
|
||||
}
|
||||
ItemStack item = dataAPI.getReward_Item(a);
|
||||
if(DemonAPI.itemIsNull(item)){
|
||||
return;
|
||||
}
|
||||
int amount = dataAPI.getReward_Item(a).getAmount();
|
||||
if(amount <= 1){
|
||||
return;
|
||||
}
|
||||
World world = Bukkit.getWorld("wudeng");
|
||||
if(world == null) {
|
||||
return;
|
||||
}
|
||||
String Lamp_Key = dataAPI.getLampKey();
|
||||
Location drop_loc = Main.MachineAPI.get(Lamp_Key).getDrop_loc(a);
|
||||
|
||||
ItemStack drop_items = item.clone();
|
||||
drop_items.setAmount(1);
|
||||
world.dropItem(drop_loc, drop_items);
|
||||
|
||||
ItemStack new_items = item.clone();
|
||||
new_items.setAmount(item.getAmount() - 1);
|
||||
dataAPI.setReward_Item(a,new_items);
|
||||
}
|
||||
|
||||
public static void Spawner_RedBlock(LampData dataAPI, int a){
|
||||
World world = Bukkit.getWorld("wudeng");
|
||||
if(world == null) {
|
||||
return;
|
||||
}
|
||||
String Lamp_Key = dataAPI.getLampKey();
|
||||
Location block_Loc = Main.MachineAPI.get(Lamp_Key).getBlock_loc(a);
|
||||
Block block = block_Loc.getBlock();
|
||||
block.setType(Material.REDSTONE_BLOCK);
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}.runTaskLater(Main.plugin, 40L);
|
||||
}
|
||||
}
|
133
src/main/java/me/Demon/DemonWuDeng/LampData.java
Normal file
133
src/main/java/me/Demon/DemonWuDeng/LampData.java
Normal file
|
@ -0,0 +1,133 @@
|
|||
package me.Demon.DemonWuDeng;
|
||||
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class LampData {
|
||||
|
||||
private final String LampKey;
|
||||
private final String CJQ_Lore;
|
||||
private final String CJQ_Name;
|
||||
private ItemStack item_1;
|
||||
private ItemStack item_2;
|
||||
private ItemStack item_3;
|
||||
private ItemStack item_4;
|
||||
private ItemStack item_5;
|
||||
private ItemStack item_6;
|
||||
|
||||
private boolean start;
|
||||
private boolean wudeng2;
|
||||
private boolean wudeng3;
|
||||
private boolean wudeng4;
|
||||
private boolean wudeng5;
|
||||
|
||||
private final int probnability_1;
|
||||
private final int probnability_2;
|
||||
private final int probnability_3;
|
||||
private final int probnability_4;
|
||||
private final int probnability_5;
|
||||
|
||||
public LampData(String LampKey,FileConfiguration yml){
|
||||
this.LampKey = LampKey;
|
||||
String str = LampKey+".";
|
||||
this.CJQ_Name = yml.getString(str+"Paper_Name");
|
||||
this.CJQ_Lore = yml.getString(str+"Paper_Lore");
|
||||
|
||||
this.item_1 = yml.getItemStack(str+"1_Reward");
|
||||
this.item_2 = yml.getItemStack(str+"2_Reward");
|
||||
this.item_3 = yml.getItemStack(str+"3_Reward");
|
||||
this.item_4 = yml.getItemStack(str+"4_Reward");
|
||||
this.item_5 = yml.getItemStack(str+"5_Reward");
|
||||
this.item_6 = yml.getItemStack(str+"6_Reward");
|
||||
|
||||
this.probnability_1 = yml.getInt(str+"Probability."+"1");
|
||||
this.probnability_2 = yml.getInt(str+"Probability."+"2");
|
||||
this.probnability_3 = yml.getInt(str+"Probability."+"3");
|
||||
this.probnability_4 = yml.getInt(str+"Probability."+"4");
|
||||
this.probnability_5 = yml.getInt(str+"Probability."+"5");
|
||||
|
||||
}
|
||||
|
||||
public void saveLampData(FileConfiguration yml){
|
||||
String str = LampKey+".";
|
||||
yml.set(str+"1_Reward",item_1);
|
||||
yml.set(str+"2_Reward",item_2);
|
||||
yml.set(str+"3_Reward",item_3);
|
||||
yml.set(str+"4_Reward",item_4);
|
||||
yml.set(str+"5_Reward",item_5);
|
||||
yml.set(str+"6_Reward",item_6);
|
||||
|
||||
}
|
||||
|
||||
public String getLampKey() {
|
||||
return LampKey;
|
||||
}
|
||||
|
||||
public String getCJQ_Name() {return CJQ_Name;}
|
||||
public String getCJQ_Lore() {return CJQ_Lore;}
|
||||
|
||||
public boolean isStart() {return start;}
|
||||
public boolean isWudeng2() {return wudeng2;}
|
||||
public boolean isWudeng3() {return wudeng3;}
|
||||
public boolean isWudeng4() {return wudeng4;}
|
||||
public boolean isWudeng5() {return wudeng5;}
|
||||
|
||||
public void setStart(boolean start) {this.start = start;}
|
||||
public void setWudeng2(boolean wudeng2) {this.wudeng2 = wudeng2;}
|
||||
public void setWudeng3(boolean wudeng3) {this.wudeng3 = wudeng3;}
|
||||
public void setWudeng4(boolean wudeng4) {this.wudeng4 = wudeng4;}
|
||||
public void setWudeng5(boolean wudeng5) {this.wudeng5 = wudeng5;}
|
||||
|
||||
public ItemStack getReward_Item(int a){
|
||||
if(a == 2){
|
||||
return this.item_2;
|
||||
}else if(a == 3){
|
||||
return this.item_3;
|
||||
}else if(a == 4){
|
||||
return this.item_4;
|
||||
}else if(a == 5){
|
||||
return this.item_5;
|
||||
}else if(a == 6){
|
||||
return this.item_6;
|
||||
}else{
|
||||
return this.item_1;
|
||||
}
|
||||
}
|
||||
public void setReward_Item(int a,ItemStack items){
|
||||
if(a == 2){
|
||||
this.item_2 = items;
|
||||
}else if(a == 3){
|
||||
this.item_3 = items;
|
||||
}else if(a == 4){
|
||||
this.item_4 = items;
|
||||
}else if(a == 5){
|
||||
this.item_5 = items;
|
||||
}else if(a == 6){
|
||||
this.item_6 = items;
|
||||
}else{
|
||||
this.item_1 = items;
|
||||
}
|
||||
}
|
||||
|
||||
public void setItem_1(ItemStack item_1) {this.item_1 = item_1;}
|
||||
public void setItem_2(ItemStack item_2) {this.item_2 = item_2;}
|
||||
public void setItem_3(ItemStack item_3) {this.item_3 = item_3;}
|
||||
public void setItem_4(ItemStack item_4) {this.item_4 = item_4;}
|
||||
public void setItem_5(ItemStack item_5) {this.item_5 = item_5;}
|
||||
public void setItem_6(ItemStack item_6) {this.item_6 = item_6;}
|
||||
|
||||
public int getProbnability(int a){
|
||||
if(a == 2){
|
||||
return this.probnability_2;
|
||||
}else if(a == 3){
|
||||
return this.probnability_3;
|
||||
}else if(a == 4){
|
||||
return this.probnability_4;
|
||||
}else if(a == 5){
|
||||
return this.probnability_5;
|
||||
}else{
|
||||
return this.probnability_1;
|
||||
}
|
||||
}
|
||||
}
|
69
src/main/java/me/Demon/DemonWuDeng/MachineData.java
Normal file
69
src/main/java/me/Demon/DemonWuDeng/MachineData.java
Normal file
|
@ -0,0 +1,69 @@
|
|||
package me.Demon.DemonWuDeng;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
public class MachineData {
|
||||
private final String MachineKey;
|
||||
private final Location drop_loc1;
|
||||
private final Location drop_loc2;
|
||||
private final Location drop_loc3;
|
||||
private final Location drop_loc4;
|
||||
private final Location drop_loc5;
|
||||
private final Location block_loc1;
|
||||
private final Location block_loc2;
|
||||
private final Location block_loc3;
|
||||
private final Location block_loc4;
|
||||
private final Location block_loc5;
|
||||
|
||||
public MachineData(String MachineKey,FileConfiguration yml){
|
||||
this.MachineKey = MachineKey;
|
||||
this.drop_loc1 = getLoadDataLoc("Drop_Items",1,yml);
|
||||
this.drop_loc2 = getLoadDataLoc("Drop_Items",2,yml);
|
||||
this.drop_loc3 = getLoadDataLoc("Drop_Items",3,yml);
|
||||
this.drop_loc4 = getLoadDataLoc("Drop_Items",4,yml);
|
||||
this.drop_loc5 = getLoadDataLoc("Drop_Items",5,yml);
|
||||
|
||||
this.block_loc1 = getLoadDataLoc("RedStone_Block",1,yml);
|
||||
this.block_loc2 = getLoadDataLoc("RedStone_Block",2,yml);
|
||||
this.block_loc3 = getLoadDataLoc("RedStone_Block",3,yml);
|
||||
this.block_loc4 = getLoadDataLoc("RedStone_Block",4,yml);
|
||||
this.block_loc5 = getLoadDataLoc("RedStone_Block",5,yml);
|
||||
}
|
||||
|
||||
public Location getLoadDataLoc(String type,int a,FileConfiguration yml){
|
||||
String drop_str = MachineKey+"."+type;
|
||||
double x = yml.getDouble(drop_str+"."+a+".x");
|
||||
double y = yml.getDouble(drop_str+"."+a+".y");
|
||||
double z = yml.getDouble(drop_str+"."+a+".z");
|
||||
return new Location(Bukkit.getWorld("wudeng"),x,y,z);
|
||||
}
|
||||
|
||||
public Location getBlock_loc(int a) {
|
||||
if(a == 2) {
|
||||
return block_loc2;
|
||||
}else if(a == 3) {
|
||||
return block_loc3;
|
||||
}else if(a == 4) {
|
||||
return block_loc4;
|
||||
}else if(a == 5) {
|
||||
return block_loc5;
|
||||
}
|
||||
return block_loc1;
|
||||
}
|
||||
|
||||
public Location getDrop_loc(int a) {
|
||||
if(a == 2) {
|
||||
return drop_loc2;
|
||||
}else if(a == 3) {
|
||||
return drop_loc3;
|
||||
}else if(a == 4) {
|
||||
return drop_loc4;
|
||||
}else if(a == 5) {
|
||||
return drop_loc5;
|
||||
}
|
||||
return drop_loc1;
|
||||
}
|
||||
|
||||
}
|
100
src/main/java/me/Demon/DemonWuDeng/Main.java
Normal file
100
src/main/java/me/Demon/DemonWuDeng/Main.java
Normal file
|
@ -0,0 +1,100 @@
|
|||
package me.Demon.DemonWuDeng;
|
||||
|
||||
import me.Demon.DemonWuDeng.GFCJJ.MachineAPI;
|
||||
import me.Demon.DemonWuDeng.listener.SignClick;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
|
||||
public static Main plugin;
|
||||
public static String prefix = "§7[§6战争领域§7] §f";
|
||||
public static List<String> getFile_Name = new ArrayList<>();
|
||||
public static HashMap<String,MachineData> MachineAPI = new HashMap<>();
|
||||
public static HashMap<String,LampData> DataAPI = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
plugin = this;
|
||||
saveDefaultConfig();
|
||||
getFile_Name.addAll(Load_FileName_List());
|
||||
Load_MachineData_or_LampData();
|
||||
Bukkit.getConsoleSender().sendMessage("§e[DemonWuDeng] §r载入抽奖方案["+DataAPI.size()+"]");
|
||||
Bukkit.getConsoleSender().sendMessage("§e[DemonWuDeng] §r载入抽奖机["+MachineAPI.size()+"]");
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new SignClick(), plugin);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new MachineAPI(), plugin);
|
||||
Bukkit.getConsoleSender().sendMessage("§e[DemonWuDeng] §r正在启动插件...");
|
||||
}
|
||||
|
||||
public static void Load_MachineData_or_LampData(){
|
||||
for (String File_Name : getFile_Name) {
|
||||
File file = new File("plugins/DemonWuDeng/配置方案", File_Name+".yml");
|
||||
FileConfiguration yml = YamlConfiguration.loadConfiguration(file);
|
||||
DataAPI.put(File_Name,new LampData(File_Name,yml));
|
||||
MachineAPI.put(File_Name,new MachineData(File_Name,yml));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
SaveLampData();
|
||||
Bukkit.getConsoleSender().sendMessage("§e[DemonWuDeng] §r正在关闭插件...");
|
||||
}
|
||||
|
||||
public void SaveLampData(){
|
||||
int a = 0;
|
||||
for (String Lamp_key : DataAPI.keySet()) {
|
||||
File file = new File("plugins/DemonWuDeng/配置方案", Lamp_key+".yml");
|
||||
YamlConfiguration yml = YamlConfiguration.loadConfiguration(file);
|
||||
DataAPI.get(Lamp_key).saveLampData(yml);
|
||||
saveFileConfig(yml,file);
|
||||
a++;
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage("§e[DemonWuDeng] §r保存抽奖数据["+a+"]个");
|
||||
}
|
||||
|
||||
public boolean onCommand (CommandSender sender, Command cmd, String Command, String[] args) {
|
||||
if (Command.equalsIgnoreCase("wudeng") && sender.isOp()) {
|
||||
if(args.length == 1 && args[0].equalsIgnoreCase("save")){
|
||||
SaveLampData();
|
||||
sender.sendMessage(prefix+"数据保存成功.");
|
||||
}
|
||||
if(args.length == 1 && args[0].equalsIgnoreCase("reload")){
|
||||
getFile_Name.clear();
|
||||
MachineAPI.clear();
|
||||
DataAPI.clear();
|
||||
getFile_Name.addAll(Load_FileName_List());
|
||||
Load_MachineData_or_LampData();
|
||||
sender.sendMessage(prefix+"配置文件重载完成.");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List<String> Load_FileName_List(){
|
||||
List<String> list = new ArrayList<>();
|
||||
File plans = new File("./plugins/DemonWuDeng", "配置方案");
|
||||
File[] files = plans.listFiles();
|
||||
File[] arrayOfFile1;
|
||||
int j = (Objects.requireNonNull(arrayOfFile1 = files)).length;
|
||||
for (int i = 0; i < j; i++) {
|
||||
File s = arrayOfFile1[i];
|
||||
String file_Name = s.getName().replace(".yml","");
|
||||
list.add(file_Name);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static void saveFileConfig(YamlConfiguration yml,File file){ try { yml.save(file); }catch (IOException e){e.printStackTrace();} }
|
||||
}
|
69
src/main/java/me/Demon/DemonWuDeng/listener/SignClick.java
Normal file
69
src/main/java/me/Demon/DemonWuDeng/listener/SignClick.java
Normal file
|
@ -0,0 +1,69 @@
|
|||
package me.Demon.DemonWuDeng.listener;
|
||||
|
||||
import me.Demon.DemonPlugin.DemonAPI;
|
||||
import me.Demon.DemonWuDeng.GFCJJ.LampAPI;
|
||||
import me.Demon.DemonWuDeng.LampData;
|
||||
import me.Demon.DemonWuDeng.Main;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class SignClick implements Listener {
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onclick_sign(PlayerInteractEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) {
|
||||
return;
|
||||
}
|
||||
if (e.getClickedBlock().getState() instanceof Sign) {
|
||||
Sign s = (Sign) e.getClickedBlock().getState();
|
||||
if (s.getLine(0).equalsIgnoreCase("§a§l[五灯抽奖机]")) {
|
||||
String lamp_type = s.getLine(2).replace("§7", "");
|
||||
LampData dataAPI = Main.DataAPI.get(lamp_type);
|
||||
if (dataAPI == null) {
|
||||
p.sendMessage(Main.prefix + "该五灯抽奖机已停止维护.");
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
|
||||
return;
|
||||
}
|
||||
if (dataAPI.isStart()) {
|
||||
p.sendMessage(Main.prefix + "§f五灯抽奖机正在冷却中...");
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
|
||||
return;
|
||||
}
|
||||
ItemStack item = p.getInventory().getItemInHand();
|
||||
boolean butt = false;
|
||||
if (!DemonAPI.itemIsNull(item) && !DemonAPI.itemIsLore(item) && item.getType() == Material.PAPER) {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta.getDisplayName().equalsIgnoreCase(dataAPI.getCJQ_Name())) {
|
||||
if (meta.getLore().contains(dataAPI.getCJQ_Lore())) {
|
||||
butt = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (butt) {
|
||||
// 扣除抽奖券
|
||||
if (item.getAmount() == 1) {
|
||||
p.getInventory().setItemInHand(new ItemStack(Material.AIR));
|
||||
} else {
|
||||
item.setAmount(item.getAmount() - 1);
|
||||
}
|
||||
dataAPI.setStart(true);
|
||||
LampAPI.Start_Event(dataAPI);
|
||||
} else {
|
||||
p.sendMessage(Main.prefix + "§f请手持" + dataAPI.getCJQ_Name() + "§f再尝试右键木牌.");
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
79
src/main/resources/config.yml
Normal file
79
src/main/resources/config.yml
Normal file
|
@ -0,0 +1,79 @@
|
|||
WuDeng_Reward:
|
||||
1:
|
||||
Amount: 128
|
||||
Items:
|
||||
==: org.bukkit.inventory.ItemStack
|
||||
v: 2975
|
||||
type: IRON_INGOT
|
||||
2:
|
||||
Amount: 128
|
||||
Items:
|
||||
==: org.bukkit.inventory.ItemStack
|
||||
v: 2975
|
||||
type: GOLD_INGOT
|
||||
3:
|
||||
Amount: 128
|
||||
Items:
|
||||
==: org.bukkit.inventory.ItemStack
|
||||
v: 2975
|
||||
type: EMERALD
|
||||
meta:
|
||||
==: ItemMeta
|
||||
meta-type: UNSPECIFIC
|
||||
display-name: '{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"["},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"green","text":"通用"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"]
|
||||
"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gold","text":"伺服器貨幣"}],"text":""}'
|
||||
lore:
|
||||
- '{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"伺服器通用貨幣"}],"text":""}'
|
||||
- '{"extra":[{"bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"red","text":"✪"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"是價值較高的貨幣!"}],"text":""}'
|
||||
enchants:
|
||||
PROTECTION_ENVIRONMENTAL: 1
|
||||
ItemFlags:
|
||||
- HIDE_ENCHANTS
|
||||
4:
|
||||
Amount: 128
|
||||
Items:
|
||||
==: org.bukkit.inventory.ItemStack
|
||||
v: 2975
|
||||
type: PAPER
|
||||
meta:
|
||||
==: ItemMeta
|
||||
meta-type: UNSPECIFIC
|
||||
display-name: '{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"yellow","text":"現金券
|
||||
"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"["},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gold","text":"500"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"]"}],"text":""}'
|
||||
lore:
|
||||
- '{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"dark_gray","text":"其他類"}],"text":""}'
|
||||
- '{"extra":[{"bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"green","text":"✔"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"右鍵開啓此券"}],"text":""}'
|
||||
- '{"extra":[{"bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"green","text":"✔"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"使用後增加500金幣並消失"}],"text":""}'
|
||||
5_1:
|
||||
Amount: 128
|
||||
Items:
|
||||
==: org.bukkit.inventory.ItemStack
|
||||
v: 2975
|
||||
type: PAPER
|
||||
meta:
|
||||
==: ItemMeta
|
||||
meta-type: UNSPECIFIC
|
||||
display-name: '{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"green","text":"點券
|
||||
"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"["},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gold","text":"1"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"]"}],"text":""}'
|
||||
lore:
|
||||
- '{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"dark_gray","text":"其他類"}],"text":""}'
|
||||
- '{"extra":[{"bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"green","text":"✔"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"右鍵開啓此券"}],"text":""}'
|
||||
- '{"extra":[{"bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"green","text":"✔"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"使用後增加1點券並消失"}],"text":""}'
|
||||
5_2:
|
||||
Amount: 128
|
||||
Items:
|
||||
==: org.bukkit.inventory.ItemStack
|
||||
v: 2975
|
||||
ype: PLAYER_HEAD
|
||||
meta:
|
||||
==: ItemMeta
|
||||
meta-type: SKULL
|
||||
display-name: '{"text":"§e§l小雞雞"}'
|
||||
lore:
|
||||
- '{"text":"§7五燈限量獎品"}'
|
||||
skull-owner:
|
||||
==: PlayerProfile
|
||||
uniqueId: 04049c90-d3e9-4621-9caf-00000aaa4267
|
||||
properties:
|
||||
- name: textures
|
||||
value: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTRkODE2YTQ3NWIzZjMxM2I2MjBkNjViZjkzNTg5MzFiNDZhZjljOGY0ZTdjOWFlNjQ3MDg4ODBiZWE2YmUifX19
|
6
src/main/resources/plugin.yml
Normal file
6
src/main/resources/plugin.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
name: DemonWuDeng
|
||||
main: me.Demon.DemonWuDeng.Main
|
||||
version: 1.0
|
||||
api-version: 1.18
|
||||
commands:
|
||||
wudeng:
|
120
src/main/resources/配置方案/GFCJJ.yml
Normal file
120
src/main/resources/配置方案/GFCJJ.yml
Normal file
|
@ -0,0 +1,120 @@
|
|||
GFCJJ:
|
||||
Paper_Name: "§7[§a官方§7] §6五燈抽獎券I"
|
||||
Paper_Lore: "§b憑此券可參與五燈抽獎"
|
||||
Probability:
|
||||
'1': 90
|
||||
'2': 70
|
||||
'3': 40
|
||||
'4': 20
|
||||
'5': 10
|
||||
Drop_Items:
|
||||
'1':
|
||||
x: 28.5
|
||||
y: 53.0
|
||||
z: 0.5
|
||||
'2':
|
||||
x: 28.5
|
||||
y: 53.0
|
||||
z: 2.5
|
||||
'3':
|
||||
x: 28.5
|
||||
y: 53.0
|
||||
z: 4.5
|
||||
'4':
|
||||
x: 28.5
|
||||
y: 53.0
|
||||
z: 6.5
|
||||
'5':
|
||||
x: 28.5
|
||||
y: 53.0
|
||||
z: 8.5
|
||||
RedStone_Block:
|
||||
'1':
|
||||
x: 30.0
|
||||
y: 53.0
|
||||
z: 0.0
|
||||
'2':
|
||||
x: 30.0
|
||||
y: 53.0
|
||||
z: 2.0
|
||||
'3':
|
||||
x: 30.0
|
||||
y: 53.0
|
||||
z: 4.0
|
||||
'4':
|
||||
x: 30.0
|
||||
y: 53.0
|
||||
z: 6.0
|
||||
'5':
|
||||
x: 30.0
|
||||
y: 53.0
|
||||
z: 8.0
|
||||
'1_Reward':
|
||||
==: org.bukkit.inventory.ItemStack
|
||||
v: 2975
|
||||
type: IRON_INGOT
|
||||
Amount: 87
|
||||
'2_Reward':
|
||||
==: org.bukkit.inventory.ItemStack
|
||||
v: 2975
|
||||
type: GOLD_INGOT
|
||||
Amount: 87
|
||||
'3_Reward':
|
||||
==: org.bukkit.inventory.ItemStack
|
||||
v: 2975
|
||||
type: EMERALD
|
||||
Amount: 87
|
||||
meta:
|
||||
==: ItemMeta
|
||||
meta-type: UNSPECIFIC
|
||||
display-name: '{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"["},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"green","text":"通用"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"]
|
||||
"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gold","text":"伺服器貨幣"}],"text":""}'
|
||||
lore:
|
||||
- '{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"伺服器通用貨幣"}],"text":""}'
|
||||
- '{"extra":[{"bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"red","text":"✪"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"是價值較高的貨幣!"}],"text":""}'
|
||||
enchants:
|
||||
PROTECTION_ENVIRONMENTAL: 1
|
||||
ItemFlags:
|
||||
- HIDE_ENCHANTS
|
||||
'4_Reward':
|
||||
==: org.bukkit.inventory.ItemStack
|
||||
v: 2975
|
||||
type: PAPER
|
||||
Amount: 128
|
||||
meta:
|
||||
==: ItemMeta
|
||||
meta-type: UNSPECIFIC
|
||||
display-name: '{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"yellow","text":"現金券
|
||||
"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"["},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gold","text":"500"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"]"}],"text":""}'
|
||||
lore:
|
||||
- '{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"dark_gray","text":"其他類"}],"text":""}'
|
||||
- '{"extra":[{"bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"green","text":"✔"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"右鍵開啓此券"}],"text":""}'
|
||||
- '{"extra":[{"bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"green","text":"✔"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"使用後增加500金幣並消失"}],"text":""}'
|
||||
'5_Reward':
|
||||
==: org.bukkit.inventory.ItemStack
|
||||
v: 2975
|
||||
type: PAPER
|
||||
Amount: 128
|
||||
meta:
|
||||
==: ItemMeta
|
||||
meta-type: UNSPECIFIC
|
||||
display-name: '{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"green","text":"點券
|
||||
"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"["},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gold","text":"1"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"]"}],"text":""}'
|
||||
lore:
|
||||
- '{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"dark_gray","text":"其他類"}],"text":""}'
|
||||
- '{"extra":[{"bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"green","text":"✔"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"右鍵開啓此券"}],"text":""}'
|
||||
- '{"extra":[{"bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"green","text":"✔"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"使用後增加1點券並消失"}],"text":""}'
|
||||
'6_Reward':
|
||||
==: org.bukkit.inventory.ItemStack
|
||||
v: 2975
|
||||
type: PAPER
|
||||
Amount: 128
|
||||
meta:
|
||||
==: ItemMeta
|
||||
meta-type: UNSPECIFIC
|
||||
display-name: '{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"green","text":"點券
|
||||
"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"["},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gold","text":"1"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"]"}],"text":""}'
|
||||
lore:
|
||||
- '{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"dark_gray","text":"其他類"}],"text":""}'
|
||||
- '{"extra":[{"bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"green","text":"✔"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"右鍵開啓此券"}],"text":""}'
|
||||
- '{"extra":[{"bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"green","text":"✔"},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"使用後增加1點券並消失"}],"text":""}'
|
Loading…
Reference in New Issue
Block a user