Welcome, Guest |
You have to register before you can post on our site.
|
Forum Statistics |
» Members: 8,079
» Latest member: seanac11
» Forum threads: 10,350
» Forum posts: 91,276
Full Statistics
|
Online Users |
There are currently 244 online users. » 0 Member(s) | 242 Guest(s) Bing, Google
|
Latest Threads |
I'm leaving the site too....
Forum: 2DWorlds Discussion
Last Post: Jacob_
07-03-2023, 04:59 AM
» Replies: 12
» Views: 6,414
|
hi there.
Forum: 2DWorlds Discussion
Last Post: Jacob_
01-03-2020, 04:30 AM
» Replies: 1
» Views: 775
|
obroke
Forum: Current Games
Last Post: FrancisSah
09-06-2017, 10:11 AM
» Replies: 0
» Views: 20,546
|
fcouldn't
Forum: Current Games
Last Post: FrancisSah
09-06-2017, 09:02 AM
» Replies: 0
» Views: 8,256
|
qhow
Forum: Current Games
Last Post: PhilipShums
09-06-2017, 07:25 AM
» Replies: 0
» Views: 2,141
|
zstone
Forum: Current Games
Last Post: TimothyTox
09-06-2017, 07:03 AM
» Replies: 0
» Views: 1,010
|
vbit
Forum: Current Games
Last Post: FrancisSah
09-06-2017, 03:00 AM
» Replies: 0
» Views: 985
|
sildenafil 100 mg sandoz
Forum: Current Games
Last Post: RichardLen
09-06-2017, 12:28 AM
» Replies: 0
» Views: 1,203
|
mhis
Forum: Current Games
Last Post: TimothyTox
09-05-2017, 04:09 PM
» Replies: 0
» Views: 1,009
|
sildenafil citrate 100mg ...
Forum: Current Games
Last Post: Waltertog
09-05-2017, 12:27 PM
» Replies: 0
» Views: 964
|
|
|
Sorry I'm invading Buildism to ask this but... |
Posted by: Komain72 - 07-17-2011, 09:45 PM - Forum: Programming
- Replies (9)
|
 |
