This repository has been archived by the owner on Jul 27, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cnaude
committed
Sep 16, 2017
1 parent
93112e4
commit 60fd520
Showing
4 changed files
with
249 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright (C) 2014 cnaude | ||
* | ||
* 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 3 of 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; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 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. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.cnaude.purpleirc.Commands; | ||
|
||
import com.cnaude.purpleirc.PurpleBot; | ||
import com.cnaude.purpleirc.PurpleIRC; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.command.CommandSender; | ||
|
||
/** | ||
* | ||
* @author Chris Naude | ||
*/ | ||
public class Nickserv implements IRCCommandInterface { | ||
|
||
private final PurpleIRC plugin; | ||
private final String usage = "([bot]) [message]"; | ||
private final String desc = "Send nickserv commands to the IRC server."; | ||
private final String name = "nickserv"; | ||
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage; | ||
|
||
/** | ||
* | ||
* @param plugin the PurpleIRC plugin | ||
*/ | ||
public Nickserv(PurpleIRC plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
/** | ||
* | ||
* @param sender | ||
* @param args | ||
*/ | ||
@Override | ||
public void dispatch(CommandSender sender, String[] args) { | ||
if (args.length >= 2) { | ||
int msgIdx = 1; | ||
List<PurpleBot> myBots = new ArrayList<>(); | ||
if (plugin.ircBots.containsKey(args[1])) { | ||
myBots.add(plugin.ircBots.get(args[1])); | ||
msgIdx = 2; | ||
} else { | ||
myBots.addAll(plugin.ircBots.values()); | ||
} | ||
for (PurpleBot ircBot : myBots) { | ||
String msg = ""; | ||
for (int i = msgIdx; i < args.length; i++) { | ||
msg = msg + " " + args[i]; | ||
} | ||
plugin.logDebug("Sending nickserv message to the server: " + msg.substring(1)); | ||
ircBot.asyncRawlineNow("nickserv " + msg.substring(1)); | ||
} | ||
} else { | ||
sender.sendMessage(fullUsage); | ||
} | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public String desc() { | ||
return desc; | ||
} | ||
|
||
@Override | ||
public String usage() { | ||
return usage; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...main/java/com/cnaude/purpleirc/GameListeners/GamePlayerPlayerAdvancementDoneListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (C) 2014 cnaude | ||
* | ||
* 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 3 of 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; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 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. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.cnaude.purpleirc.GameListeners; | ||
|
||
import com.cnaude.purpleirc.PurpleBot; | ||
import com.cnaude.purpleirc.PurpleIRC; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerAdvancementDoneEvent; | ||
|
||
/** | ||
* | ||
* @author Chris Naude | ||
*/ | ||
public class GamePlayerPlayerAdvancementDoneListener implements Listener { | ||
|
||
private final PurpleIRC plugin; | ||
|
||
/** | ||
* | ||
* @param plugin the PurpleIRC plugin | ||
*/ | ||
public GamePlayerPlayerAdvancementDoneListener(PurpleIRC plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
/** | ||
* | ||
* @param event | ||
*/ | ||
@EventHandler(priority = EventPriority.LOWEST) | ||
public void onPlayerAchievementAwardedEvent(PlayerAdvancementDoneEvent event) { | ||
plugin.logDebug("ACHIEVEMENT: " + event.getPlayer().getName() + " => " + event.getAdvancement()); | ||
for (PurpleBot ircBot : plugin.ircBots.values()) { | ||
ircBot.gameAdvancement(event.getPlayer(), event.getAdvancement()); | ||
} | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
src/main/java/com/cnaude/purpleirc/Utilities/NetPacket_112.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright (C) 2015 cnaude | ||
* | ||
* 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 3 of 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; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 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. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.cnaude.purpleirc.Utilities; | ||
|
||
import com.comphenix.protocol.events.PacketContainer; | ||
import com.comphenix.protocol.wrappers.WrappedGameProfile; | ||
import com.google.common.base.Charsets; | ||
import com.mojang.authlib.GameProfile; | ||
import java.util.UUID; | ||
import net.minecraft.server.v1_12_R1.EntityPlayer; | ||
import net.minecraft.server.v1_12_R1.MinecraftServer; | ||
import net.minecraft.server.v1_12_R1.PacketPlayOutPlayerInfo; | ||
import net.minecraft.server.v1_12_R1.PlayerInteractManager; | ||
|
||
/** | ||
* | ||
* @author Chris Naude | ||
*/ | ||
public class NetPacket_112 { | ||
|
||
public static PacketContainer add(String displayName) { | ||
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + displayName).getBytes(Charsets.UTF_8)); | ||
EntityPlayer pl = new EntityPlayer( | ||
MinecraftServer.getServer(), | ||
MinecraftServer.getServer().getWorldServer(0), | ||
(GameProfile) (new WrappedGameProfile(uuid, displayName)).getHandle(), | ||
new PlayerInteractManager(MinecraftServer.getServer().getWorldServer(0)) | ||
); | ||
PacketPlayOutPlayerInfo pi | ||
= new PacketPlayOutPlayerInfo( | ||
PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, pl); | ||
return PacketContainer.fromPacket(pi); | ||
} | ||
|
||
public static PacketContainer rem(String displayName) { | ||
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + displayName).getBytes(Charsets.UTF_8)); | ||
EntityPlayer pl = new EntityPlayer( | ||
MinecraftServer.getServer(), | ||
MinecraftServer.getServer().getWorldServer(0), | ||
(GameProfile) (new WrappedGameProfile(uuid, displayName)).getHandle(), | ||
new PlayerInteractManager(MinecraftServer.getServer().getWorldServer(0)) | ||
); | ||
PacketPlayOutPlayerInfo pi | ||
= new PacketPlayOutPlayerInfo( | ||
PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, pl); | ||
return PacketContainer.fromPacket(pi); | ||
} | ||
|
||
} |