mirror of
https://github.com/GTNewHorizons/CodeChickenCore.git
synced 2026-11-11 07:47:47 +00:00
Initial commit
This commit is contained in:
commit
0d94e9ac7f
78 files changed
+7045
No files matched your search
@@ -0,0 +1,62 @@
|
||||
package codechicken.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.command.CommandHandler;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
|
||||
public class ServerUtils extends CommonUtils
|
||||
{
|
||||
public static MinecraftServer mc() {
|
||||
return MinecraftServer.getServer();
|
||||
}
|
||||
|
||||
public static EntityPlayerMP getPlayer(String playername) {
|
||||
return mc().getConfigurationManager().getPlayerForUsername(playername);
|
||||
}
|
||||
|
||||
public static List<EntityPlayerMP> getPlayers() {
|
||||
return mc().getConfigurationManager().playerEntityList;
|
||||
}
|
||||
|
||||
public static ArrayList<EntityPlayer> getPlayersInDimension(int dimension) {
|
||||
ArrayList<EntityPlayer> players = new ArrayList<EntityPlayer>();
|
||||
for (EntityPlayer p : getPlayers())
|
||||
if(p.dimension == dimension)
|
||||
players.add(p);
|
||||
|
||||
return players;
|
||||
}
|
||||
|
||||
public static void openSMPContainer(EntityPlayerMP player, Container container, IGuiPacketSender packetSender) {
|
||||
player.getNextWindowId();
|
||||
player.closeContainer();
|
||||
packetSender.sendPacket(player, player.currentWindowId);
|
||||
player.openContainer = container;
|
||||
player.openContainer.windowId = player.currentWindowId;
|
||||
player.openContainer.addCraftingToCrafters(player);
|
||||
}
|
||||
|
||||
public static boolean isPlayerOP(String username) {
|
||||
return mc().getConfigurationManager().isPlayerOpped(username);
|
||||
}
|
||||
|
||||
public static boolean isPlayerOwner(String username) {
|
||||
return mc().isSinglePlayer() && mc().getServerOwner().equalsIgnoreCase(username);
|
||||
}
|
||||
|
||||
public static void registerCommand(ICommand command) {
|
||||
((CommandHandler) mc().getCommandManager()).registerCommand(command);
|
||||
}
|
||||
|
||||
public static void sendChatToAll(IChatComponent msg) {
|
||||
for(EntityPlayer p : getPlayers())
|
||||
p.addChatComponentMessage(msg);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user