测试版
This commit is contained in:
		
							parent
							
								
									58697dee64
								
							
						
					
					
						commit
						6a3435a852
					
				
							
								
								
									
										36
									
								
								pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								pom.xml
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,36 @@ | ||||||
|  | <?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>EnderDragonWars</artifactId> | ||||||
|  |     <version>1.0-SNAPSHOT</version> | ||||||
|  | 
 | ||||||
|  |     <properties> | ||||||
|  |         <maven.compiler.source>17</maven.compiler.source> | ||||||
|  |         <maven.compiler.target>17</maven.compiler.target> | ||||||
|  |     </properties> | ||||||
|  | 
 | ||||||
|  |     <repositories> | ||||||
|  |         <repository> | ||||||
|  |             <id>papermc-repo</id> | ||||||
|  |             <url>https://repo.papermc.io/repository/maven-public/</url> | ||||||
|  |         </repository> | ||||||
|  |         <repository> | ||||||
|  |             <id>sonatype</id> | ||||||
|  |             <url>https://oss.sonatype.org/content/groups/public/</url> | ||||||
|  |         </repository> | ||||||
|  |     </repositories> | ||||||
|  | 
 | ||||||
|  |     <dependencies> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>io.papermc.paper</groupId> | ||||||
|  |             <artifactId>paper-api</artifactId> | ||||||
|  |             <version>1.20.6-R0.1-SNAPSHOT</version> | ||||||
|  |             <scope>provided</scope> | ||||||
|  |         </dependency> | ||||||
|  |     </dependencies> | ||||||
|  | 
 | ||||||
|  | </project> | ||||||
							
								
								
									
										27
									
								
								src/main/java/com/yaohun/enderdragonWars/Main.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/main/java/com/yaohun/enderdragonWars/Main.java
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,27 @@ | ||||||
|  | package com.yaohun.enderdragonWars; | ||||||
|  | 
 | ||||||
|  | import com.yaohun.enderdragonWars.game.Game; | ||||||
|  | import com.yaohun.enderdragonWars.manage.GameManage; | ||||||
|  | import com.yaohun.enderdragonWars.manage.GiftEffectManager; | ||||||
|  | import org.bukkit.plugin.java.JavaPlugin; | ||||||
|  | 
 | ||||||
