mirror of
https://e.coding.net/circlecloud/GuiACK.git
synced 2024-12-03 16:28:48 +00:00
init project...
Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
commit
5e1b2ce224
31
.classpath
Normal file
31
.classpath
Normal file
@ -0,0 +1,31 @@
|
||||
<?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/JavaSE-1.8">
|
||||
<attributes>
|
||||
<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="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
38
.gitignore
vendored
Normal file
38
.gitignore
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
# Eclipse stuff
|
||||
/.settings
|
||||
|
||||
# netbeans
|
||||
/nbproject
|
||||
|
||||
# we use maven!
|
||||
/build.xml
|
||||
|
||||
# maven
|
||||
/target
|
||||
/repo
|
||||
|
||||
# vim
|
||||
.*.sw[a-p]
|
||||
|
||||
# various other potential build files
|
||||
/build
|
||||
/bin
|
||||
/dist
|
||||
/manifest.mf
|
||||
|
||||
/world
|
||||
|
||||
# Mac filesystem dust
|
||||
*.DS_Store
|
||||
|
||||
# intellij
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Project Stuff
|
||||
/src/main/resources/Soulbound
|
||||
|
||||
# Atlassian Stuff
|
||||
/atlassian-ide-plugin.xml
|
23
.project
Normal file
23
.project
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>GuiACK</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>
|
107
pom.xml
Normal file
107
pom.xml
Normal file
@ -0,0 +1,107 @@
|
||||
<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>cn.citycraft</groupId>
|
||||
<artifactId>GuiACK</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>GuiACK</name>
|
||||
<build>
|
||||
<finalName>${project.name}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>cn.citycraft:PluginHelper</include>
|
||||
<include>org.mcstats.*:*</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.mcstats</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}.mcstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>cn.citycraft.PluginHelper</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>citycraft-repo</id>
|
||||
<url>http://ci.citycraft.cn:8800/jenkins/plugin/repository/everything/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>Plugin Metrics</id>
|
||||
<url>http://repo.mcstats.org/content/repositories/public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>vault-repo</id>
|
||||
<url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<type>jar</type>
|
||||
<version>1.8.3-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.citycraft</groupId>
|
||||
<artifactId>PluginHelper</artifactId>
|
||||
<type>jar</type>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mcstats.bukkit</groupId>
|
||||
<artifactId>metrics</artifactId>
|
||||
<version>R8-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
</project>
|
65
src/main/java/cn/citycraft/GuiACK/GuiACK.java
Normal file
65
src/main/java/cn/citycraft/GuiACK/GuiACK.java
Normal file
@ -0,0 +1,65 @@
|
||||
package cn.citycraft.GuiACK;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.mcstats.Metrics;
|
||||
|
||||
import cn.citycraft.GuiACK.gui.VerifyGui;
|
||||
import cn.citycraft.GuiACK.listen.PlayerListen;
|
||||
import cn.citycraft.PluginHelper.config.FileConfig;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
public class GuiACK extends JavaPlugin {
|
||||
public boolean isEconomy;
|
||||
public Economy economy = null;
|
||||
FileConfig config;
|
||||
public int tasktime;
|
||||
public double reward;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (args.length == 1 && args[0].equalsIgnoreCase("reload") && sender.hasPermission("gack.reload")) {
|
||||
onLoad();
|
||||
sender.sendMessage("配置文件已重载!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerListen(this), this);
|
||||
if (setupEconomy()) {
|
||||
isEconomy = true;
|
||||
this.getLogger().info("发现Vault 载入数据...");
|
||||
} else {
|
||||
this.getLogger().warning("发现Vault 但是无法找到经济插件 关闭插件...");
|
||||
setEnabled(false);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Metrics metrics = new Metrics(this);
|
||||
metrics.start();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
config = new FileConfig(this);
|
||||
tasktime = config.getInt("TaskTime");
|
||||
reward = config.getDouble("Reward");
|
||||
VerifyGui.init(config.getStringList("VerifyList"));
|
||||
}
|
||||
|
||||
public boolean setupEconomy() {
|
||||
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||
if (economyProvider != null)
|
||||
economy = economyProvider.getProvider();
|
||||
return (economy != null);
|
||||
}
|
||||
|
||||
}
|
36
src/main/java/cn/citycraft/GuiACK/gui/VerifyGui.java
Normal file
36
src/main/java/cn/citycraft/GuiACK/gui/VerifyGui.java
Normal file
@ -0,0 +1,36 @@
|
||||
package cn.citycraft.GuiACK.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class VerifyGui {
|
||||
static List<String> verifylist = new ArrayList<String>();
|
||||
|
||||
public static String invname = "§v§e§r§c防挂机验证 §3请选择验证码: ";
|
||||
|
||||
public static void init(List<String> verifylist) {
|
||||
VerifyGui.verifylist = verifylist;
|
||||
}
|
||||
|
||||
public static void open(Player p) {
|
||||
Random r = new Random();
|
||||
ItemStack[] list = new ItemStack[9];
|
||||
for (int i = 0; i < 9; i++) {
|
||||
int ri = r.nextInt(verifylist.size());
|
||||
String[] itf = verifylist.get(ri).split(":");
|
||||
int itemid = Integer.parseInt(itf[0]);
|
||||
String itemname = itf[1];
|
||||
list[i] = new VerifyItem(itemid, itemname);
|
||||
}
|
||||
int ri = r.nextInt(9);
|
||||
Inventory inv = Bukkit.createInventory(null, 9, invname + list[ri].getItemMeta().getDisplayName());
|
||||
inv.setContents(list);
|
||||
p.openInventory(inv);
|
||||
}
|
||||
}
|
14
src/main/java/cn/citycraft/GuiACK/gui/VerifyItem.java
Normal file
14
src/main/java/cn/citycraft/GuiACK/gui/VerifyItem.java
Normal file
@ -0,0 +1,14 @@
|
||||
package cn.citycraft.GuiACK.gui;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class VerifyItem extends ItemStack {
|
||||
@SuppressWarnings("deprecation")
|
||||
public VerifyItem(int id, String name) {
|
||||
super(id);
|
||||
ItemMeta itemMeta = this.getItemMeta();
|
||||
itemMeta.setDisplayName(name);
|
||||
this.setItemMeta(itemMeta);
|
||||
}
|
||||
}
|
90
src/main/java/cn/citycraft/GuiACK/listen/PlayerListen.java
Normal file
90
src/main/java/cn/citycraft/GuiACK/listen/PlayerListen.java
Normal file
@ -0,0 +1,90 @@
|
||||
package cn.citycraft.GuiACK.listen;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import cn.citycraft.GuiACK.GuiACK;
|
||||
import cn.citycraft.GuiACK.gui.VerifyGui;
|
||||
import cn.citycraft.GuiACK.runnable.VerifyTask;
|
||||
|
||||
public class PlayerListen implements Listener {
|
||||
GuiACK plugin;
|
||||
|
||||
HashMap<String, BukkitTask> tasklist = new HashMap<String, BukkitTask>();
|
||||
|
||||
HashMap<String, Boolean> checklist = new HashMap<String, Boolean>();
|
||||
|
||||
public PlayerListen(GuiACK plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCloseInv(InventoryCloseEvent e) {
|
||||
String guiname = e.getView().getTitle();
|
||||
if (!guiname.startsWith(VerifyGui.invname))
|
||||
return;
|
||||
if (e.getInventory().getItem(0) == null)
|
||||
return;
|
||||
Player p = (Player) e.getPlayer();
|
||||
if (checklist.containsKey(p.getName()) && checklist.get(p.getName())) {
|
||||
checklist.put(p.getName(), false);
|
||||
return;
|
||||
}
|
||||
if (p.isOnline())
|
||||
Bukkit.getScheduler().runTaskLater(plugin, new VerifyTask(p), 3);
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemClick(InventoryClickEvent e) {
|
||||
Inventory inv = e.getInventory();
|
||||
String guiname = inv.getName();
|
||||
if (!guiname.startsWith(VerifyGui.invname))
|
||||
return;
|
||||
if (!(e.getWhoClicked() instanceof Player))
|
||||
return;
|
||||
e.setCancelled(true);
|
||||
Player p = (Player) e.getWhoClicked();
|
||||
ItemStack ci = e.getCurrentItem();
|
||||
if (ci == null || ci.getType() == Material.AIR)
|
||||
return;
|
||||
if (!ci.getItemMeta().hasDisplayName())
|
||||
return;
|
||||
String clickName = ci.getItemMeta().getDisplayName();
|
||||
if (!guiname.endsWith(clickName))
|
||||
p.kickPlayer("§c验证码选择错误 请重新登录!");
|
||||
else {
|
||||
plugin.economy.depositPlayer(p, plugin.reward);
|
||||
p.sendMessage("§a验证成功 奖励金钱: " + plugin.reward);
|
||||
checklist.put(p.getName(), true);
|
||||
p.closeInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
int tasktime = plugin.tasktime * 20 * 60;
|
||||
BukkitTask task = Bukkit.getScheduler().runTaskTimer(plugin, new VerifyTask(p), tasktime, tasktime);
|
||||
tasklist.put(p.getName(), task);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (tasklist.containsKey(p.getName()))
|
||||
tasklist.get(p.getName()).cancel();
|
||||
}
|
||||
}
|
20
src/main/java/cn/citycraft/GuiACK/runnable/VerifyTask.java
Normal file
20
src/main/java/cn/citycraft/GuiACK/runnable/VerifyTask.java
Normal file
@ -0,0 +1,20 @@
|
||||
package cn.citycraft.GuiACK.runnable;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.GuiACK.gui.VerifyGui;
|
||||
|
||||
public class VerifyTask implements Runnable {
|
||||
Player p;
|
||||
|
||||
public VerifyTask(Player p) {
|
||||
this.p = p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (p.isOnline())
|
||||
VerifyGui.open(p);
|
||||
}
|
||||
|
||||
}
|
12
src/main/resources/config.yml
Normal file
12
src/main/resources/config.yml
Normal file
@ -0,0 +1,12 @@
|
||||
version: 1.0
|
||||
#检测时间(分钟)
|
||||
TaskTime: 10
|
||||
#奖励金钱
|
||||
Reward: 20
|
||||
#验证码列表(ID:显示名称)注:名称可以自定义,可以使用&颜色代码
|
||||
VerifyList:
|
||||
- 1:石头
|
||||
- 2:草方块
|
||||
- 3:泥土
|
||||
- 4:圆石
|
||||
- 5:木板
|
14
src/main/resources/plugin.yml
Normal file
14
src/main/resources/plugin.yml
Normal file
@ -0,0 +1,14 @@
|
||||
name: ${project.artifactId}
|
||||
description: ${project.description}
|
||||
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
|
||||
version: ${project.version}
|
||||
auther: 喵♂呜
|
||||
website: http://ci.citycraft.cn:8800/jenkins/job/${project.artifactId}/
|
||||
commands:
|
||||
gack:
|
||||
description: gack
|
||||
usage: §b使用/gack help 查看帮助!
|
||||
permissions:
|
||||
gack.reload:
|
||||
description: 重新载入插件!
|
||||
default: op
|
Loading…
Reference in New Issue
Block a user