I really need help on understanding why this code will not work...
Code: package org.opencraft.server.net.packet.handler.impl;
/*
* OpenCraft License
*
* Copyright (c) 2009 Graham Edgecombe, S�ren Enevoldsen and Brett Russell.
* All rights reserved.
*
* Distribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Distributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Distributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the OpenCraft nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
import org.opencraft.server.game.impl.CTFGameMode;
import org.opencraft.server.model.Player;
import org.opencraft.server.model.PlayerUntagger;
import org.opencraft.server.model.Position;
import org.opencraft.server.model.Rotation;
import org.opencraft.server.model.World;
import org.opencraft.server.net.MinecraftSession;
import org.opencraft.server.net.packet.Packet;
import org.opencraft.server.net.packet.handler.PacketHandler;
/**
* A packet handler which handles movement packets.
* @author Graham Edgecombe
*/
public class MovementPacketHandler implements PacketHandler<MinecraftSession> {
Position lastPosition = null;
long lastMoveTime = 0;
@Override
public void handlePacket(MinecraftSession session, Packet packet) {
if (!session.isAuthenticated()) {
return;
}
final Player player = session.getPlayer();
Position oldPosition = player.getPosition();
Rotation oldRotation = player.getOldRotation();
final int oldX = oldPosition.getX();
final int oldY = oldPosition.getY();
final int oldZ = oldPosition.getZ();
final int x = packet.getNumericField("x").intValue();
final int y = packet.getNumericField("y").intValue();
final int z = packet.getNumericField("z").intValue();
Position blockPosition = new Position((x - 16)/32, (y - 16)/32, (z - 16)/32);
if(lastPosition == null || (Math.abs(blockPosition.getX() - lastPosition.getX()) > 2 || Math.abs(blockPosition.getY() - lastPosition.getY()) > 2 || Math.abs(blockPosition.getZ() - lastPosition.getZ()) > 2))
{
lastPosition = blockPosition;
lastMoveTime = System.currentTimeMillis();
}
else if(System.currentTimeMillis() - lastMoveTime > 300000)
{
player.getActionSender().sendLoginFailure("You were kicked for being AFK!");
World.getWorld().broadcast("- "+player.parseName()+" was kicked for being AFK!");
}
int dx = Math.abs(x - oldX);
int dy = Math.abs(y - oldY);
int dz = Math.abs(z - oldZ);
if((dx > 500 || dy > 500 || dz > 500))
{
int divider = World.getWorld().getLevel().divider;
if(player.team == 0 && blockPosition.getX() > divider)
{
player.sendToTeamSpawn();
player.getActionSender().sendChatMessage("- &eYou may not respawn on the other team's side!");
}
else if(player.team == 1 && blockPosition.getX() < divider)
{
player.sendToTeamSpawn();
player.getActionSender().sendChatMessage("- &eYou may not respawn on the other team's side!");
}
if(player.hasFlag)
{
CTFGameMode ctf = (CTFGameMode) World.getWorld().getGameMode();
if(player.team == 0)
{
ctf.blueFlagTaken = false;
ctf.placeBlueFlag();
}
else
{
ctf.redFlagTaken = false;
ctf.placeRedFlag();
}
ctf.antiStalemate = false;
player.hasFlag = false;
World.getWorld().broadcast("- "+player.parseName()+" dropped the flag due to respawning!");
}
}
if((z - 16)/32 < World.getWorld().getLevel().floor && !player.safe)
{
player.safe = true;
new Thread(new PlayerUntagger(player)).start();
World.getWorld().broadcast("- "+player.parseName()+" died!");
player.sendToTeamSpawn();
if(player.hasFlag)
{
CTFGameMode ctf = (CTFGameMode) World.getWorld().getGameMode();
if(player.team == 0)
{
ctf.blueFlagTaken = false;
ctf.placeBlueFlag();
}
else
{
ctf.redFlagTaken = false;
ctf.placeRedFlag();
}
ctf.antiStalemate = false;
player.hasFlag = false;
World.getWorld().broadcast("- "+player.parseName()+" dropped the flag!");
}
}
final int rotation = packet.getNumericField("rotation").intValue();
final int look = packet.getNumericField("look").intValue();
player.setPosition(new Position(x, y, z));
player.setRotation(new Rotation(rotation, look));
}
}
Also, how can I make it so chat messages can be longer? Would it be using this code?
Code: public void sendChatMessage(int id, String message) {
PacketBuilder bldr = new PacketBuilder(PersistingPacketManager.getPacketManager().getOutgoingPacket(13));
String message2 = "";
if(message.length() > 64)
{
message2 = message.substring(64);
int idx = message.lastIndexOf("&");
if(idx != -1)
message2 = "&"+message.charAt(idx + 1)+message2;
message = message.substring(0, 64);
}
bldr.putByte("id", id);
bldr.putString("message", message);
session.send(bldr.toPacket());
if(!message2.equals(""))
sendChatMessage(id, "> "+message2);
}
I thought I could get a quicker response if I caught you on Buildism... I thought I had an account here, but I didn't, so now I do. haha.
Thanks.
|
|
|
Forum Idea: Editing History |
Posted by: Login - 07-17-2011, 05:18 PM - Forum: Suggestions
- Replies (10)
|
 |
You have two options to work this: Let other users see previous edited versions of the post or only allow mods. If you allow users to see previously edit versions of the post, they should be able to report it. If it was a serious enough, and meant to hide something, then the user should be warned.
Here's how it works: Where it says "Edited last by: [name] [time]" It should be a click-link to previously edited versions.
|
|
|
New Games Page |
Posted by: Excel - 07-17-2011, 03:21 PM - Forum: Suggestions
- No Replies
|
 |
I Love the new games page! What did glome bribe you into making it :>?
|
|
|
|