|  | public class Main extends JavaPlugin { | ||||||
|  | 
 | ||||||
|  |     public static Main plugin; | ||||||
|  |     public static GameManage gameManage; | ||||||
|  |     public static Game game; | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public void onEnable() { | ||||||
|  |         plugin = this; | ||||||
|  |         GiftEffectManager.registerAll(); | ||||||
|  |         gameManage = new GameManage(); | ||||||
|  |         game = new Game(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public void onDisable() { | ||||||
|  |         GiftEffectManager.stopQueue(); | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										41
									
								
								src/main/java/com/yaohun/enderdragonWars/data/GiftData.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								src/main/java/com/yaohun/enderdragonWars/data/GiftData.java
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,41 @@ | ||||||
|  | package com.yaohun.enderdragonWars.data; | ||||||
|  | 
 | ||||||
|  | import com.yaohun.enderdragonWars.util.GameUtil; | ||||||
|  | import org.bukkit.Bukkit; | ||||||
|  | import org.bukkit.configuration.file.FileConfiguration; | ||||||
|  | 
 | ||||||
|  | public class GiftData { | ||||||
|  |     private String giftName; // 礼物名 | ||||||
|  |     private String event; // 效果名 | ||||||
|  |     private int minutes; // 加播或减播 | ||||||
|  |     private String sounds; // 自定义音效 | ||||||
|  | 
 | ||||||
|  |     public GiftData(String giftName, FileConfiguration yml) { | ||||||
|  |         this.giftName = giftName; | ||||||
|  |         String str = "礼物设置." + giftName + "."; | ||||||
|  |         if (yml.getString(str + "声音") != null) { | ||||||
|  |             this.sounds = yml.getString(str + "声音"); | ||||||
|  |         } | ||||||
|  |         this.event = yml.getString(str + "效果"); | ||||||
|  |         this.minutes = yml.getInt(str + "加播"); | ||||||
|  |         if (this.minutes >= 1) { | ||||||
|  |             Bukkit.getConsoleSender().sendMessage("事件: " + this.event + "  条件: " + giftName + "  加播: +" + minutes + "分钟"); | ||||||
|  |         } else { | ||||||
|  |             Bukkit.getConsoleSender().sendMessage("事件: " + this.event + "  条件: " + giftName + "  减播: -" + minutes + "分钟"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getGiftName() { | ||||||
|  |         return giftName; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getEvent() { | ||||||
|  |         return event; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void OutPlaySoundsEvent() { | ||||||
|  |         if(!sounds.equalsIgnoreCase("NULL")) { | ||||||
|  |             GameUtil.SendAllSounds(sounds); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | @ -0,0 +1,44 @@ | ||||||
|  | package com.yaohun.enderdragonWars.manage; | ||||||
|  | 
 | ||||||
|  | import com.yaohun.enderdragonWars.data.GiftData; | ||||||
|  | import org.bukkit.Bukkit; | ||||||
|  | import org.bukkit.configuration.ConfigurationSection; | ||||||
|  | import org.bukkit.configuration.file.FileConfiguration; | ||||||
|  | import org.bukkit.configuration.file.YamlConfiguration; | ||||||
|  | 
 | ||||||
|  | import java.io.File; | ||||||
|  | import java.util.HashMap; | ||||||
|  | import java.util.LinkedHashMap; | ||||||
|  | 
 | ||||||
|  | public class GameManage { | ||||||
|  | 
 | ||||||
|  |     private HashMap<String, GiftData> giftDataMap = new HashMap<>(); | ||||||
|  |     public GameManage(){ | ||||||
|  |         loadGiftData(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void loadGiftData(){ | ||||||
|  |         File file = new File("./plugins/游戏设置","礼物设置.yml"); | ||||||
|  |         FileConfiguration yml = YamlConfiguration.loadConfiguration(file); | ||||||
|  |         Bukkit.getConsoleSender().sendMessage("[日志 - 末影龙挑战] 事件注册:"); | ||||||
|  |         ConfigurationSection section = yml.getConfigurationSection("礼物设置"); | ||||||
|  |         if(section == null){ | ||||||
|  |             System.out.println("[错误 - 游戏] 礼物设置错误,请检查文件."); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         for (String giftName : section.getKeys(false)){ | ||||||
|  |             giftDataMap.put(giftName,new GiftData(giftName,yml)); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public HashMap<String, GiftData> getGiftDataMap() { | ||||||
|  |         return giftDataMap; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public GiftData getGiftData(String giftName){ | ||||||
|  |         if(getGiftDataMap().get(giftName) == null){ | ||||||
|  |             return null; | ||||||
|  |         } | ||||||
|  |         return getGiftDataMap().get(giftName); | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										37
									
								
								src/main/java/com/yaohun/enderdragonWars/util/GameUtil.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								src/main/java/com/yaohun/enderdragonWars/util/GameUtil.java
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,37 @@ | ||||||
|  | package com.yaohun.enderdragonWars.util; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | import org.bukkit.*; | ||||||
|  | import org.bukkit.block.Block; | ||||||
|  | import org.bukkit.command.CommandSender; | ||||||
|  | import org.bukkit.entity.Entity; | ||||||
|  | import org.bukkit.entity.Pig; | ||||||
|  | import org.bukkit.entity.Player; | ||||||
|  | import org.bukkit.inventory.Inventory; | ||||||
|  | import org.bukkit.inventory.ItemStack; | ||||||
|  | 
 | ||||||
|  | public class GameUtil { | ||||||
|  | 
 | ||||||
|  |     public static String HideName(String audience){ | ||||||
|  |         if(audience.length() <= 2){ | ||||||
|  |             return "**"; | ||||||
|  |         } | ||||||
|  |         // 获取第一个和第二个字符 | ||||||
|  |         char firstChar = audience.charAt(0); | ||||||
|  |         char lastChar = audience.charAt(audience.length() - 1); | ||||||
|  |         // 构建屏蔽后的字符串 | ||||||
|  |         StringBuilder maskedString = new StringBuilder(); | ||||||
|  |         for (int i = 1; i < audience.length() - 1; i++) { | ||||||
|  |             maskedString.append('*'); | ||||||
|  |         } | ||||||
|  |         return String.valueOf(firstChar) + maskedString + lastChar; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public static void SendAllSounds(String sound){ | ||||||
|  |         for (Player player : Bukkit.getOnlinePlayers()) { | ||||||
|  |             if (!sound.contains("_")) { | ||||||
|  |                 player.playSound(player.getLocation(), sound, 0.5F, 1); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										5
									
								
								src/main/resources/plugin.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/main/resources/plugin.yml
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,5 @@ | ||||||
|  | name: EnderDragonWars | ||||||
|  | main: | ||||||
|  | version: 1.0 | ||||||
|  | commands: | ||||||
|  |   game: | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 yaohunya
						yaohunya