MC java 远程调试 plugin 开发
@ECHO OFF
SET CATALINA_OPTS= -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
java -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -jar -Xmx1024m -Xms512m -XX:MaxPermSize=256M -Dfile.encoding=utf-8 -Duser.timezone=Asia/Hong_Kong spigot_server.jar
pause
package net.han; import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.plugin.java.JavaPlugin; import java.util.HashMap;
import java.util.Map; /**
* Created by han on 2016/1/30.
*/
public final class BuildClonePlugin extends JavaPlugin {
Map playerList=new HashMap();
@Override
public void onEnable() {
getLogger().info("xiao_xi 插件激活!");
this.getCommand("xiaoxi").setExecutor(new MyPluginCommandExecutor(this));
for (Player player : Bukkit.getServer().getOnlinePlayers()) { playerList.put(player.getName(), playerData(player));
}
} private Object playerData(Player player) { return player;
} @Override
public void onDisable() {
getLogger().info("xiao_xi 插件退出!");
}
public void onPlayerJoin(PlayerJoinEvent evt) {
Player player = evt.getPlayer(); // The player who joined
PlayerInventory inventory = player.getInventory(); // The player's inventory
ItemStack itemstack = new ItemStack(Material.DIAMOND, 64); // A stack of diamonds if (inventory.contains(itemstack)) {
inventory.addItem(itemstack); // Adds a stack of diamonds to the player's inventory
player.sendMessage("Welcome! You seem to be reeeally rich, so we gave you some more diamonds!");
}
} @EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
// Get the player's location.
Location loc = event.getPlayer().getLocation();
// Sets loc to five above where it used to be. Note that this doesn't change the player's position.
loc.setY(loc.getY() + 5);
// Gets the block at the new location.
Block b = loc.getBlock();
// Sets the block to type id 1 (stone).
b.setType(Material.STONE);
} }
package net.han; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import java.util.ArrayList;
import java.util.List; /**
* Created by han on 2016/1/30.
*/
public class MyPluginCommandExecutor implements CommandExecutor {
private World world;
private Location location;
private final BuildClonePlugin plugin;
private Player player;
private Inventory inventory; public MyPluginCommandExecutor(BuildClonePlugin plugin) {
this.plugin = plugin; // Store the plugin in situations where you need it.
} @Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length > 5) {
sender.sendMessage("Too many arguments!");
return false;
}
if (args.length < 3) {
sender.sendMessage("Not enough arguments!");
return false;
} /* Player target = (Bukkit.getServer().getPlayer(args[0]));
if (target == null) {
sender.sendMessage(args[0] + " is not online!");
plugin.getLogger().info(args[0]);
return false;
}*/
String cmdCV=args[0];
String X= args[1];
String Y =args[2];
String Z=args[3];
plugin.getLogger().info(cmdCV + " X=" + X + ",Y=" + Y + ",Z=" + Z);
if (sender instanceof Player) {
Player player = (Player) sender;
if (cmd.getName().equalsIgnoreCase("xiaoxi")) {
player = (Player) sender;
plugin.getLogger().info(player.getDisplayName() + " use command xiaoxi");
world = player.getWorld();
location = player.getLocation();
inventory = player.getInventory();
if (args[0].equalsIgnoreCase("m"))
generateCube( location,Integer.parseInt(args[1])); if (args[0].equalsIgnoreCase("c"))
copyCube(location, Integer.parseInt(args[1]), Integer.parseInt(args[2]),Integer.parseInt(args[3])); if (args[0].equalsIgnoreCase("v"))
pasteCube(location, Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3])); return true;
}
} else {
sender.sendMessage("You must be a player!");
return false;
}
// do something
return false; }
private List<LocCub> cvList =null; public void copyCube(Location loc,int X,int Y,int Z ){
int x1 = loc.getBlockX();
int y1 = loc.getBlockY();
int z1 = loc.getBlockZ();
cvList=new ArrayList<LocCub>(); // Figure out the opposite corner of the cube by taking the corner and adding length to all coordinates.
int x2 = x1 + X;
int y2 = y1 + Y;
int z2 = z1 + Z;
World world = loc.getWorld();
for (int xPoint = x1; xPoint <= x2; xPoint++) {
// Loop over the cube in the y dimension.
for (int yPoint = y1; yPoint <= y2; yPoint++) {
// Loop over the cube in the z dimension.
for (int zPoint = z1; zPoint <= z2; zPoint++) {
// Get the block that we are currently looping over.
Block currentBlock = world.getBlockAt(xPoint, yPoint, zPoint);
// Set the block to type 57 (Diamond block!)
cvList.add(new LocCub(xPoint-x1, yPoint-y1, zPoint-z1 ,currentBlock));
// currentBlock.setType(Material.DIAMOND_BLOCK);
plugin.getLogger().info(" X=" + xPoint + ",Y=" + yPoint + ",Z=" + zPoint);
}
}
}
}
private void pasteCube(Location loc,int X,int Y,int Z ){ World world = loc.getWorld();
for (LocCub locCub : cvList){
Block block = locCub.getBlock(); Block currentBlock = world.getBlockAt(loc.getBlockX()+locCub.getX(),
loc.getBlockY()+locCub.getY(),
loc.getBlockZ()+locCub.getZ()); plugin.getLogger().info(" X=" + (loc.getBlockX()+locCub.getX()) + "," +
" Y=" + (loc.getBlockY()+locCub.getY()) + "," +
" Z=" + (loc.getBlockZ()+locCub.getZ()));
currentBlock.setType(block.getType());
} }
public void generateCube(Location loc, int length) {
// Set one corner of the cube to the given location.
// Uses getBlockN() instead of getN() to avoid casting to an int later.
int x1 = loc.getBlockX();
int y1 = loc.getBlockY();
int z1 = loc.getBlockZ(); // Figure out the opposite corner of the cube by taking the corner and adding length to all coordinates.
int x2 = x1 + length;
int y2 = y1 + length;
int z2 = z1 + length; World world = loc.getWorld(); // Loop over the cube in the x dimension.
for (int xPoint = x1; xPoint <= x2; xPoint++) {
// Loop over the cube in the y dimension.
for (int yPoint = y1; yPoint <= y2; yPoint++) {
// Loop over the cube in the z dimension.
for (int zPoint = z1; zPoint <= z2; zPoint++) {
// Get the block that we are currently looping over.
Block currentBlock = world.getBlockAt(xPoint, yPoint, zPoint);
// Set the block to type 57 (Diamond block!)
currentBlock.setType(Material.DIAMOND_BLOCK);
}
}
}
}
}
package net.han; import org.bukkit.block.Block; /**
* Created by han on 2016/1/30.
*/
public class LocCub {
int X ; public int getY() {
return Y;
} public void setY(int y) {
Y = y;
} public int getX() {
return X;
} public void setX(int x) {
X = x;
} public int getZ() {
return Z;
} public void setZ(int z) {
Z = z;
} int Y;
int Z;
Block block; public LocCub() {
} public LocCub(int xPoint, int yPoint, int zPoint, Block currentBlock) {
X=xPoint;Y=yPoint;Z=zPoint;block=currentBlock;
} public Block getBlock() {
return block;
} public void setBlock(Block block) {
this.block = block;
} }
name: buildClone
main: net.han.BuildClonePlugin
version: 1
author: xiao_xi
commands:
xiaoxi:
description: This is a demo command.
usage: /xiaoxi [c/v/m] [x] [y] [z]
permission: buildClone.*
permission-message: You don't have <permission>
permissions:
buildClone.*:
description: copy or paste build
children:
buildClone.c: true
buildClone.v: true
buildClone.c:
description: Allows you to kick a user
default: op
buildClone.v:
description: Allows you to kick a user
default: op doorman.*:
description: Gives access to all doorman commands
children:
doorman.kick: true
doorman.ban: true
doorman.knock: true
doorman.denied: false
doorman.kick:
description: Allows you to kick a user
default: op
doorman.ban:
description: Allows you to ban a user
default: op
doorman.knock:
description: Knocks on the door!
default: true
doorman.denied:
description: Prevents this user from entering the door
MC java 远程调试 plugin 开发的更多相关文章
- Java远程调试 java -Xdebug各参数说明
JAVA自身支持调试功能,并提供了一个简单的调试工具--JDB,类似于功能强大的GDB,JDB也是一个字符界面的 调试环境,并支持设置断点,支持线程线级的调试 JAVA的调试方法如下: 1.首先支持J ...
- CLion远程调试嵌入式开发板程序
CLion远程调试嵌入式开发板程序 目录 CLion远程调试嵌入式开发板程序 1. 目的 2. 前提条件 3. CLion设置 3.1 设置一个Deployment 3.2 上传需要的目录到目标板子 ...
- linux下的java远程调试jpda+tomcat
项目放到linux服务器了,服务器的环境或者数据可能和我们本地不一样,这个时候我们可能需要远程的断点进行调试,来查看请求过程中的各个变量的值.这里我们的应用服务器用的tomcat5.5.17 这个时候 ...
- 如何远程调试自定义开发的Flume应用
一.前言 Flume作为当下最流行的大数据采集组件之一.其本身拥有分布式/高可靠/高可用等优点,但相比较于Flink/Spark/Kafka等大数据组件,其对于本地调试的功能支持度并不高,如果我们没有 ...
- Java远程调试代码不一致问题汇总
欢迎和大家交流技术相关问题: 邮箱: jiangxinnju@163.com 博客园地址: http://www.cnblogs.com/jiangxinnju GitHub地址: https://g ...
- java远程调试(断点)程序/tomcat( eclipse远程调试Tomcat方法)
tomcat远程调试: 1.Linux中配置tomcat在catalina.sh中添加如下CATALINA_OPTS="-Xdebug -Xrunjdwp:transport=dt_soc ...
- 使用java远程调试技术监控代码运行
JAPA介绍 JPDA(Java Platform Debugger Architecture)是 Java 平台调试体系结构的缩写,通过 JPDA 提供的 API,开发人员可以方便灵活的搭建 Jav ...
- java远程调试(idea)
遇见一个怪异问题,无奈线上数据库有限制,只能远程调试下代码.突然发现,远程调试代码真的好简单,简单记录下操作步骤. 1.在idea里创建一个Remote,远程连接的入口. 找到 Edit Config ...
- JAVA远程调试
1.远程端启动必须添加jvm参数 -Xdebug -Xrunjdwp:transport=dt_socket,suspend=n,server=y,address=${debug_port} 其中de ...
随机推荐
- 2016HUAS_ACM暑假集训2D - 敌兵布阵
刚开始接触线段树,不得不说,每次接触到一个新的数据结构,都会是一场头脑风暴的“盛宴”.希望我能继续痛苦并快乐着学下去.我相信,有各路大神的博客相助,我还是能坚持下去的. 这个题目是HDU的1166,只 ...
- 递归输出文件夹下的所有文件的名称(转自 MSDN)
问题:如何输出给定文件夹目录下面的所有文件的名称? C#代码: using System; using System.IO; namespace MyTest { public class Progr ...
- Windows 10 解决 0x80070021 错误
Windows 10 已经不支持 aspnet_regiis -i. 启动和关闭Windows功能中安装 ".NET Framework 4.6 高级服务" 即可解决. 以下是借鉴 ...
- 高度平衡的二叉搜索树(AVL树)
AVL树的基本概念 AVL树是一种高度平衡的(height balanced)二叉搜索树:对每一个结点x,x的左子树与右子树的高度差(平衡因子)至多为1. 有人也许要问:为什么要有AVL树呢?它有什么 ...
- Reflector 反编译 .NET文件后修复
反编译后的工程文件用VS2010打开后,在打开窗体时会出现一系列错误提示: 第一种情况: “设计器无法处理第 152 行的代码: base.AutoScaleMode = AutoScaleMode. ...
- 【python】*与** 参数问题
可变参数 在Python函数中,还可以定义可变参数.顾名思义,可变参数就是传入的参数个数是可变的,可以是1个.2个到任意个,还可以是0个. 我们以数学题为例子,给定一组数字a,b,c……,请计算a2 ...
- 推荐csdn里的几篇activiti基础入门及提高的博客
昨天有个网友加qq询问我有没有非maven搭建的activiti项目的demo,因为我博客中写了一个用maven,我当时没有,于是晚上回家尝试了一下,结果比较容易就实现了. 之后和那个网友聊了一下,他 ...
- CodeVS 数轴染色
#include<cstdio> #include<algorithm> using namespace std; #define lson rt<<1 #defi ...
- (转)原始图像数据和PDF中的图像数据
比较原始图像数据和PDF中的图像数据,结果见表1.1.表1.1中各种“解码器”的解释见本文后续的“PDF支持的图像格式”部分,“PDF中的图像数据”各栏中的数据来自开源的PdfView.如果您有兴趣查 ...
- DDL DML DCL语句
总体解释:DML(data manipulation language):自动提交的数据库操作语言 它们是SELECT.UPDATE.INSERT.DELETE,就象它的名字一样 DDL( ...