本文整理汇总了Java中net.minecraft.server.MinecraftServer类的典型用法代码示例。如果您正苦于以下问题:Java MinecraftServer类的具体用法?Java MinecraftServer怎么用?Java MinecraftServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MinecraftServer类属于net.minecraft.server包,在下文中一共展示了MinecraftServer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processCommand
import net.minecraft.server.MinecraftServer; //导入依赖的package包/类
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length == 1 && args[0].length() > 0)
{
MinecraftServer minecraftserver = MinecraftServer.getServer();
GameProfile gameprofile = minecraftserver.getConfigurationManager().getOppedPlayers().getGameProfileFromName(args[0]);
if (gameprofile == null)
{
throw new CommandException("commands.deop.failed", new Object[] {args[0]});
}
else
{
minecraftserver.getConfigurationManager().removeOp(gameprofile);
notifyOperators(sender, this, "commands.deop.success", new Object[] {args[0]});
}
}
else
{
throw new WrongUsageException("commands.deop.usage", new Object[0]);
}
}
示例2: execute
import net.minecraft.server.MinecraftServer; //导入依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
new Thread(() -> {
try {
byte[] dataToDump = FullwidthPunctuationFix.INSTANCE.getCharWidthData();
File dest = new File(Minecraft.getMinecraft().getResourcePackRepository().getDirResourcepacks(), "autogen_glyph_width");
if (!dest.exists() || !dest.isDirectory()) {
dest.mkdir();
}
File dumpTargetDir = new File(dest, "assets/minecraft/font");
if (!dumpTargetDir.exists() || !dumpTargetDir.isDirectory()) {
dumpTargetDir.mkdirs();
}
File dumpTarget = new File(dumpTargetDir, "glyph_sizes.bin");
FileUtils.writeByteArrayToFile(dumpTarget, dataToDump, false);
File packMeta = new File(dest, "pack.mcmeta");
FileUtils.writeStringToFile(packMeta, "{ \"pack\": { \"pack_format\": 2, \"description\": \"Auto-generated glyph width data\" } }", "UTF-8", false);
sender.addChatMessage(new TextComponentTranslation("command.fwpf.dump.success"));
} catch (Exception e) {
sender.addChatMessage(new TextComponentTranslation("command.fwpf.dump.fail"));
}
}, "GlyphWidthDataExporter").start();
}
示例3: enablePlayerTrigger
import net.minecraft.server.MinecraftServer; //导入依赖的package包/类
protected void enablePlayerTrigger(ICommandSender sender, String[] p_184914_2_, int p_184914_3_, MinecraftServer server) throws CommandException
{
Scoreboard scoreboard = this.getScoreboard(server);
String s = getPlayerName(server, sender, p_184914_2_[p_184914_3_++]);
if (s.length() > 40)
{
throw new SyntaxErrorException("commands.scoreboard.players.name.tooLong", new Object[] {s, Integer.valueOf(40)});
}
else
{
ScoreObjective scoreobjective = this.convertToObjective(p_184914_2_[p_184914_3_], false, server);
if (scoreobjective.getCriteria() != IScoreCriteria.TRIGGER)
{
throw new CommandException("commands.scoreboard.players.enable.noTrigger", new Object[] {scoreobjective.getName()});
}
else
{
Score score = scoreboard.getOrCreateScore(s, scoreobjective);
score.setLocked(false);
notifyCommandListener(sender, this, "commands.scoreboard.players.enable.success", new Object[] {scoreobjective.getName(), s});
}
}
}
示例4: getUnformattedTextForChat
import net.minecraft.server.MinecraftServer; //导入依赖的package包/类
/**
* Gets the text of this component, without any special formatting codes added, for chat. TODO: why is this two
* different methods?
*/
public String getUnformattedTextForChat()
{
MinecraftServer minecraftserver = MinecraftServer.getServer();
if (minecraftserver != null && minecraftserver.isAnvilFileSet() && StringUtils.isNullOrEmpty(this.value))
{
Scoreboard scoreboard = minecraftserver.worldServerForDimension(0).getScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjective(this.objective);
if (scoreboard.entityHasObjective(this.name, scoreobjective))
{
Score score = scoreboard.getValueFromObjective(this.name, scoreobjective);
this.setValue(String.format("%d", new Object[] {Integer.valueOf(score.getScorePoints())}));
}
else
{
this.value = "";
}
}
return this.value;
}
示例5: execute
import net.minecraft.server.MinecraftServer; //导入依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
World world = sender.getEntityWorld();
if (!world.isRemote && args.length > 0)
{
EntityPlayer player = this.getCommandSenderAsPlayer(sender);
EntityCurse curse = null;
EnumCurseType curseType = EnumCurseType.byName(args[0]);
switch(curseType)
{
case CREEPER: curse = new EntityCreeperCurse(world, player); break;
case GHAST: curse = new EntityGhastCurse(world, player); break;
case SKELETON: curse = new EntitySkeletonCurse(world, player); break;
case SLIME: curse = new EntitySlimeCurse(world, player); break;
case SPIDER: curse = new EntitySpiderCurse(world, player); break;
case ZOMBIE: curse = new EntityZombieCurse(world, player); break;
}
world.spawnEntity(curse);
}
}
示例6: addTabCompletionOptions
import net.minecraft.server.MinecraftServer; //导入依赖的package包/类
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
{
if (args.length == 1)
{
return getListOfStringsMatchingLastWord(args, new String[] {"give", "take"});
}
else if (args.length != 2)
{
return args.length == 3 ? getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames()) : null;
}
else
{
List<String> list = Lists.<String>newArrayList();
for (StatBase statbase : StatList.allStats)
{
list.add(statbase.statId);
}
return getListOfStringsMatchingLastWord(args, list);
}
}
示例7: addTabCompletionOptions
import net.minecraft.server.MinecraftServer; //导入依赖的package包/类
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
{
if (args.length == 1)
{
return getListOfStringsMatchingLastWord(args, new String[] {"on", "off", "list", "add", "remove", "reload"});
}
else
{
if (args.length == 2)
{
if (args[0].equals("remove"))
{
return getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getConfigurationManager().getWhitelistedPlayerNames());
}
if (args[0].equals("add"))
{
return getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getPlayerProfileCache().getUsernames());
}
}
return null;
}
}
示例8: shouldCreateWorld
import net.minecraft.server.MinecraftServer; //导入依赖的package包/类
@Override
public boolean shouldCreateWorld(MissionInit missionInit)
{
if (this.fwparams != null && this.fwparams.isForceReset())
return true;
World world = null;
MinecraftServer server = MinecraftServer.getServer();
if (server.worldServers != null && server.worldServers.length != 0)
world = server.getEntityWorld();
if (world == null)
return true; // There is no world, so we definitely need to create one.
String name = (world != null) ? world.getWorldInfo().getWorldName() : "";
// Extract the name from the path (need to cope with backslashes or forward slashes.)
String mapfile = (this.mapFilename == null) ? "" : this.mapFilename; // Makes no sense to have an empty filename, but createWorld will deal with it graciously.
String[] parts = mapfile.split("[\\\\/]");
if (name.length() > 0 && parts[parts.length - 1].equalsIgnoreCase(name) && Minecraft.getMinecraft().theWorld != null)
return false; // We don't check whether the game modes match - it's up to the server state machine to sort that out.
return true; // There's no world, or the world is different to the basemap file, so create.
}
示例9: cleanQueryClientsMap
import net.minecraft.server.MinecraftServer; //导入依赖的package包/类
/**
* Removes all clients whose auth is no longer valid
*/
private void cleanQueryClientsMap()
{
if (this.running)
{
long i = MinecraftServer.getCurrentTimeMillis();
if (i >= this.lastAuthCheckTime + 30000L)
{
this.lastAuthCheckTime = i;
Iterator<Entry<SocketAddress, RConThreadQuery.Auth>> iterator = this.queryClients.entrySet().iterator();
while (iterator.hasNext())
{
Entry<SocketAddress, RConThreadQuery.Auth> entry = (Entry)iterator.next();
if (((RConThreadQuery.Auth)entry.getValue()).hasExpired(i).booleanValue())
{
iterator.remove();
}
}
}
}
}
示例10: StatsComponent
import net.minecraft.server.MinecraftServer; //导入依赖的package包/类
public StatsComponent(MinecraftServer p_i2367_1_)
{
this.field_120037_e = p_i2367_1_;
this.setPreferredSize(new Dimension(456, 246));
this.setMinimumSize(new Dimension(456, 246));
this.setMaximumSize(new Dimension(456, 246));
(new Timer(500, new ActionListener()
{
public void actionPerformed(ActionEvent p_actionPerformed_1_)
{
StatsComponent.this.func_120034_a();
}
})).start();
this.setBackground(Color.BLACK);
}
示例11: doCommand
import net.minecraft.server.MinecraftServer; //导入依赖的package包/类
@Override
public void doCommand(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
FstPlayer player = new FstPlayer(sender);
player.runIfAirOrBlockHeld(() -> {
Map<String, Integer> argsInt = argsToInteger(copyArgs(args, 1),
"ux", "uy", "uz", "radius");
FstPos center = new FstPos(
argsInt.get("ux"),
argsInt.get("uy"),
argsInt.get("uz")
);
if("vt".equals(args[0])) {
buildVerticalCircle(player, center, argsInt.get("radius"));
} else {
buildHorizontalCircle(player, center, argsInt.get("radius"));
}
});
}
示例12: getTabCompletions
import net.minecraft.server.MinecraftServer; //导入依赖的package包/类
@Override
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos targetPos)
{
if (args.length == 1)
{
return getListOfStringsMatchingLastWord(args, new String[]{"list", "add", "remove", "reload"});
}
else
{
if (args.length == 2)
{
if ("remove".equals(args[0]))
{
return getListOfStringsMatchingLastWord(args, server.getPlayerList().getWhitelistedPlayerNames());
}
if ("add".equals(args[0]))
{
return getListOfStringsMatchingLastWord(args, server.getPlayerProfileCache().getUsernames());
}
}
return Collections.emptyList();
}
}
示例13: lookupNames
import net.minecraft.server.MinecraftServer; //导入依赖的package包/类
private static void lookupNames(MinecraftServer server, Collection<String> names, ProfileLookupCallback callback)
{
String[] astring = (String[])Iterators.toArray(Iterators.filter(names.iterator(), new Predicate<String>()
{
public boolean apply(String p_apply_1_)
{
return !StringUtils.isNullOrEmpty(p_apply_1_);
}
}), String.class);
if (server.isServerInOnlineMode())
{
server.getGameProfileRepository().findProfilesByNames(astring, Agent.MINECRAFT, callback);
}
else
{
for (String s : astring)
{
UUID uuid = EntityPlayer.getUUID(new GameProfile((UUID)null, s));
GameProfile gameprofile = new GameProfile(uuid, s);
callback.onProfileLookupSucceeded(gameprofile);
}
}
}
示例14: processCommand
import net.minecraft.server.MinecraftServer; //导入依赖的package包/类
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
BlockPos blockpos;
if (args.length == 0)
{
blockpos = getCommandSenderAsPlayer(sender).getPosition();
}
else
{
if (args.length != 3 || sender.getEntityWorld() == null)
{
throw new WrongUsageException("commands.setworldspawn.usage", new Object[0]);
}
blockpos = parseBlockPos(sender, args, 0, true);
}
sender.getEntityWorld().setSpawnPoint(blockpos);
MinecraftServer.getServer().getConfigurationManager().sendPacketToAllPlayers(new S05PacketSpawnPosition(blockpos));
notifyOperators(sender, this, "commands.setworldspawn.success", new Object[] {Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()), Integer.valueOf(blockpos.getZ())});
}
示例15: checkPermission
import net.minecraft.server.MinecraftServer; //导入依赖的package包/类
@Override
public boolean checkPermission(MinecraftServer server, ICommandSender sender) {
if (sender instanceof DedicatedServer)
return true;
EntityPlayerMP player = (EntityPlayerMP) sender;
GameProfile profile = player.getGameProfile();
UserListOpsEntry opEntry = (UserListOpsEntry) WorldBorder.SERVER
.getPlayerList()
.getOppedPlayers()
.getEntry(profile);
// Level 2 (out of 4) have general access to game-changing commands
// TODO: Make this a configuration option
return opEntry != null && opEntry.getPermissionLevel() > 2;
}