Initial commit
This commit is contained in:
commit
098c98e000
118
.gitignore
vendored
Normal file
118
.gitignore
vendored
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
# User-specific stuff
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Compiled class file
|
||||||
|
*.class
|
||||||
|
|
||||||
|
# Log file
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# BlueJ files
|
||||||
|
*.ctxt
|
||||||
|
|
||||||
|
# Package Files #
|
||||||
|
*.jar
|
||||||
|
*.war
|
||||||
|
*.nar
|
||||||
|
*.ear
|
||||||
|
*.zip
|
||||||
|
*.tar.gz
|
||||||
|
*.rar
|
||||||
|
|
||||||
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
|
hs_err_pid*
|
||||||
|
|
||||||
|
*~
|
||||||
|
|
||||||
|
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||||
|
.fuse_hidden*
|
||||||
|
|
||||||
|
# KDE directory preferences
|
||||||
|
.directory
|
||||||
|
|
||||||
|
# Linux trash folder which might appear on any partition or disk
|
||||||
|
.Trash-*
|
||||||
|
|
||||||
|
# .nfs files are created when an open file is removed but is still being accessed
|
||||||
|
.nfs*
|
||||||
|
|
||||||
|
# General
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Icon must end with two \r
|
||||||
|
Icon
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
|
|
||||||
|
# Windows thumbnail cache files
|
||||||
|
Thumbs.db
|
||||||
|
Thumbs.db:encryptable
|
||||||
|
ehthumbs.db
|
||||||
|
ehthumbs_vista.db
|
||||||
|
|
||||||
|
# Dump file
|
||||||
|
*.stackdump
|
||||||
|
|
||||||
|
# Folder config file
|
||||||
|
[Dd]esktop.ini
|
||||||
|
|
||||||
|
# Recycle Bin used on file shares
|
||||||
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
|
# Windows Installer files
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# Windows shortcuts
|
||||||
|
*.lnk
|
||||||
|
|
||||||
|
.gradle
|
||||||
|
build/
|
||||||
|
|
||||||
|
# Ignore Gradle GUI config
|
||||||
|
gradle-app.setting
|
||||||
|
|
||||||
|
# Cache of project
|
||||||
|
.gradletasknamecache
|
||||||
|
|
||||||
|
**/build/
|
||||||
|
|
||||||
|
# Common working directory
|
||||||
|
run/
|
||||||
|
|
||||||
|
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||||
|
!gradle-wrapper.jar
|
51
build.gradle
Normal file
51
build.gradle
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
plugins {
|
||||||
|
id 'java'
|
||||||
|
}
|
||||||
|
|
||||||
|
group = 'com.sakurarealm'
|
||||||
|
version = '1.0'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven {
|
||||||
|
name = "spigotmc-repo"
|
||||||
|
url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
|
||||||
|
}
|
||||||
|
maven {
|
||||||
|
name = "sonatype"
|
||||||
|
url = "https://oss.sonatype.org/content/groups/public/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnly "org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT"
|
||||||
|
|
||||||
|
compileOnly(fileTree("libs"))
|
||||||
|
}
|
||||||
|
|
||||||
|
def targetJavaVersion = 8
|
||||||
|
java {
|
||||||
|
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
||||||
|
sourceCompatibility = javaVersion
|
||||||
|
targetCompatibility = javaVersion
|
||||||
|
if (JavaVersion.current() < javaVersion) {
|
||||||
|
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(JavaCompile).configureEach {
|
||||||
|
options.encoding = 'UTF-8'
|
||||||
|
|
||||||
|
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
|
||||||
|
options.release.set(targetJavaVersion)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
def props = [version: version]
|
||||||
|
inputs.properties props
|
||||||
|
filteringCharset 'UTF-8'
|
||||||
|
filesMatching('plugin.yml') {
|
||||||
|
expand props
|
||||||
|
}
|
||||||
|
}
|
0
gradle.properties
Normal file
0
gradle.properties
Normal file
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
BIN
libs/PlaceholderAPI-2.10.9.jar
Normal file
BIN
libs/PlaceholderAPI-2.10.9.jar
Normal file
Binary file not shown.
BIN
libs/Towny-0.97.SAKU.jar
Normal file
BIN
libs/Towny-0.97.SAKU.jar
Normal file
Binary file not shown.
1
settings.gradle
Normal file
1
settings.gradle
Normal file
@ -0,0 +1 @@
|
|||||||
|
rootProject.name = 'PlayerRisk'
|
30
src/main/java/com/sakurarealm/playerrisk/CommandHandler.java
Normal file
30
src/main/java/com/sakurarealm/playerrisk/CommandHandler.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package com.sakurarealm.playerrisk;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
public class CommandHandler implements CommandExecutor {
|
||||||
|
|
||||||
|
private final PlayerRisk plugin;
|
||||||
|
|
||||||
|
public CommandHandler(PlayerRisk plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
|
||||||
|
if (args.length == 0 || !sender.hasPermission("playerrisk.admin")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("reload")) {
|
||||||
|
plugin.load();
|
||||||
|
sender.sendMessage("&aPlayerRisk plugin reloaded!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
37
src/main/java/com/sakurarealm/playerrisk/Listener.java
Normal file
37
src/main/java/com/sakurarealm/playerrisk/Listener.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package com.sakurarealm.playerrisk;
|
||||||
|
|
||||||
|
import com.palmergames.bukkit.towny.event.PlayerEnterTownEvent;
|
||||||
|
import com.palmergames.bukkit.towny.event.PlayerLeaveTownEvent;
|
||||||
|
import org.apache.commons.lang.NotImplementedException;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
|
||||||
|
public class Listener implements org.bukkit.event.Listener {
|
||||||
|
/**
|
||||||
|
* TODO: 当玩家进入城镇时, 危险度不再增加.
|
||||||
|
*
|
||||||
|
* @param event The PlayerEnterTownEvent.
|
||||||
|
*/
|
||||||
|
public void onPlayerEnterTown(PlayerEnterTownEvent event) {
|
||||||
|
throw new NotImplementedException("Not implemented yet.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: 当玩家离开城镇时, 危险度开始增加.
|
||||||
|
*
|
||||||
|
* @param event The PlayerLeaveTownEvent.
|
||||||
|
*/
|
||||||
|
public void onPlayerLeaveTown(PlayerLeaveTownEvent event) {
|
||||||
|
throw new NotImplementedException("Not implemented yet.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: 当玩家死亡时, 危险度重置.
|
||||||
|
*
|
||||||
|
* @param event The PlayerDeathEvent.
|
||||||
|
*/
|
||||||
|
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||||
|
throw new NotImplementedException("Not implemented yet.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Add any other event handlers needed to manage player risk.
|
||||||
|
}
|
39
src/main/java/com/sakurarealm/playerrisk/PlayerRisk.java
Normal file
39
src/main/java/com/sakurarealm/playerrisk/PlayerRisk.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package com.sakurarealm.playerrisk;
|
||||||
|
|
||||||
|
import com.sakurarealm.playerrisk.api.PlayerRiskManager;
|
||||||
|
import com.sakurarealm.playerrisk.api.PlayerRiskSettings;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public final class PlayerRisk extends JavaPlugin {
|
||||||
|
|
||||||
|
PlayerRiskManager playerRiskManager = null;
|
||||||
|
|
||||||
|
public PlayerRiskManager getPlayerRiskManager() {
|
||||||
|
if (playerRiskManager == null) {
|
||||||
|
throw new NullPointerException("PlayerRisk plugin is not initialized.");
|
||||||
|
}
|
||||||
|
return playerRiskManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void load() {
|
||||||
|
saveDefaultConfig();
|
||||||
|
FileConfiguration config = getConfig();
|
||||||
|
ConfigurationSection settingsSection = config.getConfigurationSection("settings");
|
||||||
|
playerRiskManager = new PlayerRiskManager(this, new PlayerRiskSettings(settingsSection));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
// Plugin startup logic
|
||||||
|
load();
|
||||||
|
getCommand("playerrisk").setExecutor(new CommandHandler(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
// Plugin shutdown logic
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
package com.sakurarealm.playerrisk.api;
|
||||||
|
|
||||||
|
import com.sakurarealm.playerrisk.Listener;
|
||||||
|
import com.sakurarealm.playerrisk.PlayerRisk;
|
||||||
|
import com.sakurarealm.playerrisk.hook.PlaceHolderAPIHook;
|
||||||
|
import org.apache.commons.lang.NotImplementedException;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 危机度区间为0~level_max级,每次离开安全区(城镇),重置危险等级:每待n秒会使危机等级(变量)提升1点,
|
||||||
|
* 但开始计算时玩家在的每一个每种生物群系最多使危机等级提升10 (如上限level_max是50的话, 玩家至少进入5个不同的生物群系才能达到上限),
|
||||||
|
* 玩家每次死亡重生或回到安全区,会重置当前危机等级。
|
||||||
|
* 所有变量见config.yml
|
||||||
|
* <a href="https://drawrealm.feishu.cn/wiki/ZqTQwSQNyiZUIWkHCRgcuAcYn3f?chunked=false">...</a>
|
||||||
|
*/
|
||||||
|
public class PlayerRiskManager {
|
||||||
|
|
||||||
|
private final PlayerRisk plugin;
|
||||||
|
|
||||||
|
// TODO: Add any data structures needed to manage player risk.
|
||||||
|
|
||||||
|
public PlayerRiskManager(PlayerRisk plugin, PlayerRiskSettings settings) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
// Register the event listener.
|
||||||
|
plugin.getServer().getPluginManager().registerEvents(new Listener(), plugin);
|
||||||
|
new PlaceHolderAPIHook(this).register();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPlayerRiskLevel(String playerName) {
|
||||||
|
// Get offline player by name.
|
||||||
|
OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
|
||||||
|
return getPlayerRiskLevel(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPlayerRiskLevel(UUID playerId) {
|
||||||
|
// Get offline player by UUID.
|
||||||
|
OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerId);
|
||||||
|
return getPlayerRiskLevel(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: 获取玩家的危险度等级
|
||||||
|
*
|
||||||
|
* @param player 玩家
|
||||||
|
* @return 危险度等级
|
||||||
|
*/
|
||||||
|
public int getPlayerRiskLevel(OfflinePlayer player) {
|
||||||
|
throw new NotImplementedException("Not implemented yet.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlayerRiskLevel(String playerName, int level) {
|
||||||
|
// Get offline player by name.
|
||||||
|
OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
|
||||||
|
setPlayerRiskLevel(player, level);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlayerRiskLevel(UUID playerId, int level) {
|
||||||
|
// Get offline player by UUID.
|
||||||
|
OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerId);
|
||||||
|
setPlayerRiskLevel(player, level);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: 设置玩家的危险度等级
|
||||||
|
*/
|
||||||
|
public void setPlayerRiskLevel(OfflinePlayer player, int level) {
|
||||||
|
throw new NotImplementedException("Not implemented yet.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Add any other methods needed to manage player risk.
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.sakurarealm.playerrisk.api;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
|
public class PlayerRiskSettings {
|
||||||
|
|
||||||
|
private final int levelMax;
|
||||||
|
private final int increaseInterval;
|
||||||
|
|
||||||
|
public PlayerRiskSettings(ConfigurationSection config) {
|
||||||
|
levelMax = config.getInt("level-max");
|
||||||
|
increaseInterval = config.getInt("increase-interval");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIncreaseInterval() {
|
||||||
|
return increaseInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLevelMax() {
|
||||||
|
return levelMax;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package com.sakurarealm.playerrisk.hook;
|
||||||
|
|
||||||
|
import com.sakurarealm.playerrisk.api.PlayerRiskManager;
|
||||||
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
|
public class PlaceHolderAPIHook extends PlaceholderExpansion {
|
||||||
|
|
||||||
|
private final PlayerRiskManager playerRiskManager;
|
||||||
|
|
||||||
|
public PlaceHolderAPIHook(PlayerRiskManager playerRiskManager) {
|
||||||
|
super();
|
||||||
|
this.playerRiskManager = playerRiskManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIdentifier() {
|
||||||
|
return "prisk";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAuthor() {
|
||||||
|
return "sakurarealm";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getVersion() {
|
||||||
|
return "1.0";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String onRequest(OfflinePlayer player, String params) {
|
||||||
|
if (params.equals("level")) { // prisk_level
|
||||||
|
return String.valueOf(playerRiskManager.getPlayerRiskLevel(player));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
5
src/main/resources/config.yml
Normal file
5
src/main/resources/config.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
settings:
|
||||||
|
# 危险度最大值
|
||||||
|
level-max: 50
|
||||||
|
# 每隔n秒危险度会增加一点
|
||||||
|
increase-interval: 60
|
14
src/main/resources/plugin.yml
Normal file
14
src/main/resources/plugin.yml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
name: PlayerRisk
|
||||||
|
version: '${version}'
|
||||||
|
main: com.sakurarealm.playerrisk.PlayerRisk
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
playerrisk.admin:
|
||||||
|
description: PlayerRisk admin permission
|
||||||
|
default: op
|
||||||
|
|
||||||
|
commands:
|
||||||
|
playerrisk:
|
||||||
|
description: PlayerRisk command
|
||||||
|
usage: /playerrisk
|
||||||
|
aliases: [ pr, prisk ]
|
Loading…
x
Reference in New Issue
Block a user