[ItemDisguise] Update ItemDisguise to 1.8
Dieser Commit ist enthalten in:
Ursprung
a60e2522c9
Commit
4c1fac9aa3
@ -1,27 +1,31 @@
|
|||||||
<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">
|
<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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.comphenix.itemdisguise</groupId>
|
<groupId>com.comphenix.itemdisguise</groupId>
|
||||||
<artifactId>ItemDisguise</artifactId>
|
<artifactId>ItemDisguise</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.1.0</version>
|
||||||
<name>Item Disguise</name>
|
<name>Item Disguise</name>
|
||||||
<description>Change the appearance of inventory items.</description>
|
<description>Change the appearance of inventory items.</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>cp1252</project.build.sourceEncoding>
|
<project.build.sourceEncoding>cp1252</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>bukkit-rep</id>
|
<id>spigot-repo</id>
|
||||||
<url>http://repo.bukkit.org/content/groups/public</url>
|
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>comphenix-rep</id>
|
<id>comphenix-releases</id>
|
||||||
<name>Comphenix Maven Releases</name>
|
<url>http://repo.comphenix.net/content/repositories/releases/</url>
|
||||||
<url>http://repo.comphenix.net/content/groups/public</url>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>shadowvolt-repo</id>
|
||||||
|
<url>http://ci.shadowvolt.com/plugin/repository/everything/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src/main/java</sourceDirectory>
|
<sourceDirectory>src/main/java</sourceDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
@ -43,13 +47,13 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:git://github.com/aadnk/ProtocolLib.git</connection>
|
<connection>scm:git:git://github.com/aadnk/ProtocolLib.git</connection>
|
||||||
<developerConnection>scm:git:git@github.com:aadnk/ProtocolLib.git</developerConnection>
|
<developerConnection>scm:git:git@github.com:aadnk/ProtocolLib.git</developerConnection>
|
||||||
<url>https://github.com/aadnk/ProtocolLib</url>
|
<url>https://github.com/aadnk/ProtocolLib</url>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
<name>GNU GENERAL PUBLIC LICENSE - Version 2, June 1991</name>
|
<name>GNU GENERAL PUBLIC LICENSE - Version 2, June 1991</name>
|
||||||
@ -58,15 +62,21 @@
|
|||||||
</license>
|
</license>
|
||||||
</licenses>
|
</licenses>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.3.2-R1.0</version>
|
<version>1.8-R0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.comphenix.protocol</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>ProtocolLib</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.3.2</version>
|
<version>1.8-R0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.comphenix.protocol</groupId>
|
||||||
|
<artifactId>ProtocolLib</artifactId>
|
||||||
|
<version>3.6.3-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -2,16 +2,16 @@
|
|||||||
* ItemDisguise - A simple Bukkit plugin that illustrates how to use ProtocolLib.
|
* ItemDisguise - A simple Bukkit plugin that illustrates how to use ProtocolLib.
|
||||||
* Copyright (C) 2012 Kristian S. Stangeland
|
* Copyright (C) 2012 Kristian S. Stangeland
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
* GNU General Public License as published by the Free Software Foundation; either version 2 of
|
* GNU General Public License as published by the Free Software Foundation; either version 2 of
|
||||||
* the License, or (at your option) any later version.
|
* the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with this program;
|
* You should have received a copy of the GNU General Public License along with this program;
|
||||||
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
* 02111-1307 USA
|
* 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -25,8 +25,8 @@ import org.bukkit.enchantments.Enchantment;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
import com.comphenix.protocol.ProtocolManager;
|
||||||
import com.comphenix.protocol.events.ConnectionSide;
|
|
||||||
import com.comphenix.protocol.events.PacketAdapter;
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
@ -36,62 +36,52 @@ public class HideEnchantmentsListener {
|
|||||||
|
|
||||||
private final Server server;
|
private final Server server;
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
|
|
||||||
public HideEnchantmentsListener(Server server, Logger logger) {
|
public HideEnchantmentsListener(Server server, Logger logger) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addListener(ProtocolManager protocolManager, JavaPlugin plugin) {
|
|
||||||
|
|
||||||
|
public void addListener(ProtocolManager protocolManager, JavaPlugin plugin) {
|
||||||
// Hide all enchantments
|
// Hide all enchantments
|
||||||
protocolManager.addPacketListener(new PacketAdapter(plugin, ConnectionSide.SERVER_SIDE, 0x67, 0x68, 0x3E) {
|
protocolManager.addPacketListener(new PacketAdapter(plugin, PacketType.Play.Server.SET_SLOT, PacketType.Play.Server.WINDOW_ITEMS,
|
||||||
|
PacketType.Play.Server.NAMED_SOUND_EFFECT) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent event) {
|
public void onPacketSending(PacketEvent event) {
|
||||||
PacketContainer packet = event.getPacket();
|
PacketContainer packet = event.getPacket();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Item packets
|
// Item packets
|
||||||
switch (event.getPacketID()) {
|
if (event.getPacketType() == PacketType.Play.Server.SET_SLOT) {
|
||||||
case 0x67: // Set slot
|
|
||||||
removeEnchantments(packet.getItemModifier().read(0));
|
removeEnchantments(packet.getItemModifier().read(0));
|
||||||
break;
|
} else if (event.getPacketType() == PacketType.Play.Server.WINDOW_ITEMS) {
|
||||||
|
|
||||||
case 0x68: // Set Window Items
|
|
||||||
ItemStack[] elements = packet.getItemArrayModifier().read(0);
|
ItemStack[] elements = packet.getItemArrayModifier().read(0);
|
||||||
|
|
||||||
for (int i = 0; i < elements.length; i++) {
|
for (int i = 0; i < elements.length; i++) {
|
||||||
if (elements[i] != null) {
|
if (elements[i] != null) {
|
||||||
removeEnchantments(elements[i]);
|
removeEnchantments(elements[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
} else if (event.getPacketType() == PacketType.Play.Server.NAMED_SOUND_EFFECT) {
|
||||||
|
|
||||||
case 0x3E: // Sound effect
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (FieldAccessException e) {
|
} catch (FieldAccessException e) {
|
||||||
logger.log(Level.SEVERE, "Couldn't access field.", e);
|
logger.log(Level.SEVERE, "Couldn't access field.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Censor
|
// Censor
|
||||||
protocolManager.addPacketListener(new PacketAdapter(plugin, ConnectionSide.CLIENT_SIDE, 0x3) {
|
protocolManager.addPacketListener(new PacketAdapter(plugin, PacketType.Play.Client.CHAT) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketReceiving(PacketEvent event) {
|
public void onPacketReceiving(PacketEvent event) {
|
||||||
if (event.getPacketID() == 0x3) {
|
if (event.getPacketType() == PacketType.Play.Client.CHAT) {
|
||||||
try {
|
try {
|
||||||
String message = event.getPacket().
|
String message = event.getPacket().getSpecificModifier(String.class).read(0);
|
||||||
getSpecificModifier(String.class).read(0);
|
|
||||||
|
|
||||||
if (message.contains("shit") || message.contains("fuck")) {
|
if (message.contains("shit") || message.contains("fuck")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getPlayer().sendMessage("Bad manners!");
|
event.getPlayer().sendMessage("Bad manners!");
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (FieldAccessException e) {
|
} catch (FieldAccessException e) {
|
||||||
logger.log(Level.SEVERE, "Couldn't access field.", e);
|
logger.log(Level.SEVERE, "Couldn't access field.", e);
|
||||||
}
|
}
|
||||||
@ -99,24 +89,23 @@ public class HideEnchantmentsListener {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Server getServer() {
|
public Server getServer() {
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeListener(ProtocolManager protocolManager, JavaPlugin plugin) {
|
public void removeListener(ProtocolManager protocolManager, JavaPlugin plugin) {
|
||||||
// Just remove every adapter with this plugin
|
// Just remove every adapter with this plugin
|
||||||
protocolManager.removePacketListeners(plugin);
|
protocolManager.removePacketListeners(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeEnchantments(ItemStack stack) {
|
private void removeEnchantments(ItemStack stack) {
|
||||||
if (stack == null)
|
if (stack == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Object[] copy = stack.getEnchantments().keySet().toArray();
|
Enchantment[] copy = stack.getEnchantments().keySet().toArray(new Enchantment[0]);
|
||||||
|
for (Enchantment enchantment : copy) {
|
||||||
for (Object enchantment : copy) {
|
stack.removeEnchantment(enchantment);
|
||||||
stack.removeEnchantment((Enchantment) enchantment);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,16 +2,16 @@
|
|||||||
* ItemDisguise - A simple Bukkit plugin that illustrates how to use ProtocolLib.
|
* ItemDisguise - A simple Bukkit plugin that illustrates how to use ProtocolLib.
|
||||||
* Copyright (C) 2012 Kristian S. Stangeland
|
* Copyright (C) 2012 Kristian S. Stangeland
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
* GNU General Public License as published by the Free Software Foundation; either version 2 of
|
* GNU General Public License as published by the Free Software Foundation; either version 2 of
|
||||||
* the License, or (at your option) any later version.
|
* the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with this program;
|
* You should have received a copy of the GNU General Public License along with this program;
|
||||||
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
* 02111-1307 USA
|
* 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -24,23 +24,23 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
import com.comphenix.protocol.ProtocolManager;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
|
||||||
public class ItemDisguiseMod extends JavaPlugin {
|
public class ItemDisguiseMod extends JavaPlugin {
|
||||||
|
|
||||||
private ProtocolManager protocolManager;
|
private ProtocolManager protocolManager;
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
|
|
||||||
private HideEnchantmentsListener enchantmentsListener;
|
private HideEnchantmentsListener enchantmentsListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
||||||
logger = getLoggerSafely();
|
logger = getLoggerSafely();
|
||||||
protocolManager = ProtocolLibrary.getProtocolManager();
|
protocolManager = ProtocolLibrary.getProtocolManager();
|
||||||
|
|
||||||
enchantmentsListener = new HideEnchantmentsListener(getServer(), logger);
|
enchantmentsListener = new HideEnchantmentsListener(getServer(), logger);
|
||||||
enchantmentsListener.addListener(protocolManager, this);
|
enchantmentsListener.addListener(protocolManager, this);
|
||||||
}
|
}
|
||||||
@ -49,49 +49,42 @@ public class ItemDisguiseMod extends JavaPlugin {
|
|||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
enchantmentsListener.removeListener(protocolManager, this);
|
enchantmentsListener.removeListener(protocolManager, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if (label.equalsIgnoreCase("explosion")) {
|
if (label.equalsIgnoreCase("explosion")) {
|
||||||
PacketContainer fakeExplosion = protocolManager.createPacket(0x3C);
|
PacketContainer fakeExplosion = protocolManager.createPacket(PacketType.Play.Server.EXPLOSION);
|
||||||
|
|
||||||
// Set the coordinates
|
// Set the coordinates
|
||||||
try {
|
try {
|
||||||
fakeExplosion.getSpecificModifier(double.class).
|
fakeExplosion.getSpecificModifier(double.class).write(0, player.getLocation().getX()).write(1, player.getLocation().getY()).write(2, player.getLocation().getZ());
|
||||||
write(0, player.getLocation().getX()).
|
fakeExplosion.getSpecificModifier(float.class).write(0, 3.0F);
|
||||||
write(1, player.getLocation().getY()).
|
|
||||||
write(2, player.getLocation().getZ());
|
|
||||||
fakeExplosion.getSpecificModifier(float.class).
|
|
||||||
write(0, 3.0F);
|
|
||||||
|
|
||||||
protocolManager.sendServerPacket(player, fakeExplosion);
|
protocolManager.sendServerPacket(player, fakeExplosion);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the Bukkit logger first, before we try to create our own
|
// Get the Bukkit logger first, before we try to create our own
|
||||||
private Logger getLoggerSafely() {
|
private Logger getLoggerSafely() {
|
||||||
|
|
||||||
Logger log = null;
|
Logger log = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
log = getLogger();
|
log = getLogger();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
// We'll handle it
|
// We'll handle it
|
||||||
}
|
}
|
||||||
|
|
||||||
if (log == null)
|
if (log == null)
|
||||||
log = Logger.getLogger("Minecraft");
|
log = Logger.getLogger("Minecraft");
|
||||||
return log;
|
return log;
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren